打印

V4L2图像采集程序问题

[复制链接]
1850|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
15051860045|  楼主 | 2013-7-29 11:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
运行下面这段程序时,报错VIDIOC_CROPCAP error 22, Invalid argument,可是CROPCAP这段程序我是用的TI的官方文件里的程序啊,不理解为何还会有错误

int fd_init()
{
    fd = open("/dev/video0", O_RDWR);   
        if(fd == -1)  { error_exit("capture device"); }
    else          { printf("******************** Open capture devive success ********************\n");}


    struct v4l2_capability cap;
       
    if(ioctl(fd,VIDIOC_QUERYCAP,&cap)==-1)  { error_exit("VIOIOV_QUERYCAP"); }

        printf("*********************** Capability Informations *************************\n");
    printf(" driver: %s\n", cap.driver);
    printf(" card: %s\n", cap.card);
    printf(" bus_info: %s\n", cap.bus_info);
    printf(" version: %u.%u.%u\n", (cap.version >> 16) & 0xFF,(cap.version >> 8) & 0xFF,cap.version & 0xFF);
    printf(" capabilities: %08x\n", cap.capabilities);

    if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
    {  
        printf("******************* Device is no video capture device *********************\n");  
        return -1;  
    }  

        struct v4l2_input input;
       
        CLEAR(input);                  
        if (-1 == ioctl (fd, VIDIOC_G_INPUT, &input.index))   { error_exit ("VIDIOC_G_INPUT");}
        if (-1 == ioctl (fd,VIDIOC_ENUMINPUT, &input))         { error_exit ("VIDIOC_ENUMINPUT");}
       
        printf("************************ Input information ************************\n");
        printf (" inputname: %s\n", input.name);
        switch (input.type) {  
                                                  case V4L2_INPUT_TYPE_TUNER:           printf(" V4L2_INPUT_TYPE_TUNER\n");
                              case V4L2_INPUT_TYPE_CAMERA:           printf(" V4L2_INPUT_TYPE_CAMERA\n");
                                                }
        printf (" status: %0x\n", input.status);


        struct v4l2_fmtdesc fmtdesc;
       
        CLEAR(fmtdesc);
        fmtdesc.index = 0;
        fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        printf("********************* Support Format Informations **********************\n");
        while ((ret = ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc)) == 0)
              {
                        fmtdesc.index++;
                        printf(" pixelformat ''%c%c%c%c'', description ''%s''\n",
                                          fmtdesc.pixelformat & 0xFF, (fmtdesc.pixelformat >> 8) & 0xFF, (fmtdesc.pixelformat >> 16) & 0xFF,
                                          (fmtdesc.pixelformat >> 24) & 0xFF, fmtdesc.description);
              }


        struct v4l2_cropcap cropcap;
        struct v4l2_crop crop;
       
        CLEAR(cropcap);
        cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        if (-1 == ioctl (fd, VIDIOC_CROPCAP, &cropcap)) { error_exit("VIDIOC_CROPCAP"); }
        CLEAR(crop);
        crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        crop.c = cropcap.defrect;
        if (-1 == ioctl (fd, VIDIOC_S_CROP, &crop) && errno != EINVAL) { error_exit("VIDIOC_S_CROP"); }

相关帖子

沙发
zhangmangui| | 2013-7-29 13:57 | 只看该作者
不懂  帮忙顶
下来帮你问

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

13

主题

28

帖子

0

粉丝