Can I play a video in detected blobs??
in
Contributed Library Questions
•
2 years ago
Can I have two layers of video, one that plays as the background image and one that plays in the OpenCV blob shapes? This is what I have so far.
Any suggestions is greatly appreciated! thank you in advance.
import hypermedia.video.*;
import processing.video.*;
OpenCV opencv;
Movie mov;
Movie movtwo;
PImage movie1;
PImage movie2;
void setup() {
size( 640, 480, P3D );
mov = new Movie(this, "homepage.mov");
mov.loop();
movtwo = new Movie(this, "changehomepage.mov");
movtwo.loop();
// open video stream
opencv = new OpenCV( this );
opencv.capture( 640, 480 );
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
background (255);
image(mov, 0, 0);
opencv.read(); // grab frame from camera
opencv.threshold(40); // set black & white threshold
// find blobs
Blob[] blobs = opencv.blobs( 20, width*height/2, 200, true);
// draw blob results
for( int i=0; i<blobs.length; i++ ) {
//stroke(255,255,255,10); this works to fill the blob shapes with a color but I want to replace this with the second video
beginShape();
for( int j=0; j<blobs[i].points.length; j++ ) {
vertex( blobs[i].points[j].x, blobs[i].points[j].y );
vertex (320,160,0);
}
endShape(CLOSE);
}
}
1