Opencv 在VLC播放器Ubuntu 12.04上同时打开2个USB摄像头

Opencv 在VLC播放器Ubuntu 12.04上同时打开2个USB摄像头,opencv,ubuntu,camera,vlc,vmware-fusion,Opencv,Ubuntu,Camera,Vlc,Vmware Fusion,如何打开相机: 在终端中($prompt=我键入的命令后的文本):\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu $ ls /dev/video* /dev/video0 /dev/video1 $ vlc v4l2:///dev/video0 VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b) [0x9f2

如何打开相机: 在终端中($prompt=我键入的命令后的文本):\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

$ ls /dev/video*
/dev/video0  /dev/video1
$ vlc v4l2:///dev/video0
VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b)
[0x9f2d908] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
VLC开始播放相机输出

在另一个新终端中(粗体=我键入的命令):

没有播放视频,只有错误消息

主要目标:我想在opencv(c++)中同时打开两个摄像头。。。opencv也有类似的错误。。所以我用VLC播放器来调试这个问题。 用C++ OpenCV同时打开两台摄像机时的误差(代码相似)

更新7/24: 这个Ubuntu 12.04(32位)是运行在VMware Fusion上的来宾操作系统。这里的主机操作系统是在Mac Pro计算机硬件上运行的OSX 10.9.4

$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 2, If 0, Class=HID, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 0, Class=hub, Driver=hub/7p, 12M
        |__ Port 1: Dev 4, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
        |__ Port 1: Dev 4, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/6p, 480M
    |__ Port 1: Dev 6, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 1: Dev 6, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 2: Dev 7, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 2: Dev 7, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
$ 

这是USB带宽问题,不是VLC问题

VIDIOC\u STREAMON:设备上没有剩余空间
是USB带宽已满时给出的消息

大多数现代USB摄像头都能进行高速、高密度的图像输出。USB2限制为480Mbps,理论上为60兆字节/秒。实际上,所有类型的开销都将占用大约一半的开销,而30兆字节/秒是您可以获得的最大值。这意味着摄像机可以以每秒30帧的速度发送1兆字节的图像

所有你能做的就是得到多个USB总线主板。所有的小型计算机往往只有一台。高端游戏主板有2..3条USB2.0总线。您可以在linux下看到它:

$ lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 4: Dev 2, If 0, Class=scard, Driver=usbfs, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
        |__ Port 5: Dev 3, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
        |__ Port 5: Dev 3, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
        |__ Port 3: Dev 3, If 0, Class=vend., Driver=rts5139, 480M
        |__ Port 5: Dev 4, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
        |__ Port 5: Dev 4, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
$ 
很可能两个摄像头都连接到同一条总线上


另一种选择是降低FPS速度或分辨率。但这并不总是有帮助,因为我见过的相机保留了80%的USB带宽。

请参阅上面主要帖子底部的“更新7/24:”。它具有lsusb的结果-t此更新中只有一条USB2.0总线(寻找480Mbps总线。这是2.0。我如何在VMware fusion中再添加1条总线?我认为这是硬件,而不是VMware限制。额外的USB卡可能会有所帮助。硬件实际上非常强大。我在VMware上做事情之前对其进行了测试。这是一台Mac Pro计算机/工作站。早些时候,在Mac OS X上,我使用Mac端口安装了opencv(Python bindngs)我成功地用C++代码打开了2个相机。我也能用Python代码来做同样的事情。
$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 2, If 0, Class=HID, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 0, Class=hub, Driver=hub/7p, 12M
        |__ Port 1: Dev 4, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
        |__ Port 1: Dev 4, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/6p, 480M
    |__ Port 1: Dev 6, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 1: Dev 6, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 2: Dev 7, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 2: Dev 7, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
$ 
$ lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 4: Dev 2, If 0, Class=scard, Driver=usbfs, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
        |__ Port 5: Dev 3, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
        |__ Port 5: Dev 3, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
        |__ Port 3: Dev 3, If 0, Class=vend., Driver=rts5139, 480M
        |__ Port 5: Dev 4, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
        |__ Port 5: Dev 4, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
$