How to get the friendly names of the cameras? (see my code)

asked 2015-12-29 02:01:34 -0600

happycoder gravatar image

updated 2015-12-29 02:09:28 -0600

I wrote a small paragraph of code. See below.


#include <opencv2 core.hpp="">
#include <opencv2 imgcodecs.hpp="">
#include <opencv2 highgui.hpp="">
#include <opencv2 videoio.hpp="">
#include <iostream>
using namespace cv;
using namespace std;

void SimpleEnumerateDirectShowCameras()
{    
    int maxID = 100; 
    for (int idx = 0; idx smaller_than maxID; idx++)
    {
        VideoCapture cap(CV_CAP_DSHOW + idx);  // open the camera
        // cap.release();
    }
}

int main()
{
    SimpleEnumerateDirectShowCameras();
    return 0;
}

The output of the code above is as below, as my machine has several cameras installed on.


***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

SETUP: Setting up device 0
SETUP: USB Camera-OV580
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 1104x828
SETUP: trying specified format RGB24 @ 640x480
SETUP: trying format RGB24 @ 640x480
SETUP: trying format RGB32 @ 640x480
SETUP: trying format RGB555 @ 640x480
SETUP: trying format RGB565 @ 640x480
SETUP: trying format YUY2 @ 640x480
SETUP: trying format YVYU @ 640x480
SETUP: trying format YUYV @ 640x480
SETUP: trying format IYUV @ 640x480
SETUP: trying format UYVY @ 640x480
SETUP: trying format YV12 @ 640x480
SETUP: trying format YVU9 @ 640x480
SETUP: trying format Y411 @ 640x480
SETUP: trying format Y41P @ 640x480
SETUP: trying format Y211 @ 640x480
SETUP: trying format AYUV @ 640x480
SETUP: trying format MJPG @ 640x480
SETUP: trying format Y800 @ 640x480
SETUP: trying format Y800 @ 640x480
SETUP: trying format Y800 @ 640x480
SETUP: trying format I420 @ 640x480
SETUP: couldn't find requested size - searching for closest matching size
SETUP: closest supported size is YUY2 @ 1104 828
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.


SETUP: Disconnecting device 0
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer...
SETUP: filter removed NullRenderer
SETUP: removing filter Sample Grabber...
SETUP: filter removed Sample Grabber
SETUP: removing filter AVI Decompressor...
SETUP: filter removed AVI Decompressor
SETUP: removing filter Smart Tee...
SETUP: filter removed Smart Tee
SETUP: removing filter USB Camera-OV580...
SETUP: filter removed USB Camera-OV580
SETUP: freeing Capture Graph
SETUP: freeing Main Graph
SETUP: Device 0 disconnected and freed

SETUP: Setting up device 1
SETUP: Forward Facing camera
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 320x240
SETUP: trying specified format RGB24 @ 640x480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.


SETUP: Disconnecting device 1
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer...
SETUP: filter removed NullRenderer
SETUP: removing filter Sample Grabber...
SETUP: filter removed Sample Grabber
SETUP: removing filter Smart Tee...
SETUP: filter removed Smart Tee
SETUP: removing filter Forward Facing camera...
SETUP: filter removed Forward Facing camera
SETUP: freeing Capture Graph
SETUP: freeing Main Graph
SETUP: Device 1 disconnected and freed

SETUP: Setting up device 2
SETUP: Downward Facing camera
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 320x240
SETUP: trying specified format RGB24 @ 640x480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.


SETUP: Disconnecting device 2
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer ...
(more)
edit retag flag offensive close merge delete

Comments

make a pull request?

LBerger gravatar imageLBerger ( 2015-12-29 03:37:14 -0600 )edit