1

I am working on a software, where an USB video device is used. I use cv2.VideoCapture() function from the openCV library in the software. The function need to get index of the video device, but my usb cam has sometimes index 0, sometimes index 1 or index 7. Because the software must be user friendly, so I would like to get list of all available USB video devices and let the user choose what device he wants. The best would be get name and address of the devices. I tried search in older questions but if there was answer, user used c++ and I do not know how to do it in python. The solution should be easy and elegant Thank you very much for your help and I hope that the question is understandable.

Michal
  • 11
  • 2
  • Have you seen ? – Lexiam Apr 03 '20 at 18:25
  • Ok @Lexiam , so If I understood well, get the list of video devices is impossible , am I right? – Michal Apr 03 '20 at 18:33
  • Have you seen https://stackoverflow.com/questions/8044539/listing-available-devices-in-python-opencv? technically you cannot get the list of devices, but you can see the answer under the accepted one. he gets the list in a brute force way. – Lexiam Apr 03 '20 at 20:33
  • @Lexiam, I seen, but I have two video devices and I must choose the external one and I think it is possible only by using the name of the cam. – Michal Apr 04 '20 at 05:29

1 Answers1

0

There is a solution https://github.com/pvys/CV-camera-finder

from pymf import get_MF_devices
device_list = get_MF_devices()
for i, device_name in enumerate(device_list):
    print(f"opencv_index: {i}, device_name: {device_name}")

=> opencv_index: 0, device_name: Integrated Webcam

with get_MF_devices function, you can recieve device list (opencv index and friendly name). But if you have multiple cameras with same friendly names, this library can't solve your problem.