How to capture an image after contour.draw();?

I am using the “FindContours” example from the OpenCV library.

All works well, but I would like to capture an image after the countours have been drawn. (For further analysis of the the contours.)

So I tried:

    contour.draw();
    PImage draw = opencv.getOutput();
       image(draw, 0, 0);

But I do not get an image containing the green contours.
I also tried “Get” and “getSnapshot” but none of them captures the contours. What to do?
Thanks

if

contour.draw();

show on screen (canvas)
what you want to see / to store,
you can make a screenshot:

String outfilename = "data/screenshot.png";

void setup() {
  size(500,500);
}

void draw() {
 background(200,200,0);
 fill(0,200,0);
 stroke(0,0,200);
 strokeWeight(5);
 circle(width/2,height/2,width/2);
}

void keyPressed() {
 if ( key == 's' ) saveFrame(outfilename); 
}

1 Like