Skip to content

Instantly share code, notes, and snippets.

@qingfeng
Created February 17, 2011 17:40
Show Gist options
  • Save qingfeng/832217 to your computer and use it in GitHub Desktop.
Save qingfeng/832217 to your computer and use it in GitHub Desktop.
Processing+OpenCV
import hypermedia.video.*;
import java.awt.Rectangle;
OpenCV opencv;
void setup() {
size( 320, 240 );
opencv = new OpenCV(this);
opencv.capture( width, height );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load the FRONTALFACE description file
}
void draw() {
opencv.read();
image( opencv.image(), 0, 0 );
// detect anything ressembling a FRONTALFACE
Rectangle[] faces = opencv.detect();
// draw detected face area(s)
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment