The normal way to create a videocapture is this:
cam = cv2.VideoCapture(n)
where n corresponds to the number of /dev/video0
, dev/video1
But because I'm building a robot that uses multiple cameras for different things, I needed to make sure that it was being assigned to the correct camera, I created udev rules that created devices with symbolic links to the correct port whenever a specific camera was plugged in.
They appear to be working because when I look in the /dev
directory I can see the link:
/dev/front_cam -> video1
However I'm not sure how to actually use this now.
I thought I could just open it from the filename, as if it was a video, but cam = cv2.VideoCapture('/dev/front_cam')
doesn't work.
Neither does cv2.VideoCapture('/dev/video1')
It doesn't throw an error, it does return a VideoCapture object, just not one that's opened (cam.isOpened()
returns False
).