我正在使用 Visual Studio 2022 和 VCPKG 创建一个应用程序,该应用程序使用 GStreamer 从 RaspberryPi 捕获通过 UDP 传输的视频。我更新了
vcpkg/ports/gstreamer/portfile.cmake
并添加了:
-Dgst-plugins-good:udp=enabled
位于vcpkg_configure_meson
下。之后,用gstreamer安装了opencv4,所以vcpkh list
看起来像这样:
gstreamer:x64-windows 1.19.2#9 GStreamer open-source multimedia framework core ...
gstreamer[flac]:x64-windows FLAC audio codec plugin
gstreamer[gl-graphene]:x64-windows Use Graphene in OpenGL plugin
gstreamer[plugins-base]:x64-windows 'Base' GStreamer plugins and helper libraries
gstreamer[plugins-good]:x64-windows 'Good' GStreamer plugins and helper libraries
gstreamer[plugins-ugly]:x64-windows 'Ugly' GStreamer plugins and helper libraries
gstreamer[rawparse]:x64-windows Build with libraw support
gstreamer[x264]:x64-windows Colon separated list of additional x264 library ...
opencv4:x64-windows 4.6.0#5 computer vision library
opencv4[default-features]:x64-windows Platform-dependent default features
opencv4[dnn]:x64-windows Enable dnn module
opencv4[gstreamer]:x64-windows gstreamer support for opencv
opencv4[jpeg]:x64-windows JPEG support for opencv
opencv4[png]:x64-windows PNG support for opencv
opencv4[quirc]:x64-windows Enable QR code module
opencv4[tiff]:x64-windows TIFF support for opencv
opencv4[webp]:x64-windows WebP support for opencv
但是,即使这样
gstudp.dll
也不会复制到任何地方,如果我手动将其复制到 /x64/Debug
并运行我的应用程序,我得到:
[ WARN:[email protected]] global D:\C++Libs\vcpkg\buildtrees\opencv4\src\4.6.0-e24d1d7a25.clean\modules\videoio\src\cap_gstreamer.cpp (1127) cv::GStreamerCapture::open OpenCV | GStreamer warning: Error opening bin: no element "udpsrc"
[ WARN:[email protected]] global D:\C++Libs\vcpkg\buildtrees\opencv4\src\4.6.0-e24d1d7a25.clean\modules\videoio\src\cap_gstreamer.cpp (862) cv::GStreamerCapture::isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Failed to open camera.
通过 UDP 和 vcpkg 使用 OpenCV/GStreamer 我做错了什么?
发生这种情况是因为插件安装在 gstreamer 找不到它们的文件夹中。
要解决这个问题,您可以指定指向它的变量
GST_PLUGIN_PATH
,如c:\src\vcpkg\installed\x64-windows\plugins
(只需更改路径以反映您的路径并尝试一下)。
你还可以设置一个名为 GST_DEBUG 的变量,值为 5,它会打印一堆为什么找不到插件的信息。
另外,检查这个答案GStreamer插件搜索路径?.
我使用
vcpkg
,但在运行 GStreamer 时遇到问题。 它没有找到它的插件。 我最终需要设置GST_PLUGIN_PATH=X:\vcpkg\installed\x64-windows\plugins\gstreamer
。 我还将 D:\vcpkg\installed\x64-windows\tools\gstreamer
添加到我的路径中。
完成此操作后,您仍然需要有一个有效的管道供 GStreamer 与 OpenCV 配合使用。 像这样的东西:
std::string gstPipeline =
"appsrc is-live=true ! videoconvert ! "
"openh264enc bitrate=500 ! rtph264pay config-interval=1 "
"pt=96 ! udpsink host=127.0.0.1 port=5000";
cv::VideoWriter writer(gstPipeline, cv::CAP_GSTREAMER, 0, 30,
cv::Size(frame_width, frame_height), true);
writer.write(cvframe);