Ask Your Question

Revision history [back]

Custom gstreamer libraries within opencv

Is there a way to target custom gstreamer libraries when using a pipeline within videocapture in opencv 3.1 ?

for reference this is my working pipeline for gstreamer

gst-launch-1.0 --gst-debug=4 --gst-plugin-path=$HOME/gst/rtp/.libs udpsrc multicast-iface=eth0 address=239.192.1.32 port=5004 caps="application/x-rtp, media=(string)video, clockrate=(int)90000, encoding-name=(string)RAW, sampling=(string)DEFSTAN-00-82-YCbCr-4:2:2, depth=(string)8, width=(string)640, height=(string)480, framerate=(fraction)25/1, colorimetry=(string)BT601-5, payload=(int)26, ssrc=(uint)0000000000" ! rtpvrawdepay ! queue ! videoconvert ! video/x-raw,format=YUY2 ! xvimagesink

using opencv with

pipe = "udpsrc multicast-iface=eth0 address=239.192.1.32 port=5004 ! application/x-rtp, media=(string)video, clockrate=(int)90000, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:2, depth=(string)8, width=(string)640, height=(string)480, framerate=(fraction)25/1, colorimetry=(string)BT601-5, payload=(int)26, ssrc=(uint)0000000000 ! queue ! rtpvrawdepay ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"

cap = cv2.VideoCapture(pipe)

works though does not target my modified library ( I need this for raw grayscale, line offset modifications and other fixes )

pipe = "--gst-plugin-path=$HOME/gst/rtp/.libs udpsrc multicast-iface=eth0 address=239.192.1.32 port=5004 ! application/x-rtp, media=(string)video, clockrate=(int)90000, encoding-name=(string)RAW, sampling=(string)DEFSTAN-00-82-YCbCr-4:2:2, depth=(string)8, width=(string)640, height=(string)480, framerate=(fraction)25/1, colorimetry=(string)BT601-5, payload=(int)26, ssrc=(uint)0000000000 ! queue ! rtpvrawdepay ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"

cap = cv2.VideoCapture(pipe)

gives the following errors

GStreamer Plugin: Embedded video playback halted; module udpsrc0 reported: Internal data flow error.
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/ubuntu/opencv/modules/videoio/src/cap_gstreamer.cpp, line 818
Traceback (most recent call last):
  File "Desktop/kenny.py", line 9, in <module>
    cap = cv2.VideoCapture(pipe)
cv2.error: /home/ubuntu/opencv/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

is there a way around this or am i stuck using the source libraries ?