环境准备
参考官方配置方案:
git clone https://github.com/NVIDIA-AI-IOT/jetcam
cd jetcam
sudo python3 setup.py install
即可完成库的下载和安装。
报错No nodule named ‘traitlets’
若遇到该报错:
pip3 install traitlets
安装该包即可。
CSI摄像头测试代码
若只有一个CSI摄像头,将camera1相关的代码注释掉即可。
from jetcam.csi_camera import CSICamera
import cv2
camera0 = CSICamera(capture_device=0, width=224, height=224)
camera1 = CSICamera(capture_device=1, width=224, height=224)
image0 = camera0.read()
print(image0.shape)
image1 = camera1.read()
print(image1.shape)
print(camera0.value.shape)
print(camera1.value.shape)
while 1:
image0 = camera0.read()
image1 = camera1.read()
cv2.imshow("CSI Camera0", image0)
cv2.imshow("CSI Camera1", image1)
kk = cv2.waitKey(1)
if kk == ord('q'): # 按下 q 键,退出
break
成功运行即可。