Linux: 两个USB摄像头的数据采集问题
2011-08-03 19:48
651 查看
引子: 课题需要,同时采集两个摄像头数据,频率不高,但要同时。中间遇到的问题,唉一言难尽啊!
为了图省事使用UVC摄像头,但是板子是USB1.1接口的,故挑选兼容USB1.1的UVC驱动的摄像头,最终选定两个301V芯片的摄像头,先使用一个摄像头,因频率不高,将采集频率设到了最低5帧每秒,打开视频流,正常!视频缓冲出列,入列,正常!保存图像,正常!再添加一个摄像头,先使用VIDIOC_STREAMON打开一个摄像头,正常,再打开另一个,报错了!
出错代码:
uvcvideo: Failed to submit URB 0 (-28).
经查疑似带宽不足,
(摘自http://answerpot.com/showthread.php?272129-Stream+from+multimple+cameras)
The uvcvideo driver requests bandwidth based on values reported by the camera.
There are two settings involved there. The first one is the alternate settings
for the video streaming interface. The video streaming interface has an
isochronous endpoint for video streaming, and each alternate setting has a
different maximum packet size for the endpoint, resulting in different
bandwidth requirements.
The second one is the dwMaxPayloadTransferSize value reported by the camera
when querying its video streaming control. The driver selects the alternate
setting with the lowest bandwidth that fulfills the dwMaxPayloadTransferSize
requirements.
If your camera has a single alternate setting (this can be checked using
lsusb) you're probably screwed, as the bandwidth is fixed. If it has multiple
alternate settings, it might be requesting a bandwidth higher than what it
really needs. In that case you could try to hardcode a lower bandwidth (see
the uvc_init_video function in uvc_video.c), or let the driver compute a
bandwidth estimation on its own by setting the UVC_QUIRK_FIX_BANDWIDTH quirk.
It's also possible to play with URB submission order to use higher bandwidths
and alternate capture between the different webcams. Dennis Muhlestein
investigated that and got interesting results. Search the list archives for a
thread called "Multiple camera framerate".
郁闷数日,度日如年啊!一头雾水,未解,唉,菜鸟吗!难道吃菜的鸟真的飞不高吗?或许天生就不是搞代码的料。
后来的后来,试了试另外的两个摄像头,301PL的,USB1.1接口,Linux2.6.28中包含了该类型摄像头的驱动(gspca,据说是位法国学者编的),同时打开两个摄像头,意想不到的是,报了3次错后,打开了
zc3xx: probe 2wr ov vga 0x0000
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2140 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2180 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d21c0 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
this is vidCapture_thread of Left
the 1 of Left
state at:978442537 719669
this is vidCapture_thread of right
the 1 of right
state at:978442537 823039
不知为什么,但是对比UVC和gspca驱动的源代码,发现对于usb_submit_urb () 函数的返回值的处理是不同的,gspca中加了对错误代码的判断,将28号错误(ENOSPC)同其他的区别对待了
/* submit the URBs */
614 for (n = 0; n < gspca_dev->nurbs; n++) {
615 ret = usb_submit_urb(gspca_dev->urb
, GFP_KERNEL);
616 if (ret < 0) {
617 PDEBUG(D_ERR|D_STREAM,
618 "usb_submit_urb [%d] err %d", n, ret);
619 gspca_dev->streaming = 0;
620 destroy_urbs(gspca_dev);
621 if (ret == -ENOSPC)
622 break; /* try the previous alt */
623 goto out;
624 }
625 }
而UVC中只要是提交没成功就退出。
菜鸟只能将问题提出来,解决问题还要靠大侠们啊
为了图省事使用UVC摄像头,但是板子是USB1.1接口的,故挑选兼容USB1.1的UVC驱动的摄像头,最终选定两个301V芯片的摄像头,先使用一个摄像头,因频率不高,将采集频率设到了最低5帧每秒,打开视频流,正常!视频缓冲出列,入列,正常!保存图像,正常!再添加一个摄像头,先使用VIDIOC_STREAMON打开一个摄像头,正常,再打开另一个,报错了!
出错代码:
uvcvideo: Failed to submit URB 0 (-28).
经查疑似带宽不足,
(摘自http://answerpot.com/showthread.php?272129-Stream+from+multimple+cameras)
The uvcvideo driver requests bandwidth based on values reported by the camera.
There are two settings involved there. The first one is the alternate settings
for the video streaming interface. The video streaming interface has an
isochronous endpoint for video streaming, and each alternate setting has a
different maximum packet size for the endpoint, resulting in different
bandwidth requirements.
The second one is the dwMaxPayloadTransferSize value reported by the camera
when querying its video streaming control. The driver selects the alternate
setting with the lowest bandwidth that fulfills the dwMaxPayloadTransferSize
requirements.
If your camera has a single alternate setting (this can be checked using
lsusb) you're probably screwed, as the bandwidth is fixed. If it has multiple
alternate settings, it might be requesting a bandwidth higher than what it
really needs. In that case you could try to hardcode a lower bandwidth (see
the uvc_init_video function in uvc_video.c), or let the driver compute a
bandwidth estimation on its own by setting the UVC_QUIRK_FIX_BANDWIDTH quirk.
It's also possible to play with URB submission order to use higher bandwidths
and alternate capture between the different webcams. Dennis Muhlestein
investigated that and got interesting results. Search the list archives for a
thread called "Multiple camera framerate".
郁闷数日,度日如年啊!一头雾水,未解,唉,菜鸟吗!难道吃菜的鸟真的飞不高吗?或许天生就不是搞代码的料。
后来的后来,试了试另外的两个摄像头,301PL的,USB1.1接口,Linux2.6.28中包含了该类型摄像头的驱动(gspca,据说是位法国学者编的),同时打开两个摄像头,意想不到的是,报了3次错后,打开了
zc3xx: probe 2wr ov vga 0x0000
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2140 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d2180 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
gspca: usb_submit_urb [0] err -28
s3c2410-ohci s3c2410-ohci: leak ed ff1d21c0 (#81) state 2
zc3xx: probe 2wr ov vga 0x0000
this is vidCapture_thread of Left
the 1 of Left
state at:978442537 719669
this is vidCapture_thread of right
the 1 of right
state at:978442537 823039
不知为什么,但是对比UVC和gspca驱动的源代码,发现对于usb_submit_urb () 函数的返回值的处理是不同的,gspca中加了对错误代码的判断,将28号错误(ENOSPC)同其他的区别对待了
/* submit the URBs */
614 for (n = 0; n < gspca_dev->nurbs; n++) {
615 ret = usb_submit_urb(gspca_dev->urb
, GFP_KERNEL);
616 if (ret < 0) {
617 PDEBUG(D_ERR|D_STREAM,
618 "usb_submit_urb [%d] err %d", n, ret);
619 gspca_dev->streaming = 0;
620 destroy_urbs(gspca_dev);
621 if (ret == -ENOSPC)
622 break; /* try the previous alt */
623 goto out;
624 }
625 }
而UVC中只要是提交没成功就退出。
菜鸟只能将问题提出来,解决问题还要靠大侠们啊
相关文章推荐
- Linux: 两个USB摄像头的数据采集问题(嵌入式)
- Linux下基于XScale的USB摄像头图像采集
- Linux下用FFMPEG采集usb摄像头到RTMP
- linux下usb摄像头采集的YUYV格式转换成JPEG格式的图片
- linux下usb摄像头采集的YUYV格式转换成JPEG格式的图片
- 基于USB摄像头视频数据采集和利用FFMPEG库函数进行视频数据压缩
- 基于嵌入式linux的usb摄像头的驱动及采集程序的实现
- ubuntu-Linux系统读取USB摄像头数据(gspca)
- -06-OpenCV通过USB摄像头采集图像【Xilinx-Petalinux学习】
- Linux下 打开多个USB 2.0 摄像头的问题( libv4l2: error turning on stream: No space left on device )
- Linux下用FFMPEG采集usb摄像头到RTMP
- 虚拟机上Linux读取播放USB摄像头视频卡住的问题
- ubuntu-Linux系统读取USB摄像头数据(uvc)
- 基于itop4412在Linux最小系统下的USB摄像头采集视频的H264编码
- Linux下基于OpenCV的摄像头数据采集与传输
- 两个usb摄像头的同时采集图像的一般方法。
- 【Xilinx-Petalinux学习】-06-OpenCV通过USB摄像头采集图像。
- 基于USB摄像头视频数据采集和利用FFMPEG库函数进行视频数据压缩
- C#调用两个至多个USB摄像头的问题
- 关于linux调用多个usb摄像头时无法工作的问题