int random = rng.uniform(0, 9);
row = i + c_yoff[random];
if (row < 0)
row = 0;
if (row >= _image.rows)
row = _image.rows - 1;
col = j + c_xoff[random];
if (col < 0)
col = 0;
if (col >= _image.cols)
col = _image.cols - 1;
m_samples[k].at<uchar>(i, j) = _image.at<uchar>(row, col);
}
}
}
}
/**************** Test a new frame and update model ********************/
void ViBe_BGS::testAndUpdate(const Mat _image)
{
RNG rng;
for(int i = 0; i < _image.rows; i++)
{
for(int j = 0; j < _image.cols; j++)
{
int matches(0), count(0);
float dist;
while(matches < MIN_MATCHES && count < NUM_SAMPLES)
{
dist = abs(m_samples[count].at<uchar>(i, j) - _image.at<uchar>(i, j));
if (dist < RADIUS)
matches++;
count++;
}
if (matches >= MIN_MATCHES)
{
// It is a background pixel
m_foregroundMatchCount.at<uchar>(i, j) = 0;