Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of webcam devices using opencv?

I am using OpenCV2.2 with videoInput. I want to upgrade to OpenCV2.3.1 where videoInput has apparently been merged into OpenCV2.3.

My problem is that there doesn't appear to be a listdevices() function to return all the video sources available.

Does anybody know the new equivalent?

like image 623
Phil Hannent Avatar asked Feb 14 '12 11:02

Phil Hannent


1 Answers

As you said videoinput has been merged in OpenCV since 2.3rc.

Looking at the relevant source videoinput appears to be in highgui as the OpenCV changelog specifies. Though whether your OpenCV is built with it enabled is a configurable option in Cmake (The option is WITH_VIDEOINPUT and also requires it be a WIN32 build, see here).

OpenCV calls listdevices internally as VI.listDevices() in the implementation of CvCaptureCAM_DShow::open and the videoInput Class is a protected member of CvCaptureCAM_DShow.

You can get access listdevices function using

 CvCapture* capture = cvCaptureFromCAM( CV_CAP_DSHOW );
 capture->VI.listDevices();
like image 196
Appleman1234 Avatar answered Oct 01 '22 18:10

Appleman1234