OpenCV count the number of connected camera 检测连接的摄像头的数量
2015-03-12 03:51
525 查看
有时候在项目中我们需要检测当前连接在机子上的摄像头的数量,可以通过下面的代码实现,其中连接摄像头的最大数量maxCamNum可以任意修改:
OpenCV中没有能返回摄像头设备名称的函数,有些时候也不太方便,但是没有办法,将就的用着吧~~
/** * Count current camera number */ int countCamera() { int maxCamNum = 5; int count = 0; for(int device = 0; device < maxCamNum; device++) { CvCapture* capture; if (_capture[device]) { ++count; } else { capture = cvCaptureFromCAM(CV_CAP_DSHOW + device); if (capture) { ++count; } cvReleaseCapture(&capture); } } return count; }
OpenCV中没有能返回摄像头设备名称的函数,有些时候也不太方便,但是没有办法,将就的用着吧~~
相关文章推荐
- HLG 1253 Count the Number of Cycles【ldpc环】
- *Count the number of possible triangles
- 14.7.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量和大小
- count the number of objects--物体计数
- Count the number of occurrences in a sorted array
- 14.5.2 Changing the Number or Size of InnoDB Redo Log Files 改变InnoDB Redo Log Files的数量
- Count the number of alphabets, spaces, digits and other characters in one line character
- 非零比特的个数 count the number of bits
- FB面经prepare: Count the number of Vector
- Regex 101 Exercise I9 - Count the number of matches
- Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.
- count the number of "1" in the binary figure
- leetcode 600 Count number of binary strings without consecutive 1 不出现连续1二进制数量
- Count the number of bits that are on in an unsigned integer(计算一个无符整数中1Bit的个数)-- (1)
- opencv3_java 摄像头图形图像检测DetectObjectsCamera videoioVideoCapture
- 14.4.2 Changing the Number or Size of InnoDB Redo Log Files 改变 InnoDB Redo Log Fiels 的大小和数量
- Q9.11 count the number of ways of parenthesizing the expression
- [geeksforgeeks] Count the number of occurrences in a sorted array
- Count the number of 1(MIT hackmem)
- quick count the number of the rows in a big table