gpt4 book ai didi

opencv - OpenCV 中的 GStreamer API : autovideosink vs appsink

转载 作者:太空宇宙 更新时间:2023-11-03 22:36:02 34 4
gpt4 key购买 nike

当我在终端上运行时,以下 Gstreamer Receiver 命令工作正常。

gst-launch-1.0 -v udpsrc port=5004 !'application/x-rtp,payload=96,encoding-name=H264' ! rtpjitterbuffermode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert !autovideosink

我需要捕获这些帧并使用 OpenCV 的 Gstreamer API 进行一些处理。我在我的 C++ 代码中使用了确切的管道,但 VideoCapture 无法启动。代码如下:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
using namespace cv;

#include <iostream>
using namespace std;

int main()
{
VideoCapture cap("udpsrc port=5004 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! autovideosink", CAP_GSTREAMER);

if (!cap.isOpened()) {
cerr <<"VideoCapture not opened"<<endl;
exit(-1);
}

while (true) {

Mat frame;

cap.read(frame);

imshow("receiver", frame);

// Process the frame.

if (waitKey(1) == 27) {
break;
}
}

return 0;
}

当我尝试编译和运行时,我收到:

(Receiver_Teal:2292): GStreamer-CRITICAL **: gst_element_get_state:assertion 'GST_IS_ELEMENT (element)' failed

VideoCapture not opened

最佳答案

尝试用 appsink 替换末尾的 autovideosink

VideoCapture cap("udpsrc port=5004 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink", CAP_GSTREAMER);

关于opencv - OpenCV 中的 GStreamer API : autovideosink vs appsink,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58526948/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com