函数:VideoCapture
VideoCapture capture(0);//调用摄像头
VideoCapture capture("E:/images/01.mp4");//调用视频文件
总代码:
void QuickDemo::video_demo(Mat &image) {
//VideoCapture capture(0);//调用摄像头
VideoCapture capture("E:/images/01.mp4");//调用视频文件
Mat frame;
while (true)
{
capture.read(frame);//读取文件后存储在frame中
flip(frame,frame,1);//翻转函数
if (frame.empty()) {//如果视频文件为空退出
break;
}
colorSpace_Demo(frame);//色彩空间转换函数
imshow("frame",frame);
int c = waitKey(1);//延时
if (c == 27) {
break;//退出
}
}
//release
capture.release();//释放空间
}