//M*/
-//This is based on the "An Improved Adaptive Background Mixture Model for
-//Real-time Tracking and Shadow Detection" by P. KaewTraKulPong and R. Bowden
-//The windowing method is used, but not the shadow detection. I make some of my
-//own modifications which make more sense. There are some errors in some of their
-//equations.
+// This is based on the "An Improved Adaptive Background Mixture Model for
+// Real-time Tracking with Shadow Detection" by P. KaewTraKulPong and R. Bowden
+// http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
+//
+// The windowing method is used, but not the shadow detection. I make some of my
+// own modifications which make more sense. There are some errors in some of their
+// equations.
+//
//IplImage values of image that are useful
//int nSize; /* sizeof(IplImage) */
//int depth; /* pixel depth in bits: IPL_DEPTH_8U ...*/
static void icvGetSortKey( const int nChannels, double* sort_key, const CvGaussBGPoint* g_point,
const CvGaussBGStatModelParams *bg_model_params );
-static void icvBackgroundTest( const int nChannels, int n, int p, int *match, CvGaussBGModel* bg_model );
+static void icvBackgroundTest( const int nChannels, int n, int i, int j, int *match, CvGaussBGModel* bg_model );
static void CV_CDECL icvReleaseGaussianBGModel( CvGaussBGModel** bg_model );
static int CV_CDECL icvUpdateGaussianBGModel( IplImage* curr_frame, CvGaussBGModel* bg_model );
//init parameters
if( parameters == NULL )
- {
- params.win_size = CV_BGFG_MOG_WINDOW_SIZE;
- params.bg_threshold = CV_BGFG_MOG_BACKGROUND_THRESHOLD;
+ { /* These constants are defined in cvaux/include/cvaux.h: */
+ params.win_size = CV_BGFG_MOG_WINDOW_SIZE;
+ params.bg_threshold = CV_BGFG_MOG_BACKGROUND_THRESHOLD;
+
params.std_threshold = CV_BGFG_MOG_STD_THRESHOLD;
- params.weight_init = CV_BGFG_MOG_WEIGHT_INIT;
+ params.weight_init = CV_BGFG_MOG_WEIGHT_INIT;
+
params.variance_init = CV_BGFG_MOG_SIGMA_INIT*CV_BGFG_MOG_SIGMA_INIT;
- params.minArea = CV_BGFG_MOG_MINAREA;
- params.n_gauss = CV_BGFG_MOG_NGAUSSIANS;
+ params.minArea = CV_BGFG_MOG_MINAREA;
+ params.n_gauss = CV_BGFG_MOG_NGAUSSIANS;
}
else
{
}
icvGetSortKey( nChannels, sort_key, g_point, &bg_model_params );
icvInsertionSortGaussians( g_point, sort_key, (CvGaussBGStatModelParams *)&bg_model_params );
- icvBackgroundTest( nChannels, n, p, match, bg_model );
+ icvBackgroundTest( nChannels, n, i, j, match, bg_model );
}
}
}
-static void icvBackgroundTest( const int nChannels, int n, int p, int *match, CvGaussBGModel* bg_model )
+static void icvBackgroundTest( const int nChannels, int n, int i, int j, int *match, CvGaussBGModel* bg_model )
{
int m, b;
uchar pixelValue = (uchar)255; // will switch to 0 if match found
CvGaussBGPoint* g_point = bg_model->g_point;
for( m = 0; m < nChannels; m++)
- bg_model->background->imageData[p+m] = (unsigned char)(g_point[n].g_values[0].mean[m]+0.5);
+ bg_model->background->imageData[ bg_model->background->widthStep*i + j*nChannels + m] = (unsigned char)(g_point[n].g_values[0].mean[m]+0.5);
for( b = 0; b < bg_model->params.n_gauss; b++)
{
break;
}
- bg_model->foreground->imageData[p/nChannels] = pixelValue;
+ bg_model->foreground->imageData[ bg_model->foreground->widthStep*i + j] = pixelValue;
}
/* End of file. */