In this video lesson we learn how to launch the Raspberry Pi Camera or a simple WEB cam on the Jetson Xavier NX using openCV and a Gstreamer command. This simple code shows you how to set up the camera, and then how to grab a frame and show a frame to create live video from the cameras.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import cv2 print(cv2.__version__) width=1280 height=720 flip=2 camSet='nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=3264, height=2464, framerate=21/1,format=NV12 ! nvvidconv flip-method='+str(flip)+' ! video/x-raw, width='+str(width)+', height='+str(height)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink' #camSet ='v4l2src device=/dev/video1 ! video/x-raw,width='+str(width)+',height='+str(height)+',framerate=24/1 ! videoconvert ! appsink' cam=cv2.VideoCapture(camSet) while True: _, frame = cam.read() cv2.imshow('myCam',frame) cv2.moveWindow('myCam',0,0) if cv2.waitKey(1)==ord('q'): break cam.release() cv2.destroyAllWindows() |