1 | initial version |
I copy your code ,but it does not work, I can not save the picture in the folder --"D:/Projects/vs2010/text11/"
can you tell me the reason,please...
int main() {
char file[256];
time_t mytime; mytime = time(NULL); struct tm tm = *localtime(&mytime);
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY ); if ( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar(); return -1; } int counter = 0; cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE ); while ( 1 ) { IplImage* frame = cvQueryFrame(capture); if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
break;
}
cvShowImage( "mywindow", frame );
sprintf(file,"%d%d%d_%d%d%d_%d.pgm\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, clock() );
sprintf(file,"%s","D:/Projects/vs2010/text11/");
sprintf(file,"%d%d%d_%d%d%d.pgm\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
cvSaveImage(file, frame,0);
//sleep(2);
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if ( (cvWaitKey(10) & 255) == 27 ) break;
} // Release the capture device housekeeping cvReleaseCapture( &capture ); cvDestroyWindow( "mywindow" ); return 0; }