Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the number of webcams/cameras on PC with OpenCv

Tags:

opencv

I'm making an application running multiple webcams/cameras. I cannot manage to detect the number of webcams I have with OpenCV to arrage a big display window with multiple sub webcams in it.

Someone can help me this?

I've searched openCV willowgarage but failed

thanks

like image 585
TSL_ Avatar asked May 06 '12 15:05

TSL_


1 Answers

I don't think OpenCV provides any function to tell how many cameras are detected. An easy and cross-platform way is to call VideoCapture::open() in a loop with say 0 to 10, and in each iteration check if VideoCapture::isOpened() returns true. This way you know the index of the cameras and how many of them you've got.

like image 180
fireant Avatar answered Sep 30 '22 16:09

fireant