We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Projector "blank page" (Read 1256 times)
Projector "blank page"
May 26th, 2009, 10:09am
 
Hey,

For school i am building a "stop motion machine" with an dv camera for capturing the frames, and an projector for displaying the union effect on top of the working area.

On top of a white working space children can put together images, a dv-camera beneath the working space captures their "frames" and the projector beneath the working space places the union skin on it.

Off-course i don`t want to capture the union skin wen saving a frame picture because of the Droste-effect it creates ( duplicate images until infinity, like video-recording a tv monitor ).

My question is, can i display a blank ( black ) frame on the projectorwen capturing the image. ?

The code i use:

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

//----------------------------------------------------------
import  processing.video.*;
PImage  previousImage;
Capture myCapture;
int     saveCount = 0;
boolean bDoSave = false;

//----------------------------------------------------------
void setup(){
 myCapture = new Capture(this, videoWidth,videoHeight);
 size(myCapture.width,myCapture.height);
 previousImage = new PImage(myCapture.width,myCapture.height);
}

//----------------------------------------------------------
void keyPressed(){
 bDoSave = false;
}
void mousePressed(){
 bDoSave = true;
}

//----------------------------------------------------------
void draw() {
 if(myCapture.available()) {
   myCapture.read();

   if (bDoSave){
     noTint();
     image(myCapture, 0,0);

     String filename = "stopframe_" + nf(saveCount++, 5) + ".jpg";
     saveFrame(filename);
     bDoSave = false;

     previousImage.loadPixels();
     arrayCopy (myCapture.pixels, previousImage.pixels);
     previousImage.updatePixels();
   }
   else {
     noTint();
     image(previousImage, 0,0);
     tint(255, 255, 255, onionSkinTransparency);
     image(myCapture, 0,0);
   }
 }
}


I am new to processing, and scripting. Please help, thank you!  Smiley
Re: Beamer "blank page"
Reply #1 - May 26th, 2009, 2:21pm
 
While I don't have a camera to test here, I think I understand the logic behind it.

By beamer, do you mean a projector? (I mean no offense, just trying to clarify)

You may have to set up a 3 step recording such as
Code:
boolean bReady = false;
...
void mousePressed() {
bReady = true;
}
...
void draw() {
...
if (bReady) {
//draw black frame
background(0);
bReady = false;
bDoSave = true;

} else if (bDoSave) {
//capture image
bDoSave = false;

} else {
//draw previous image

}
}
This way, you draw a blank frame just before recording.
Re: Beamer "blank page"
Reply #2 - May 27th, 2009, 4:27am
 
Thx NoahBuddy,

by beamer i indeed mean projector, srry  Smiley
I am trying to implement the code now.

Thank you!
Re: Projector "blank page"
Reply #3 - May 27th, 2009, 4:44am
 
Just tried, implemented the code without errors. But when i take a picture my screen does not show the "blank" frame. Is it possible that the frame is shown to fast?
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

//----------------------------------------------------------
import  processing.video.*;
PImage  previousImage;
Capture myCapture;
int     saveCount = 0;
boolean bDoSave = false;
boolean bReady = false;

//----------------------------------------------------------
void setup(){
 myCapture = new Capture(this, videoWidth,videoHeight);
 size(myCapture.width,myCapture.height);
 previousImage = new PImage(myCapture.width,myCapture.height);
}

//----------------------------------------------------------
void keyPressed(){
 bDoSave = false;
}
void mousePressed(){
 bDoSave = true;
 bReady = true;
}



//----------------------------------------------------------
void draw() {
 if(myCapture.available()) {
   myCapture.read();
   
     if (bReady) {
   //draw black frame
   background(0);
   bReady = false;
   bDoSave = true;

 } else if (bDoSave) {
   //capture image
   bDoSave = false;

 } else {
   //draw previous image

 }
}

   if (bDoSave){
     noTint();
     image(myCapture, 0,0);

     String filename = "stopframe_" + nf(saveCount++, 5) + ".jpg";
     saveFrame(filename);
     bDoSave = false;

     previousImage.loadPixels();
     arrayCopy (myCapture.pixels, previousImage.pixels);
     previousImage.updatePixels();
   }
   else {
     noTint();
     image(previousImage, 0,0);
     tint(255, 255, 255, onionSkinTransparency);
     image(myCapture, 0,0);
   }
 }

Re: Projector "blank page"
Reply #4 - May 27th, 2009, 8:48am
 
Under mousePressed(), you set both the ready and save flag to true.

Set only the ready flag to true.

And during draw(), you still have your original code, which will continue as it did before.

Use parts of your original code in place of the comments "//capture image" and "//draw previous" to save an image and draw the old image.
Re: Projector "blank page"
Reply #5 - May 27th, 2009, 9:58am
 
Hey thanks! Its shows a blank frame now.

Sometime this week i can test it with the projector setup, but i am not sure if one frame is enough for al the analog parts ( dv camera, projector ) to "line up". Is it possible to show more frames, or display the black frame longer during to photo taking process?

Thanks for your help in advance! This is really helping me to create something.
Re: Projector "blank page"
Reply #6 - May 27th, 2009, 10:26am
 
Since it is stop motion (not a lot going on Smiley ) you could use keyPressed()  and keyReleased() to toggle a 'photoshoot' mode... or something...
Re: Projector "blank page"
Reply #7 - May 27th, 2009, 10:40am
 
Thank you, since this is my first processing project, and my first encounter with programming at all i will search for some options.

Maybe you can also give me some tips on how to put together all the images my script makes and display them frame by frame when the user presses the "play" button ( yet to define wich button this is ).
Re: Projector "blank page"
Reply #8 - May 27th, 2009, 3:14pm
 
If you really want to get fancy, you could always save each frame to a movie file, then play that file when done.

http://processing.org/learning/libraries/drawingmovie.html

Then again, that won't let you change anything before playing unless you back up each frame at the same time.

I am curious to see how this works out. I have seen a stop motion tool before (only for Mac). Can't remember what it was called at the moment, but I don't think it was open source. :]
Re: Projector "blank page"
Reply #9 - May 28th, 2009, 1:39am
 
Saving each frame to a movie file is exactly what we are aiming for. And then playback the progress until the last frame with a press on a button.
And when done save it to a file

The installation is meant for children so it has to be pretty bullet proof. Our plan was to make an installation with three buttons:

Record a frame ( i have implemented this in the code including sound playback and an union skin that is projected on the surface with a projector )

Play all frames until the last frame so children can see what they have done before ( this will be projected on a surface with the same projector that projects the union-skin. )

Save the project ( save the project to a movie file, preferring flash, and upload it to a website, this means that each movie has to be saved separately and the working space has to be reset "new project" )

So things i need to program now are: save frame to a movie, and the option to playback frames when pressed on a button.


I see the script you send me in your previous reply, but i dont exactly understand how i can implement this in my code so each frame will be saved to one movie file? Sorry for all the questions but i am new to this. I appreciate your help with this!

Is anyone needs it this is my latest code including sound playback:
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

//----------------------------------------------------------
import  processing.video.*;
PImage  previousImage;
Capture myCapture;
int     saveCount = 0;
boolean bDoSave = false;
boolean bReady = false;
//SOUND CODE----------------------------------------------------------
import ddf.minim.*;
Minim minim;
AudioSample foto;
AudioSample play;
AudioSample upload;



//----------------------------------------------------------
void setup(){
 myCapture = new Capture(this, videoWidth,videoHeight);
 size(myCapture.width,myCapture.height);
 previousImage = new PImage(myCapture.width,myCapture.height);
//SOUND CODE----------------------------------------------------------  
 minim = new Minim(this);
 foto = minim.loadSample("camera.wav", 2048);
 play = minim.loadSample("bloop.wav", 2048);
 upload = minim.loadSample("boing.wav", 2048);  
 
}


//----------------------------------------------------------
void keyPressed(){
 if ( key == 'f' ) bDoSave = true;
 if ( key == 'f' ) bReady = true;
//SOUND CODE----------------------------------------------------------
   if ( key == 'f' ) foto.trigger();
   if ( key == 'p' ) play.trigger();
   if ( key == 'u' ) upload.trigger();
}
void mousePressed(){
 bDoSave = false;
 bReady = true;
}


//----------------------------------------------------------
void draw()
{
 
 if(myCapture.available()) {
   myCapture.read();
   
     if (bReady) {
   //draw black frame
   background(0);
   bReady = false;
   bDoSave = true;

 } else if (bDoSave) {
   //capture image
    noTint();
     image(myCapture, 0,0);

     String filename = "stopframe_" + nf(saveCount++, 5) + ".jpg";
     saveFrame(filename);
   bDoSave = false;
   previousImage.loadPixels();
    arrayCopy (myCapture.pixels, previousImage.pixels);
    previousImage.updatePixels();

 } else {
   //draw previous image
   noTint();
     image(previousImage, 0,0);
     tint(255, 255, 255, onionSkinTransparency);
     image(myCapture, 0,0);

 }
}


}
//SOUND CODE----------------------------------------------------------
void stop()
{
 // always close Minim audio classes when you are done with them
 foto.close();
 minim.stop();
 
 super.stop();
}




Page Index Toggle Pages: 1