#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
int main(void)
{
CvCapture * capture = NULL;
IplImage * frame = NULL;
capture = cvCreateFileCapture("E:\\test\\fish1.avi");
if(capture == NULL)
{
cout<<"read video file error!"<<endl;
}
while(1)
{
frame = cvQueryFrame(capture);
if(frame == NULL)
{
break;
}
cvShowImage("video",frame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("video");
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
#include "cv.h"
#include "highgui.h"
int main(void)
{
CvCapture * capture = NULL;
IplImage * frame = NULL;
capture = cvCreateFileCapture("E:\\test\\fish1.avi");
if(capture == NULL)
{
cout<<"read video file error!"<<endl;
}
while(1)
{
frame = cvQueryFrame(capture);
if(frame == NULL)
{
break;
}
cvShowImage("video",frame);
char c = cvWaitKey(33);
if(c == 27)
{
break;
}
}
cvReleaseCapture(&capture);
cvDestroyWindow("video");
return 0;
}
本文介绍了一个简单的C++程序示例,该程序利用OpenCV库读取并播放本地视频文件。通过创建文件捕获对象并调用相关函数,程序实现了视频帧的连续读取与显示,并能够响应键盘输入来终止播放。
7789

被折叠的 条评论
为什么被折叠?



