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 & HelpVideo Capture,  Movie Playback,  Vision Libraries › capturing with 2 webcam and switching with key
Page Index Toggle Pages: 1
capturing with 2 webcam and switching with key (Read 957 times)
capturing with 2 webcam and switching with key
Jun 14th, 2010, 10:45am
 
hello,
I am not very good with processing and ı need urgent help for my final project. I am capturing with 2 logitech cams on a mac osx system and what I want is feed from cam 1 to switch to feed from cam 2 when I press the button b. I think my problem is about the part keyPressed() but I can't find a solution. the code was working until 10 min ago with two webcams aptuing and also now, all I get is a grey screen. any help??

my code is this:

import processing.video.*;



Capture myCapture;
Capture myCapture2;
String[] captureDevices;


void setup()
{
 size( 600, 800 );
 println (Capture.list());
 captureDevices = Capture.list();
 
 myCapture = new Capture(this, width, height, 30);
 myCapture.settings();  
 
 myCapture2 = new Capture(this, width, height, 30);
 myCapture2.settings();

}

void draw() {
  if(keyPressed) {
   if (key == 'b' || key == 'B') {

 
    image(myCapture, 200, 200);
 
        }else{
 

image(myCapture2, 200, 200);
 }
}

}
   


Re: capturing with 2 webcam and switching with key
Reply #1 - Jun 14th, 2010, 11:21am
 
supernova wrote on Jun 14th, 2010, 10:45am:
keyPressed() but I can't find a solution. the code was working until 10 min ago with two webcams aptuing and also now, all I get is a grey screen. any help?


The first thing you should do, in that case is get back so at least you get some input from the webcams, and not just grey screen. Finding errors in code, regarding one thing, is not very easy when there are other, more basic problems as well.

You should also probably have a separate keypress-function, and not check for it in the draw-loop. But it might not that important.

Anyway, from what I can tell from the code you have here, an image will only be displayed as long as a key is pressed. Either 'b' for camera 2, or any other key for camera 1.

Page Index Toggle Pages: 1