Ask Your Question

OpenCV 4.0 count cameras number

asked 2019-01-10 05:32:19 -0600

cherault gravatar image

Dear all,

I would like to set a code to count the number of active cameras detected by OpenCV-4.0.

To achieve my goal, I used a for loop, because I didn't found how to do it by another way. Apparently, it is no part of the API.

Does it exist another way to detect all the active cameras ?

Thank you for your help and support.


edit retag flag offensive close merge delete


I do not know other solutions

LBerger gravatar imageLBerger ( 2019-01-10 07:26:58 -0600 )edit

Thank you LBerger.

cherault gravatar imagecherault ( 2019-01-12 23:22:41 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-01-12 06:11:43 -0600

berak gravatar image

opencv does not have any means for this builtin. you can try external utilities, like:

v4l2-ctl --list-devices

on linux, of if you have ffmpeg:

ffmpeg -list_devices true -f dshow -i dummy

there's also hidden code in cap_dshow.cpp, but you'll have a hard time, accessing it ;(

edit flag offensive delete link more


I merely do on python.

supra56 gravatar imagesupra56 ( 2019-01-12 11:09:34 -0600 )edit

Thank you Berak.

cherault gravatar imagecherault ( 2019-01-12 23:23:08 -0600 )edit

Question Tools

1 follower


Asked: 2019-01-10 05:32:19 -0600

Seen: 795 times

Last updated: Jan 12 '19