我正在尝试使用以下脚本(tx1_mipi.py)在 TX1 上使用 opencv 访问相机(外部:豹成像 mipi)。当我运行“sudo python tx1_mipi.py”时,我可以访问它。(它确实给出了一个错误“VIDEOIO ERROR: V4L: appsink: Unable to query number of channel”,但它可以工作)
但是,我无法运行 python tx1_mipi.py (camera open fail) 。如何更改相机的权限,这样我就不必 sudo ...
我已经尝试将用户添加到视频组(gpasswd -a sidmeister video)
ls -l /dev/video0 crw-rw----+ 1 根视频 81, 0 Jul 6 14:45 /dev/video0
import sys
import cv2
def read_cam():
cap = cv2.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int) 1920, height=(int)1080,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")
if cap.isOpened():
cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
while True:
ret_val, img = cap.read();
cv2.imshow('demo',img)
cv2.waitKey(10)
else:
print "camera open failed"
cv2.destroyAllWindows()
if name == 'main': read_cam()