Lines Matching refs:g_point
73 static void icvInsertionSortGaussians( CvGaussBGPoint* g_point, double* sort_key, CvGaussBGStatModelParams *bg_model_params );
83 const CvGaussBGPoint* g_point, const CvGaussBGStatModelParams *bg_model_params );
85 const CvGaussBGPoint* g_point, const CvGaussBGStatModelParams *bg_model_params );*/
96 CvGaussBGPoint* g_point,
100 CvGaussBGPoint* g_point,
103 CvGaussBGPoint* g_point, const CvGaussBGStatModelParams *bg_model_params );
106 CvGaussBGPoint* g_point,
110 static void icvGetSortKey( const int nChannels, double* sort_key, const CvGaussBGPoint* g_point,
178 CV_CALL( bg_model->g_point = (CvGaussBGPoint*)cvAlloc(sizeof(CvGaussBGPoint)*
190 CV_CALL( bg_model->g_point[0].g_values =
200 bg_model->g_point[n].g_values =
201 bg_model->g_point[0].g_values + n*params.n_gauss;
202 bg_model->g_point[n].g_values[0].weight = 1; //the first value seen has weight one
203 bg_model->g_point[n].g_values[0].match_sum = 1;
206 bg_model->g_point[n].g_values[0].variance[m] = var_init;
207 bg_model->g_point[n].g_values[0].mean[m] = (unsigned char)first_frame->imageData[p + m];
211 bg_model->g_point[n].g_values[k].weight = 0;
212 bg_model->g_point[n].g_values[k].match_sum = 0;
214 bg_model->g_point[n].g_values[k].variance[m] = var_init;
215 bg_model->g_point[n].g_values[k].mean[m] = 0;
253 if( bg_model->g_point )
255 cvFree( &bg_model->g_point[0].g_values );
256 cvFree( &bg_model->g_point );
289 CvGaussBGPoint* g_point = &bg_model->g_point[n];
297 no_match = icvMatchTest( pixel, nChannels, match, g_point, &bg_model_params );
300 icvUpdateFullWindow( pixel, nChannels, match, g_point, &bg_model->params );
302 icvUpdateFullNoMatch( curr_frame, p, match, g_point, &bg_model_params );
306 icvUpdatePartialWindow( pixel, nChannels, match, g_point, &bg_model_params );
308 icvUpdatePartialNoMatch( pixel, nChannels, match, g_point, &bg_model_params );
310 icvGetSortKey( nChannels, sort_key, g_point, &bg_model_params );
311 icvInsertionSortGaussians( g_point, sort_key, (CvGaussBGStatModelParams *)&bg_model_params );
355 static void icvInsertionSortGaussians( CvGaussBGPoint* g_point, double* sort_key, CvGaussBGStatModelParams *bg_model_params )
367 CvGaussBGValues temp_gauss_values = g_point->g_values[j];
368 g_point->g_values[j] = g_point->g_values[j-1];
369 g_point->g_values[j-1] = temp_gauss_values;
377 const CvGaussBGPoint* g_point,
388 double d = g_point->g_values[k].mean[m]- src_pixel[m];
390 var_threshold += g_point->g_values[k].variance[m];
405 const CvGaussBGPoint* g_point,
419 double d = g_point->g_values[k].mean[m]- src_pixel[m];
420 sum_d2 += (d*d) / (g_point->g_values[k].variance[m] * g_point->g_values[k].variance[m]);
437 CvGaussBGPoint* g_point,
442 g_point->g_values[k].weight = g_point->g_values[k].weight +
444 g_point->g_values[k].weight));
446 double learning_rate_gaussian = (double)match[k]/(g_point->g_values[k].weight*
449 const double tmpDiff = src_pixel[m] - g_point->g_values[k].mean[m];
450 g_point->g_values[k].mean[m] = g_point->g_values[k].mean[m] +
452 g_point->g_values[k].variance[m] = g_point->g_values[k].variance[m]+
453 (learning_rate_gaussian*((tmpDiff*tmpDiff) - g_point->g_values[k].variance[m]));
460 static void icvUpdatePartialWindow( double* src_pixel, int nChannels, int* match, CvGaussBGPoint* g_point, const CvGaussBGStatModelParams *bg_model_params )
466 window_current += g_point->g_values[k].match_sum;
470 g_point->g_values[k].match_sum += match[k];
472 g_point->g_values[k].weight = g_point->g_values[k].weight +
473 (learning_rate_weight*((double)match[k] - g_point->g_values[k].weight));
475 if( g_point->g_values[k].match_sum > 0 && match[k] )
477 double learning_rate_gaussian = (double)match[k]/((double)g_point->g_values[k].match_sum);
480 const double tmpDiff = src_pixel[m] - g_point->g_values[k].mean[m];
481 g_point->g_values[k].mean[m] = g_point->g_values[k].mean[m] +
483 g_point->g_values[k].variance[m] = g_point->g_values[k].variance[m]+
484 (learning_rate_gaussian*((tmpDiff*tmpDiff) - g_point->g_values[k].variance[m]));
491 CvGaussBGPoint* g_point,
499 g_point->g_values[bg_model_params->n_gauss - 1].match_sum = 1;
504 match_sum_total += g_point->g_values[k].match_sum;
506 g_point->g_values[bg_model_params->n_gauss - 1].weight = 1./(double)match_sum_total;
510 g_point->g_values[bg_model_params->n_gauss - 1].variance[m] = bg_model_params->variance_init;
511 g_point->g_values[bg_model_params->n_gauss - 1].mean[m] = (unsigned char)gm_image->imageData[p + m];
517 g_point->g_values[k].weight *= alpha;
519 g_point->g_values[k].weight += alpha;
528 CvGaussBGPoint* g_point,
533 g_point->g_values[bg_model_params->n_gauss - 1].match_sum = 1;
538 match_sum_total += g_point->g_values[k].match_sum;
543 g_point->g_values[bg_model_params->n_gauss - 1].variance[m] = bg_model_params->variance_init;
544 g_point->g_values[bg_model_params->n_gauss - 1].mean[m] = pixel[m];
548 g_point->g_values[k].weight = (double)g_point->g_values[k].match_sum /
553 static void icvGetSortKey( const int nChannels, double* sort_key, const CvGaussBGPoint* g_point,
560 if( g_point->g_values[k].match_sum > 0 )
565 variance_sum += g_point->g_values[k].variance[m];
567 sort_key[k] = g_point->g_values[k].weight/sqrt(variance_sum);
580 CvGaussBGPoint* g_point = bg_model->g_point;
583 bg_model->background->imageData[ bg_model->background->widthStep*i + j*nChannels + m] = (unsigned char)(g_point[n].g_values[0].mean[m]+0.5);
587 weight_sum += g_point[n].g_values[b].weight;