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

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


Viewing all articles
Browse latest Browse all 4929

Trending Articles