调用Emgu中函数进行高斯背景建模

来源:互联网 发布:阿里云架设服务器 编辑:程序博客网 时间:2024/04/30 19:01

刚刚学习Emgu,调用其中的函数进行混合高斯背景建模。

 BackgroundSubtractorMOG bg_mog = null;//高斯模型            const int defaultNMixtures = 5;//默认混合模型个数            const int defaultHistory = 200;//默认历史帧数            const double defaultBackgroundRatio = 0.7;//默认背景门限            const double defaultVarThreshold = 2.5*2.5;//默认方差门限            const double defaultNoiseSigma = 30*0.5;//默认噪声方差            const double defaultInitialWeight = 0.05;//默认初始权值            while ((img = pCapture.QueryFrame()) != null)            {                this.count++;                if (this.count == 1)                {                    bg_mog = new BackgroundSubtractorMOG(defaultHistory, defaultNMixtures, defaultBackgroundRatio, defaultNoiseSigma);                }                else                {                    bg_mog.Update(img);                    this.pictureBox1.Image = img.Bitmap;                    this.pictureBox2.Image = bg_mog.ForegroundMask.Bitmap;                    Application.DoEvents();                    System.Threading.Thread.Sleep(30);                }            }


原创粉丝点击