Patch takes two images instead of one.
in
Contributed Library Questions
•
1 year ago
I am trying to build a simple photobooth and I got most of the things in place in my programming.
Except that the patch takes two images instead of one, and randomly selects which one to show.
The patch is as follows:
import codeanticode.gsvideo.*;
import processing.serial.*;
import ddf.minim.*;
Serial arduino;
GSCapture webcam;
Minim minim;
AudioPlayer audio;
boolean takePicture;
void setup() {
takePicture = false;
size(960, 720);
println(Serial.list());
arduino = new Serial(this, Serial.list()[0], 9600);
webcam = new GSCapture(this, 640, 480);
minim = new Minim(this);
audio = minim.loadFile("click.wav");
}
void draw() {
while (arduino.available() > 0) {
int inByte = arduino.read();
println(inByte);
println("Input received, take picture.");
webcam.play();
takePicture = true;
break;
}
if(takePicture && webcam.available() && webcam.isPlaying()) {
audio.play();
while(audio.isPlaying()) {
}
webcam.play();
webcam.read();
image(webcam, 0, 0);
save(String.format("%d-%02d-%02d-%02d-%02d-%02d.jpg", year(),month(),day(),hour(),minute(),second()));
save("nowimage.jpg");
webcam.pause();
println("Input received, take picture2.");
takePicture = false;
}
delay(1000);
}
void stop()
{
audio.close();
minim.stop();
super.stop();
}
This is what it tells me:
49
Input received, take picture.
49
Input received, take picture.
Input received, take picture2.
The sketch on the Arduino has a debounce, which should prevent it from 'pushing' the button twice in a row.
I hope one of you clever people can help me!
1