Today I was working in a code to stop and play a movie file using camera as mouse for a friend who wants to build an installation in a store window. The library I'm using is JMyron for Processing. Here is the first code I finished, but I'm still having problems using the function myMovie.pause and my.Movie.speed:
import fullscreen.*;
import JMyron.*;
import processing.video.*;
Movie myMovie;
FullScreen fs;
JMyron m;
void setup() {
size(800, 600);
background(0);
myMovie = new Movie(this, "vitrine.3gp");
myMovie.loop();
fs = new FullScreen(this);
fs.enter();
m = new JMyron();
m.start(width,height);
m.trackColor(255,255,255,256*3-100); //adjust 3-5
m.update();
m.adaptivity(100); // how fast the white is capted! it was 100
m.adapt();// immediately take a snapshot of the background for differencing
println("Myron " + m.version());
rectMode(CENTER);
noStroke();
}
void movieEvent(Movie myMovie) {
myMovie.read();
}
void draw() {
m.update();
drawCamera();
int[][] centers = m.globCenters();
float avX=0;
float avY=0;
for(int i=0;i
avX += centers[i][0];
avY += centers[i][1];
}
if(centers.length-1>0){
avX/=centers.length-1;
avY/=centers.length-1;
}
image(myMovie, 0, 0);
if(!(avX==0&&avY==0)&¢ers.length>1){
myMovie.stop();
}
if(!(avX==1&&avY==1)&¢ers.length>1){
myMovie.play();
}
fill(0,0,0);
ellipseMode(CENTER);
}
void drawCamera(){
loadPixels();
updatePixels();
}
No comments:
Post a Comment