40 int main(
int argc,
char *argv[])
44 std::vector<int> camIDs(1, CV_CAP_ANY);
47 camIDs.resize(numCams);
48 for (
int i = 0; i < numCams; i++)
49 camIDs[i] = atoi(argv[i+1]);
53 std::vector<CvCapture*> camDevs(numCams, NULL);
54 for (
int i = 0; i < numCams; i++) {
55 camDevs[i] = cvCaptureFromCAM(camIDs[i]);
57 cout <<
"Failed to create capture device for ID " << camIDs[i] << endl;
60 cout <<
"Created capture device for ID " << camIDs[i] << endl;
65 cvNamedWindow(
"ExampleOpenCVCam", CV_WINDOW_AUTOSIZE);
69 bool isRunning =
true;
70 std::vector<IplImage*> frames(numCams, NULL);
74 for (
int i = 0; i < numCams; i++)
75 frames[i] = cvQueryFrame(camDevs[i]);
78 if (!frames[currentID]) {
79 cout <<
"Captured frame is empty!" << endl;
82 cvShowImage(
"ExampleOpenCVCam", frames[currentID]);
83 int key = cvWaitKey(10) & 255;
87 currentID = (currentID + 1) % numCams;
89 currentID = (currentID + numCams - 1) % numCams;
94 cout <<
"Release capture devices and quit" << endl;
95 for (
int i = 0; i < numCams; i++)
96 cvReleaseCapture(&camDevs[i]);
97 cvDestroyWindow(
"ExampleOpenCVCam");