Navigation

    全志在线开发者论坛

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

    Tina V821 Linux系统使用V4L2打开摄像头报错,如何解决?

    其它全志芯片讨论区
    2
    3
    1273
    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.
    • V
      Volcan_W LV 4 last edited by

      在使用V4L2打开GC2053摄像头,获取摄像头支持的格式时,无打印,然后设置格式也一直报错无法成功,返回:Set format。
      有无使用V4L2的可执行的应用层代码参考?

      struct v4l2_fmtdesc fmtdesc;
          memset(&fmtdesc, 0, sizeof(fmtdesc));
          fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
          fmtdesc.index = 0;
          
          printf("Supported formats:\n");
          while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc) == 0) {
          	printf("  %c%c%c%c\n",
              fmtdesc.pixelformat & 0xFF,
              (fmtdesc.pixelformat >> 8) & 0xFF,
              (fmtdesc.pixelformat >> 16) & 0xFF,
              (fmtdesc.pixelformat >> 24) & 0xFF);
          	fmtdesc.index++;
      	printf("1\n");
          }
      
          // 设置格式
          struct v4l2_format fmt;
          memset(&fmt, 0, sizeof(fmt));
          fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
          fmt.fmt.pix.width = WIDTH;
          fmt.fmt.pix.height = HEIGHT;
          fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; // 或者根据摄像头支持格式修改
          //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565;
          //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
          //fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
          fmt.fmt.pix.field = V4L2_FIELD_NONE;
      
          ret = ioctl(fd, VIDIOC_S_FMT, &fmt);
          printf("%d\n", ret);
      
          if (ioctl(fd, VIDIOC_S_FMT, &fmt) < 0) {
              perror("Set format");
              close(fd);
              return -1;
          }
      
      1 Reply Last reply Reply Quote Share 0
      • I
        indream LV 5 last edited by

        @volcan_w 在 Tina V821 Linux系统使用V4L2打开摄像头报错,如何解决? 中说:

        V4L2_BUF_TYPE_VIDEO_CAPTURE

        用V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE

        V 1 Reply Last reply Reply Quote Share 0
        • V
          Volcan_W LV 4 @indream last edited by

          @indream 能具体说一下吗?

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

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

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