We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. I have a new question about code. I'm trying to save frames from a web cam while a video is playing in the screen.
I have this code that allows me to save frames, but I don't want to save frames from the displayed video. What I'm not seeing?
Thanks in advance!
import processing.video.*;
Capture cam;
Movie video;
boolean showVideo=false;
boolean saveframe=false;
void setup() {
size(640, 480);
cam = new Capture(this, 640, 480, 30);
video = new Movie(this, "ex.mp4");
cam.start();
}
void draw() {
background(0);
if (showVideo==false) {
image(cam, 0, 0);
} else {
image(video, 0, 0);
}
if (saveframe==true) {saveFrame("output.##.jpg");
}
}
void keyPressed() {
showVideo=true;
video.loop();
saveframe=true;
}
void keyReleased() {
showVideo=false;
video.stop();
saveframe=false;
}
void captureEvent(Capture webCam) {
webCam.read();
}
void movieEvent(Movie m) {
m.read();
}
Answers
Two approaches to consider:
Thanks, I'll try!