导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页

    T113-s3获取ov5640下枚举格式失败

    MR Series
    2
    2
    1462
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • S
      shz18877605430 LV 6 最后由 编辑

      各位大佬救救急!!!

      T113-s3获取ov5640下枚举格式失败,再if(0 != ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc))处直接break掉了。

      说明一下:ov5640正常使用没有问题,能拍照,已测试过的。

      #include <sys/types.h>
      #include <sys/stat.h>
      #include <fcntl.h>
      #include <sys/ioctl.h>
      #include <unistd.h>
      #include <stdio.h>
      #include <string.h>
      #include <linux/types.h>
      #include <linux/videodev2.h>
      
      /* ./app_ov5640 </dev/video0>*/
      int main(int argc,char **argv)
      {
          int fd;
          struct v4l2_fmtdesc fmtdesc;
          struct v4l2_frmsizeenum fsenum;
          int fmt_index = 0;
          int frame_index = 0;
          
          if(argc != 2){
              printf("Usage %s </dev/videoX>,print format detail for video device\n",argv[0]);
              return -1;
          }
      
          /* open */
          fd = open(argv[1],O_RDWR);
          if(fd < 0){
              printf("can not open %s\n",argv[1]);
              return -1;
          }
      
          while(1)
          {
              /* 枚举格式 */
              fmtdesc.index = fmt_index;  //比如从0开始
              fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;    //指定type为"捕获"
              
              if(0 != ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc))
                  break;
      
              frame_index = 0;
              while(1)
              {
                  /* 枚举这种个格式所支持的帧大小*/
                  memset(&fsenum,0,sizeof(struct v4l2_frmsizeenum));
                  fsenum.pixel_format = fmtdesc.pixelformat;
                  fsenum.index = frame_index;
      
                  if(ioctl(fd,VIDIOC_ENUM_FRAMESIZES,&fsenum) == 0){
                      printf("format %s,%d, framesize %d: %d x %d\n",fmtdesc.description,fmtdesc.pixelformat,frame_index,fsenum.discrete.width,fsenum.discrete.height);
                  }else{
                      break;
                  }
                  frame_index++;
              }
              fmt_index++;
          }
      
          return 0;
      }
      
      
      H 1 条回复 最后回复 回复 引用 分享 0
      • H
        honghu886 LV 4 @shz18877605430 最后由 编辑

        @shz18877605430 ov5640 的类型不对fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        而是多视频捕获

        1 条回复 最后回复 回复 引用 分享 0
        • 1 / 1
        • First post
          Last post

        Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

        行为准则 | 用户协议 | 隐私权政策