==> 学习汇总(持续更新)
==> 从零搭建后端基础设施系列(一)-- 背景介绍
OPENCV3.0大大的简化了视频流的读取,用了>>流操作符来读取帧。
获取摄像头画面:
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
VideoCapture capture(0);
Mat frame;
while (capture.isOpened())
{
capture >> frame;
imshow("capture", frame);
if (cvWaitKey(40) == 27) //cvWaitKey的参数相当于多少ms一帧,现在是40ms一帧,1s25帧
break; //按ESC就退出
}
return 0;
}
获取视频画面:
#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
VideoCapture capture("test.mp4");
Mat frame;
while (capture.isOpened())
{
capture >> frame;
imshow("capture", frame);
if (cvWaitKey(40) == 27) //cvWaitKey的参数相当于多少ms一帧,现在是40ms一帧,1s25帧
break; //按ESC就退出
}
return 0;
}