CvCapture *capture = NULL;
IplImage *frame = NULL;
char *AviSavePath ;//图片保存的位置
AviSavePath = "E:\\53827";
const int jiange = 1;//间隔两帧保存一次图片
capture = cvCaptureFromAVI("E:\\53827.avi");
cvNamedWindow("AVI player",1);
int count_tmp = 0;//计数总帧数
char tmpfile[100]={'\0'};
while(true)
{
if(cvGrabFrame(capture))
{
if (count_tmp % jiange == 0)
{
frame=cvRetrieveFrame(capture);
cvShowImage("AVI player",frame);//显示当前帧
sprintf(tmpfile,"%s//%d.jpg",AviSavePath,count_tmp/jiange);//使用帧号作为图片名
cvSaveImage(tmpfile,frame);
}
if(cvWaitKey(10)>=0) //延时
break;
++count_tmp;
}
else
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("AVI player");
std::cout<<"总帧数" << count_tmp << std::endl;
IplImage *frame = NULL;
char *AviSavePath ;//图片保存的位置
AviSavePath = "E:\\53827";
const int jiange = 1;//间隔两帧保存一次图片
capture = cvCaptureFromAVI("E:\\53827.avi");
cvNamedWindow("AVI player",1);
int count_tmp = 0;//计数总帧数
char tmpfile[100]={'\0'};
while(true)
{
if(cvGrabFrame(capture))
{
if (count_tmp % jiange == 0)
{
frame=cvRetrieveFrame(capture);
cvShowImage("AVI player",frame);//显示当前帧
sprintf(tmpfile,"%s//%d.jpg",AviSavePath,count_tmp/jiange);//使用帧号作为图片名
cvSaveImage(tmpfile,frame);
}
if(cvWaitKey(10)>=0) //延时
break;
++count_tmp;
}
else
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("AVI player");
std::cout<<"总帧数" << count_tmp << std::endl;