We are about to switch to a new forum software. Until then we have removed the registration on this forum.
My goal is to have processing connecting to every webcam connected to the pc,but even with two cameras the code:
import processing.video.*;
Capture cam;
String[] cameras = Capture.list();
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
(from the manual,edited to add spacing) outputs something like this:
name=Logitech HD Webcam C270,size=640x480,fps=5
name=Logitech HD Webcam C270,size=640x480,fps=30
name=Logitech HD Webcam C270,size=160x120,fps=5
name=Logitech HD Webcam C270,size=352x288,fps=5
name=Logitech HD Webcam C270,size=352x288,fps=30
...
name=Logitech HD Webcam C270,size=1280x720,fps=5
name=Logitech HD Webcam C270,size=1280x720,fps=30
name=Logitech HD Webcam C270,size=1280x960,fps=5
name=Logitech HD Webcam C270,size=1280x960,fps=30
...
name=Logitech QuickCam Pro 9000,size=320x240,fps=5
name=Logitech QuickCam Pro 9000,size=320x240,fps=30
name=Logitech QuickCam Pro 9000,size=352x288,fps=5
name=Logitech QuickCam Pro 9000,size=352x288,fps=30
name=Logitech QuickCam Pro 9000,size=640x360,fps=5
....
actually there are more than 80 lines for each camera...
So I guess that processing lists every possible combination of resolution and fps... How do I connect only to the "real" webcams? I could try to identify them by the name but What if there are 2 same model cameras?
And anyway is there a way to detect when a camera is connected to the pc after the program has started?
Thanks to everybody.... waiting for you
Answers
Just conjecturing, since I've never had more than 1 webcam in the same computer:
','
in order to get those 3 properties: name, size & fps.'='
in order to separate those properties from their respective values.Dunno. Perhaps we'd see identical String or w/ some slightly diff. name? :-/
awww man I accidentally pressed yes but I'm not completely satisfied; Anyway, your is a good idea but the problem is also that since Capture.list() has over 150 elements calling this function,wich is needed to have cameras working ,becomes very slow; with just 2 cameras and calling only:
Capture.list()
it takes up to 20 sec to start the program;and with 3 it takes over 40 secs! So does every computer load such weird list of camera combinations or is it some setting I have?
This function returns an array with the unique values of the camera names: