OpenCV camera (using python) w/TX1 works with sudo, but not without

368 Views Asked by At

I am trying to access a camera (external: leopard imaging mipi) with opencv on TX1 using the following script (tx1_mipi.py). I am able to access it when I run "sudo python tx1_mipi.py". (It does gives an error "VIDEOIO ERROR: V4L: appsink: Unable to query number of channel", but it works)

However, I am not able to run python tx1_mipi.py (camera open fail) . How do I change the permission of the camera so that I don't have to sudo...

I have already tried adding user to video group (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()
0

There are 0 best solutions below