multiple webcams VC++
Need simple code in Visual Studio C++ to list multiple webcam attached to pc so to be able to select a particular webcam. Thanks
Need simple code in Visual Studio C++ to list multiple webcam attached to pc so to be able to select a particular webcam. Thanks
One simple method is to try open webcams until you fail. The number of successes is the number of webcams.
How is how I would do this:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
/** @function main */
int main(int argc, const char** argv)
{
int numOfWebCams = 0;
cv::VideoCapture cap[MAX_NUM_OF_CAMERAS];
cv::Mat frame;
for (size_t i = 0; i < MAX_NUM_OF_CAMERAS; i++)
{
cap[i].open(i);
bool bSuccess = true;
if (!cap[i].isOpened()) // check if we succeeded
bSuccess &= false;
bSuccess &= cap[i].read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
std::cout << "The number of active webcams is: " << numOfWebCams << std::endl;
break;
}
else
++numOfWebCams;
}
return 0;
}
Asked: 2014-05-23 19:22:20 -0600
Seen: 284 times
Last updated: May 24 '14
autogain. how to disable autogain and set a fixed value
Computer Vision - Craps Coach Project from a Newbie
Camera is not working in OpenCV on Ubuntu 12.04 with version 2.3.1 or 2.4.2
How to set resolution of video capture in python with Logitech c910 & c920
VideoCapture open and source switching problems [closed]
VideoCapture parameters CV_CAP_PROP_FOURCC or CV_CAP_PROP_FPS, among others, not working
Get 50% faulty pictures from webcam using VideoCapture
Create_capture video compression
sorry, dear, but there's no such functionality in opencv.
@berak isn't it can be done using VideoCapture cap(0); then VideoCapture cap(1); and so on
i think he was asking for a list of names. (but sure you can just iterate over the ids)
if you try -1 on win, vfw sometimes comes up with a choice box.