Parameter of BackgroundSubtractorMOG2
Asked Answered
B

1

7

I have Problem understanding all Parameter of backgroundsubtractormog2.

I looked in the code (located in bfgf_gaussmix2.cpp), but don't see the connection to the mentioned paper. For exmaple is Tb = varThreshold, but what is the name of Tb in the paper?

I am especially interested in the fat marked parameter.

Let's start with the easy parameter [my remarks]:

  • int nmixtures

    Maximum allowed number of mixture components. Actual number is determined dynamically per pixel. [set 0 for GMG]

  • uchar nShadowDetection

    The value for marking shadow pixels in the output foreground mask. Default value is 127.

  • float fTau

    Shadow threshold. The shadow is detected if the pixel is a darker version of the background. Tau is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel is more than twice darker then it is not shadow.

Now to the ones i don't understand:

  • float backgroundRatio

    Threshold defining whether the component is significant enough to be included into the background model ( corresponds to TB=1-cf from the paper??which paper??). cf=0.1 => TB=0.9 is default. For alpha=0.001, it means that the mode should exist for approximately 105 frames before it is considered foreground.

  • float varThresholdGen

    Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to Tg). If it is not close to any component, a new component is generated. 3 sigma => Tg=3*3=9 is default. A smaller Tg value generates more components. A higher Tg value may result in a small number of components but they can grow too large. [i don't understand a word of this]

  • In the Constructor the variable varThreshold is used. Is it the same as varThresholdGen?

    Threshold on the squared Mahalanobis distance to decide whether it is well described by the background model (see Cthr??). This parameter does not affect the background update. A typical value could be 4 sigma, that is, varThreshold=4*4=16; (see Tb??).

  • float fVarInit

    Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.

  • float fVarMin

    Parameter used to further control the variance.

  • float fVarMax

    Parameter used to further control the variance.

  • float fCT

    Complexity reduction parameter. This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the standard Stauffer&Grimson algorithm.

Someone asked pretty much the same question on the OpenCV website, but without an answer.

Bordelaise answered 2/4, 2014 at 10:39 Comment(2)
Have you tried changing the values of these parameters to see their effect on the resulting image?Starr
@Starr Considering this is an algorithm intended to build a persistent buffer based on video feed over time, and it can take up to 5 or 10 minutes (depending on your history and complexityReductionThreshold values, which of course need to be tuned based on the amount of movement in your video), adjusting these values and observing the results to determine what they do is an extremely droll task that could take days or weeks to do properly. This isn't static values or images, where a programmer can iterate quickly.Waken
G
13

Well, I don't think anyone could tell you which parameter is what if you don't know the details of the algorithm that you are using. Besides, you should not need anyone to tell you which parameter is what if you know the details of the algorithm. I'm telling this for detailed parameters (fCT, fVarMax, etc.) not for straightforward ones (nmixtures, nShadowDetection, etc.).

So, I think you should read the papers referenced in the documentation. Here are the links for the papers 1, 2, 3.

And also you should read this paper as well, which is the beginning of background estimation.

After reading these papers and checking out the code with, I'm sure you will understand what those parameters are.

Good luck!

Ginni answered 6/4, 2014 at 7:32 Comment(2)
+1 I wasn't sure how to communicate that to the OP, but you did a good job. There's a reason why nobody up voted the question, I hope he understands that.Starr
@SlippD.Thompson I respectfully disagree with your interpretation of what I meant. It is not even remotely close. Using an end-user software like Windows and using a 3rd party API like OpenCV for SW development are quite different than each other. If you develop you need to understand what algorithms you are using. If you use a SW you just need to know how to use. Similarly, you need to know how to drive a car to drive a car, you don't need to know how aerodynamics work. And yes, my answer is not answering the question because it simply cannot be answered. I just gave directions.Ginni

© 2022 - 2024 — McMap. All rights reserved.