1

Before opening doing a capture by creating a VideoCapture object I want to display a list of available devices to select from. I believe this can be done in Windows using DirectShow and in Linux by checking the /dev/video* entries.

But I am wondering if there is any platform independent way I can get this list?

NOTE. I know I can enumerate the devices using VideoCapture.open and checking isOpen but I want to be able to display a meaningful name also and I don't think VideoCapture gives me that?

user79074
  • 4,937
  • 5
  • 29
  • 57
  • Have a look here: http://www.codepool.biz/multiple-camera-opencv-python-windows.html and https://stackoverflow.com/questions/8044539/listing-available-devices-in-python-opencv – Giancarlo Romeo Apr 29 '20 at 20:03

1 Answers1

1

I understand that available devices means cameras connected to your computer.

  • Firstly, to be able to use VideoCapture with a camera; camera shouldn't have a driver. Generally, VideoCapture is available to use with simple cameras such as webcams, some usb cameras etc.
  • OpenCV doesn't have a property to count or list the available cameras which are connected. You can also check this post.
  • Just for counting cameras, you can also use a brute way like this:

Example:

VideoCapture cap;
    int device_counts = 0;
    while ( true ) {
        if ( !cap.open(device_counts++) ) {
            break;
        }
    }
  • But in my opinion, the best solution is that using a framework to achieve that. For example Qt Creator.
Yunus Temurlenk
  • 4,085
  • 4
  • 18
  • 39