标签:names style AC opencv out size int end capture
视觉算法原理:背景提取
1. 打开视频(文件或摄像头)
2. 从视频中提取当前帧
3. 计算背景:以前多帧求取平均
4. 根据背景得到运动目标(当前帧 - 背景)
5. 返回2,程序不断循环
实例1:打开视频+提取视频帧
#include <opencv2/opencv.hpp>
#include <stdio.h>
using namespace cv;
int main()
{
const char *name = "D:\\project_opencv\\_media\\1.avi";
VideoCapture capture;
capture.open(name);
if(!capture.isOpened())
std::cout << "video can‘t opened!" << name << std::endl;
while(1)
{
Mat frame; //定义frame存储视屏帧
capture>>frame; //读取当前帧
if(frame.empty())
break;
imshow("video capture", frame); //显示当前帧
waitKey(30); //延时
}
return 0;
}
实例2:计算背景
标签:names style AC opencv out size int end capture
原文地址:https://www.cnblogs.com/ingy0923/p/9029339.html