开发者

How to let user select a video recording device (web-cam) with OpenCV?

开发者 https://www.devze.com 2023-01-26 19:19 出处:网络
So what I need is something likecapture devices list. And some function to get from user on which device he wants to stream.

So what I need is something like capture devices list.

And some function to get from user on which device he wants to stream.

How to do s开发者_C百科uch thing with openCV in win32 C++ console application?


As Martin said it's not supported in OpenCV but you could use a little trick. If that satisfies your needs, you can find out the number of cameras by successively enumerating the cameras by calling cvCreateCameraCapture() until it returns NULL.

Sth like this:

CvCapture *cap;
int n = 0;
while(1)
{
   cap = cvCreateCameraCapture(n++);
   if (cap == NULL) break;
   cvReleaseCapture(&cap);
}

cvReleaseCapture(&cap);
return n-1;

Now you have a number of camera devices so you can let your user to select one by its index from i.e. list box.

Disadvantage is that OpenCV doesn't give you any information about device name so if you want to accomplish that too you should take a look at Microsoft DirectShow or the library Martin proposed.


Not directly supported in opencv (AFAIK) but try http://www.muonics.net/school/spring05/videoInput/


Try using some OS functions to enumerate webcams. It might take some work, but this approach will guarantee that you get a list every time (unlike the OpenCV hack, which sometimes doesn't work, for some reason).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号