We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to make video play when motion is detected, but for some reason the video won't play and I'm rather blind to my code from looking at it now. Anyone with experience have any ideas? The motion detection works, it starts the video, but the video won't actually show up but I can't tell what is writing over it. import processing.video.*; Capture video; Movie newVideo; PImage prevFrame; float theshold = 150;
void setup() {
size(displayWidth,displayHeight);
video = new Capture(this, width, height, 30);
newVideo = new Movie(this, "Nightman.mov");
prevFrame = createImage(video.width,video.height,RGB);
video.start();
}
void draw() {
background(60);
if (video.available()) {
prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); //Saves last frame to compare against the new one
prevFrame.updatePixels();
video.read();
}
loadPixels();
video.loadPixels();
prevFrame.loadPixels();
//This loop begins the walkthrough the pixels
for( int x = 0; x < video.width; x++){
for(int y = 0; y < video.height; y++){
int location = x + y * video.width;
color current = video.pixels[location];
color previous = prevFrame.pixels[location];
float vidR = red(current); float vidG = green(current); float vidB = blue(current);
float prevR = red(previous); float prevG = green(previous); float prevB = blue(previous);
float collrDiff = dist(vidR,vidG,vidB,prevR,prevG,prevB);
if(collrDiff > theshold){
newVideo.play();
}
}
updatePixels();
image(newVideo,0,0);
}
void movieEvent(Movie m){
m.read();
}
Thanks!
Answers
Are you saying the movie isn't playing? or the cam capture?
The movie won't play when the motion is detected. Even when the cam pixels aren't even shown or updating, there's something overwriting the screen and I can't find it.