We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
OpenCV, blobs() / Tracing outline? (Read 1013 times)
OpenCV, blobs() / Tracing outline?
Nov 8th, 2009, 11:44pm
 
Hi, I am using OpenCV for blob detection,
This is code from the OpenCV website
and I change background to black to give more contrast white/black.


In front of the webcam, I gonna have a picture that has a black color shape and white background.

Is there way to trace the outline of the  black color shape?

Thanks.

-------------Code---------------

import hypermedia.video.*;

OpenCV opencv;

void setup() {

   size( 640, 480 );

   // open video stream
   opencv = new OpenCV( this );
   opencv.capture( 640, 480 );

}

void draw() {

   background(0);

   opencv.read();           // grab frame from camera
   opencv.threshold(80);    // set black & white threshold

   // find blobs
   Blob[] blobs = opencv.blobs( 10, width*height/2, 100, true, OpenCV.MAX_VERTICES*4 );

   // draw blob results
   for( int i=0; i<blobs.length; i++ ) {
       beginShape();
       for( int j=0; j<blobs[i].points.length; j++ ) {
           vertex( blobs[i].points[j].x, blobs[i].points[j].y );
       }
       endShape(CLOSE);
   }

}
Page Index Toggle Pages: 1