So I have a usb logitech webcam and a built in laptop webcam. I am trying to start both the webcam at same time. I made a demo code below to test but cap2 object keep failing to open. Do any you guys have a suggestion.
include <iostream>
include <opencv2\highgui\highgui.hpp>
include <string>
int main(int arg, char * args[]) { cv::VideoCapture cap, cap2; cv::Mat mat1; cv::Mat mat2;
cap.open(0);
cap2.open(1);
if(!cap.isOpened())
return -1;
if(!cap2.isOpened())
return -2;
cv::namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"
cv::namedWindow("MyVideo2",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo2"
while(true)
{
cap.read(mat1);
cap2.read(mat2);
cv::imshow("MyVideo",mat1);
cv::imshow("MyVideo2", mat2);
}
cap.release();
cap2.release();
return 0;
}