您的位置:首页 > 其它

高斯背景建模之icvMatchTest函数篇

2015-01-17 08:51 211 查看
//对每个象素点进行匹配
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;
        }
    }
   
    return
matchPosition;
}

创建高斯背景模型

cvCreateGaussianBGModel( IplImage* first_frame, CvGaussBGStatModelParams* parameters )

{

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: