For better advice, you may post the exact command or code that that you’re trying and error messages that you’re facing, so that your case can be easily reproduced.
First be sure that your python env has an opencv version supporting GStreamer:
If it shows Gstreamer SUPPORT YES, then you can get further.
# Reading BGRx frames into opencv:
cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3264, height=2464, framerate=21/1, format=NV12 ! nvvidconv ! video/x-raw,format=BGRx ! appsink drop=1", cv2.CAP_GSTREAMER)
# Or reading BGR frames as expected by most opencv algorithms:
# cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3264, height=2464, framerate=21/1, format=NV12 ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)
if not cap.isOpened():
print("failed to open video capture")
# Run for 10s @21fps
while frames < 210:
ret_val, img = cap.read();
if not ret_val:
print("failed to read from video capture")
frames = frames + 1
if cv2.waitKey(1) == ord('q'):
If this works, you may try resizing into lower resolution.
Note that nvvidconv may not be able to scale into huge factors (but multiple nvviconv rescaling stages may work).
I notice that your gst-launch command uses 320x240 while your opencv example uses 224x224.
Thank you for sharing and I just found out that I need to install the right version for opencv when using csi camera in jetson nano which was 4.1.1. After installing this version, it run successfully. Also, the code that you shared is helpful.