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

Taking to much time compiling

$
0
0

@gabrielsalvador wrote:

Hi there.
I’m new to openFramework and i’m not sure if its normal for my project taking around 20 seconds to compile. It seems way to much time, sometime I just want to change something small like a color or something and just have to stare at the screen for a while until its done.
When I build it in the terminal it seems that a lot of what it’s doing could be precompiled or something.

Edit:
I’m with a 2012 13’’ MacBook Pro running macOS 10.14.

Posts: 4

Participants: 3

Read full topic


Color Tracking and Background Subtraction

$
0
0

@maximosigniorini wrote:

Hi all, I am trying to do color tracking and background subtraction to track IR light with a modded webcam. I’m currently using ofxCv and i am having trouble integrating both color tracking and background subtraction. Im getting the following error: “OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor”

Here’s the code:

void ofApp::setup(){
cam.setup(640,360);

learningTime = 500;

thresh.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_GRAYSCALE);

contourFinder.setTargetColor(targetColor, TRACK_COLOR_HSV);
contourFinder.setMinAreaRadius(10);
contourFinder.setMaxAreaRadius(150);

}

void ofApp::update(){
cam.update();

if(resetBackground) {
    background.reset();
    resetBackground = false;
}


if(cam.isFrameNew()){
    contourFinder.setTargetColor(targetColor, TRACK_COLOR_HSV);
    targetColor.setHsb(208, 100, 100);
    contourFinder.setThreshold(threshold);

    background.setLearningTime(learningTime);
    background.setThresholdValue(150);
    background.update(cam, thresh);

    contourFinder.findContours(thresh);

    thresh.update();
}

}

Posts: 1

Participants: 1

Read full topic

How to leave trails of polyline?

$
0
0

@armonnaeini wrote:

Hello all,

My apologies for such a novice question, but I am running into some trouble with OfxCV. I have taken the contour from my camera, fed it into a polyline and have smoothed out the polyline to achieve an illustrative effect.

Now I would like to do further manipulations to the appearance of the polyline, for example changing its size or creating a trailing effect, where the user’s previous image stays on the screen for a small duration and fades away.

for(int i = 0; i < n; i++) {
        //FOR FILLING
        ofPolyline polyline = contourFinder.getPolyline(i);//to convert
        ofPolyline smoothPoly = polyline.getSmoothed(70);
        
        ofPath pathFromContour;//path to be built
        
        for(int i = 0; i < smoothPoly.getVertices().size(); i++) {
            if(i == 0) {
                pathFromContour.newSubPath();
                pathFromContour.moveTo(smoothPoly.getVertices()[i]);
                
            } else {
                pathFromContour.lineTo(smoothPoly.getVertices()[i]);
            }
        }
 
        pathFromContour.close();
        pathFromContour.setFillColor(col);
        pathFromContour.draw(100,100);
        smoothPoly.draw();
    }

Above is my current code where I take the contour and convert it to a polyline. What I have done already is take the declaration ‘ofPath pathFromContouer’ and threw that in my header file to globally declare it. This actually created a trailing effect but it broke my program after a short amount of time as the old frames weren’t clearing and obvious memory leaks.

Is there any direction someone could point me in terms of taking the already created polyLine/ofPath and manipulating it further, specifically in terms of trailing?

Thank you guys so much!

Posts: 2

Participants: 1

Read full topic

How to add build settings for emscripten on addon_config.mk file?

Manipulation of OFPath from a live video source?

$
0
0

@armonnaeini wrote:

Hi All,

I posted about an hour ago asking about how I can leave trails of a polyline, but I wanted to ask a much more straightforward question.

I am creating an interactive installation where I take the contour of the body and manipulate in an illustrative manner.

Currently, in my draw() function, I have iterated through the contour finder and stored the contour into an ofPath. I then draw the ofPath within my draw() function.

My question is…how can I now take this ofPath and conduct further manipulations to it? As in, I want to fluctuate its shape/size/animate it external of user’s input, etc. I am confused on where this would take place in the application. I understand that I can do this in the update() function, but my ofPath is not declared globally, it is declared in the draw() function. When it is declared globally, it leaves a trail of previous frames and eventually breaks the program…

Any pointers would be ever greatly appreciated. Thanks so much guys!

Posts: 1

Participants: 1

Read full topic

Mindwave mobile 2

$
0
0

@pandereto wrote:

Hello

I have a installation that use a mindWave mobile and im going to re-use it so i bought a new pair of headsets, but now you can only buy the new version v2

And ofxThinkGear do not work, i see that @bakercp has a recent cleanup version of the addon.

Someone uses a mindWave mobile 2? Maybe backercp tried one of those

Thanks

Posts: 3

Participants: 2

Read full topic

ofxFX Addon Empty Vertex Shaders

$
0
0

@motorcycleboy wrote:

Hey,

I am trying to work out exactly how ofxFX works so I can recreate some of the ideas and use them in other projects.

I am finding it difficult to understand what this code in ofxFXObject.h does:

// Constructor Shader Source Strings: These strings can be specified
// by inheritors in their constructors, and will be loaded when
// appropriate. If any of the above strings are empty, the ones
// below are tried. If shaders are loaded from file, these are also
// ignored.

string          glESFragmentShader;
string          glESVertexShader;

string          gl2FragmentShader;
string          gl2VertexShader;

I can see that from this code in the selectShaderSource() function, that if we are not using the programmable renderer and a vertex shader is not specified then vertexShader is assigned the string gl2VertexShader:

if (ofIsGLProgrammableRenderer()){
        vertexShader = gl3VertexShader;
        // If the vertex shader for GL3 isn't specified, we fill
        // in a simple pass-through shader. This way, users can
        // give only fragment shaders, just like for GL2/ES. This
        // is necessary because having a vertex shader is mandatory
        // in GL3.
        if (vertexShader.empty()){
            vertexShader = "#version 150\n";
            vertexShader += STRINGIFY(
                    uniform mat4 modelViewProjectionMatrix;
                    in vec4 position;
                    void main(){
                        gl_Position = modelViewProjectionMatrix * position;
                    });
        }
    } else {
        vertexShader = gl2VertexShader;
    }

Then when compileCode() is called the vertex shader is loaded as follows:

shader.setupShaderFromSource(GL_VERTEX_SHADER, vertexShader);

As far as I can see gl2VertexShader is never assigned anything in ofxFXObject.cpp so this is the same as passing in an empty string.

However, if I pass in an empty string when attempting to recreate this in one of my own projects I get the following error:

ERROR: Compiled vertex shader was corrupt

I have tried to use a very simple vertex shader instead, i.e.

void main() {
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

But then the output is not the same as what I am seeing with the ofxFX examples.

Posts: 1

Participants: 1

Read full topic

I made harmonic mean code for two images. But

$
0
0

@bemoregt wrote:

Hi, All.

I made harmonic mean code for two images.

// Function that returns harmonic mean.
int harmonicMean(float arr[], int n)
{
// Declare sum variables and initialize
// with zero.
float sum = 0;
for (int i = 0; i < n; i++)
sum = sum + 1 / arr[i];

return (int)n/sum;

}

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

aa.load("/Users/kerbal/Desktop/low.png");
bb.load("/Users/kerbal/Desktop/high.png");

ofPixels p1 = aa.getPixels();
ofPixels p2 = bb.getPixels();
ofPixels pp = aa.getPixels();

float arr[] = {};
for(int i = 0; i < aa.getWidth()*aa.getHeight(); i++){
    arr[0]= p1[i];
    arr[1]= p2[i];
    
    pp[i]= harmonicMean(arr, 2); // <-bad access error happen
}
cc.setFromPixels(pp);
cc.update();

}

But bad access error happen like above.
What’s wrong to me ?

Thanks.
Best,
@bemoregt.

Posts: 3

Participants: 2

Read full topic


How to check if two or more values are similar in array

$
0
0

@cyrstem wrote:

hi, so i been stuck on this for a while so maybe one of you can point how to approach this, i develop a OF app that activates some videos when a series of buttons are press via OSC when the video finish they are suppose to go back to a intro scene and wait for the next interaction, my issue comes when a user only press maybe one or two of the buttons then the app never goes back to the intro scene i can only make them come back when they press all the buttons so my approach until now is to try to store the states of each video in a array of bools
like this

void ofApp::videoStatus(){
 for (unsigned int  i = 0; i < players.size(); i++)
    {
        if (players[i].getIsMovieDone() ==true)
        {
            players[i].stop();

            stado[i] =true;
        }
        
    }

and then my idea is to check if there are more than one similar value in the array so if there is they go back to intro scene like this

void ofApp::compareStatus(bool _stado[],int size){
    int i,j;
    printf("Repeating numbers are");
    for ( i = 0; i < size; i++)
    {
        for ( j = i+1; j < size; j++)
        {
            if (_stado[i] == _stado[j])
            {
                cout<< _stado[i]<< " ";
               //cout<<" mas de dos videos se acabaron"<<endl;
            }
            
        }
        
    }
    
}

but if i do this it will set back to intro scene if the user took some time in pressing all the buttons has someone develop something similar how can i can make it wait for a while before resetting, should i use timers? maybe im overthinking this to much ?

Posts: 1

Participants: 1

Read full topic

Error No package ‘libmpg123’ found when setting up qtcreator

Example-texture-mode won't display video properly on certain monitor

$
0
0

@marcassin22 wrote:

It feels like I am missing something obvious, but I really can’t find the source of this problem. I’m using the example-texture-mode example on a Raspberry Pi 3B+, and when the Pi is booted connected to one of my monitor, the example works perfectly, but when it’s booted to my other monitor, the video player displays a grey image and nothing else.

Both screens are connected on the HDMI port, and there is no effect wether I force the Pi to a certain resolution or let it choose the best resolution for the monitor.

The OS is raspbian stretch with desktop, I’m using openframeworks 0.10.0 and the code is the example with no modification. Both monitors are fairly recent and use 1920x1080.

I would greatly appreciate any pointers on where to look or what kind of setting or configuration am I not doing correctly.

Posts: 1

Participants: 1

Read full topic

Running OFX App Slows Python In Background

Problem linking addon after modifying it

$
0
0

@Antonio_Castles wrote:

Hello forum,

I have been modifying a version of ofxBlackMagic lately by duplicating it and renaming the addon ofxBlackMagicFork in my addons folder. I tried to re-connect a project to this forked version, and everything seems to work fine: when I “follow the symbols under cursor” (I’m in Ubuntu using Qt) it links correctly to the modified file and so on. Everything seems to be connected fine, but when I run the application it says

/home/antonio/dev/of_v0.10.1_linux64gcc6_release/apps/myApps/trigger4/src/Editor.h:45: error: undefined reference to 'ofxBlackMagic::ofxBlackMagic()'

And that on every single line where ofxBlackMagic is referenced. I didn’t change the name of the object nor the methods, I only added new stuff. Any idea on what could be happening? I also included the new header at the beggining, which was also tricky because qt didn’t normalize the path, so I had to include it as

#include "../../../addons/ofxBlackmagicFork/src/ofxBlackMagic.h"

Am I missing something?

Thank you!

Posts: 1

Participants: 1

Read full topic

Transformations

$
0
0

@thatboy69 wrote:

I am new to OF and can’t seem to understand the hang of this. I created a box shape but am not sure how to get it to rotate on the origin. I basically just want the mouse to be able to drag my square clockwise. Where are any tutorials / sources that may be able to help me?

Thanks.

Posts: 1

Participants: 1

Read full topic

First Person Camera Movement

$
0
0

@JoseMan wrote:

Hello,

i want to implement a first person camera movement with mouse and the ofCamera.
I get the mouse delta: the mouse movent from the previous to the current frame.
Now I want to set the new LookAt-Dir from this mouse-delta.

How can I realize that?

Chears :slight_smile:

Posts: 2

Participants: 1

Read full topic


Set mouse position without trigger ofApp::mouseMoved(...)

$
0
0

@JoseMan wrote:

Hello Again,

I run in another problem. I want to set the mouse position at the start of my App with SetCursorPos(x,y) at the center.
But this triggers a mouse event an my ofApp::mouseMoved(int x, int y ) gets triggert. But I don’t want it. I only want to set the mouse cursor at the center but without triggering/call the ofApp::mouseMoved function…

Any ideas?

Chears

Posts: 1

Participants: 1

Read full topic

Openframeworks Processing Load

$
0
0

@Hantoo wrote:

Hi All,
I have a project that is using ASDFPixelSort to sort a row of pixels in an image whenever a user triggers a MQTT message.
The project is being shown on a 4K monitor. Whenever the OFX app is launched, the entire system slows down and the graphics card usage rockets up to 100% usage.
I think this is due to OFX re-drawing the image every cycle , however I can no be sure.
I just wondered if anyone has run into a similar issue or if anyone has any ideas of how to fix it?
Thanks,
Joel

Posts: 1

Participants: 1

Read full topic

How do I do mocap with kinect 360 on ubuntu

$
0
0

@ca3 wrote:

Hi, I just got a kinect 360 to do mocap with blender, but can’t find a proper ubuntu software to do such task.

I would love any recomendations to do this.

Posts: 1

Participants: 1

Read full topic

FBO and Polylines

$
0
0

@armonnaeini wrote:

Howdy all!

Quick question for you guys… I posted here about a week ago asking about how I can manipulate the contour from OfxCV’s contourfinder. Y’all are amazing and answered my question, but now I am running into a performance issue. I know my solution is to use an FBO, but I am unsure of how to do so.

I have a vector of polyLines called ‘pp’. pp is instantiated in my update() function where I call pp = contourFinder.getPolylines(); After the instantiation, I then iterate through pp, which is usually 1-3 items at most, since there are usually no more than 1-3 contours in the picture at once. I call a nested for loop and iterate through that specific contour/polyline and then call the arc function to arc the polyline to that specific point, which goes through well over 5000-10000 iterations. This is where my program begins to break. I then iterate through my vectors of polylines (pp [like i said which is between 1-3] in my draw function, and draw every polyline, which is simultaneously being updated in my update function. I tried to declare an fbo and begin() and end() at my update function, but only a black box appeared in my sketch. How exactly do I “load” my sketch onto an FBO? Is that even the right terminology?

In essence, I would just like to run my sketch quicker. I know OpenFrameworks takes advantage of OpenGL, which streamlines processes like these, using classes such as FBO. Where exactly would I fit an FBO into my sketch?

update function:

fbo.begin();
    pp = contourFinder.getPolylines();
    // 1. We iterate through everything within pp (vector of polyLines)
    // 2. pp[i] represents the entire POLYLINE. IT IS WHAT YOU ARE LOOKING AT, ON THE SCREEN
    int sizz = pp.size(); //1 CONTOUR
    
    for(int i = 0; i < pp.size(); i++) {
        pp[i] = pp[i].getSmoothed(50); //this takes pp at position i, (there should only be 1 pp), and smooths out the ENTIRE polyline
        

        int polySize = pp[i].size() ; //this will be a large number, as it is the size of all the polylines within our main (1) poly. Polylines are objects consisting of smaller polylines
        for (int j = 0; j < polySize; j+=2){ //now we iterate through all the little polylines within our main pp
            


            ofPoint current = pp[i][j];
            pp[i].arc(current, 20, 200, 240, 120, 200);  //center, radius x, radius y, anglebegin, angle end, circle res
            cout <<  pp[i][j].x  << endl;
        }
     
    }
    for (int i =  0; i < pp.size(); i++){
        pp[i].draw();
    }
    
    fbo.end();

Draw function: So, when I iterate through the for loop, my current sketch draws in the background. When I call fbo.draw(), it just draws a black box on top of my current, running sketch. I just don’t know how I can load the current running sketch into the FBO.

 ofTranslate(100, 100, 0);
    for (int i =  0; i < pp.size(); i++){
        pp[i].draw();
    }

    fbo.draw(100, 100);
    

Thank you all so much for your time.

Posts: 1

Participants: 1

Read full topic

TrueType font sizing

$
0
0

@buglog wrote:

Hi I want to know how to reset a font size when the program is running, not only on setup. Can anyone help me out with this?

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live