Quantcast
Channel: beginners - openFrameworks
Viewing all 4929 articles
Browse latest View live

Using -std=c++14 in osx

$
0
0

@Jotaro wrote:

I just want to compile my oF project on c++14 environment.
I added PROJECT_CFLAGS in config.make file in my project but it didn't worked (log says -std=c++11)

oF version is v0.9.8 release.

Any advices? or am I doing wrong?

Thanks,
Joe

Posts: 3

Participants: 2

Read full topic


SinWave1 don't listen sound

$
0
0

@yuri4817 wrote:

build succeed! but don't listen sound.

why?Is class failed?

include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
sampleRate=44100;
amp=0.5;
pan=0.5;
phase=0;
frequency=440;
ofSetFrameRate(30);
ofBackground(32, 32, 32);
ofSoundStreamSetup(2, 0);

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
float audioHeight=ofGetHeight()/2.0f;
float phaseDiff=ofGetWidth()/float(bufSize);

ofSetColor(0, 0, 255);
ofNoFill();
ofSetLineWidth(2);

ofBeginShape();
for(int i=0;i<bufSize;i++){
    ofVertex(i*phaseDiff,audioHeight/2+lAudio[i]*audioHeight);
}
ofEndShape();

ofBeginShape();
for(int i=0;i<bufSize;i++){
    ofVertex(i*phaseDiff,audioHeight/2*3+rAudio[i]*audioHeight);
}
ofEndShape();

}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}

//---------------------------------------------------------------
void ofApp::audioRequested (float*output,int bufferSize,int nChannels){
float sample;
float phaseDiff;

phaseDiff=TWO_PI*frequency/sampleRate;

for(int i=0;i<bufferSize;i++){

    phase +=phaseDiff;
    while(phase>TWO_PI) {
        phase -=TWO_PI;
    }

    sample=sin(phase);

    lAudio[i]=output[i*nChannels]=sample*pan*amp;
    rAudio[i]=output[i*nChannels+1]=sample*pan*amp;
}

}

Posts: 2

Participants: 2

Read full topic

Best solution for 2d particle collision

$
0
0

@haggi wrote:

Hi,
I was seraching for the best way to do particle collision. The final result should be a kinect import where particles collide with the human shape coming from kinect. I hope I can find a way to display several thousend of particles in realtime.
Unfortunately I am a bit confused because there are several ways to do collisions, bullet, box2d and others. Does anyone has some hints which way I should go?

Thanks.

Posts: 1

Participants: 1

Read full topic

Face normals and vertex normals are flipped

$
0
0

@edapx wrote:

I'm doing a generative geometry setting vertex position and vertex normals.
It works correctly, as you see when I open the generated mesh with mesh lab and the light is correctly calculated, if the selected view is the vertex view.

When I select the faces view, the normals are flipped, they are pointing inside the tube

As this tube is an instance of of3DPrimitive, i can use drawNormals to debug them.
But in both cases, when drawing the normals per vertex:

tube.drawNormals(2, false);

Or when drawing the normals per face

tube.drawNormals(2, true);

The normals are always pointing out in the right direction, from inside the tube to outside, it is just in meshlab that they look wrong in the "faces" view.

I think it is a problem in my code because I've downloaded a couple of meshes and I've opened them in meshlab, and they look good
Is there something that I'm not taking into consideration?

Posts: 6

Participants: 4

Read full topic

0.9.8 video playback 1-2 frames in debug mode

$
0
0

@mindthegap wrote:

hello,

the HD video is running fine in release mode, in debug mode I get around one frame per seconds. I reinstalled the k-lite stuff, the same. Where's the problem. I have seen the issue in github for a long time now.

regards

Posts: 1

Participants: 1

Read full topic

OF 9.7 HD WebCam Playback lag on Windows

$
0
0

@jeffrey9700 wrote:

Is there any way to reduce the lag on an HD WebCam video feed (Logitech C930e)? I'm using OF 0.9.7 on a Windows 8 and a Windows 10 machine. The lag is pretty significant at 1920x1080.

Does this have to do with the c930e having uvc h.264 encoding? Previously used the Logitech c910 with no lag at 1080p.

Posts: 2

Participants: 1

Read full topic

ofxOpenCv.blob / ofMesh to ofTexture

$
0
0

@numu wrote:

hello dear of-forum :slight_smile:

i've got a small newbie problem here.. i'm very new to openframeworks and c++ in general..

the basic program works quite fine already, i've got an image slideshow and on top of it there is a ofVideoGrabber instance in combination with ofxOpenCv that acts as a mask.

colorImage.setFromPixels(vidGrabber.getPixels());
grayImage = colorImage;
grayImage.brightnessContrast(brightness, contrast);

if (bLearnBakground == true) {
	grayBg = grayImage;
	saveBg.setFromPixels(grayImage.getPixels());
	saveBg.save(bgFile, OF_IMAGE_QUALITY_BEST);
	bLearnBakground = false;
}
    // take the abs value of the difference between background and incoming and then threshold:
grayDiff.absDiff(grayBg, grayImage);
grayDiff.threshold(threshold);
grayDiff.blurGaussian(blur);

pixels = grayDiff.getPixels();

ofPixels lPixels = pixels.getChannel(0);

ofPixels lumPixels = maskPixels.getChannel(0);
ofPixels alpPixels = maskPixels.getChannel(1);

// masking
for (int y = 0; y < camHeight; y++) {
	for (int x = 0; x < camWidth; x++) {

		int idx = (y * camWidth) + x;

		lumPixels[idx] = 0;
		alpPixels[idx] = 255 - lPixels[idx];
	}
}

// store pixels in maskPixels ofPixels
maskPixels.setChannel(0, lumPixels);
maskPixels.setChannel(1, alpPixels);

// load blurred maskPixels into ofTexture
maskTexture.loadData(maskPixels, GL_LUMINANCE_ALPHA);

but as i only need one big object being masked (and projected onto) i thought it might work better if i would use the blob function of openCv. the problem now is that i dont know how to get the shape of the blob into an ofImage (or even better an ofxGrayscaleImage) that i can handle it the same way (with blurring and masking) as i do in my code.

in this video you can see what it should look like in the end (thats an old video where the object was projected by dia-projectors infront of a black molton background).
and this video shows the stage i am in at the moment. instead of the object you see me infront of my pc.. but i think you should see what i mean :wink:

thanks a lot in advance
numu

Posts: 1

Participants: 1

Read full topic

Addon ofxOpenNI

$
0
0

@sleepy-maker wrote:

Hi,

I'm trying to use ofxOpenNI then I got errors like below.
I tried a few things from this forum and stackoverflow, but still I can't use it.


os mac osx Sierra
of ver 0.9.8
xcode 8.3.3

Does anyone know a solution?

Thank you for your help!

Apple Mach-O Linker (ld) Error Group

"_xnEnumerationErrorsFree", referenced from:

"_xnNodeInfoListIteratorIsValid", referenced from:

"_xnNodeInfoListFree", referenced from:

"_xnEnumerationErrorsAllocate", referenced from:

"_xnForceShutdown", referenced from:

"_xnContextAddRef", referenced from:

"_xnOSFreeAligned", referenced from:

"_xnProductionNodeAddRef", referenced from:

"_xnGetRefContextFromNodeHandle", referenced from:

"_xnContextRegisterForShutdown", referenced from:

"_xnContextRelease", referenced from:

"_xnRegisterToPoseDetected", referenced from:

"_xnStopPoseDetection", referenced from:

"_xnResetSkeleton", referenced from:

"_xnAbortSkeletonCalibration", referenced from:

"_xnLogSetConsoleOutput", referenced from:

"_xnConvertRealWorldToProjective", referenced from:

"_xnStartSkeletonTracking", referenced from:

"_xnNodeInfoListGetFirst", referenced from:

"_xnSetMapOutputMode", referenced from:

"_xnSetMirror", referenced from:

"_xnNodeInfoListAllocate", referenced from:

"_xnIsMirrored", referenced from:

"_xnStopFrameSyncWith", referenced from:

"_xnRegisterHandCallbacks", referenced from:

"_xnFrameSyncWith", referenced from:

"_xnIsNewDataAvailable", referenced from:

"_xnCanFrameSyncWith", referenced from:

"_xnRemoveGesture", referenced from:

"_xnAddGesture", referenced from:

"_xnGetNumberOfAvailableGestures", referenced from:

"_xnCreatePlayer", referenced from:

"_xnSetSkeletonProfile", referenced from:

"_xnRemoveNodeFromRecording", referenced from:

"_xnOSMalloc", referenced from:

"_xnAddNodeToRecording", referenced from:

"_xnStartTracking", referenced from:

"_xnGetUserCoM", referenced from:

"_xnGetUsers", referenced from:

"_xnIsDataNew", referenced from:

"_xnEnumerateProductionTrees", referenced from:

"_xnRecord", referenced from:

"_xnEnumerateGestures", referenced from:

"_xnCreateSceneAnalyzer", referenced from:

"_xnResetViewPoint", referenced from:

"_xnGetImageMetaData", referenced from:

"_xnWaitAndUpdateData", referenced from:

"_xnGetIRMetaData", referenced from:

"_xnRegisterGestureCallbacks", referenced from:

"_xnGetSkeletonCalibrationPose", referenced from:

"_xnConvertProjectiveToRealWorld", referenced from:

"_xnRegisterUserCallbacks", referenced from:

"_xnCreateDepthGenerator", referenced from:

"_xnOSFree", referenced from:

"_xnContextUnregisterFromShutdown", referenced from:

"_xnGetDeviceMaxDepth", referenced from:

"_xnCreateImageGenerator", referenced from:

"_xnCreateRecorder", referenced from:

"_xnCreateUserGenerator", referenced from:

"_xnNodeInfoListGetCurrent", referenced from:

"_xnLogSetSeverityFilter", referenced from:

"_xnStartPoseDetection", referenced from:

"_xnIsPlayerAtEOF", referenced from:

"_xnGetUserPixels", referenced from:

"_xnGetNodeName", referenced from:

"_xnSetPlaybackSpeed", referenced from:

"_xnCreateAudioGenerator", referenced from:

"_xnOSStrNCopy", referenced from:

"_xnGetVersion", referenced from:

"_xnGetPlaybackSpeed", referenced from:

"_xnGetSkeletonJointOrientation", referenced from:

"_xnProductionNodeRelease", referenced from:

"_xnContextOpenFileRecording", referenced from:

"_xnSetSkeletonSmoothing", referenced from:

"_xnEnumerationErrorsGetCurrentError", referenced from:

"_xnNodeInfoGetRefHandle", referenced from:

"_xnGetSkeletonJointPosition", referenced from:

"_xnEnumerationErrorsGetCurrentDescription", referenced from:

"_xnSetViewPoint", referenced from:

"_xnStartGenerating", referenced from:

"_xnCreateGestureGenerator", referenced from:

"_xnLogSetMaskState", referenced from:

"_xnEnumerationErrorsGetFirst", referenced from:

"_xnIsSkeletonCalibrating", referenced from:

"_xnStopGeneratingAll", referenced from:

"_xnAddLicense", referenced from:

"_xnSetPlayerRepeat", referenced from:

"_xnIsCapabilitySupported", referenced from:

"_xnNodeInfoGetDescription", referenced from:

"_xnIsSkeletonTracking", referenced from:

"_xnCreateProductionTree", referenced from:

"_xnCreateIRGenerator", referenced from:

"_xnSeekPlayerToFrame", referenced from:

"_xnGetStatusString", referenced from:

"_xnSetRecorderDestination", referenced from:

"_xnGetDepthMetaData", referenced from:

"_xnNodeInfoListGetNext", referenced from:

"_xnGetPlayerNumFrames", referenced from:

"_xnStopGenerating", referenced from:

"_xnRegisterToCalibrationComplete", referenced from:

"_xnCreateHandsGenerator", referenced from:

"_xnRequestSkeletonCalibration", referenced from:

"_xnEnumerateExistingNodes", referenced from:

"_xnProductionNodeDescriptionToString", referenced from:

"_xnOSMemSet", referenced from:

"_xnNeedPoseForSkeletonCalibration", referenced from:

"_xnInit", referenced from:

"_xnInitFromXmlFile", referenced from:

"_xnTellPlayerFrame", referenced from:

"_xnRegisterToCalibrationStart", referenced from:

"_xnEnumerationErrorsGetNext", referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Posts: 1

Participants: 1

Read full topic


64 bit Video player with dynamic speed changing

$
0
0

@Mortec wrote:

Hi there,
I'm looking for a video player that would support speed change dynamically.
The only one I found actually is the ofxHapPlayer but it compiles only in 32 bits.
ofxHapAVPlayer works well in 64bit but doesn't support continuous speed changes.
(Continuous speed change meaning changing the speed without frame dropping and sound muting)
Any suggestions ?

(I'm on macOS 10.11.6, El Capitan with Xcode 8.2)

edit : Just tried the ofxVLCPlayer with no more success. My video file are recorded with ffmpeg from HLS stream in H264 at 25fps with AAC 44100 for the audio encoding.

Posts: 3

Participants: 2

Read full topic

Basic authentication with ofLoadURL

$
0
0

@tom_d_chambers wrote:

I'm trying to call a URL that I'd with this style in curl/browser:

https://username:password@website.com/api/v1/call

but I get an error with Unauthorized and a 401 back from the server, so the credentials don't appear to be passed. How can I use authentication with ofLoadURL and ofLoadURLAsync?

Posts: 1

Participants: 1

Read full topic

"Cutting out" multiple layers of a plane

$
0
0

@aceslowman wrote:

I swear this is something I managed to do in the past, but I can't find the sketch that I did it in. What I'm looking to do is take a plane, and effectively "cut out" shapes, allowing for sections to be fully detached. Right now I have what I need in a vertex shader, but as expected, it is not cut out, rather points are just being interpolated.

Is there a way of allowing this? To have abrupt changes in depth, that aren't interpolated?

I think maybe the best example I have is what ofZach has been doing lately on instagram:

Shader below:
https://pastebin.com/HQVSQ2tM

Posts: 2

Participants: 2

Read full topic

ofSetBackgroundAuto(false) and OF_BlendMode_ADD

$
0
0

@KeitoTakaishi wrote:

I want to draw track so I use ofSetbackgroundaAuto(false), and l want to represent luminescence so l use ofenableblendmode(of-blend mode-add).However, that is bad result. I understand the reason, but l have no idea to represent track and luminescence.

void ofApp::setup(){

/*#define num 100↓ */
for(int i = 0; i < num; i++){
    pos[i] = ofVec2f(ofRandom(ofGetWidth()),ofRandom(ofGetHeight()));
    speed[i] = ofVec2f(ofRandom(-10,10),ofRandom(-10,10));
}
ofEnableBlendMode(OF_BLENDMODE_ADD);
/*to represent track*/

ofSetBackgroundAuto(false);
}

void ofApp::update(){
for(int i = 0; i < num; i++){
if(pos[i].x > ofGetWidth()){
speed[i].x *= -1;
}else if(pos[i].x < 0){
speed[i].x *= -1;
}if(pos[i].y > ofGetHeight()){
speed[i].y *= -1;
}else if(pos[i].y < 0){
speed[i].y *= -1;
}

    pos[i] += speed[i];
}

}
void ofApp::draw(){
ofSetColor(255);

for(int i = 0; i < num; i++){
    ofDrawCircle(pos[i],5);
}


/*to represent track*/
ofSetColor(0,0,0,50);
ofDrawRectangle(0,0,ofGetWidth(),ofGetHeight());

}

Posts: 2

Participants: 2

Read full topic

ofToString returns me a hex!

$
0
0

@aliva666 wrote:

Hi! this had never happend before but i'm trying to convert a int to string but it returns me instead of a string a hex numer
Code:
ofToString(contourFindRedBlueAll.nBlobs);

Posts: 1

Participants: 1

Read full topic

Mesh and particle morph

Debugging error appears in the instance of ofImage function


ofxMath -particlesExample change number of particles dynamically

$
0
0

@heaversm wrote:

I am running the particles example from /examples/math/particlesExample. I want to learn to implement a GUI to control the number of particles.

I can successfully implement a GUI and intSlider:

//ofApp.h
    void numParticlesChanged(int & numParticles);
    ofxIntSlider numParticles;
    ofxPanel gui;

//ofApp.cpp, within void ofApp::setup(){
    gui.setup();
    numParticles.addListener(this, &ofApp::numParticlesChanged);
    gui.add(numParticles.setup("particles", 300, 10, 1500)); //MH initial, min, max
    //int num = 300;
    int num = numParticles;
    p.assign(num, demoParticle());

//Particles changed function
    void ofApp::numParticlesChanged(int &numParticles){
        //DO SOMETHING HERE
    }

The problem is that the number of particles is established within the setup function, so I'm not sure how to update the number of particles within the numParticlesChanged function. I can't just call ofApp::setup() again, because it will just revert to the default number in the GUI. I've also tried p.size(numParticles) and p.assign(numParticles,demoParticle());

How do I accomplish this?

Posts: 2

Participants: 2

Read full topic

Error on microsoft

$
0
0

@edapx wrote:

Hello, I've added CI testing to an addon, I do not have any problem except for the windows platform, the
Environment: platform=x86, BUILDER=MSYS2 job works perfectly but these jobs:

Environment: platform=x64, BUILDER=VS, BITS=64
and
Environment: platform=x86, BUILDER=VS, BITS=32

Gives me an error. The thing is that the error is a bit strange:
https://ci.appveyor.com/project/edap/ofxspacecolonization/build/job/j2kebunfwoa01bj5

src\ofApp.cpp(66): error C2397: conversion from 'double' to 'float' requires a narrowing conversion [C:\projects\openFrameworks\addons\ofxSpaceColonization\example-ofxenvelope\example-ofxenvelope.vcxproj]

I'm looking at the documentation, https://msdn.microsoft.com/en-us/library/mt763946.aspx

And I assume that what make the compiler unhappy is the initialization of the struct that defines some options:

    auto optEnv = ofxEnvelopeOptions({
        400,
        1.0,
        0.002,
        600,
        0.3,
        0.3
    }); // this is line 66

That should contain these types:

struct ofxEnvelopeOptions{
    int curveHeight;
    float curveCutoffTop;
    float curvature;
    int nVertices;
    float deviationOnY;
    float deviationOnX;
};

But I do not see any double there.
Am I missing something?

Posts: 3

Participants: 2

Read full topic

How to keep animating even when I drag an oF app on win10?

$
0
0

@yuma_taesu wrote:

Hi
I'm starting to oF-programming on win10.

As you know, a whole animating stop when dragging oF app's title bar to move.

[What I wanna do]
Sending oF image to touch designer by ofxSpout.

[problem]
it is difficult to arrange layout oF app in display during performance..

[question]
Is threr how to keep animating even when I drag an oF app on win10?

here is my env

  • Windows 10
  • VS 2015
  • oF 0.9.8

cheers.

Posts: 1

Participants: 1

Read full topic

Convert rgba image to rgb

$
0
0

@aliva666 wrote:

Hi! I'm trying to convert a RGBA image to RGB i use to use this algorightm :

      photo.setFromPixels(camera.getPixelsRef());
     unsigned char * photoCvPix = photoCV.getPixels();
     unsigned char * photoPix = photo.getPixels();

    for (int i = 0; i < capW * capH; i++){
        photoCvPix[ i * 3 + 0] = photoPix[i*nChannels + 0];
        photoCvPix[ i * 3 + 1] = photoPix[i*nChannels + 1];
        photoCvPix[ i * 3 + 2] = photoPix[i*nChannels + 2];

}

  photoCV.flagImageChanged();

But now i try it and i got this errors:

Any idea?

Posts: 7

Participants: 3

Read full topic

What kind of behavior does this shader do?

$
0
0

@taketori7616 wrote:

How does this shader fit in the imageResolution with the vertical and horizontal values of the image?

shader.vert

attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;

void main(void) {
    vUv = uv;
    gl_Position = vec4(position, 1.0);
}

shader.frag

uniform vec2 resolution;
uniform vec2 imageResolution;
uniform sampler2D texture;
varying vec2 vUv;

void main(void) {
    vec2 ratio = vec2(
                      min((resolution.x / resolution.y) / (imageResolution.x / imageResolution.y), 1.0),
                      min((resolution.y / resolution.x) / (imageResolution.y / imageResolution.x), 1.0)              );
    vec2 uv = vec2(
                   vUv.x * ratio.x + (1.0 - ratio.x) * 0.5,
                   vUv.y * ratio.y + (1.0 - ratio.y) * 0.5
                   );

    gl_FragColor = texture2D(texture, uv);
}

What happens to the image read as a texture?

Posts: 3

Participants: 2

Read full topic

Viewing all 4929 articles
Browse latest View live