import cv2 # GStreamer pipeline for IMX477 pipeline = ( "nvarguscamerasrc sensor-id=0 ! " "video/x-raw(memory:NVMM), width=4056, height=3040, format=NV12, framerate=30/1 ! " "nvvidconv flip-method=2 ! " "video/x-raw, width=1920, height=1080, format=BGRx ! " "videoconvert ! " "video/x-raw, format=BGR ! appsink" ) cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER) if not cap.isOpened(): print("Failed to open camera") exit() while True: ret, frame = cap.read() if not ret: print("Failed to capture image") break cv2.imshow("CSI Camera", frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()