【问题标题】:Get v4l2 video devices maximum resolution获取 v4l2 视频设备的最大分辨率
【发布时间】:2013-02-27 19:55:00
【问题描述】:

我如何才能检测连接的视频设备能够提供的最大分辨率?

我不想捕获任何东西,只是从 v4l2 中检索此信息。

谢谢!

【问题讨论】:

    标签: linux resolution video-capture v4l2


    【解决方案1】:

    使用VIDIOC_ENUM_FRAMESIZESioctl:

        enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        struct v4l2_fmtdesc fmt;
        struct v4l2_frmsizeenum frmsize;
        struct v4l2_frmivalenum frmival;
    
        fmt.index = 0;
        fmt.type = type;
        while (ioctl(fd, VIDIOC_ENUM_FMT, &fmt) >= 0) {
            frmsize.pixel_format = fmt.pixelformat;
            frmsize.index = 0;
            while (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize) >= 0) {
                if (frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
                    printf("%dx%d\n", 
                                      frmsize.discrete.width,
                                      frmsize.discrete.height);
                } else if (frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
                    printf("%dx%d\n", 
                                      frmsize.stepwise.max_width,
                                      frmsize.stepwise.max_height);
                }
                    frmsize.index++;
                }
                fmt.index++;
        }
    

    afaik,VIDIOC_ENUM_FRAMESIZES 是在 linux-2.6.29 中引入的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-02
      • 2017-05-09
      • 2011-07-05
      • 2015-01-01
      相关资源
      最近更新 更多