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 & HelpSyntax Questions › Is it possible to post real-time webcam image
Page Index Toggle Pages: 1
Is it possible to post real-time webcam image? (Read 368 times)
Is it possible to post real-time webcam image?
Mar 6th, 2006, 2:38am
 
I am doing my project, but it doesn't work well... Please help me.

I am making an interacive design thing using processing, webcam and html.
What i want to do is to show the real-time webcam image on the web.
My code works well when I run it in processing. But when I run it on web browser after exporting, it doesn't work. I can see just white image.

I've tried in various kinds of webbrowser and many processing versions.
Is there any way that I can show the real-time webcam image on the web using processing?

If it is impossible by html, is there any other ways that show the real time webcam image on the screen with the timer ( I made it using Flash )? I guess it is not complex thing, but i don't know.

Thak you.


There is a "JAR file" in the HTML file.

I'm using Mac, I-sight, Safari, processing0103.

The code that I used is,
-----------------------------------------------------------
import processing.video.*;

Capture video;
int threshold = 25;
PImage edges;


void setup(){
 video = new Capture(this,640, 480, 30); //initiate the video, resolution and frame rate
 size(640, 480); //give you Processingwindow a size
 edges = new PImage( width,height); //create another image besides the video image for showing the edge
}

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


void draw(){

//edges = new PImage( width,height);
 for(int row=1; row<video.height-1; row=row+1) { //for each row
   for(int col=1; col<video.width-1; col=col+1) { //for each column
     //notice these start at 1 and leave off the last pixel so you don't overrun the array with your + 1 and -1

     int right = video.pixels[(row)*video.width+col+1];
     int left = video.pixels[(row)*video.width+col-1];
     if (abs(red(right)-red(left)) > threshold){
       edges.pixels[row*video.width+col] = color(200);  
       //change the pixels in the other one so you don't infect the one you are checking
     }else{
      edges.pixels[row*video.width+col] = color(0,0,0);  
     }
   }
 }
 edges.updatePixels();
 image(edges,0,0);
}


void keyPressed(){  //conviences for changing variables while you are the applet is running
if (keyCode ==38) { //up arrow
  threshold++;
}
else if(keyCode == 40){ //down arrow
  threshold--;
}
println("key: " + keyCode   + " Threshold: " + threshold);
}

Re: Is it possible to post real-time webcam image?
Reply #1 - Mar 6th, 2006, 11:47am
 
under "export and browser troubles" in the FAQ, see the last item:
http://processing.org/faq/bugs.html#applet
Page Index Toggle Pages: 1