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 );
}
}
}