1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
int main()
{
IplImage* img;
CvCapture* capture = cvCaptureFromCAM (CV_CAP_ANY);
if (!capture)
return 10;
cvNamedWindow("video", CV_WINDOW_AUTOSIZE);
char key = 'a';
if (!cvGrabFrame(capture))
return 20;
while (key != 'q'){
img = cvRetrieveFrame(capture);
cvShowImage("video", img);
key = cvWaitKey(60);
if (!cvGrabFrame(capture))
key = 'q';
}
cvDestroyAllWindows();
img = NULL;
cvReleaseCapture(&capture);
return 0;
} |
Partager