UVC摄像头驱动怎么识别一帧图像数据?
通过UVC的负载数据头(payload header informatiion)来实现的。
如我们通过BUSHOUND进行抓包:
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 2f fa b1 0a
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 69 c8 92 51
30.3 IN 0c 0e 00 00 00 00 00 00 00 00 00 00 ed e7 3e 2c
30 IN
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 ae 0c 8e 63
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 63 68 78 d0
30.3 IN 0c 0f 00 00 00 00 00 00 00 00 00 00 d0 93 b5 aa
30 IN
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 df ac 8a 22
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 55 e3 23 cc
30.3 IN 0c 0e 00 00 00 00 00 00 00 00 00 00 3c f8 30 f4
可以看到,负载数据头为12字节,其bmHeaderInfo的bit1为1时(可选),代表一个完整的帧传输完成,而BIT0从0变成1或者从1变成0时,代表一个新帧的开始。所以以上数据的格式帧应该这样划化:
//第一帧
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 2f fa b1 0a
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 69 c8 92 51
30.3 IN 0c 0e 00 00 00 00 00 00 00 00 00 00 ed e7 3e 2c
//第2帧
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 ae 0c 8e 63
30.3 IN 0c 0d 00 00 00 00 00 00 00 00 00 00 63 68 78 d0
30.3 IN 0c 0f 00 00 00 00 00 00 00 00 00 00 d0 93 b5 aa
//第3帧
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 01
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 df ac 8a 22
30.3 IN 0c 0c 00 00 00 00 00 00 00 00 00 00 55 e3 23 cc
30.3 IN 0c 0e 00 00 00 00 00 00 00 00 00 00 3c f8 30 f4
更细节的内容分析可见:http://www.usbzh.com/article/detail-7.html