In a nutshell: The sample code in
Reference:Libraries:Video for
Capture.list() doesn't work with my MacBook's built-in iSight camera. Some of the example code distributed with the Processing 1.0.3 application does.
Details: I was curious to see how the built-in iSight shows up in Capture.list() so I cut and pasted the following code from the Reference entry for Capture.list():
Quote:import processing.video.*;
void setup() {
size(200, 200);
print(Capture.list()); [/color]
}
When I ran the code, I got the following message in the console:
[Ljava.lang.String;@e2161dSo I went to the main entry for Capture in the Reference and cut and pasted the following code. I uncommented the println() statement and ran it.
Quote:import processing.video.*;
Capture myCapture;
void setup()
{
size(200, 200);
myCapture = new Capture(this, width, height, 30);
// The name of the capture device is dependent those
// plugged into the computer. To get a list of the
// choices, uncomment the following line
println(Capture.list());
// And to specify the camera, replace "Camera Name"
// in the next line with one from Capture.list()
// myCapture = new Capture(this, width, height, "Camera Name", 30);
}
void captureEvent(Capture myCapture) {
myCapture.read();
}
void draw() {
image(myCapture, 0, 0);
}
This came back with the println() statement highlighted and an error in the status bar:
Couldn't find any capture devices, read the video reference for more info. Ha, that's where I got the code! (I love recursion!) There was also a long list of Java exceptions in the console window.
After a bunch of scratching my head, trying other code, searching the site and the 'Net, blaming Canada, etc., I found the following code that does seem to work. It's from the built-in examples,
File/Examples/Libraries/Video (Capture)/GettingStartedCapture. (I've edited it down to just the part about listing the devices).
Quote:import processing.video.*;
Capture cam;
void setup() {
size(640, 480);
String[] devices = Capture.list();
println(devices);
}
void draw() {
}
This gives the expected(?) result:
[0] "DV Video"
[1] "IIDC FireWire Video"
[2] "USB Video Class Video"(I put a question mark after "expected" because I was expecting to only see devices that were connected.)
Conclusion: I am definitely not an expert in any of this, but my assumption is that this has something to do with needing to cast the return of Capture.list() to a string, and the Reference entries need to be updated. (And I'll bet there is a lot of code in the Reference and examples and everywhere else that has this same problem.)
MacBook 13" (built-in iSight)
OS X 10.5.6
QT 7.6 (Pro)
Java 1.5.0_16
Processing 1.0.3