Search code examples
pythonwindowsopencvcameravideo-capture

How to read OpenCV camera by name/ID instead of device index?


In python you can do

import cv2
cap = cv2.VideoCapture(index)

to open a webcam at index where index is a number ranging from 0,1,2,3...

But if I have multiple cameras and the order is arbitrary, my camera accessing code will be unreliable.

Is there a way to open a specific camera with a name or ID using OpenCV on Windows 10? How to do it?


Solution

  • I used this library and it seems to work: https://github.com/pvys/CV-camera-finder

    Might be interesting to check this too: https://github.com/econsystems/opencv