Issue with BackgroundSubtractorMOG2
I'm having an issue with the BackgroundSubtractorMOG2 where foreground detection is just not happening at all.
backgroundFrame = 5;
while(true)
{
if(backgroundFrame>0)
{
bg.operator ()(frame,fore,.01);
backgroundFrame--;
}
else
{
bg.operator()(frame,fore,0);
}
imshow("MyFrame", fore);
}
the idea is that the background is collected using 5 frames, and then subsequent frames will not be calculated as part of the background. This is done by changing the learningRate variable from .01 to 0 after 5 iterations. However, after 5 iterations, fore shows up as a completely black screen. From my understanding, it should show any deviance of current frames from the background as white. Does anybody have past experience in this matter?
Thanks!
Just a remark, it is more standard to start your counter at 0, then do a counter++ after each loop and checking when a value reaches a certain level :) The counter-- construction is somehow weird.