C++ Opencv播放AVI

#include "cxcore.h"
#include "cvcam.h"
#include "windows.h"
#include <string>
#include "highgui.h"



int main( int argc ,char ** argv)
{
	
	CvCapture * capture = cvCreateFileCapture ("camera.avi"); 
    if(capture==NULL) 
	{
		printf("NO capture");   
		return 1;
	};
    
	double fps=cvGetCaptureProperty(capture, CV_CAP_PROP_FPS );   
	
	int vfps = 1000 / fps;                                        
    printf("%5.1f\t%5d\n",fps,vfps);

	cvNamedWindow("example",CV_WINDOW_AUTOSIZE);                 
	IplImage * frame;

	while(1)
	{ 
		frame = cvQueryFrame( capture );                        
		if(!frame)
			break;
		cvShowImage("example",frame);  
		char c = cvWaitKey(vfps);
		if(c == 27 )break;
	}

	 cvReleaseCapture(&capture);
	 cvDestroyWindow("example");
	 return 0;
}


posted @ 2015-08-01 11:11  QQ76211822  阅读(521)  评论(0编辑  收藏  举报