开发者

Two webcams on one usb 2.0 hub - works in windows but not linux

开发者 https://www.devze.com 2023-03-19 23:58 出处:网络
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

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


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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号