Ask Your Question

miav's profile - activity

2020-07-23 09:54:08 -0600 received badge  Popular Question (source)
2016-10-20 13:25:48 -0600 received badge  Nice Question (source)
2015-09-07 10:05:24 -0600 received badge  Student (source)
2015-09-07 09:42:51 -0600 asked a question What is the history parameter in BackgroundSubtractorMOG2?

I'm on OpenCV for java. I have read and understood the Zivkovic paper about the algorithm. I can't seem to understand what the history param in the BackgroundSubtractorMOG2 constructor is about.

From here, https://github.com/Itseez/opencv/blob... , line 106, it is said that alpha = 1/ history. That would mean that history is namely the T parameter inside the paper, i.e. (more or less) the number of frames that constitute the training set.

However it doesn't seem so. Changing the value in the constructor, from 10 to 500 or beyond, has no effect on the final result.

Mat result = new Mat();
int history = 10; //or 50, or 500, or whatever
BackgroundSubtractorMOG2 sub = new BackgroundSubtractorMOG2(history, 16, false);
for (....) {
    sub.apply(frame[i], result);
}
//here result is the same no matter what "history" I have set

Where as, I can change the alpha value in the apply() call, and that is really effective:

Mat result = new Mat();
float alpha = 0.1;
BackgroundSubtractorMOG2 sub = new BackgroundSubtractorMOG2(whatever, 16, false);
for (....) {
    sub.apply(frame[i], result, alpha);
}
//if I change alpha here, result changes a lot, which is understandable.

So, either history is not equal to 1/alpha (or there's a bug in the java wrapper which make history useless). But then, what is it?