Welcome to Jetson ORIN NANO SUPER repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
17.Preview USB camera image
Preview USB camera image
1. Implementation principle
Use cv2.VideoCapture() function to capture video from USB camera or video file.
2. Implementation effect
xxxxxxxxxxcd ~/opencv
xxxxxxxxxxpython3 17.camera_preview_usb.py # The program opens video0 by default, open other cameras and modify the device number by yourself
Note: Select the camera screen and press q to exit the program!

3. Implementation code
ximport cv2def preview_usb_camera():cap = cv2.VideoCapture(0)if not cap.isOpened():print("Error: Could not open USB camera.")returnwhile True:ret, frame = cap.read()if not ret:breakcv2.imshow('USB Camera Preview', cv2.resize(frame, (640, 480)))if cv2.waitKey(1) & 0xFF == ord('q'):breakcap.release()cv2.destroyAllWindows()preview_usb_camera()