Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created April 16, 2013 16:42
Show Gist options
  • Save atduskgreg/5397471 to your computer and use it in GitHub Desktop.
Save atduskgreg/5397471 to your computer and use it in GitHub Desktop.
Real time face detection in OpenCVPro
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