#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/core/mat.hpp>
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
int main(int argc,char* argv[])
{
// Open the video file
cv::VideoCapture capture("f:/1.rmvb");//要读取的视频文件
// check if video successfully opened
if (!capture.isOpened())
return 1;
// Get the frame rate
double rate= capture.get(CV_CAP_PROP_FPS);
bool stop(false);
cv::Mat frame; // current video frame
cv::namedWindow("Extracted Frame");
// Delay between each frame in ms
// corresponds to video frame rate
int delay= 1000/rate;
// for all frames in video
while (!stop) {
// read next frame if any
if (!capture.read(frame))
break;
cv::imshow("Extracted Frame",frame);
// introduce a delay
// or press key to stop
if (cv::waitKey(delay)>=0)
stop= true;
}
// Close the video file.
// Not required since called by destructor
capture.release();
waitKey(3000);
return 0;
}