我正在尝试使用以下脚本(tx1_mipi.py)在TX1上使用opencv访问摄像头(外部:leopard成像mipi)。当我运行“sudo python tx1_mipi.py”时,我能够访问它。 (它确实给出了错误“VIDEOIO ERROR:V4L:appsink:无法查询频道数”,但它确实有效)
但是,我无法运行python tx1_mipi.py(相机打开失败)。如何更改相机的权限,以便我不必sudo ...
我已尝试将用户添加到视频群组(gpasswd -a sidmeister video)
ls -l / dev / video0 crw-rw ---- + 1 root video 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()