2014-07-24 100 views
1

我怎么打开摄像头: 在终端($提示符后的文本=命令,I型):_________________开2个USB摄像头的Ubuntu 12.04

$ 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开始播放摄像机输出。

在另一新的终端(即I型BOLD =命令):

$ vlc v4l2:///dev/video1 
VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b) 
[0x9b24908] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface. 
[0xb0500960] v4l2 demux error: VIDIOC_STREAMON failed 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
libv4l2: error setting pixformat: Device or resource busy 
[0xb0501188] v4l2 access error: cannot set input 0: Device or resource busy 
[0xb0501188] v4l2 access error: cannot set input 0: Device or resource busy 
[0xb5300618] main input error: open of `v4l2:///dev/video1' failed 

无视频被播放时,只有错误消息。

主要目标:我想在opencv(C++)中同时打开两个摄像头...与opencv有类似的错误..所以我使用VLC播放器来调试问题。 打开两个摄像机当同时使用C++的OpenCV的误差(该代码是类似于https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/cpp/starter_video.cpp?rev=4705

[email protected]:~/Desktop/Camera/starter_video2$ ls /dev/video* 
/dev/video0 /dev/video1 /dev/video2 
[email protected]:~/Desktop/Camera/starter_video2$ ./starter_video2 0 1 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
VIDIOC_QUERYMENU: Invalid argument 
press space to save a picture. q or esc to quit 
init done 
opengl support available 
libv4l2: error turning on stream: No space left on device 
VIDIOC_STREAMON: No space left on device 

UPDATE 7/24: 这Ubuntu的12.04(32位)是VMware的融合运行的来宾OS。这里的主机操作系统是在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 
$ 

回答

2

这是USB带宽问题,而不是VLC之一。

VIDIOC_STREAMON: No space left on device是当USB带宽已满时给出的消息。

大多数现代USB摄像机都可以实现高速,高密度图像输出。 USB2限于480Mbps,理论上是60兆字节/秒。在实践中,所有类型的开销将使用它的大约一半,最大可达30兆字节/秒。这意味着相机可以以30fps发送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带宽。

+0

请参阅上文主要帖子底部的“更新7/24:”。它具有lsusb -t – ironhyde

+0

的结果此更新中只有一个USB2.0总线(查找480Mbps总线,这是2.0。 –

+0

如何在VMware融合中添加1个总线? – ironhyde