Issue with BackgroundSubtractorMOG2

asked 2013-08-28 16:59:30 -0600

rkwong gravatar image

updated 2013-08-29 00:38:38 -0600

Vladislav Vinogradov gravatar image

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!

edit retag flag offensive close merge delete

Comments

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.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-29 04:53:45 -0600 )edit