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
shape detection with opencv (Read 6380 times)
shape detection with opencv
Mar 27th, 2009, 12:18am
 
hi,

i"m trying to detect shapes with opencv and processing.
i just need to detect three distinct shapes. right now i run blob detection and check if a blob is within another blob using isHole. then if the blob is smaller than a certain area i call it shape A.

this is pretty messy, do you guys know of a better way out? i just need a way to distinguish between three distinct shapes of blobs.

here is my messy code:


////////////////////////////////////////

import hypermedia.video.*;

OpenCV opencv;
PImage zaz1, zaz2;

void setup() {
  size( 920, 600 );

  // open video stream
  opencv = new OpenCV( this );
  opencv.capture( 640, 480 );
zaz1 = loadImage("w1.gif");
zaz2 = loadImage("w2.gif");

}

void draw() {

background(255, 210, 0);

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


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

  // draw blob results

 for( int i=0; i<blobs.length; i++ ) {

   if(blobs[i].isHole && (blobs[i].area>=300))   {
                image(zaz1, (blobs[i]).centroid.x, (blobs[i]).centroid.y);
    }

/*  if(!(blobs[i].isHole) && (blobs[i].area>1200))   {
     
      image(zaz2, (blobs[i]).centroid.x, (blobs[i]).centroid.y);
 
     }
     
  */    
   
 }
}


//////////////////////////////////////////////////
Re: shape detection with opencv
Reply #1 - Dec 12th, 2009, 2:27pm
 
i have a question how can i take each blob and i put it in a picture box  ???
where is the coordinates x,y,width,heght in open cv of each blob and how can i get them ??

thanks for the answers
Re: shape detection with opencv
Reply #2 - Dec 12th, 2009, 7:36pm
 
please how can i get x,y,width,heigt of each blob ? i want to call a function with this variables i the main form and i don't know how can i get . Opencv class blob i work at c#.

how i tell the opencv blob :take the first blob olny ??

some advise al least
Page Index Toggle Pages: 1