簡體   English   中英

取消引用指向 cv::Mat 的“cv::Mat*”指針以接收 Gstreamer 視頻並在 OpenCV 中使用

[英]Dereferencing " cv::Mat* " pointer to cv::Mat to Receive Gstreamer Video and Use in OpenCV

我正在從源接收視頻流。 (Gazebo Simulation)首先,我在python端接收成功,但我想移動代碼C++。 這是python代碼: Python代碼我也可以使用以下方法輕松地將跟蹤器添加到python:

video = Video()
frame = video.frame()
bbox = (287, 23, 86, 320)
ok = tracker.init(frame, bbox)

但是當我嘗試在 C++ 上做同樣的事情時,不可能輕松地通過這些步驟。 我使用了這段代碼,並且工作正常: C++ Code Gstream

但是我不能像opencv那樣使用。 關鍵代碼行是:

        // Main loop
    while(1) {
        g_main_iteration(false);

        cv::Mat* frame = atomicFrame.load();

        if(frame) {
            cv::imshow("Frame", frame[0]);
            cv::waitKey(30);
        }
    }

當我嘗試添加基本文本時,例如:

putText(frame[0], " Hello", Point(100,20), FONT_HERSHEY_SIMPLEX, 0.75, Scalar(50,170,50),2);

我越來越難“分段錯誤”。

我也嘗試過使用單線正常方式接收視頻:

VideoCapture video("udpsrc port=5600 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! avdec_h264! decodebin ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert! appsink name=sink emit-signals=true sync=false max-buffers=1 drop=true",CAP_GSTREAMER);

但是視頻打不開。

不再需要將 cv::Mat* 轉換為 cv::Mat。 此外,這不合邏輯。

以下是在 Gazebo Simulation 中正常工作的當前管道:

VideoCapture video("udpsrc port=5600 ! application/x-rtp,payload=96,encoding-name=H264 ! rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoco

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM