无法使用OpenCV GSTREAMER接收UDP流

发布于 2025-02-03 06:53:04 字数 3353 浏览 2 评论 0原文

我正在尝试通过UDP和接收端通过网络传输RGB原始数据,我想使用OpenCV C ++对数据进行一些图像处理。

发件人管道

gst-launch-1.0 -v k4asrc serial=$k4a_serial timestamp-mode=clock_all enable-color=true ! rgbddemux name=demux demux.src_color ! rtpvrawpay ! udpsink host=192.168.100.46 port=9001

接收器:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap("udpsrc port=9001 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=RAW, sampling=(string)RGB, width=(string)1280, height=(string)720, payload=96 ! rtpvrawdepay ! videoconvert ! queue ! appsink", CAP_GSTREAMER);

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

    while (true) {

        Mat frame;

        cap.read(frame);

        imshow("receiver", frame);

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

    return 0;
}

我在终端中获得以下输出:

[ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (223) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(8, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (383) cv::impl::getPluginCandidates Found 2 plugin(s) for GSTREAMER
[ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load C:\opencv\build\x64\vc15\bin\opencv_videoio_gstreamer455_64d.dll => FAILED
[ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load opencv_videoio_gstreamer455_64d.dll => FAILED

VideoCapture not opened !!!

C:\Users\username\g-streamer\gst_sample\gst-udp-03\out\build\x64-Debug\gstreamer_udp_03.exe (process 21264) exited with code -1.
Press any key to close this window . . .

为什么opencv_videoio_gstreamer455_64d.dll load失败?我检查了一下,它已经在提供的路径中。

当我在终端中尝试同一条管道时,我可以看到预期的视频。

终端接收器管道:

gst-launch-1.0 udpsrc port=9001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)RGB, width=(string)1280, height=(string)720, payload=(int)96" ! rtpvrawdepay ! videoconvert ! queue ! autovideosink sync=false

系统:

Sender-PC = Ubuntu 18.04
Receiver-PC = Windows 10
Python = 3.7.9
OpenCV = 4.5.5 

I am trying to transmit RGB raw data over the network via UDP and on the receiving side, I want to do some image processing on the data using OpenCV C++.

Sender Pipeline

gst-launch-1.0 -v k4asrc serial=$k4a_serial timestamp-mode=clock_all enable-color=true ! rgbddemux name=demux demux.src_color ! rtpvrawpay ! udpsink host=192.168.100.46 port=9001

Receiver:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{
    VideoCapture cap("udpsrc port=9001 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=RAW, sampling=(string)RGB, width=(string)1280, height=(string)720, payload=96 ! rtpvrawdepay ! videoconvert ! queue ! appsink", CAP_GSTREAMER);

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

    while (true) {

        Mat frame;

        cap.read(frame);

        imshow("receiver", frame);

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

    return 0;
}

I get the following output in the terminal:

[ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\videoio_registry.cpp (223) cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(8, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930)
[ INFO:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\videoio\src\backend_plugin.cpp (383) cv::impl::getPluginCandidates Found 2 plugin(s) for GSTREAMER
[ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load C:\opencv\build\x64\vc15\bin\opencv_videoio_gstreamer455_64d.dll => FAILED
[ INFO:[email protected]] global c:\build\master_winpack-build-win64-vc15\opencv\modules\core\src\utils\plugin_loader.impl.hpp (67) cv::plugin::impl::DynamicLib::libraryLoad load opencv_videoio_gstreamer455_64d.dll => FAILED

VideoCapture not opened !!!

C:\Users\username\g-streamer\gst_sample\gst-udp-03\out\build\x64-Debug\gstreamer_udp_03.exe (process 21264) exited with code -1.
Press any key to close this window . . .

Why does the opencv_videoio_gstreamer455_64d.dll load fail? I checked and it is already in the provided path.

When I try the same Pipeline in the terminal, I can see the expected video.

Terminal Receiver Pipeline:

gst-launch-1.0 udpsrc port=9001 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)RGB, width=(string)1280, height=(string)720, payload=(int)96" ! rtpvrawdepay ! videoconvert ! queue ! autovideosink sync=false

System:

Sender-PC = Ubuntu 18.04
Receiver-PC = Windows 10
Python = 3.7.9
OpenCV = 4.5.5 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2025-02-10 06:53:04

几次尝试后解决。希望它对其他人有帮助。

我重新安装了一切。构建了另一个版本的OpENCV,它正在按预期工作。还必须更改管道以添加所有上限信息。

发件人管道

gst-launch-1.0 -v k4asrc serial=$k4a_serial timestamp-mode=clock_all enable-color=true ! rgbddemux name=demux demux.src_color ! rtpvrawpay ! udpsink host=192.168.100.46 port=9001

接收器:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{
    // Receiving Pipeline
    VideoCapture cap("udpsrc port=9001 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)RGB, depth=(string)8, width=(string)1280, height=(string)720, colorimetry=(string)SMPTE240M, payload=(int)96, ssrc=(uint)597927397, timestamp-offset=(uint)407659256, seqnum-offset=(uint)20318, a-framerate=(string)30 ! rtpvrawdepay ! videoconvert ! appsink", CAP_GSTREAMER);


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

    while (true) {

        Mat frame;

        cap.read(frame);

        imshow("receiver", frame);

        if (waitKey(1) == 27) {
            break;
        }
    }
    // When everything done, release the video capture object

    cap0.release();
    cap1.release();

    // Closes all the frames
    destroyAllWindows();

    return 0;
}

系统:

Sender-PC = Ubuntu 18.04
Receiver-PC = Windows 10
OpenCV = 4.2.0
Gstreamer = 1.20.1
Python = 3.8.9

SOLVED after several tries. Hope it helps someone else.

I reinstalled everything. Built another version of OpenCV and it's working as expected. Also had to change the Pipeline a bit to add all the CAPS information.

Sender Pipeline

gst-launch-1.0 -v k4asrc serial=$k4a_serial timestamp-mode=clock_all enable-color=true ! rgbddemux name=demux demux.src_color ! rtpvrawpay ! udpsink host=192.168.100.46 port=9001

Receiver:

#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{
    // Receiving Pipeline
    VideoCapture cap("udpsrc port=9001 ! application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, sampling=(string)RGB, depth=(string)8, width=(string)1280, height=(string)720, colorimetry=(string)SMPTE240M, payload=(int)96, ssrc=(uint)597927397, timestamp-offset=(uint)407659256, seqnum-offset=(uint)20318, a-framerate=(string)30 ! rtpvrawdepay ! videoconvert ! appsink", CAP_GSTREAMER);


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

    while (true) {

        Mat frame;

        cap.read(frame);

        imshow("receiver", frame);

        if (waitKey(1) == 27) {
            break;
        }
    }
    // When everything done, release the video capture object

    cap0.release();
    cap1.release();

    // Closes all the frames
    destroyAllWindows();

    return 0;
}

System:

Sender-PC = Ubuntu 18.04
Receiver-PC = Windows 10
OpenCV = 4.2.0
Gstreamer = 1.20.1
Python = 3.8.9
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文