1 | initial version |
Maybe your capture device maps each input with different device index... try enumerating multiple APIs and devices with this code... may be it works
Mat img;
VideoCapture cap;
string str;
vector<int> apiList({ CAP_DSHOW, CAP_MSMF, CAP_VFW });
for (int apiIdx = 0; apiIdx < apiList.size(); apiIdx++)
{
int api = apiList[apiIdx];
for (int camIdx = 0; camIdx<10; camIdx++)
{
cap.release();
cap.open(camIdx + api);
if (!cap.isOpened())
continue;
str = cv::format("API: %d device : %d", apiIdx, camIdx);
cout << "Device found !! " << str << endl;
cap >> img;
if (img.empty()) {
cout << "\t Unable to grab from " << str << endl;
continue;
}
putText(img, str, Point(10, 20), FONT_HERSHEY_PLAIN,2,
Scalar(0, 255, 255),2);
//a window for each device
//imshow(str, img);
//a single window for all device
imshow("Frame from current device", img);
cv::waitKey(10);
} // for devices
} //for APIs
cout << endl << "Press Enter to terminate "; cin.get();