I’m on Jetpack 5.1.1 on Jetson orin Nano. I’m trying to use Raspberry PI High Quality camera which have an IMX477 sensor OpenCV-python version is 4.7.0.
I’m trying to get the camera output with python and I am using this code to do so:
import cv2
def gstreamer_pipeline(
sensor_id=0,
capture_width=3840,
capture_height=2160,
display_width=1920,
display_height=1080,
framerate=30,
flip_method=2,
):
return “nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM),width=3840, height=2160,framerate=30/1, format=NV12 ! nvvidconv flip-method=2 ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1”def show_camera():
window_title = “CSI Camera”# To flip the image, modify the flip_method parameter (0 and 2 are the most common) print(gstreamer_pipeline(flip_method=2)) video_capture = cv2.VideoCapture(gstreamer_pipeline(flip_method=2), cv2.CAP_GSTREAMER) print(video_capture.isOpened()) if video_capture.isOpened(): try: window_handle = cv2.namedWindow(window_title, cv2.WINDOW_AUTOSIZE) while True: ret_val, frame = video_capture.read() # Check to see if the user closed the window # Under GTK+ (Jetson Default), WND_PROP_VISIBLE does not work correctly. Under Qt it does # GTK - Substitute WND_PROP_AUTOSIZE to detect if window has been closed by user if cv2.getWindowProperty(window_title, cv2.WND_PROP_AUTOSIZE) >= 0: cv2.imshow(window_title, frame) else: break keyCode = cv2.waitKey(10) & 0xFF # Stop the program on the ESC key or 'q' if keyCode == 27 or keyCode == ord('q'): break finally: video_capture.release() cv2.destroyAllWindows() else: print("Error: Unable to open camera")
if name == “main”:
show_camera()
I’m getting this output :
nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM),width=3840, height=2160,framerate=30/1, format=NV12 ! nvvidconv flip-method=2 ! videoconvert ! video/x-raw,format=BGR ! appsink drop=1
Error: Unable to open camera
Please help