Skip to content

Instantly share code, notes, and snippets.

@dave-santiano
Created April 19, 2017 17:37
Show Gist options
  • Save dave-santiano/8d42c91221e74f954f7095906c5f1275 to your computer and use it in GitHub Desktop.
Save dave-santiano/8d42c91221e74f954f7095906c5f1275 to your computer and use it in GitHub Desktop.
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture video;
OpenCV opencv;
String timestamp;
void setup(){
size(1280,720);
video = new Capture(this, 1280,720);
opencv = new OpenCV(this, 1280,720);
opencv.startBackgroundSubtraction(5,3,0.5);
video.start();
}
void draw(){
timestamp = year() + nf(month(),2) + nf(day(),2) + "-" + nf(hour(),2) + nf(minute(),2) + nf(second(),2);
background(0);
// image(video,0,0);
opencv.loadImage(video);
opencv.dilate();
opencv.erode();
opencv.updateBackground();
noFill();
stroke(207,23,47);
strokeWeight(5);
for (Contour contour : opencv.findContours()){
contour.draw();
if (contour.numPoints() > 1000){
saveFrame(timestamp + "faces_of_fear-#######.png");
}
}
}
void captureEvent(Capture c){
c.read();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment