Gstreamer pipeline with CV2 and python

Hi i am attempting to use gstreamer to build a pipeline so I can save images to an external drive. I am having issues opening the file with cv2.VideoCapture.

gstreamer_0 = ('gst-launch-1.0 ’
'nvarguscamerasrc ’
'sensor-id=0 ’
"! ‘video/x-raw(memory:NVMM), "
"width=4056, height=3040, "
"framerate=15/1’ "
“! nvvidconv flip-method=0 "
“! ‘video/x-raw(memory:NVMM), "
"format=I420’”
" ! appsink”)

cap0 = cv2.VideoCapture(gstreamer_0,cv2.CAP_GSTREAMER)

if cap0.isOpened() is not True:
print(gstreamer_0)
print(“Cannot open camera”)
quit()

the gst-launch-1.0 works in terminal when ! appsink is replaced by !autovideosink. however when in python I recieve no errors, and the video capture simply does not open.
Thanks in advance

Hi,
Please try the two samples:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL
[Gstreamer] nvvidconv, BGR as INPUT - #4 by DaneLLL

For working with OpenCV, you would need to convert frame data to BGR.

Hi,
I used the following line from the samples you gave me
cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)I420 ! appsink") However I still could not open the capture video.
I also attempted

gstreamer_0 = ('gst-launch-1.0 ’
'nvarguscamerasrc ’
'sensor-id=0 ’
"! ‘video/x-raw(memory:NVMM), "
"width=4056, height=3040, "
"framerate=15/1’ "
“! nvvidconv flip-method=0 "
“! ‘video/x-raw(memory:NVMM), "
"format=BGR’”
" ! appsink”)
I also attempted ! videoconvert before and after I format to BGR.
Thanks

Hi,
I have investigated the issue further and found using cv2.getBuildInformation that for ‘video I/O’ GStreamer is set to NO.
Is the only way to resolved this to reflash CV2 onto the system using the SDK manager?

Hi,
We have included OpenCV 4.1.1 package which enables gstreamer in SDK components. Yo may re-flash system image and install SDK components through SDKManager.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.