简体   繁体   中英

How to list the camera devices that are connected to a system using OpenCV?

The question is complete in itself. Adding a few more details to include the things which I have already tried:

  • I have searched across stackexchange platform, but was unable to get my query solved.
  • Through some clues which I gathered along the way, I could only count the number of connected devices.

VideoCapture class has been mentioned in some posts, but that was only so much useful.

I am working on Windows platform with C++.

I created this C++ class that allows you to enumerate the devices (including ID) that you can use in order to get the list of devices to use in OpenCV. It is hosted on GitHub

https://github.com/studiosi/OpenCVDeviceEnumerator

The idea is to use DirectShow to get all the devices that have the category with GUID CLSID_VideoInputDeviceCategory, and then, through an enumerator, you get in which order they appear on the system, which is the ID you need to open them on OpenCV by creating a VideoCapture object (by using the constructor that receives the ID, which would be the index of the device on the enumeration). Obviously, this approach only works on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM