I am trying to use 2 USB webcams with OpenCV. I can get a visual with one webcam but I haven't done with two webcams. Can anybody help me?
I use this code for a webcam.
void WebCam()
{
char Vid[] = "WebCam";
IplImage * frm;
CvCapture * capture;
capture = cvCaptureFromCAM(-1); // the parameter for a cam
if( capture ) {
cvNamedWindow (Vid);
do {
frm = cvQueryFrame( capture );
if( frm )
cvShowImage (Vid, frm);
int k = cvWaitKey( 50 );
if (k == 27 || k == '\r') // Press ESC and Enter
break; // for out
} while( frm );
cvDestroyWindow( Vid ); // Destroy the window
cvReleaseCapture( &capture );
}
else
puts( "Can not Open the Webcam" );
}
Thanks a lot.