6

I need explanations on parameters of

createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0, bool detectShadows=true)

How do history, dist2Threshold, and detectShadows affect the background substractor ?

hassan
  • 7,812
  • 2
  • 25
  • 36

1 Answers1

9

Sometimes, the easiest way to understand function's parameters is by playing with them. Here is what I could figure out by reading the documentation and testing out the function :

  • history is the number of frames used to build the statistic model of the background. The smaller the value is, the faster changes in the background will be taken into account by the model and thus be considered as background. And vice versa.
  • dist2Threshold is a threshold to define whether a pixel is different from the background or not. The smaller the value is, the more sensitive movement detection is. And vice versa.
  • detectShadows : If set to true, shadows will be displayed in gray on the generated mask. (Example bellow)

Gray color region shows shadow region

Hope my explanations make sens and that it's a bit clearer for you now.

Community
  • 1
  • 1
Elouarn Laine
  • 1,665
  • 15
  • 27