急!!!!!opencv 用摄像头提取图片后图片命名问题。。。
利用OpenCV提供的头文件和动态链接库,实现一个每隔10s钟利用摄像头抓取一副图片,并且将图片保存在当前目录images文件下,图片名字为日期-小时-分-秒.jpg。保...
利用OpenCV提供的头文件和动态链接库,实现一个每隔10s钟利用摄像头抓取一副图片,并且将图片保存在当前目录images文件下,图片名字为日期-小时-分-秒.jpg。保存后,可以浏览图片。(Linux系统) 麻烦各位大侠解决下,我是新手...嘿嘿
#include<stdio.h>
#include<stdlib.h>
#include"cv.h"
#include"highgui.h"
#include<time.h>
int main()
{
while(1)
{
time_t now;
struct tm *timenow;
time(&now);
timenow = localtime(&now);
char *outFileName="./Images/*****************.jpg";
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,0)) printf("Could not save: %s\n", outFileName);
char c = cvWaitKey(10000);
if(c == 27)
{
break;
}
cvReleaseCapture(&capture);
}
return 0;
} 展开
#include<stdio.h>
#include<stdlib.h>
#include"cv.h"
#include"highgui.h"
#include<time.h>
int main()
{
while(1)
{
time_t now;
struct tm *timenow;
time(&now);
timenow = localtime(&now);
char *outFileName="./Images/*****************.jpg";
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,0)) printf("Could not save: %s\n", outFileName);
char c = cvWaitKey(10000);
if(c == 27)
{
break;
}
cvReleaseCapture(&capture);
}
return 0;
} 展开
1个回答
展开全部
#include<stdio.h>
#include<stdlib.h>
#include"cv.h"
#include"highgui.h"
#include<time.h>
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为 改程序同时分秒 运行通过
//本人也是菜鸟 欢迎交流
时间上不精确 欢迎高手指点
#include<stdlib.h>
#include"cv.h"
#include"highgui.h"
#include<time.h>
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为 改程序同时分秒 运行通过
//本人也是菜鸟 欢迎交流
时间上不精确 欢迎高手指点
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询