Created
May 17, 2011 14:36
-
-
Save qingfeng/976593 to your computer and use it in GitHub Desktop.
opencv blob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hypermedia.video.*; | |
OpenCV opencv; | |
void setup() { | |
size( 640, 480 ); | |
// open video stream | |
opencv = new OpenCV( this ); | |
opencv.capture( 640, 480 ); | |
} | |
void draw() { | |
background(192); | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment