Opencv 4.1 打开Jetson TX 2 板载摄像头
网上总结很多opencv打开板载摄像头方法,但大多需要卸载刷机安装的原始opencv. 下面我的方法则不用,只需要运行python文件。
// An highlighted block
import cv2
def open_cam_onboard(width, height):
gst_str = ('nvarguscamerasrc ! '
'video/x-raw(memory:NVMM), '
'width=(int)2592, height=(int)1458, '
'format=(string)NV12, framerate=(fraction)30/1 ! '
'nvvidconv flip-method=2 ! '
'video/x-raw, width=(int){}, height=(int){}, '
'format=(string)BGRx ! '
'videoconvert ! appsink').format(width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
cap=open_cam_onboard(500,300)
while(True):
ret,frame=cap.read()
frame=cv2.flip(frame,-1) #翻转
cv2.imshow('frame',frame)
if cv2.waitKey(1) == ord('q'):
break
运行即可
nvidia官方论坛原解决问题地址:
https://devtalk.nvidia.com/default/topic/1043623/jetson-agx-xavier/on-board-cam