www.pudn.com > backmode824.rar > GaussianModel.h
// GaussianModel.h: interface for the CGaussianModel class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GAUSSIANMODEL_H__B790B9CF_B0C7_45CA_BBA2_44809FDB67AA__INCLUDED_)
#define AFX_GAUSSIANMODEL_H__B790B9CF_B0C7_45CA_BBA2_44809FDB67AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// number of models in the mixture
#define K_MODELS 3
// possible pixel classification values
typedef enum
{
PC_Background = 0,
PC_Foreground,
PC_Unknown,
PC_Error,
NumPixelCategories
} PixelCategory;
//////////////////////////////////////////////////////////////////////
class PixelModel
{
public:
PixelModel()
{
weight = 0.0;
for(int i=0; i<3; i++) mean[i] = -1.0;
dev = 0.0;
var = 0.0;
id = ++gid;
//模型中加入上帧图像的rgb值
r = 0.0;
g = 0.0;
b = 0.0;
}
double r,g,b;
double weight;
double mean[3];
// zot: currently v(r) = v(g) = v(b) as in the paper
// it seems that this is an unnecessary constraint
double var; // var = dev^2 = sigma
double dev; // sigma * sigma
double dist2; // squared distance from mean to current pixel (Xt-u)*(xt-u)
double mah2; // (mahalanobis distance)^2 for current pixel
UINT id;
static UINT gid;
};
//////////////////////////////////////////////////////////////////////
class PixelProcess
{
public:
PixelProcess();
virtual ~PixelProcess();
PixelCategory Process(BYTE *fgr,int frmae_num);
PixelCategory Process(BYTE fcr, BYTE fcg, BYTE fcb,int frame_num);
PixelCategory GetLastCategory();
void MeanInitial(BYTE cr,BYTE cg,BYTE cb);
ProcessFirst(BYTE *fgr);
protected:
void NormalizeWeights();
void SortModelsByKey();
void SortModelsByVariance();
PixelModel* GetLeastProbableModel();
double Gauss(PixelModel *pm);
PixelModel *model[K_MODELS];
PixelModel *pmMatch;
PixelCategory lastCategory;
};
#endif // !defined(AFX_GAUSSIANMODEL_H__B790B9CF_B0C7_45CA_BBA2_44809FDB67AA__INCLUDED_)