Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1514477
  • 博文数量: 129
  • 博客积分: 1449
  • 博客等级: 上尉
  • 技术积分: 3048
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-24 18:36
文章分类

全部博文(129)

文章存档

2015年(3)

2014年(20)

2013年(65)

2012年(41)

分类: 项目管理

2013-08-28 12:20:41

1. 前言
UVC(USB video class/USB video device class): 不需要安装驱动程序即插即用,因为其驱动程序已经固化在硬件的芯片里面

V4L,其全称是Video4Linux(Video for Linux),是在linux内核中关于视频设备的API接口(网上有些帖子说是内核驱动,这种说法是不妥的),涉及开关视频设备、采集并处理视频图像信息。V4L从2.1.x版本的内核中开始出现。
V4L2,其全称是Video4Linux2(Video for Linux Two)。很显然,他是V4L的改进版,修复了第一代的部分设计bug。从2.5.x开始,V4L2就被集成到内核里面去了。尽管如此,还是有一部分设备的驱动不支持新版本的V4L2,所以,有时候我们会看到V4L跟V4L2同时出现在代码里面。

现在的摄像头品牌太多了,而且大部分都不会说自己的主控芯片,所以很难根据主控芯片去买。那么UVC摄像头是不是都支持呢?理论上大部分UVC摄像头是支持的,但我们看到,即使是官方的列表,UVC摄像头也很多有些问题,而且如果UVC摄像头不支持mjpg输出,那分辨率只能设为320x240,还有不小的延迟。怎么看UVC摄像头是否支持mjpg输出呢?还是要看主控芯片...不过我可以很负责任的告诉你,市面上低于50元的全新摄像头,肯定不支持mjpg输出(主控芯片的价格问题)

2. 5个摄像头驱动OK, 但初始化mjpg失败, 不支持mjpg格式输出, 仅支持YUV格式输出. 

#TTL中的信息
[  369.820000] usb 1-1: new high-speed USB device number 4 using ath79-ehci
[  370.090000] uvcvideo: Found UVC 1.00 device WebCam-HM1355 (058f:5608)
[  370.100000] input: WebCam-HM1355 as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input0

root@OpenWrt:/tmp# dmesg | grep usb
[    8.110000] usbcore: registered new interface driver usbfs
[    8.120000] usbcore: registered new interface driver hub
[    8.130000] usbcore: registered new device driver usb
[    8.980000] usbcore: registered new interface driver usb-storage
[   35.310000] usbcore: registered new interface driver cdc_acm
[   35.450000] usbcore: registered new interface driver ums-alauda
[   35.470000] usbcore: registered new interface driver ums-cypress
[   35.490000] usbcore: registered new interface driver ums-datafab
[   35.510000] usbcore: registered new interface driver ums-freecom
[   35.530000] usbcore: registered new interface driver ums-isd200
[   35.550000] usbcore: registered new interface driver ums-jumpshot
[   35.570000] usbcore: registered new interface driver ums-karma
[   35.590000] usbcore: registered new interface driver ums-sddr09
[   35.610000] usbcore: registered new interface driver ums-sddr55
[   35.740000] usbcore: registered new interface driver ums-usbat
[   36.090000] usbcore: registered new interface driver usbhid
[   36.100000] usbhid: USB HID core driver
[   36.170000] usbcore: registered new interface driver uvcvideo
[  357.140000] usb 1-1: new high-speed USB device number 2 using ath79-ehci
[  357.420000] input: WebCam-HM1355 as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input0
[  918.600000] usb 1-1: USB disconnect, device number 2
[ 1225.220000] usb 1-1: new high-speed USB device number 3 using ath79-ehci
[ 1225.500000] input: WebCam-HM1355 as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input1
[ 1617.680000] usb 1-1: USB disconnect, device number 3
[ 2761.400000] usb 1-1: new high-speed USB device number 4 using ath79-ehci
[ 2761.680000] input: WebCam-HM1355 as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input2

root@OpenWrt:/tmp# ls /dev/video*
/dev/video0

root@OpenWrt:/tmp# mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 -f 20" -o "output_http.so -p 8082 -w /www/camwww"

MJPG Streamer Version: svn rev: exported
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 30
i: Format............: MJPEG
Unable to set format: 1196444237 res: 640x480
Init v4L2 failed !! exit fatal
i: init_VideoIn failed

#可能是摄像头不支持mjpg格式输出, 修改命令增加参数: -yuv, 格式化OK, 但查看图像非常慢,占用了大量的CPU. 
root@OpenWrt:~# mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 -f 20 -yuv"  -o "output_http.so -p 8082 -w /www/camwww"
MJPG Streamer Version: svn rev: exported
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 20
 i: Format............: YUV
 i: JPEG Quality......: 80
Adding control for Pan (relative)
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Tilt (relative)
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Pan Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Tilt Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Pan/tilt Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Focus (absolute)
UVCIOC_CTRL_ADD - Error: Invalid argument
mapping control for Pan (relative)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Tilt (relative)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Pan Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Tilt Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Pan/tilt Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Focus (absolute)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for LED1 Mode
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for LED1 Frequency
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Disable video processing
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Raw bits per pixel
UVCIOC_CTRL_MAP - Error: Invalid argument
 o: www-folder-path...: /www/camwww/
 o: HTTP TCP port.....: 8082
 o: username:password.: disabled
 o: commands..........: enabled
 

#调低显示分辩率为320*240, 图像显示OK.
root@OpenWrt:~# mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 320x240 -f 20 -yuv"  -o "output_http.so -p 8082 -w /www/camwww"
MJPG Streamer Version: svn rev: exported
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 320 x 240
 i: Frames Per Second.: 20
 i: Format............: YUV
 i: JPEG Quality......: 80
Adding control for Pan (relative)
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Tilt (relative)
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Pan Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Tilt Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Pan/tilt Reset
UVCIOC_CTRL_ADD - Error: Invalid argument
Adding control for Focus (absolute)
UVCIOC_CTRL_ADD - Error: Invalid argument
mapping control for Pan (relative)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Tilt (relative)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Pan Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Tilt Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Pan/tilt Reset
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Focus (absolute)
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for LED1 Mode
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for LED1 Frequency
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Disable video processing
UVCIOC_CTRL_MAP - Error: Invalid argument
mapping control for Raw bits per pixel
UVCIOC_CTRL_MAP - Error: Invalid argument
 o: www-folder-path...: /www/camwww/
 o: HTTP TCP port.....: 8082
 o: username:password.: disabled
 o: commands..........: enabled

#正常的支持mjpg格式摄像头显示如下
MJPG Streamer Version: svn rev: exported
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 30
 i: Format............: MJPEG
Adding control for Pan (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Tilt (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Pan Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Tilt Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Pan/tilt Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Focus (absolute)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
mapping control for Pan (relative)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Tilt (relative)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Pan Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Tilt Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Pan/tilt Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Focus (absolute)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for LED1 Mode
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for LED1 Frequency
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Disable video processing
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Raw bits per pixel
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
 o: www-folder-path...: /camwww/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled


3. 有2个摄像头无法识别驱动


4. 有2个摄像头能识别驱动, 但出现如下错误-71和-145?
[ 7518.810000] usb 1-1: new full-speed USB device number 21 using ath79-ehci
[ 7519.030000] usb 1-1: device descriptor read/64, error -71
[ 7519.350000] usb 1-1: device descriptor read/64, error -71
[ 7519.580000] usb 1-1: new full-speed USB device number 22 using ath79-ehci
[ 7519.800000] usb 1-1: device descriptor read/64, error -71
[ 7520.120000] usb 1-1: device descriptor read/64, error -71
[ 7520.350000] usb 1-1: new full-speed USB device number 23 using ath79-ehci
[ 7520.830000] usb 1-1: device not accepting address 23, error -71
[ 7520.950000] usb 1-1: new full-speed USB device number 24 using ath79-ehci
[ 7521.430000] usb 1-1: device not accepting address 24, error -71
[ 7521.430000] hub 1-0:1.0: unable to enumerate USB device on port 1

源代码中的-71(/include/asm-generic/erro.h)代表的是协议的错误,百思不得其解

[  367.790000] usb 1-1: new full-speed USB device number 14 using ath79-ehci
[  382.940000] usb 1-1: device descriptor read/64, error -145
[  398.200000] usb 1-1: device descriptor read/64, error -145
[  398.430000] usb 1-1: new full-speed USB device number 15 using ath79-ehci
[  413.580000] usb 1-1: device descriptor read/64, error -145
[  428.840000] usb 1-1: device descriptor read/64, error -145
[  429.070000] usb 1-1: new full-speed USB device number 16 using ath79-ehci
[  439.510000] usb 1-1: device not accepting address 16, error -145
[  439.630000] usb 1-1: new full-speed USB device number 17 using ath79-ehci
[  450.070000] usb 1-1: device not accepting address 17, error -145
[  450.070000] hub 1-0:1.0: unable to enumerate USB device on port 1


5. 内核3.2.14和3.8.11, 2个摄像头都OK

[   70.330000] usb 1-1: new high-speed USB device number 2 using ath79-ehci
[   70.550000] uvcvideo: Found UVC 1.00 device USB 2.0 PC Camera (058f:3841)
[   70.560000] input: USB 2.0 PC Camera as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input0
[  109.010000] usb 1-1: USB disconnect, device number 2
[  111.440000] usb 1-1: new high-speed USB device number 3 using ath79-ehci
[  111.660000] uvcvideo: Found UVC 1.00 device USB 2.0 PC Camera (058f:3823)
[  111.670000] input: USB 2.0 PC Camera as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input1

root@OpenWrt:/tmp# dmesg | grep usb
[   10.260000] usbcore: registered new interface driver usbfs
[   10.270000] usbcore: registered new interface driver hub
[   10.270000] usbcore: registered new device driver usb
[   14.100000] usbcore: registered new interface driver usb-storage
[   14.230000] usbcore: registered new interface driver ums-alauda
[   14.240000] usbcore: registered new interface driver ums-cypress
[   14.260000] usbcore: registered new interface driver ums-datafab
[   14.280000] usbcore: registered new interface driver ums-freecom
[   14.300000] usbcore: registered new interface driver ums-isd200
[   14.320000] usbcore: registered new interface driver ums-jumpshot
[   14.340000] usbcore: registered new interface driver ums-karma
[   14.360000] usbcore: registered new interface driver ums-sddr09
[   14.380000] usbcore: registered new interface driver ums-sddr55
[   14.390000] usbcore: registered new interface driver ums-usbat
[   14.790000] usbcore: registered new interface driver usbhid
[   14.790000] usbhid: USB HID core driver
[   14.820000] usbcore: registered new interface driver uvcvideo
[   70.330000] usb 1-1: new high-speed USB device number 2 using ath79-ehci
[   70.560000] input: USB 2.0 PC Camera as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input0
[  109.010000] usb 1-1: USB disconnect, device number 2
[  111.440000] usb 1-1: new high-speed USB device number 3 using ath79-ehci
[  111.670000] input: USB 2.0 PC Camera as /devices/platform/ar933x-ehci/usb1/1-1/1-1:1.0/input/input1



1. openwrt摄像头选购
2. 官方文档 usb video support


3. 参考 Linux UVC driver 查询支援。


阅读(17602) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~