Created
April 16, 2013 16:42
-
-
Save atduskgreg/5397471 to your computer and use it in GitHub Desktop.
Real time face detection in OpenCVPro
This file contains 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 gab.opencvpro.*; | |
import processing.video.*; | |
import java.awt.*; | |
Capture video; | |
OpenCVPro opencv; | |
void setup() { | |
size(640, 480, P2D); | |
video = new Capture(this, 640/2, 480/2); | |
opencv = new OpenCVPro(this, 640/2, 480/2); | |
opencv.loadCascade(OpenCVPro.CASCADE_FRONTALFACE_ALT); | |
video.start(); | |
} | |
void draw() { | |
scale(2); | |
background(0); | |
image(video, 0,0 ); | |
opencv.loadImage(video); | |
noFill(); | |
stroke(0,255,0); | |
strokeWeight(3); | |
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); | |
} | |
} | |
void captureEvent(Capture c) { | |
c.read(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment