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.