Jetson Orin Nano 使用OpenCV调用USB摄像头

环境

Jetson Orin Nano 8G
ubuntu 20.04

usb摄像头

安装cv库

pip3 install opencv-contrib-python

检查usb摄像头是否被识别到

jetson@ubuntu:~$ lsusb
Bus 002 Device 002: ID 0bda:0489 Realtek Semiconductor Corp. 4-Port USB 3.0 Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 13d3:3549 IMC Networks Bluetooth Radio
Bus 001 Device 004: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
Bus 001 Device 002: ID 0bda:5489 Realtek Semiconductor Corp. 4-Port USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

或者

jetson@ubuntu:~$ ls /dev/video*
/dev/video0  /dev/video1

测试代码

import cv2
cap = cv2.VideoCapture(0)
if not cap.isOpened():
    print("Cannot open camera")
    exit()
while True:
    ret, frame = cap.read()
    if not ret:
        print("no stream!")
        break
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

效果

Jetson Orin Nano 使用OpenCV调用USB摄像头_第1张图片

Jetson Orin Nano 使用OpenCV调用USB摄像头

你可能感兴趣的:(jetson,opencv,人工智能,计算机视觉)