使用OpenCv检测PC上的网络摄像头/摄像机数量 [英] Detect the number of webcams/cameras on PC with OpenCv
问题描述
我正在制作一个运行多个网络摄像头/摄像机的应用程序.我无法设法检测使用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.
有人可以帮助我吗?
我搜索过openCV柳编车库,但失败了
I've searched openCV willowgarage but failed
谢谢
推荐答案
我不认为OpenCV提供任何功能来告诉您检测到多少台摄像机.一种简单且跨平台的方法是在循环中以0到10调用VideoCapture::open()
,并在每次迭代中检查VideoCapture::isOpened()
是否返回true
.这样,您就可以知道摄像机的索引以及您拥有多少个摄像机.
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.
这篇关于使用OpenCv检测PC上的网络摄像头/摄像机数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!