【发布时间】:2022-06-27 19:43:20
【问题描述】:
我目前正在尝试访问从 Rosetta 无人机应用程序发送的无人机实时信息。我之前已经看到通过使用 OpenCV 中的 VideoCapture 来完成它,如下所示:
self.cap_receive = cv2.VideoCapture('udpsrc port=5600 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! rtph264depay ! avdec_h264 ! videoconvert ! appsink ', cv2.CAP_GSTREAMER)
我正在使用 Conda 并手动编译 OpenCV 以包含 Gstreamer(我预先安装)。当我执行我的代码时,我收到以下错误:
[ WARN:0@2.585] global /home/max/openCV-GS/opencv-4.x/modules/videoio/src/cap_gstreamer.cpp (1127) open OpenCV | GStreamer warning: Error opening bin: no element "udpsrc"
[ WARN:0@2.585] global /home/max/openCV-GS/opencv-4.x/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
我通过在控制台(在我的 conda 环境中)输入 gst-inspect-1.0 udpsrc 来检查 Gstreamer 是否安装正确,这最初不起作用。它告诉我没有这样的元素或插件,但在添加sudo(如here 所述)后,它显示了所有插件详细信息。
这是否意味着 Gstreamer 的 udpsrc 已正确安装?如果是这样,为什么我的 Python 代码不起作用,我是否也必须在其中获得 sudo 权限(以及我将如何做到这一点)?
如果相关,那是sudo gst-inspect-1.0 udpsrc的结果
(liveImMapper) max@max-ubuntu:~$ sudo gst-inspect-1.0 udpsrc
Factory Details:
Rank none (0)
Long-name UDP packet receiver
Klass Source/Network
Description Receive data over the network via UDP
Author Wim Taymans <wim@fluendo.com>, Thijs Vermeir <thijs.vermeir@barco.com>
Plugin Details:
Name udp
Description transfer data via UDP
Filename /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstudp.so
Version 1.16.2
License LGPL
Source module gst-plugins-good
Source release date 2019-12-03
Binary package GStreamer Good Plugins (Ubuntu)
Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0
GObject
+----GInitiallyUnowned
+----GstObject
+----GstElement
+----GstBaseSrc
+----GstPushSrc
+----GstUDPSrc
Implementierte Schnittstellen:
GstURIHandler
Pad Templates:
SRC template: 'src'
Availability: Always
Capabilities:
ANY
Element has no clocking capabilities.
URI handling capabilities:
Element can act as source.
Supported URI protocols:
udp
Pads:
SRC: 'src'
Pad Template: 'src'
Element Properties:
address : Address to receive packets for. This is equivalent to the multicast-group property for now
flags: lesbar, schreibbar
String. Default: "0.0.0.0"
auto-multicast : Automatically join/leave multicast groups
flags: lesbar, schreibbar
Boolean. Default: true
:```
【问题讨论】:
-
感觉很奇怪,你必须使用
sudo来调用gst-inspect-1.0... 你是如何安装gstreamer 的? -
我用新的 conda 环境重新安装了所有东西,现在它可以工作了。在某些时候,我可能在我的 conda 环境中安装了 gstreamer 的某些部分,现在它总是引用错误的路径(安装的某些部分丢失了)。我假设通过使用 suodo 它使用了安装在 conda env 之外的版本。没有重新安装所有东西,并且 gstreamer 脱离了 conda env,一切似乎都运行良好(即使不使用 sudo)
-
对。也许您可以将其写为答案并解决您的问题!
标签: python opencv udp conda gstreamer