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
pieces of a video (Read 699 times)
pieces of a video
Dec 1st, 2005, 5:06pm
 
what i am hoping to do for my next project is to have a webcam set up and what i want to do is have the image piece together in blocks. basically i want the webcam to eventually form a still image made up of pieces of the video throughout time. my problem is i dont really know how to get started. is it possible to have a video cropped down to a piece then paused with that still image and then have another piece cropped down and paused. id perfer not to do it pixel by pixel but it seems like it may be the easiest way.

if anyone has any sketches that would give me an idea of where to go, thatd be greatly appreciated. or even some advice as to how to go about this. thanks.

randy
Re: pieces of a video
Reply #1 - Dec 5th, 2005, 8:32pm
 
sorry for the dumb question before i did some more looking and found that it is easier to crop then i thought. so far i have this:

<code>
import processing.video.*;  
Capture myCapture;
Piece [] piece;

void setup()
{
 size(200, 200);
 framerate(30);
 myCapture = new Capture(this, 200, 200, 15);
 
 for (int i = 0; i < 15; i++){
   piece[i] = new Piece(i+10, i+10, 10, 10, i*10);
 }  
 background(0);  
}


void captureEvent(Capture camera)
{
 camera.read();
}

void draw()
{
 background(0);
 for (int i = 0; i < 15; i++){
   piece[i].make();
   piece[i].update();
 }
}  


class Piece{
 float x, y, pwidth, pheight, stoptime;
 
 Piece(float x, float y, float pwidth, float pheight, float stoptime){
   this.x = x;
   this.y = y;
   this.pwidth = pwidth;
   this.pheight = pheight;
   this.stoptime = stoptime;
 }
 
 void make() {
   myCapture.crop(x, y, pwidth, pheight);
 }
 
 void update() {
   timer++;
   if(timer > 10+stoptime){
     myCapture.stop();
     }  
 }
}                

</code>

my next problem is that i cant seem to get it to display the video multiple times. also will myCapture.stop stop the video but keep the last image up similar to the way in which pause works? is there a different way in which i could get the pause effect then and keep the last image on screen? please help, im confusing myself more and more the deeper i get in this project.
Re: pieces of a video
Reply #2 - Dec 6th, 2005, 1:10pm
 
Have you tried using copy() or get() to put your video still into an image buffer?

I would suggest Piece have a PImage property
Code:

//before constructor
PImage buffer;

//during constructor
buffer = new PImage(pwidth,pheight);

//new method for loading current Capture image into a given piece
void load(){
buffer.copy(myCapture, x, y, pwidth, pheight, 0, 0, pwidth, pheight);
//might have to use buffer.updatePixels(); here, not sure
}

I would also suggest basing your timer on millis() as your project will run differently on different computers.
Page Index Toggle Pages: 1