How to interface with multiple webcams via USB hub
in
Programming Questions
•
5 months ago
So i've been trying to get 4 webcams talking to processing through a usb hub, but i get a white screen for each webcam after the first one.
Below is the code im using, all the cams show up as available but don't give an image.
- import processing.video.*;
- Capture [] cam = new Capture[5];
- void setup() {
- size(640, 480, P2D);
- String[] cameras = Capture.list();
- if (cameras.length == 0) {
- println("There are no cameras available for capture.");
- exit();
- }
- else {
- println("Available cameras:");
- for (int i = 0; i < cameras.length; i++) {
- println(i+" ");
- println(cameras[i]);
- }
- cam[0] = new Capture(this, cameras[0]);
- cam[0].start();
- println("camera 1 ready " + cam[0]);
- cam[1] = new Capture(this, cameras[30]);
- cam[1].start();
- println("camera 2 ready " + cam[1]);
- cam[2] = new Capture(this, cameras[45]);
- cam[2].start();
- println("camera 3 ready " + cam[2]);
- cam[3] = new Capture(this, cameras[60]);
- cam[3].start();
- println("camera 4 ready " + cam[3]);
- }
- }
- void draw() {
- int c = int(random(cam.length-1));
- if (cam[c].available() == true) {
- cam[c].read();
- }
- image(cam[c], width/4, height/4, width/2, height/2);
- delay(1000);
- }
1