[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

v4l摄像头问题



描述:
使用v4l对摄像头访问的时候出现错误。
可以通过xawtv启动摄像头(并看到视频输出)。
但是按照如下步骤访问摄像头的时候,出现错误。

相关代码段:
   vid->fd = open(vid->dev, O_RDWR);// vid是自定义结构,vid->fd放摄像头的文件描述符,这里没有错误
   //异常处理。省略。
   if(ioctl(vid->fd,VIDIOCGCAP,&vd) < 0){  //查询设备信息,这里也没问题
       printf("ioctl failed\n");
       free( vid );
       return 0;
   }
   //输出调试输出信息。自动选择通道。省略
   for(i = 0;i < vd.channels && i < MAXCHANNEL; i++){
       vc[i].channel = i;

       if(ioctl(vid->fd,VIDIOCGCHAN,&vc[i]) < 0){    //查询channel信息,这里出了问题。
           printf("error: acquireing channel(%d) info\n",i);
           free( vid );
           return 0;
       }
gdb 输出::
vd = {name = "USB 2.0 PC Cam", '\0' <repeats 17 times>, type = 1,
channels = 1, audios = 0, maxwidth = 640, maxheight = 480, minwidth =
48, minheight = 32}
vc[i] = {channel = 0, name =
"\000\000\000\000\001\000\000\000H\005\000\000\000\000\000\000h��m̷\000b̷�̷",
tuners = 1, flags = 3085987828, type = 32612, norm = 58322}

问题:
为什么查询通道错误?是v4l模块的问题,还是uvc模块的问题,还是其他别的问题?
哪位遇到过类似问题?

Part of output of "lsusb -v":

Bus 005 Device 004: ID 090c:b370 Feiya Technology Corp.
Device Descriptor:
 bLength                18
 bDescriptorType         1
 bcdUSB               2.00
 bDeviceClass          239 Miscellaneous Device
 bDeviceSubClass         2 ?
 bDeviceProtocol         1 Interface Association
 bMaxPacketSize0        64
 idVendor           0x090c Feiya Technology Corp.
 idProduct          0xb370
 bcdDevice            1.00
 iManufacturer           1
 iProduct                2
 iSerial                 0
 bNumConfigurations      1

Output of "lsmod | grep video":

uvcvideo               45576  0
compat_ioctl32          1312  1 uvcvideo
videodev               27520  1 uvcvideo
v4l1_compat            12260  2 uvcvideo,videodev
video                  16400  0
output                  2912  1 video
usbcore               118160  6 uvcvideo,usbhid,usb_storage,ehci_hcd,uhci_hcd
thermal_sys            10856  4 video,thermal,processor,fan

Attachment: 完整代码段
Description: Binary data


Reply to: