有时候在项目中我们需要检测当前连接在机子上的摄像头的数量,可以通过下面的代码实现,其中连接摄像头的最大数量maxCamNum可以任意修改:

/**
* Count current camera number
*/
int countCamera() {
int maxCamNum = ;
int count = ;
for(int device = ; device < maxCamNum; device++)
{
CvCapture* capture;
if (_capture[device]) {
++count;
}
else {
capture = cvCaptureFromCAM(CV_CAP_DSHOW + device);
if (capture) {
++count;
}
cvReleaseCapture(&capture);
}
}
return count;
}

OpenCV中没有能返回摄像头设备名称的函数,有些时候也不太方便,但是没有办法,将就的用着吧~~

OpenCV count the number of connected camera 检测连接的摄像头的数量的更多相关文章

  1. LeetCode Number of Connected Components in an Undirected Graph

    原题链接在这里:https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ 题目: Giv ...

  2. [Swift]LeetCode323. 无向图中的连通区域的个数 $ Number of Connected Components in an Undirected Graph

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  3. 323. Number of Connected Components in an Undirected Graph按照线段添加的并查集

    [抄题]: Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of n ...

  4. LeetCode 323. Number of Connected Components in an Undirected Graph

    原题链接在这里:https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/ 题目: Giv ...

  5. 323. Number of Connected Components in an Undirected Graph (leetcode)

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  6. [LeetCode] 323. Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  7. [LeetCode] Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  8. [geeksforgeeks] Count the number of occurrences in a sorted array

    Count the number of occurrences in a sorted array Given a sorted array arr[] and a number x, write a ...

  9. [Locked] Number of Connected Components in an Undirected Graph

    Number of Connected Components in an Undirected Graph Given n nodes labeled from 0 to n - 1 and a li ...

随机推荐

  1. SQL union和union all的区别

    Union因为要进行重复值扫描,所以效率低.如果合并没有刻意要删除重复行,那么就使用Union All  两个要联合的SQL语句 字段个数必须一样,而且字段类型要“相容”(一致): 如果我们需要将两个 ...

  2. Android dp px转化公式

    // DisplayMetrics metrics = getResources().getDisplayMetrics(); // int statusBarHeight = (int) Math. ...

  3. Android 中获得notification的发出时间

    最近做程序时,有一个类似闹钟的功能,用notification唤醒程序后,希望能得到发出这个notification时的具体时间,就是notification右边写着的那个时间.查了notificat ...

  4. codeforces C. Fixing Typos 解题报告

    题目链接:http://codeforces.com/problemset/problem/363/C 题目意思:纠正两种类型的typos.第一种为同一个字母连续出现3次以上(包括3次):另一种为两个 ...

  5. [SVN(ubuntu)] ubuntu使用svn

    转载自:http://lee2013.iteye.com/blog/1058047 SVN作为日常开发中不可缺少的工具,Ubuntu下的SVN安装十分简单,sudo apt-get install s ...

  6. C语言中的break、continue和goto三者的区别与用法

    exit的话是在stdlib的头文件里面定义的,他是的程序退出,正如exit的字面意思一样break的话是终止当前循环继续进行循环后面的语句,但是程序照样还在进行只能while switch for中 ...

  7. grep -w

    [root@86 ~]# mysqladmin -uroot -p123456 -S /tmp/mysql.sock extended-status|grep -w "Com_update& ...

  8. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem G: Check The Check(模拟国际象棋)

    Problem G: Check The Check Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 10  Solved: 3[Submit][Statu ...

  9. git学习 远程仓库02

    使用远程仓库: 查看当前远程库://克隆后,至少有一个名为 origin 的远程库,Git 默认使用这个名字来标识你所克隆的原始仓库 git remote -v: 并显示所有远程库的地址: 添加远程仓 ...

  10. parseFloat

    parseFloat会把输入完整的数进行比较,不会比较中间数字.