I'm trying to connect to several USB cameras that are connected to different USB buses (hopefully cancelling the bandwidth bottleneck caused by the USB). Before accessing to the cameras, I'm probing them with V4L2 API directly to see if they're accessible. For now, there are 3 cameras and V4L2 sees them all. Then I'm trying to access them using openCV like this, each in its own object:
this->camera = new cv::VideoCapture(camera_port);
if(this->camera->isOpened()) {
....
cv::Mat capturedImage;
bool read;
read = this->camera->read(capturedImage);
....
}
where camera_port
is 0,1,2.
Obviously this->camera
is called with release()
on program closure.
The problem arises when I'm accessing more than 1 camera. Only one camera out of the three returns an image. The others return errors that I'm seeing on the console (not the same on every run):
- libv4l2: error turning on stream: Connection timed out, VIDIOC_STREAMON: Connection timed out
- libv4l2: error turning on stream: Input/output error, VIDIOC_STREAMON: Input/output error
- libv4l2: error turning on stream: Invalid argument, VIDIOC_STREAMON: Invalid argument
- Some other errors, but the above are the most frequent
However, this does work on the first run after replugging-in the USB cameras, but not on further runs of the program. Thoughts?