Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

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

    MR Series
    3
    3
    1622
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      shz18877605430 LV 6 last edited by

      各位大佬救救急!!!

      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 Reply Last reply Reply Quote Share 0
      • H
        honghu886 LV 4 @shz18877605430 last edited by

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

        1 Reply Last reply Reply Quote Share 0
        • Q
          qwss_7410Ljq LV 2 last edited by

          我也碰到此问题,请问您是怎么解决的啊

          1 Reply Last reply Reply Quote Share 0
          • 1 / 1
          • First post
            Last post

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

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