高斯背景建模之icvMatchTest函数篇
时间:
2015-01-17 10:01:54
阅读:
326
评论:
收藏:
0
[点我收藏+]
标签:
//对每个象素点进行匹配
static int icvMatchTest( double* src_pixel, int nChannels, int* match,
const
CvGaussBGPoint* g_point,
const
CvGaussBGStatModelParams *bg_model_params
)
{
int
k;
int
matchPosition=-1; //这个匹配的位置只能是0,1,2(在假设3个高斯的前提下)
for
( k = 0; k < bg_model_params->n_gauss; k++) match[k]=0;
for
( k = 0; k < bg_model_params->n_gauss; k++)
{
double
sum_d2 = 0.0;
double
var_threshold = 0.0;
for(int
m = 0; m < nChannels; m++)
{ //src_pixel的值是由pixel传送
//pixel
= (uchar)curr_frame->imageData[p+k]
//即是如果是单通道或者是多通道,都是把一个象素点的所有分量全部读出来进行比较
//g_point->g_values[].mean[]就是在cvCreateGaussianBGModel对bg_model进行赋值的结果
double
d = g_point->g_values[k].mean[m]- src_pixel[m];
sum_d2
+= (d*d);
var_threshold
+= g_point->g_values[k].variance[m];
} //difference
< STD_LIMIT*STD_LIMIT or difference**2 < STD_LIMIT*STD_LIMIT*VAR
//我觉得这里有问题,我觉得应该是:
//var_threshold
= bg_model_params->std_threshold*var_threshold*var_threshold;
var_threshold
= bg_model_params->std_threshold*bg_model_params->std_threshold*var_threshold;
if(sum_d2
< var_threshold)
{
match[k]
= 1;
matchPosition
= k;
break;
}
}