关闭

opencv2简单的视频读取

标签: opencv视频读取opencv2视频读取opencv视频
4383人阅读 评论(0) 收藏 举报
分类:




#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;
}


1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:319190次
    • 积分:4685
    • 等级:
    • 排名:第6199名
    • 原创:133篇
    • 转载:74篇
    • 译文:0篇
    • 评论:320条
    最新评论