Gstreamer pipeline in Opencv videoCapture()

Sam picture Sam · Apr 4, 2017 · Viewed 8.5k times · Source

I'm trying to open an IP camera in OpenCV using gstreamer pipleine. I can open the IPcamera using Gstreamer in terminal, using :

gst-launch-1.0 -v rtspsrc location="rtsp://192.168.0.220:554/user=admin&password=admin&channel=1&stream=0.sdp?real_stream--rtp-caching=10" latency=10 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! xvimagesink

Now with this how can I open the same camera in OpenCV videoCapture().

Any help is appreciated.

Answer

Alper Kucukkomurler picture Alper Kucukkomurler · Apr 4, 2017

You can copy the same pipe and use it in VideoCapture (if you built OpenCV with gstreamer modules).

Important point is you need to finish the pipe with an appsink element.

const char* pipe =  "rtspsrc location=\"rtsp://192.168.0.220:554/user=admin&password=admin&channel=1&stream=0.sdp?real_stream--rtp-caching=10\" latency=10 ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! appsink";
VideoCapture cap(pipe);