#include
#include
#include"cv.h"
#include"highgui.h"
#include
int main()
{
while(1)
{
time_t now;
struct tm *timenow;
time(&now);
char outFileName[]="2011-01-01 24H00M00S.jpg";//修改
timenow = localtime(&now);
printf("saving...\n");
*(outFileName+5)=timenow->tm_mon/10+'0';
*(outFileName+6)=timenow->tm_mon%10+'0';
*(outFileName+8)=timenow->tm_mday/10+'0';
*(outFileName+9)=timenow->tm_mday%10+'0';
*(outFileName+11)=timenow->tm_hour/10+'0';
*(outFileName+12)=timenow->tm_hour%10+'0';
*(outFileName+14)=timenow->tm_min/10+'0';
*(outFileName+15)=timenow->tm_min%10+'0';
*(outFileName+17)=(timenow->tm_sec)/10+'0';
*(outFileName+18)=(timenow->tm_sec)%10+'0';
CvCapture *capture =cvCaptureFromCAM(0);
IplImage *img=0;
img = cvQueryFrame(capture);
if (!img)
{
printf("Could not grab a frame\n\7");
exit(0);
}
if(!cvSaveImage(outFileName,img)) printf("Could not save: %s\n",outFileName);
char c = cvWaitKey(10000);
if(c == 5)
{
break;
}
cvReleaseCapture(&capture);
}
return 0;
}
//输出图片在 当前文件夹下 年份自2011为 改程序同时分秒 运行通过
//本人也是菜鸟 欢迎交流
时间上不精确 欢迎高手指点