Hey there,
For school i am building an interactive installation for children. The concept for this machine is "stop motion". With some help from this forum i build a stopmotion script with three basic options:
Take photo & Project Onion skin
Play image sequence up until the last taken "photo"
Reset & save new .mov file in wich frames will be placed
Because this installation will be placed in an museum it has to contain an "standby modus" in which i want to include some basic information. My idea is to play a movie after X minutes.
Is it possible to play a preset movie after a defined sum of minutes? And when it plays return to the normal running code after a push on a button ( button can be whatever, mouse button etc. my script also uses arduino for input )
Thanks in advance!
My code:
Quote:// TINY STOP-FRAME PROGRAM
// Saves an image from the camera when a key/mouse is pressed.
// For Processing Version 1.01.
//----------------------------------------------------------
// Parameters you can modify:
int videoWidth = 1280; // could be 160, 320, 640, etc.
int videoHeight = 800; // could be 120, 240, 480, etc.
int onionSkinTransparency = 0; // between 0 and 255
int playbackSpeed = 125; // speed van tussentijdse playback
int takePicDelay = 2; //delay tussen scherm zwart maken en foto maken.
//----------------------------------------------------------
import processing.video.*;
PImage previousImage;
PImage _sequenceImage;
Capture myCapture;
int saveCount = 0;
int saveCountBackup = 0;
int takePictureDelay = takePicDelay;
SerialListener serialListener;
boolean bDoSave = false;
boolean bReady = false;
boolean playSequence = false;
boolean startNew = true;
//SOUND CODE----------------------------------------------------------
import ddf.minim.*;
Minim minim;
AudioSample foto;
AudioSample play;
AudioSample upload;
//VIDEO CODE----------------------------------------------------------
import processing.video.*;
MovieMaker mm;
//----------------------------------------------------------
void setup(){
myCapture = new Capture(this, videoWidth,videoHeight);
size(myCapture.width,myCapture.height);
serialListener = new SerialListener(this, "COM4");
//SOUND CODE----------------------------------------------------------
minim = new Minim(this);
foto = minim.loadSample("camera.wav", 2048);
play = minim.loadSample("bloop.wav", 2048);
upload = minim.loadSample("boing.wav", 2048);
// video code -----------------------------------------
// Or, set specific compression and frame rate options
createM();
}
void createM(){
previousImage = new PImage(myCapture.width,myCapture.height);
mm = new MovieMaker(this, width, height, "/data/movies/stop_motion"+ day()+ hour()+ minute()+ second()+".mov", 2,
MovieMaker.ANIMATION, MovieMaker.BEST);
}
//----------------------------------------------------------
void keyPressed(){
if ( key == 'f' ) bDoSave = true;
if ( key == 'f' ) bReady = true;
if ( key == 'f' ) mm.addFrame();
//SOUND CODE----------------------------------------------------------
if ( key == 'f' ) foto.trigger();
if ( key == 'p' ) play.trigger();
if ( key == 'u' ) upload.trigger();
}
void mousePressed(){
if (mouseButton == LEFT) {
makeFoto();
}
if (mouseButton == CENTER) {
startNew();
}
if (mouseButton == RIGHT) {
playMovie();
}
}
void makeFoto() {
bDoSave = true;
bReady = true;
foto.trigger();
}
void startNew() {
upload.trigger();
saveCount = 0;
createM();
startNew = true;
}
void playMovie() {
play.trigger();
playSequence = true;
}
//----------------------------------------------------------
void draw()
{
//SAVEIN-------------------------------------------------------
// Add window's pixels to movie
serialListener.serialRead();
if(myCapture.available()) {
background(0);
delay(200);
//myCapture.read();
//BLACKFRAME-------------------------------------------------------
if (bReady) {
//draw black frame
startNew = false;
bReady = false;
bDoSave = true;
} else if (bDoSave) {
if(takePictureDelay > 0) {
drawBlack();
takePictureDelay--;
} else {
if(takePicture()){
takePictureDelay = takePicDelay;
bDoSave = false;
}
}
} else {
if(!playSequence) {
//draw previous image
if(startNew) {
drawBlack();
} else {
image(previousImage, 0,0);
image(myCapture, 0,0);
}
}
}
// playsequence
if(playSequence) {
if(saveCountBackup < saveCount) {
_sequenceImage = loadImage("/data/fotos/stopframe_"+ nf(saveCountBackup, 5)+ ".jpg");
image(_sequenceImage,0,0);
delay(playbackSpeed);
saveCountBackup++;
}else {
saveCountBackup = 0;
playSequence = false;
}
}
}
}
void drawBlack() {
fill(0);
rect(0,0,this.width,this.height);
}
boolean takePicture() {
//capture image
noTint();
myCapture.read();
image(myCapture, 0,0);
String filename = "/data/fotos/stopframe_" + nf(saveCount++, 5) + ".jpg";
saveFrame(filename);
previousImage.loadPixels();
arrayCopy (myCapture.pixels, previousImage.pixels);
previousImage.updatePixels();
mm.addFrame();
return true;
}
//SOUND CODE----------------------------------------------------------
void stop()
{
// always close Minim audio classes when you are done with them
foto.close();
minim.stop();
serialListener.destroy();
super.stop();
}