惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
L
LangChain Blog
博客园_首页
Recent Announcements
Recent Announcements
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
博客园 - 叶小钗
博客园 - 【当耐特】
The Cloudflare Blog
J
Java Code Geeks
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans

博客园 - zengqs

很久没有登录了 交警手势信号图解(新)----07年10月1日全国施行 在线幻灯片Slide Show System汇总 - PPT的替代品 转载:高速交警的忠告(为了安全,走高速必看) 转帖:如何替换系统自带的记事本(notepad.exe) 转摘:PCA算法 Haar分类器,ObjectMarker程序源代码 OpenCV训练分类器 - zengqs - 博客园 摘自:Emgu.CV项目,An object recognizer using PCA (Principle Components Analysis) VisualSVN1.6.1破解 视频监控和行为理解的网络资源 高斯背景建模C#版本 高斯背景建模 转帖:人脸检测概述 人脸检测的算法 - zengqs - 博客园 C#转换为灰度图的算法 一个人脸检测器 测试用是Windows Live Writer写日志 转帖:关于computer vision的会议及vision guys (zz)
C#定义一个模板类
zengqs · 2009-02-02 · via 博客园 - zengqs

今天要实现模板类,查找一些资料,发现非常有意思,估计对大家有帮助,所以共享一下。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Emgu.CV;

namespace VSL.Plugin.TrackingSystem.GaitAnalysisTrackingSystem
{

    /// <summary>
    /// 背景估计模型
    /// </summary>
    /// <typeparam name="TColor"></typeparam>
    /// <typeparam name="TDepth"></typeparam>
    public class BackgroundEstimatorModel<TColor, TDepth> where TColor : Emgu.CV.IColor, new()
    {
        protected int _bufferMax;//缓冲区最大的尺寸
        //背景缓冲区
        protected Queue<Emgu.CV.Image<TColor, TDepth>> _buffer = new Queue<Emgu.CV.Image<TColor, TDepth>>();
        protected Emgu.CV.Image<TColor, TDepth> _background = null;

        public BackgroundEstimatorModel()
        {

        }

        /// <summary>
        /// 更新背景
        /// </summary>
        /// <param name="image"></param>
        public virtual void Update(Emgu.CV.Image<TColor, TDepth> image)
        {
            if (_buffer.Count == _bufferMax)//达到缓冲队列的最大值,则出队列
            {
                _buffer.Dequeue();//出队列
            }
            _buffer.Enqueue(image);//新的帧入队列

            //创建背景图像
            if (_background == null)
                _background = new Emgu.CV.Image<TColor, TDepth>(image.Size);

            foreach (var frame in _buffer)
            {
                //更具不同的算法更新背景

            }
        }
    }

    /// <summary>
    /// 灰度背景模型
    /// </summary>
    public class GrayBackgroundEstimatorModel : BackgroundEstimatorModel<Gray, Byte>
    {
        //只支持灰度背景
        public override void Update(Image<Gray, byte> image)
        {
            if (_buffer.Count == _bufferMax)//达到缓冲队列的最大值,则出队列
            {
                _buffer.Dequeue();//出队列
            }
            _buffer.Enqueue(image);//新的帧入队列

            //创建背景图像
            if (_background == null)
                _background = new Emgu.CV.Image<Gray, Byte>(image.Size);

            foreach (var frame in _buffer)
            {
                //更具不同的算法更新背景

            }
        }

    }
    public enum BG_EISTIMATOR_TYPE
    {
        /// <summary>
        ///
        /// </summary>
        FGD_STAT_MODEL,
        /// <summary>
        /// Gaussian background model
        /// </summary>
        GAUSSIAN_BG_MODEL,

        /// <summary>
        /// Move Forward
        /// </summary>
        MOVEFORWARD
    }
}