1

The openCV code below grabs simultaneous images from two cameras. It works fine in windows, with the cameras both attached to one usb 2.0 hub. When I try the same code in linux, it only has enough bandwidth for one camera at a time. I've also tried viewing the two streams at once with guvcview, same issue. What I need is some way to force the webcams to work together, possibly by setting the amount of bandwidth the driver requests.

capture = cv.CaptureFromCAM(0)
capture2 = cv.CaptureFromCAM(1)

while True: 
    frame = cv.QueryFrame(capture)
    frame2 = cv.QueryFrame(capture2)
    cv.ShowImage("w1", frame)
    cv.ShowImage("w2", frame2)    
    if cv.WaitKey(10) != -1:
        break
pkinsky
  • 1,718
  • 2
  • 23
  • 28

3 Answers3

2

I had a USB bandwidth issue with webcams (LifeCam Cinema) as well and solved it by using the FIX_BANDWIDTH quirk of the uvcvideo driver. See this answer for details on using the quirk.

Without quirk, for some USB host controllers I tried, two LifeCams worked (per controller); for others, only one. Here the controllers in one of my machine vision machines:

uli@KL04:~$ lspci | grep USB
00:1a.0 USB controller: Intel Corporation C600/X79 series chipset USB2 Enhanced Host Controller #2 (rev 06)
00:1d.0 USB controller: Intel Corporation C600/X79 series chipset USB2 Enhanced Host Controller #1 (rev 06)
03:00.0 USB controller: VIA Technologies, Inc. Device 3483 (rev 01)
0a:00.0 USB controller: ASMedia Technology Inc. Device 1142
0b:00.0 USB controller: ASMedia Technology Inc. Device 1142

(The Intel and ASMedia controllers are on the motherboard, the VIA is on a PCIe card.) Without quirk, each ASMedia controller supported only one LifeCam.

Community
  • 1
  • 1
Ulrich Stern
  • 10,761
  • 5
  • 55
  • 76
1

The issue might be here that the cameras run some sort of video compression in their windows drivers, while they might run uncompressed in Linux - at a higher data rate.

If that is the case, then you may need to put them on different USB busses to make them work both at a time in Linux. This could require you to add a PCI or PCIe USB card to your system - many motherboards do only implement one USB2.0 high speed bus.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
  • This is for a robotics application where I also have access to an old laptop. It's running windows server 2003 now, but if I put XP on it, should it work with the two cameras? According to a program called lsusb, it also has a 2.0 hub. – pkinsky Jul 14 '11 at 07:04
1

Can you configure the webcams to use a lower resolution or frame rate and thus less bandwidth?

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • I've tried to do so from within opencv(the function to do so is broken), and to view both cameras simultaneously using other applications at a lower resolution/framerate. Neither works. Because of this, I think it might be a driver level problem. – pkinsky Jul 14 '11 at 06:14