[英]Dereferencing " cv::Mat* " pointer to cv::Mat to Receive Gstreamer Video and Use in OpenCV
I'm working on receiving video stream from source.我正在从源接收视频流。 (Gazebo Simulation) First of all, I'm succesful to receive on python side, but I want to move code C++.
(Gazebo Simulation)首先,我在python端接收成功,但我想移动代码C++。 This is python code: Python code Also I can easily add tracker to python by using:
这是python代码: Python代码我也可以使用以下方法轻松地将跟踪器添加到python:
video = Video()
frame = video.frame()
bbox = (287, 23, 86, 320)
ok = tracker.init(frame, bbox)
But when I tried to same thing on C++ it's not possible to pass easily these steps.但是当我尝试在 C++ 上做同样的事情时,不可能轻松地通过这些步骤。 I used this code and this is working fine: C++ Code Gstream
我使用了这段代码,并且工作正常: C++ Code Gstream
But I couldn't be able to use like opencv.但是我不能像opencv那样使用。 Key code lines are:
关键代码行是:
// Main loop
while(1) {
g_main_iteration(false);
cv::Mat* frame = atomicFrame.load();
if(frame) {
cv::imshow("Frame", frame[0]);
cv::waitKey(30);
}
}
When I tried to add basic text like:当我尝试添加基本文本时,例如:
putText(frame[0], " Hello", Point(100,20), FONT_HERSHEY_SIMPLEX, 0.75, Scalar(50,170,50),2);
I'm getting hard "Segmentation fault".我越来越难“分段错误”。
I tried also use single line to receive video normal way:我也尝试过使用单线正常方式接收视频:
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);
But video couldn't be open.但是视频打不开。
It is not necessary anymore to convert cv::Mat* to cv::Mat.不再需要将 cv::Mat* 转换为 cv::Mat。 Furthermore, it's not logical.
此外,这不合逻辑。
Here is current pipeline that working without error in Gazebo Simulation:以下是在 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.