OpenCV高斯模型
int main(int argc, char** argv)
{
//std::string videoFile = "E:\\C_VC_code\\Text_Photo\\dingdang.avi"; //cv::VideoCapture capture;
//capture.open(videoFile);
//VideoCapture capture("E:\\C_VC_code\\Text_Photo\\大屏互动+行人检测_标清.flv");
VideoCapture capture();
if (!capture.isOpened())
{
std::cout<<"read video failure"<<std::endl;
return -;
} cv::BackgroundSubtractorMOG2 mog; cv::Mat foreground;
cv::Mat background; cv::Mat frame;
Mat frame1;
long frameNo = ;
double scalar = 0.3; while ()
{ capture>>frame1;
resize(frame1,frame,Size(frame1.cols*scalar,frame1.rows*scalar),,,); // 运动前景检测,并更新背景
mog(frame, foreground, 0.2); // 腐蚀
cv::erode(foreground, foreground, cv::Mat()); // 膨胀
cv::dilate(foreground, foreground, cv::Mat()); mog.getBackgroundImage(background); // 返回当前背景图像 threshold(foreground,foreground,,,CV_THRESH_BINARY_INV);
cv::imshow("foreground", foreground);
cv::imshow("background", background); if (cv::waitKey() > )
{
break;
}
} return ;
}
opencv-3.0.0版本的变化:
int main(int argc, char *argv[]) {
cv::Mat frame;
cv::Mat back;
cv::Mat fore;
cv::VideoCapture cap();
cv::Ptr<BackgroundSubtractorMOG2> bg = createBackgroundSubtractorMOG2();
bg->setNMixtures();
//bg.bShadowDetection = false;
std::vector<std::vector<cv::Point> > contours;
cv::namedWindow("Frame");
cv::namedWindow("Background");
for (;;) {
cap >> frame;
//bg.operator()(frame, fore);
bg->apply(frame, fore,0.01);
bg->getBackgroundImage(back);
cv::erode(fore, fore, cv::Mat());
cv::dilate(fore, fore, cv::Mat());
cv::findContours(fore, contours, CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
cv::drawContours(frame, contours, -, cv::Scalar(, , ), );
threshold(fore, fore, , , CV_THRESH_BINARY_INV);
cv::imshow("Foreground", fore);
cv::imshow("Frame", frame);
cv::imshow("Background", back);
if (cv::waitKey() >= )
break;
}
return ;
}
OpenCV高斯模型的更多相关文章
- Opencv混合高斯模型前景分离
#include "stdio.h" #include "string.h" #include "iostream" #include &q ...
- 混合高斯模型:opencv中MOG2的代码结构梳理
/* 头文件:OurGaussmix2.h */ #include "opencv2/core/core.hpp" #include <list> #include&q ...
- OpenCV混合高斯模型函数注释说明
OpenCV混合高斯模型函数注释说明 一.cvaux.h #define CV_BGFG_MOG_MAX_NGAUSSIANS 500 //高斯背景检测算法的默认参数设置 #define CV_BGF ...
- [zz] 混合高斯模型 Gaussian Mixture Model
聚类(1)——混合高斯模型 Gaussian Mixture Model http://blog.csdn.net/jwh_bupt/article/details/7663885 聚类系列: 聚类( ...
- 运动检测(前景检测)之(二)混合高斯模型GMM
运动检测(前景检测)之(二)混合高斯模型GMM zouxy09@qq.com http://blog.csdn.net/zouxy09 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新 ...
- [转]运动检测(前景检测)之(二)混合高斯模型GMM
转自:http://blog.csdn.net/zouxy09/article/details/9622401 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新的方法和思路.个人了解的 ...
- PRML读书会第九章 Mixture Models and EM(Kmeans,混合高斯模型,Expectation Maximization)
主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:10:56 今天的主要内容有k-means.混合高斯模型. EM算法.对于k-me ...
- [学习opencv]高斯、中值、均值、双边滤波
http://www.cnblogs.com/tiandsp/archive/2013/04/20/3031862.html [学习opencv]高斯.中值.均值.双边滤波 四种经典滤波算法,在ope ...
- 混合高斯模型(GMM)推导及实现
作者:桂. 时间:2017-03-20 06:20:54 链接:http://www.cnblogs.com/xingshansi/p/6584555.html 声明:欢迎被转载,不过记得注明出处哦 ...
随机推荐
- jquery 获取 json文件内容后,将其内容显示到 下拉列表框中,再将下拉列表中的内容,显示到文本框中
<script type="text/javascript"> $(function(){ $("#huoqv").click(function() ...
- WinForm------弹出MessageBox窗口的同时隐藏当前窗口
private void Btn_OK_Click(object sender, EventArgs e) { this.Hide(); //隐藏当前窗口 MessageBox.Show(" ...
- WinForm------ToolTipController与GridControl的连用
1.拖入一个ToolTipController控件,和一个GridControl控件 2.设置GridControl中的GridView的中的属性ToolTipController为刚刚拖入的Tool ...
- 获取网卡的MAC地址原码;目前支持WIN/LINUX系统 获取机器网卡的物理(MAC)地址(服务器端)
<?php class GetMacAddr{ var $return_array = array(); // 返回带有MAC地址的字串数组 var $mac_addr; function Ge ...
- Python MySQLdb在Linux下的快速安装
在家里windows环境下搞了一次 见 python MySQLdb在windows环境下的快速安装.问题解决方式 http://blog.csdn.NET/wklken/article/deta ...
- ajax返回数据类型为XML数据的处理
/*XML:可扩展标记语言 HTML:超文本标记语言 标签:<标签名></标签名> 特点: 1.必须要有一个根 2.标签名自定义 3.对大小写敏感 4.有开始就要有结束 5.同 ...
- delphi---控件使用
1.TBitBtn控件 属性:Glyph,指定要显示的位图: Layout ,设置位图在按钮的位置:Kind,要想用自设位图,这个属性要设置bkCustom; 2.TTreeView TTree ...
- C-指针
//格式:变量类型 *变量名//定义了一个指针变量p//指针变量只能存储地址//指针就一个作用:能够根据一个地址值,访问对应的存储空间//指针变量p前面的int:指针变量p只能指向int类型的数据in ...
- 改变Vim在iTerm2中的光标
vim ~/.vimrc 添加 " Change cursor shape between insert and normal mode in iTerm2.appif $TERM_PROG ...
- elasticsearch集群管理工具head插件(转)
elasticsearch-head是一个elasticsearch的集群管理工具,它是完全由html5编写的独立网页程序,你可以通过插件把它集成到es 插件安装方法1: 1.elasticsearc ...