Skip to content

Instantly share code, notes, and snippets.

@REAS
Created July 3, 2016 10:41
Show Gist options
  • Save REAS/dd67dafe5b26fe35026a55e2e74348d5 to your computer and use it in GitHub Desktop.
Save REAS/dd67dafe5b26fe35026a55e2e74348d5 to your computer and use it in GitHub Desktop.
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture video;
OpenCV opencv;
void setup() {
size(640, 480);
video = new Capture(this, width, height);
opencv = new OpenCV(this, width, height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start();
}
void draw() {
if (video.available() == true) {
video.read();
}
opencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(0, 255, 0);
strokeWeight(3);
Rectangle[] faces = opencv.detect();
for (int i = 0; i < faces.length; i++) {
//println(faces[i].x + "," + faces[i].y);
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