Ask Your Question

Using multiple external cameras

asked 2014-04-13 16:17:51 -0500

GiulSDU gravatar image

updated 2015-03-13 02:34:22 -0500

Hi, i am using 2 external webcams. The problem is that openCV does not recognize the second one, and it is the same exact model of the first is my code

int main(int, char**)
VideoCapture cap(0); // open the default camera
VideoCapture web(1);
VideoCapture web2(2);

Mat laptop;
cap >> laptop;
imshow("laptop ", laptop);

Mat webcam;
web >> webcam;
imshow("webcam", webcam);

Mat webcam2;
web2 >> webcam2;
imshow("webcam2", webcam2);
return 0;

It is an easy program to understand the index of my cameras. The problem is that i got the built-in camera to the index 0, one external webcam to index 1 ..and does not link the third camera to any index. Here is the output

HIGHGUI ERROR: V4L: index 2 is not correct!
libv4l2: error turning on stream: No space left on device
VIDIOC_STREAMON: No space left on device
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /build/buildd/opencv-2.3.1/modules/core/src/array.cpp, line 2482
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.3.1/modules/core/src/array.cpp:2482: error: (-206) Unrecognized or unsupported array type in function cvGetMat

thank you

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-03-13 02:11:31 -0500

Why didn't you do any research first? The error message is even a good hint: There is some device that is running out of some kind of space. And you attach hardware that produces a good deal of data. So probably your usb-controller isn't able to process your images with the current encoding.

a) Enter you error message into google (

google: libv4l2: error turning on stream: No space left on device

b) select the first or second link:

edit flag offensive delete link more


I know that this is an old post but I couldn't help myself to reply to your useless answer. Please do yourself and everyone else a favor and never answer a question like this again. You're wasting everybody's time answering a question that you have no clue what it means. By the way the links you posted are as useless as your answer since they don't show a valid solution. For everybody else that still wondering if it's possible to plug multiple USB cameras to the same USB port using a hub. I should be possible, but the problem seems to be libv4l. USB3 should have enough bandwidth for supporting multiple USB cameras connected to a hub. If you try using different USB ports you may find a combination that works, but if you are using a laptop you'll be limited by 2/3 ...(more)

Ariel Bernal gravatar imageAriel Bernal ( 2018-01-25 01:00:48 -0500 )edit

answered 2015-03-12 21:31:39 -0500

Hello, I don't know how to solve this problem just because I have a same situation as you discribed. I read 5 USB cameras but only first two of CvCapture returned with other camerals return NULL. So, I try to read the camera dynamically. However, I am facing a new weird problem. You can see my problem at:

edit flag offensive delete link more

Question Tools


Asked: 2014-04-13 16:17:51 -0500

Seen: 2,486 times

Last updated: Mar 13 '15