euglena/lib/opencv_processing/examples/BackgroundSubtraction/BackgroundSubtraction.pde
2016-07-10 00:36:44 -07:00

38 lines
588 B
Plaintext

import gab.opencv.*;
import processing.video.*;
Movie video;
OpenCV opencv;
void setup() {
size(720, 480);
video = new Movie(this, "street.mov");
opencv = new OpenCV(this, 720, 480);
opencv.startBackgroundSubtraction(5, 3, 0.5);
video.loop();
video.play();
}
void draw() {
image(video, 0, 0);
opencv.loadImage(video);
opencv.updateBackground();
opencv.dilate();
opencv.erode();
noFill();
stroke(255, 0, 0);
strokeWeight(3);
for (Contour contour : opencv.findContours()) {
contour.draw();
}
}
void movieEvent(Movie m) {
m.read();
}