Connecting to USB camera using device name in Python

asked 2018-06-27 11:23:14 -0600

In Python, connecting to a USB camera is as follows:

cap = cv2.VideoCapture(index)

where index is an int, 0 is the default camera. But I have a multi-camera setup with specific FOVs and I would like to ensure that I am connecting to the same camera each time. How would you do this in Python? Ubuntu gives you the device id and I placed this id into the videocapture function, for example:

cap = cv2.VideoCapture("/dev/v4l/by-path/usb-CNFEH53F301030002730_Integrated_Webcam_HD_0001-video-index0");

However, the above does not work. Does anyone know how to do this? Thanks for the help.

edit retag flag offensive close merge delete