#include "cv.h" #include <highgui.h> #include "stdio.h" #include <iostream> #include <time.h> using namespace std; void sleep(clock_t delayms); int main(int argc, char* argv[]) { int logincounter = 3; CvCapture* cptMyCam; cptMyCam = cvCreateCameraCapture(-1);//get the default cam //initializing IplImage* frame = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 1); if (cptMyCam == NULL) { exit(0); } cvNamedWindow("WebCam", 0); int counter = 1; while (-1) { if (cvGrabFrame(cptMyCam) == 0)//grabe a frame from the cam { cout << "Could not Capture"; break; } counter--; frame = cvRetrieveFrame(cptMyCam); cvShowImage("WebCam", frame);//display the grabbed fram while (logincounter>0) { if (counter == 0) { counter = 4; sleep(4000); cvSaveImage("C:\\FromCam\\image.jpeg", frame);//saving the captured image cvDestroyWindow("WebCam"); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)