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 and multiple cascade()? (Read 819 times)
OpenCV and multiple cascade()?
Feb 7th, 2009, 9:38am
 
Hello~

Grabbed openCV the other day in response to the article on CreateDigitalMotion and started screwing around with it instead of doing my readings for Qualitative Methods in Political Science....


Anyway, very new to processing, but my _goal_ is to have a rectangle surround a positive response to a front face detect(), and an ellipse to surround a profile detect(), with seperate cascade functions in the class constructors....

Here's my code.  Again, I'm very new to both processing and programming, so... yeah.  My only experience with code before was PHP... anyway, please help.  Any explanation, be it regarding openCV or a chiding regarding my programming follies, would be appreciated.

I copied a wee bit of the code here:
http://ubaa.net/shared/processing/opencv/opencv_cascade.html

I didn't realize that primatives could be used as array types prior to this also... are there further array types beyond Rectangle?

Code:

import hypermedia.video.*;
OpenCV opencv;
Front front;
Profile profile;

PImage pstImage;

void setup(){
size(320,240);
opencv = new OpenCV( this );
opencv.capture(width,height);
front = new Front();

profile = new Profile();

ellipseMode(CORNER);
noFill();
smooth();
}

void draw() {
opencv.read();
image( opencv.image(), 0, 0);

front.update();
profile.update();


}

class Front{


Front(){
opencv.cascade(OpenCV.CASCADE_FRONTALFACE_ALT);

}

void update() {
Rectangle[] faces = opencv.detect();
for( int i=0; i<faces.length; i++ ) {
rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
}

}

}


class Profile{


Profile() {
opencv.cascade(OpenCV.CASCADE_PROFILEFACE);
}

void update() {
Rectangle[] faces2 = opencv.detect();
for( int i=0; i<faces2.length; i++ ) {
ellipse( faces2[i].x, faces2[i].y, faces2[i].width, faces2[i].height );
}

}


}
Re: OpenCV and multiple cascade()?
Reply #1 - Mar 11th, 2009, 9:36am
 
hi there,
i'm wondering if you figured out how to use multiple cascade files correcty? with most implementations i could think of, processing crashes after a while due to exhausting memory use. i think you hit the same problem with you patch.

it would seems logical that opencv.detect() needs to take cascade name as one of the arguments, however it does not.

regards,
Page Index Toggle Pages: 1