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?
In c++ I have found this line
Hence what is default value of learningRate when you call sub.apply(frame[i], result);? can you use sub.apply(frame[i], result,-1); ?
Of course it is C++ and I don't know java source code for MOG2. But may be it could help you.
Did you find an answer? I'm having a problem with this in opencv 2.4.11 for python. Changing the history value doesn't seem to work.