【问题标题】:C++/Ubuntu/openCv: gopro very low fps/resolutionC++/Ubuntu/openCv:gopro 非常低的 fps/分辨率
【发布时间】:2021-03-07 18:04:40
【问题描述】:

https://www.amazon.fr/gp/product/B08CGVSRQV/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

我的系统:

gopro3 => microHDMI 转 HDMI => HDMI 转 USB3(我在上面购买的)=> 我的电脑。

与:

gst-launch-1.0 -v v4l2src! video/x-raw, framerate=30/1 ! xvimagesink

终端:

...
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, framerate=(fraction)30/1, format=(string)YUY2, width=(int)720, height=(int)480, pixel-aspect-ratio=(fraction)1/1, colorimetry=(string)2:4:5:1, interlace-mode=(string)progressive
...

=> 宽度=(int)720,高度=(int)480

我的 gopro 给我 1920/1080/60,只需更改 fps 捕获,分辨率就会自动调整。

例如,如果我强制解决:

gst-launch-1.0 -v v4l2src! video/x-raw, framerate=30/1,width=1920,height=1080! xvimagesink

gst-launch 或 opencv 总是崩溃:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000049118
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

1920/1080/5fps 或 1280/720/10fps 或 800/600/20fps 或 720/480/ 除外>30fps,60fps 是不可能的。但是我的 gopro3 black 发送给我 1920/1080/60fps,有什么解释吗??我真的不明白发生了什么。 gopro可以,cable可以,采集卡可以,我的电脑可以……

Morover,在 1080p 中,大约 1 秒延迟和 5 fps,在 720p 中大约 0.5 秒延迟,对于 800/600 延迟是可以的,而 480p 延迟大约是 0.2 秒(对我来说完美)。

对于 opencv,它和 gst-streamer 一样糟糕:

cv::VideoCapture video_capture(0, cv::CAP_V4L2);

显示480p,非常流畅 和

cv::VideoCapture video_capture(0, cv::CAP_GSTREAMER);

显示 1080p 并具有很强的延迟

我在哪里做错了?我不明白。 是我的采集卡坏了吗? 我在 gst-launch-1.0 中的参数是否错误? (那我肯定对 gstreamer 了解不多)

【问题讨论】:

    标签: opencv camera gstreamer video-capture frame-rate


    【解决方案1】:

    使用以下方法检查相机功能:

    v4l2-ctl --list-formats-ext -d /dev/video0

    很可能您只能为 MJPG 获得 1080p/60FPS(并且您已明确请求 x-raw,没有进行压缩)。如果是这样,请尝试:

    gst-launch-1.0 -e v4l2src !  image/jpeg,width=1920,height=1080,framerate=30/1 ! jpegdec ! xvimagesink
    

    【讨论】:

      【解决方案2】:

      v4l2-ctl --list-formats-ext -d /dev/video0

      ioctl: VIDIOC_ENUM_FMT
          Type: Video Capture
      
          [0]: 'MJPG' (Motion-JPEG, compressed)
              Size: Discrete 1920x1080
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.040s (25.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1600x1200
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.040s (25.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1360x768
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.040s (25.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1280x1024
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.040s (25.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1280x960
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1280x720
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 1024x768
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 800x600
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 720x576
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 720x480
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 640x480
                  Interval: Discrete 0.017s (60.000 fps)
                  Interval: Discrete 0.020s (50.000 fps)
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
          [1]: 'YUYV' (YUYV 4:2:2)
              Size: Discrete 1920x1080
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1600x1200
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 1360x768
                  Interval: Discrete 0.125s (8.000 fps)
              Size: Discrete 1280x1024
                  Interval: Discrete 0.125s (8.000 fps)
              Size: Discrete 1280x960
                  Interval: Discrete 0.125s (8.000 fps)
              Size: Discrete 1280x720
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 1024x768
                  Interval: Discrete 0.100s (10.000 fps)
              Size: Discrete 800x600
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 720x576
                  Interval: Discrete 0.040s (25.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 720x480
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
              Size: Discrete 640x480
                  Interval: Discrete 0.033s (30.000 fps)
                  Interval: Discrete 0.050s (20.000 fps)
                  Interval: Discrete 0.100s (10.000 fps)
                  Interval: Discrete 0.200s (5.000 fps)
      

      v4l2src !图像/JPEG,宽度=1920,高度=1080,帧率=30/1! JPEG格式! xvimagesink

      Setting pipeline to PAUSED ...
      Pipeline is live and does not need PREROLL ...
      Setting pipeline to PLAYING ...
      New clock: GstSystemClock
      X Error of failed request:  BadAlloc (insufficient resources for operation)
        Major opcode of failed request:  150 (XVideo)
        Minor opcode of failed request:  19 ()
        Serial number of failed request:  72
        Current serial number in output stream:  73
      

      【讨论】:

        【解决方案3】:

        我发现这似乎有效

        gst-launch-1.0 -v v4l2src ! "image/jpeg;video/x-raw" ! decodebin ! glimagesink
        

        对于opencv,就是这个:

        cv::VideoCapture video_capture("v4l2src ! image/jpeg;video/x-raw,framerate=30/1 ! decodebin ! videoconvert ! appsink", cv::CAP_GSTREAMER);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多