Determine the number of webcams / cameras on a PC using OpenCv

I am making an application with multiple webcams / cameras. I cannot determine the number of webcams that I have with OpenCV in order to create a large window with several sub-webcams in it.

Can someone help me?

I searched openCV willowgarage but could not

thank

+5
source share
1 answer

I do not think that OpenCV provides any function to determine how many cameras are detected. A simple and cross-platform way is to call VideoCapture::open()in a loop from 0 to 10, and in each iteration check if it returns VideoCapture::isOpened() true. Thus, you know the index of cameras and the number of them you have.

+6
source

All Articles