Created
February 17, 2011 17:40
-
-
Save qingfeng/832217 to your computer and use it in GitHub Desktop.
Processing+OpenCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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