Ask Your Question
4

Using 2 Webcams Simultaneously

asked 2012-12-05 04:42:19 -0600

imran gravatar image

Can someone tell me if it is possible to capture from 2 webcams simultaneously at a resolution of 640x480? When capturing at a resolution of 320x240 or less, everything is fine, however when capturing at a resolution greater than that then I get the following the error:

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

VIDIOC_STREAMON: No space left on device

Does anyone know how to solve this problem?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-02-11 04:41:47 -0600

tuner gravatar image

I had the same problem with two Digitus webcams and the same resolution. Most likely this is because the resolution, framerate and protocol used by your cameras overloads the USB 2.0 connection. Even USB 3.0 might not help here depending how your USB hardware is run internally. Most webcams you can buy are USB 2.0 only and that means the protocol is USB 2.0 even on a USB 3.0 host (backward compatibility).

The easiest fix is to put them on two different USB 2.0 hosts. With lsusb you can find out to which bus you're cameras are attached to. Make sure they don't have to share - especially with USB 1.0 hardware like keyboards and such.

The next thing you can do is to change the protocol used by the cameras. With

v4l2-ctl -d /dev/video1 --list-formats-ext

you can list the different protocols you're camera understands. In my case there where two pixelformats: YUYV and MJPG. The latter one uses less bandwith on the USB connection but added more lag in my connection. Guvcview does a good job in Ubuntu to try different protocols. Be sure to switch to tab "video & files" - there you can change the frame rate, pixel format and other things related to the format.

Getting the exact settings to work with OpenCV is a different story though. I use OpenCV 2.4.3.2 and had to patch the sources to be able to correctly set framerate and resolution for my 2x PS3-eye cameras. When I cleaned up a little bit I will try to submit a patch.

edit flag offensive delete link more

Comments

Thanks, this helps.

imran gravatar imageimran ( 2013-02-14 16:31:39 -0600 )edit

It is pretty simple to change FPS. Go to ./modules/highgui/src/cap_libv4l.cpp and find this segment:

/* try to set framerate to 30 fps */
struct v4l2_streamparm setfps;
memset (&setfps, 0, sizeof(struct v4l2_streamparm));
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;
setfps.parm.capture.timeperframe.denominator = 30;
xioctl (capture->deviceHandle, VIDIOC_S_PARM, &setfps);

Change here 30 to desired FPS and after that recompile OpenCV. Yes, hard way, but it works. I've got problems with FOURCC - it isn't implemented. That's bad but I am okay to go the same way as for changing FPS. But I don't know how :\ (read my post in this thread for more details)

fliker09 gravatar imagefliker09 ( 2013-03-18 08:32:09 -0600 )edit

Starting from 2.4.6 where is no more need for this dirty workaround, CV_CAP_PROP_FPS is finally implemented. Hooray!

P.S. Regarding the speeds. Try this workaround: unplug your cameras, sudo modprobe -r uvcvideo, sudo modprobe uvcvideo quirk=0x80, plug your cameras back and check. In this way I achieved 1280x960@5fps instead of 640x480@15fps. No comments needed I hope ;)

fliker09 gravatar imagefliker09 ( 2013-09-26 15:01:07 -0600 )edit

Using lsusb and getting onto 2 different buses got it working for me, thanks!

elucidation gravatar imageelucidation ( 2014-11-25 21:43:19 -0600 )edit

Can this be solved by any of the USB adaptor cards, which comes with onboard controller? Or the host memory will also be a problem while DMA?

mdeore gravatar imagemdeore ( 2017-06-20 21:26:46 -0600 )edit
0

answered 2012-12-14 09:27:48 -0600

ubehagelig gravatar image

I think the problem is that your USB port is not running at USB 2.0 speeds, but at USB 1.1 speeds.

Which operating system are you running? If you are on Linux then check this out: http://superuser.com/questions/431759/using-multiple-usb-webcams-in-linux

If you are running Windows then I would update the chipset drivers or something to that extent. If you are plugging them into a USB 3.0 port then make sure you install drivers for those. Many USB 3.0 controllers require specific drivers.

edit flag offensive delete link more

Comments

I checked and it is running at USB 2.0 speeds. I'm using Linux (Ubuntu 12.04) and I used lsusb -t which showed the webcam is using the ehci_hcd module which is used by USB 2.0.

imran gravatar imageimran ( 2012-12-18 09:36:33 -0600 )edit
Ralph058 gravatar imageRalph058 ( 2013-03-18 09:37:21 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-12-05 04:42:19 -0600

Seen: 17,860 times

Last updated: Mar 18 '13