1

I'm studying about object tracking and detecting in Gazebo Simulation. So, I'm trying to send Simulation video(Gst Plugin) to Raspberry Pi 4 via ethernet cable over UDP stream. And Pi 4 side, catch video by using Gstreamer pipeline.

I installed OpenCV 4.2.0-pre from source to Raspberry Pi 4. debianBuster comes with some useful GStreamer libraries and plugins. Following this site and customized installation with some correction. I succesfully receive video with this command on Pi side:

gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink fps-update-interval=1000 sync=false

Also this code also works well by using gstreamer library:

Get video udp h264 with gstreamer and opencv

But it's using cv::Mat* pointer and OpenCV functions doesn't allow pointer to use as a function parameter. So following code which use Opencv and Gstreamer runs without error or problem in Ubuntu.

VideoCapture video("udpsrc port=5600 ! application/x-rtp,payload=96,encoding-name=H264 !"
                       "rtpjitterbuffer mode=1 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink emit-signals=true sync=false max-buffers=1 drop=true", CAP_GSTREAMER);


// Exit if video is not opened
if(!video.isOpened())
{
    cout << "Could not read video file" << endl;
    return 1;
}

But in Pi side it can't be opened and code exit in if statement.

2

Actually, I was think that problem is related to Raspberry Pi but it wasn't. Somehow, OpenCV doesn't recognize GStreamer library when building OpenCV with cmake and make. Also when I use OpenCV in C++ code stack, OpenCV didn't throw exception when it couldn't find gstreamer support.

I added -D WITH_GSTREAMER=ON flag when I'm using cmake command. You can find more information at stackoverflow: Opencv GStreamer pipeline doesn't work on Raspberry Pi 4

Note: Please let me know if it's counted as a duplicated.

2
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Feb 17 '20 at 10:35
  • Thanks for advice. Done
    – Bozkurthan
    Feb 18 '20 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.