首页 > 解决方案 > C++/Ubuntu/openCv:gopro 非常低的 fps/分辨率

问题描述

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之外,60 fps 是不可能的。但是我的 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 了解甚少)

标签: opencvcameragstreamervideo-captureframe-rate

解决方案


我发现这似乎有效

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);

推荐阅读