第一章
2.1,经过opencv读取本地视频:web
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
VideoCapture capture("D:\\Data\\2016-03-04-22-41-31.MOV");
//上面等价于下面两步:
//VideoCapture capture; //建立实例
//capture.open("D:\\Data\\2016-03-04-22-41-31.MOV"); //初始化
while (1)
{
Mat frame; // 定义一个Mat变量,用于存储每一帧图像
capture >> frame; //读取当前帧
imshow("【读取视频】", frame); //显示当前帧
waitKey(10); //延时10ms
}
return 0;
}
效果显示:
ide
2.2,经过opencv从摄像头读入视频:
只须要将2.1中的VideoCapture capture(“D:\Data\2016-03-04-22-41-31.MOV”);改成VideoCapture capture(0);便可
效果显示:
svg