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.
IndexProgramming Questions & HelpPrograms › video delay
Page Index Toggle Pages: 1
video delay (Read 897 times)
video delay
Nov 8th, 2005, 6:14pm
 
Hi

Trying to make a 10 second delay in a video stream but I'm completely stuck as to why it doesn't seem to have a delay after the inital delay.  Below is my code - any help much appreciated...


import processing.video.*;
Capture v_capture;
int v_width;
int v_height;

int framerate = 1; //per sec  
int delay = 10; // secs
PImage[] videobuffer;
boolean bufffull = false;
int bufindex;
 
int j = 0;

//setup function
void setup()
{
 //set stage size
 //size(screen.width, screen.height);
 size(500, 500, P3D);
   
 //set stage background
 background(0, 0, 0);
   
 //set the framerate
 framerate(1);

 //webcam name
 String webcam = "Quickcam";

 //width and height stored as a variable
 v_width = 318;
 v_height = 256;

 //capture the camera
 v_capture = new Capture(this, webcam, v_width, v_height);
 v_capture.framerate(1);

 //video buffer and index
 videobuffer = new PImage[framerate * delay];
 bufindex = 0;

 //while less than the length of the video buffer
 for (int i = 0; i < videobuffer.length; i++)
 {
   //add an image to the video buffer
   videobuffer[i] = new PImage(v_width, v_height);
 }

}



void captureEvent(Capture v_capture)
{
 //read the latest image from the capture event
 v_capture.read();
}




void draw()
{

 //while less than the length of the video buffer
 if (j < videobuffer.length)
 {
   //add an image to the video buffer
   videobuffer[j] = v_capture;
   bufffull = true;
   j++;
 }
 else
 {  
   //shuffle everything in the array left or back one
   for(int i = 1; i < videobuffer.length; i++)
   {  
     videobuffer[i-1] = videobuffer[i];
   }
   
   //set the last item in array to be latest video capture
   videobuffer[videobuffer.length - 1] = v_capture;
 }
 
 // this flag waits for the buffer to become full
 if (bufffull = true)
 {
   //calculate position for video on screen according to window size and video size
   int xpos = 100; int ypos = 100;
     
   //set the image to be the first image from the videobuffer array
   image(videobuffer[1], xpos, ypos);  
 }

}
Re: video delay
Reply #1 - Nov 10th, 2005, 1:25am
 
Don't know if this will work 'cause my webcam is at uni, but try copying from v_capture instead equaling it. v_capture was made from the Capture class. Using "=" is like saying, "turn this into that Capture class object". All you want is a copy of the image in the Capture object. Use copy().

I know I seem to be answering all your questions but I'm avoiding working on a back-propagation neural net for gesture recognition that's doing my head in. I've inquired but no-one is rushing to my aid. It's a bit specialist (and brain hurty).
Re: video delay
Reply #2 - Nov 12th, 2005, 3:10am
 
so...


videobuffer[j] = v_capture;
becomes this...
videobuffer[j].copy(v_capture, 0, 0, v_width, v_height, 0, 0, v_width,

and this...
videobuffer[videobuffer.length - 1] = v_capture;
becomes this...
videobuffer[videobuffer.length - 1].copy(v_capture, 0, 0, v_width, v_height, 0, 0, v_width, v_height);

am getting an initial delay now.  it seems as if the first time the array is filled it works but ether the for() loop which shifts images left or the copy which adds a new image to the end of the array don't seem to be working.  will work on this tomorrow.

am appreciating the help very much, gesture recognition - this is that EyesWeb motion capture mentioned on your site? way beyond me in processing for the moment so i'd be little help there, php is my thing so will gladly reciprocate if you need help in that.

a+
gar
Page Index Toggle Pages: 1