用OpenCV读取视频的简单例子

#include "stdafx.h"
#include "cv.h"
#include <cxcore.h>
#include <highgui.h>


int main(int argc,char** argv)
{
	CvCapture* g_capture = cvCreateFileCapture("D:\\test2.avi");    // 视频地址


	IplImage* frame;
	string originVideoWinName = "Video_Origin";


	cvNamedWindow(originVideoWinName.c_str(),CV_WINDOW_AUTOSIZE);
	while (1)
	{
		frame = cvQueryFrame(g_capture);                                      // 捕获每帧
		if (!frame)
		{
			break;
		}
		cvShowImage(originVideoWinName.c_str(),frame);
		char c = cvWaitKey(33);
		if (c==27)
		{
			break;
		}
	}
	cvReleaseCapture(&g_capture);
	cvDestroyWindow(originVideoWinName.c_str());
}


你可能感兴趣的:(c,video,include)