// vfc.cpp : 定義控制台應用程序的入口點。
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
#include <cv.h>
int main(int argc, char *argv[])
{
CvCapture* capture = cvCaptureFromAVI("111.avi");
int i = 0;
IplImage* img = 0;
char image_name[25];
cvNamedWindow( "vivi");
//讀取和顯示
while(1)
{
img = cvQueryFrame(capture); //獲取一幀圖片
if(img == NULL)
break;
cvShowImage( "vivi", img ); //將其顯示
char key = cvWaitKey(20);
sprintf(image_name, "%s%d%s", "..\\tutu\\image", ++i, ".jpg");//保存的圖片名
cvSaveImage( image_name, img); //保存一幀圖片
}
cvReleaseCapture(&capture);
cvDestroyWindow("vivi");
return 0;
}
在目錄之下建立一個tutu文件夾就可以存儲讀入視頻的每一幀