主题 : 讨论个USB摄像头图像采集问题, 复制链接 | 浏览器收藏 | 打印
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
楼主  发表于: 2011-04-21 15:26

 讨论个USB摄像头图像采集问题,

用qtopia自带的摄像头程序测试两种USB摄像头
第一种为yuyv格式输出的,大小640*480,采集大小320*240
[root@FriendlyARM wiggly]# usb 1-1.4: USB disconnect, address 13
usb 1-1.4: new full speed USB device using s3c2410-ohci and address 14
usb 1-1.4: New USB device found, idVendor=1871, idProduct=0316
usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.4: Product: USB2.0 Camera
usb 1-1.4: Manufacturer: AVEO Technology Corp.
usb 1-1.4: configuration #1 chosen from 1 choice
uvcvideo: Found UVC 1.00 device USB2.0 Camera (1871:0316)

[root@FriendlyARM wiggly]# ./wiggly-yuv-old -qws
open camera is sucess.fd=14.
camara driver: uvcvideo
camara card: USB2.0 Camera
camara bus info: usb-s3c24xx-1.4
camara version: 256
camara capabilities: 0x4000001
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
Camara set fmt before width=320,height=240,pixelformat=YUYV,field=4.
Camara set fmt after width=320,height=240,pixelformat=YUYV,field=1.
v4l2_read_pic_use_time=1055.
v4l2_read_pic_use_time=543.
v4l2_read_pic_use_time=1055.
v4l2_read_pic_use_time=543.
不进行格式转换显示,只测试采集时间,采集时间代码如下:
    time_test.start();
        v4l2_read_pic();
        printf("v4l2_read_pic_use_time=%d.\n",time_test.elapsed());
也就是输出为1秒1.5帧
若采集大小640*480,
v4l2_read_pic_use_time=1087.
v4l2_read_pic_use_time=1055.
v4l2_read_pic_use_time=1055.
v4l2_read_pic_use_time=1087.
v4l2_read_pic_use_time=1055.
v4l2_read_pic_use_time=1056.
也就是采集时间为1秒1帧。
第二种为ANC摄像头zc301,输出的是jpeg格式,大小320*240
[root@FriendlyARM wiggly]# usb 1-1.4: USB disconnect, address 14
usb 1-1.4: new full speed USB device using s3c2410-ohci and address 15
usb 1-1.4: New USB device found, idVendor=058f, idProduct=9254
usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.4: Product: Generic USB Hub
usb 1-1.4: Manufacturer: ALCOR
usb 1-1.4: configuration #1 chosen from 1 choice
hub 1-1.4:1.0: USB hub found
hub 1-1.4:1.0: 4 ports detected
usb 1-1.4.1: new full speed USB device using s3c2410-ohci and address 16
usb 1-1.4.1: New USB device found, idVendor=0ac8, idProduct=301b
usb 1-1.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.4.1: Product: PC Camera
usb 1-1.4.1: Manufacturer: Vimicro Corp.
usb 1-1.4.1: configuration #1 chosen from 1 choice
gspca: probing 0ac8:301b
zc3xx: probe sensor -> 000a
zc3xx: Find Sensor PB0330. Chip revision 0
gspca: probe ok

[root@FriendlyARM wiggly]# ./myusbcamera-thread-yuv -qws
open camera is sucess.fd=14.
camara driver: zc3xx
camara card: PC Camera
camara bus info: usb-s3c24xx-1.4.1
camara version: 132864
camara capabilities: 0x5000001
{ pixelformat = 'JPEG', description = 'JPEG' }
Camara set fmt before width=640,height=480,pixelformat=YUYV,field=4.
Camara set fmt after width=640,height=480,pixelformat=JPEG,field=1.
open style fail.
v4l2_read_pic_use_time=351.
v4l2_read_pic_use_time=383.
v4l2_read_pic_use_time=378.
v4l2_read_pic_use_time=383.
v4l2_read_pic_use_time=349.
v4l2_read_pic_use_time=382.
v4l2_read_pic_use_time=382.
[root@FriendlyARM wiggly]# ./myusbcamera-thread-yuv-test-read-time -qws
open camera is sucess.fd=14.
camara driver: zc3xx
camara card: PC Camera
camara bus info: usb-s3c24xx-1.4.1
camara version: 132864
camara capabilities: 0x5000001
{ pixelformat = 'JPEG', description = 'JPEG' }
Camara set fmt before width=320,height=240,pixelformat=YUYV,field=4.
Camara set fmt after width=320,height=240,pixelformat=JPEG,field=1.
v4l2_read_pic_use_time=159.
v4l2_read_pic_use_time=190.
v4l2_read_pic_use_time=256.
v4l2_read_pic_use_time=255.
v4l2_read_pic_use_time=288.
[root@FriendlyARM wiggly]#
可以看出320*240输出为1秒4帧左右。
有没有朋友一起分析下原因!
[ 此帖被xphyym在2011-04-22 09:00重新编辑 ]
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
1楼  发表于: 2011-04-21 15:31
我的分析如下:
理论上USB1.1的速度有1.5M,实际上只有500-1000Kbs左右。
一张640*480数据YUYV占用的数据长度为640*480*2BTYE=600kb.那么每秒能读取到的内存数据最多2-3帧了。
如我用jpeg 320*240开辟的内存空间为32K而已。读取快了点,反而是要解决的是转换为RGB。
在读取一次数据的同时还要准备下一帧的数据,同样也在耗时,就出现上面的jpeg读取一次的时间也比较长。


同样我又分析了下CPU使用情况,
top -n 10

Mem: 31528K used, 28780K free, 0K shrd, 0K buff, 23648K cached
CPU: 13.0% usr  0.3% sys  0.0% nic 85.9% idle  0.0% io  0.3% irq  0.1% sirq
Load average: 0.19 0.07 0.02 2/31 932
  PID  PPID USER     STAT   VSZ %MEM CPU %CPU COMMAND
  930   697 root     S    29572 48.7   0 12.8 ./wiggly-yuv-old -qws
  932   697 root     R     3392  5.5   0  0.5 top -n 10
  714     1 root     S <   8892 14.6   0  0.0 /opt/Qtopia/bin/qss
  697     1 root     S     3392  5.5   0  0.0 -/bin/sh
  684     1 root     S     3328  5.4   0  0.0 /usr/sbin/inetd
    1     0 root     S     3068  5.0   0  0.0 init      
  681     1 root     S     3068  5.0   0  0.0 syslogd
  698     1 root     S     3068  5.0   0  0.0 init      
  699     1 root     S     3068  5.0   0  0.0 init      
  701     1 root     S     3068  5.0   0  0.0 init      
  688     1 root     S     1940  3.2   0  0.0 /usr/sbin/boa
  691     1 root     S     1416  2.3   0  0.0 /usr/bin/led-player
  244     2 root     SW       0  0.0   0  0.0 [rpciod/0]
  302     2 root     SW       0  0.0   0  0.0 [nfsiod]
  222     2 root     SW       0  0.0   0  0.0 [khubd]
    5     2 root     SW       0  0.0   0  0.0 [khelper]
    2     0 root     SW       0  0.0   0  0.0 [kthreadd]
    3     2 root     SW       0  0.0   0  0.0 [ksoftirqd/0]
    4     2 root     SW       0  0.0   0  0.0 [events/0]
   11     2 root     SW       0  0.0   0  0.0 [async/mgr]
[root@FriendlyARM wiggly]#
占用率很少。
是否这样,等待大家讨论
[ 此帖被xphyym在2011-04-21 15:38重新编辑 ]
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
2楼  发表于: 2011-04-21 15:32
不知道tiny6410的usb是1.0的还是2.0的。是否更快一点
有没有在2440上添加2.0的朋友?
[ 此帖被xphyym在2011-04-21 22:38重新编辑 ]
级别: 新手上路
UID: 42166
精华: 0
发帖: 15
金钱: 75 两
威望: 15 点
综合积分: 30 分
注册时间: 2011-04-05
最后登录: 2011-04-24
3楼  发表于: 2011-04-21 22:57
请问你的usb摄像头远程控制能拍到图片吗?我的能进入但没拍到图片
附件: 222.txt (1 K) 下载次数:13
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
4楼  发表于: 2011-04-22 08:57

 回 3楼(momowjm) 的帖子

远程监控可以进入的话,就是浏览器的问题。用火狐浏览器就可以拍到了
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
5楼  发表于: 2011-04-22 08:58
没人参与?
级别: 新手上路
UID: 36043
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2011-01-10
最后登录: 2013-05-08
6楼  发表于: 2011-05-08 23:52
6410 快些 应该有5~10帧

不过换了好多摄像头都只能YUYV输出。。。。
级别: 新手上路
UID: 44545
精华: 0
发帖: 9
金钱: 45 两
威望: 9 点
综合积分: 18 分
注册时间: 2011-04-26
最后登录: 2011-10-09
7楼  发表于: 2011-08-27 12:23
同求啊,摄像头采集每秒4帧明显不够啊,就是usb1.1的问题吗?有没有人能改成2.0的啊。
级别: 新手上路
UID: 38945
精华: 0
发帖: 41
金钱: 205 两
威望: 41 点
综合积分: 82 分
注册时间: 2011-03-03
最后登录: 2015-09-06
8楼  发表于: 2011-10-15 07:31
能给下源码不。418018886@qq.com