FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   video processing Q
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: video processing Q  (Read 841 times)
mawend

Email
video processing Q
« on: Oct 5th, 2003, 7:36am »

Can anyone point me to some code snippets for doing realtime video image processing? I'd like to do things like accumulate (add) sequential captured frames of webcam video, but am having trouble with the syntax for storing and doing math on video images.
 
ANy help appreciated. thanks.
 
JohnG

WWW
Re: video processing Q
« Reply #1 on: Oct 5th, 2003, 12:19pm »

on Oct 5th, 2003, 7:36am, mawend wrote:
Can anyone point me to some code snippets for doing realtime video image processing I'd like to do things like accumulate (add) sequential captured frames of webcam video, but am having trouble with the syntax for storing and doing math on video images.
 
ANy help appreciated. thanks.

 
I *think* that if you've done beginVideo(...); you can then just access video.pixels[x+(y*width)] to access the pixels of the image captured, and then do whatever you want with them before drawing them to screen.
 
you can create an array of pixels to do storage/maths on like this:
color screen[width][height]; (after you've done size(..); )
 
With that you can copy the video pixels into the screen array, do maths on them, then loop through that 2D array drawing to screen:
for(int y=0;y<height;y++)
{
  for(int x=0;x<width;x++)
  {
    set(x,y,screen[x][y]);
  }
}
 
elout

12747371274737 WWW
Re: video processing Q
« Reply #2 on: Oct 5th, 2003, 3:20pm »

A simple negative camera image example.
 
Code:

// cam002 - elout de kok 5okt03  
// www.xs4all.nl/~elout
// p5-v.0065
 
int vidx=320;
int vidy=240;
 
boolean vid_update=false;
BImage my_buffer=new BImage(vidx,vidy);
int my_r,my_g,my_b;
 
void setup()  
{  
  size(600, 400);
  beginVideo(vidx, vidy, 12);
}  
 
public void videoEvent()  
{
  vid_update=true;
}  
 
void loop()  
{  
 
  if (vid_update==true)
  {
    for (int i=0;i<vidx*vidy;i++)
    {
 my_r=255-((video.pixels[i] >> 16) & 0xff);
 my_g=255-((video.pixels[i] >>  8) & 0xff);
 my_b=255-(video.pixels[i] & 0xff);    
 my_buffer.pixels[i]=( ( my_r << 16) | ( my_g << 8) | my_b);  
    }
    image(my_buffer, 0, 0, width, height);    
    vid_update=false;
  }
   
 // just add a little delay so system can handle other stuff as well
 delay(15);
}

« Last Edit: Oct 5th, 2003, 3:23pm by elout »  
Mark Wendell
Guest
Email
Re: video processing Q
« Reply #3 on: Oct 7th, 2003, 6:15am »

Excellent! Thank you. That did the trick.
 
I'm experiementing with accumulating low-exposure imagery with a cheap ccd camera. One of the challenges now is to come up with ways to "calibrate" the results by removing inherent noise in the camera.
 
Anyone else doing stuff like this, for example for low-res amateur astronomy?
 
Mark
 
Jerronimo

WWW
Re: video processing Q
« Reply #4 on: Oct 7th, 2003, 10:59pm »

I've done stuff like that for non-amateur astronomy.  (we had an infrared camera down at the south pole a few years back, and I helped write the software that reduced the data coming off of the sensor.)
 
There are a bunch of standard things you'll want to do. I'm wicked busy right now, so I can't really go into details, but i can answer questions.
 
carlos g
Guest
Email
Re: video processing Q
« Reply #5 on: Nov 4th, 2003, 4:11pm »

Hello I am having problems getting any live video straming into processing going, is just freezing when I run the simple example code Ive tried with versions 65 and 67  
 
 void setup() {  
  size(320, 240);  
  beginVideo(320, 240, 24);  
}  
 
void loop() {  
  // Display the video image at location [0, 0]  
  image(video, 0, 0);  
}  
 
 
 
bren

WWW Email
Re: video processing Q
« Reply #6 on: Nov 4th, 2003, 7:17pm »

I think you'll need the videoEvent method (see above)
 
fry


WWW
Re: video processing Q
« Reply #7 on: Nov 4th, 2003, 11:06pm »

on Nov 4th, 2003, 4:11pm, carlos g wrote:
Hello I am having problems getting any live video straming into processing going, is just freezing when I run the simple example code Ive tried with versions 65 and 67
 

if you're using windows, you'll probably need to install winvdig, if you haven't yet. there's a note about it in readme.txt.
 
milov

WWW
Re: video processing Q
« Reply #8 on: Nov 30th, 2003, 11:44pm »

I have a tv-tuner card as well as a webcam. Whenever I try a p5 video processing script such as elout's example above, it uses the tv-tuner as source, not the webcam. Any idea how I can get it to use the webcam instead?
 
fry


WWW
Re: video processing Q
« Reply #9 on: Dec 1st, 2003, 5:59pm »

not currently.. though this will be something i'll fix for the next verrsion of the video api.
 
Pages: 1 

« Previous topic | Next topic »