Save Image Sequence real time,but cannot save Consecutive pictures ,why?
#include <opencv2/opencv.hpp>
#include<time.h>
int main()
{
char file[256];
time_t mytime;
mytime = time(NULL);
struct tm tm = *localtime(&mytime);
printf("now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
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,"%s%d%d%d_%d%d%d%d.jpg\n","D:/Projects/vs2010/text11/", 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;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}
Please be so kind to not only post code, but to point out your system, configuration, where the problem arises. I mean this is an example of a bad question structure. Nevertheless I will have a look at your problem.