Capture two identical video camera feeds

Using the example video capture code I can read and display captured video from two USB cameras attached to my PC. However, video.capture seems to refer to the cameras by name, so when I plug in two identical USB webcams they both have the same device name and the code only picks up one of the cameras to display. If I plug in two different webcams, that have different device names, then all is well. However my project calls for several identical USB cameras.

Anyone know how to address the cameras separately when they have the same device name, or what am I doing wrong?

Running Processing 3.1.1 on Win10.

Here's the code:

import processing.video.*;

Capture camA;
Capture camB;

void setup() {
  size(1280, 480);

  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    printArray(cameras);

    camA = new Capture(this, 640, 480, cameras[33]);
    camB = new Capture(this, 640, 480, cameras[43]);

    // Start capturing the images from the camera
    camA.start();
    camB.start();
  }
}

void draw() {
  if (camA.available() == true) {
    camA.read();
  }
  if (camB.available() == true) {
    camB.read();
  }
  image(camA, 0, 0, 640, 480);
  image(camB, 640, 0, 640, 480);
}

Here's the array of found camera modes (as displayed by _printArray(cameras); _ above). CamA is modes 33 - 42. CamB is modes 43 - 52. Unplugging CamB drops lines 43 - 52 from the list.

[33] "name=USB2.0 PC CAMERA,size=640x480,fps=15"

[34] "name=USB2.0 PC CAMERA,size=640x480,fps=30"

[35] "name=USB2.0 PC CAMERA,size=352x288,fps=15"

[36] "name=USB2.0 PC CAMERA,size=352x288,fps=30"

[37] "name=USB2.0 PC CAMERA,size=320x240,fps=15"

[38] "name=USB2.0 PC CAMERA,size=320x240,fps=30"

[39] "name=USB2.0 PC CAMERA,size=176x144,fps=15"

[40] "name=USB2.0 PC CAMERA,size=176x144,fps=30"

[41] "name=USB2.0 PC CAMERA,size=160x120,fps=15"

[42] "name=USB2.0 PC CAMERA,size=160x120,fps=30"

[43] "name=USB2.0 PC CAMERA,size=640x480,fps=15"

[44] "name=USB2.0 PC CAMERA,size=640x480,fps=30"

[45] "name=USB2.0 PC CAMERA,size=352x288,fps=15"

[46] "name=USB2.0 PC CAMERA,size=352x288,fps=30"

[47] "name=USB2.0 PC CAMERA,size=320x240,fps=15"

[48] "name=USB2.0 PC CAMERA,size=320x240,fps=30"

[49] "name=USB2.0 PC CAMERA,size=176x144,fps=15"

[50] "name=USB2.0 PC CAMERA,size=176x144,fps=30"

[51] "name=USB2.0 PC CAMERA,size=160x120,fps=15"

[52] "name=USB2.0 PC CAMERA,size=160x120,fps=30"

Answers

Sign In or Register to comment.