OpenCV Inverting Blob
in
Contributed Library Questions
•
2 years ago
I'm currently using the code I pulled form the OpenCV and website messing around and trying to understand blob detection. I applied a red stroke to the blob, but it seems that it is outlining everything around me, rather than myself. Does that mean that, technically, I'm NOT the blob? If so, how can I fix this?
Any help is greatly appreciated as I'm trying to understand this so I can implement it into a project I'm starting, which incorporates people as the blobs. For your convenience, here's the code to copy into Processing (as long as you have the OpenCV library):
- 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(100); // 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();
- //stroke
- stroke(255,0,0);
- strokeWeight(3);
- for( int j=0; j<blobs[i].points.length; j++ ) {
- vertex( blobs[i].points[j].x, blobs[i].points[j].y );
- }
- endShape(CLOSE);
- }
- }
1