The normal way to create a videocapture is this:
cam = cv2.VideoCapture(n)
where n corresponds to the number of /dev/video0
,
Instead of the suggested solution I found a shorter one, that feels a little bit hacky.
I just look at where the symbolic link points, find the integer in it, and then use that.
import subprocess
cmd = "readlink -f /dev/CAMC"
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
# output of form /dev/videoX
out = process.communicate()[0]
# parse for ints
nums = [int(x) for x in out if x.isdigit()]
cap = cv2.VideoCapture(nums[0])