1

I am unable to understand what the parameters of cv2.BackgroundSubtractorMOG and cv2.BackgroundSubtractorMOG2 stand for.

I've gone through this page of official documentation - http://docs.opencv.org/2.4/modules/video/doc/motion_analysis_and_object_tracking.html?highlight=backgroundsubtractormog#backgroundsubtractormog-backgroundsubtractormog

and also through Stack Overflow Page - How to use cv::BackgroundSubtractorMOG in OpenCV?

but I am not able to understand how to manipulate the parameters to get good foreground extraction.

Can somebody please explain me what the parameters of these functions really mean?

P.S. I am using version 2.4.9 of opencv and 2.7.11+ of python.

Community
  • 1
  • 1
Anmol Kagrecha
  • 153
  • 2
  • 10
  • THese are classes deriving from algorithm, so skimming through the given documentation, you will need to walk up the inheritance tree one or two steps to find the applicable parameters and than have to play around with values for those I guess to "get good foreground extraction". – Dilettant Jun 10 '16 at 05:13
  • @Dilettant Sir, can you please explain the use of parameters in detail or share I link where I can walk up the inheritance tree. The official documentation does not contain any such details nor do any related blogs. Even the default parameters are difficult to find. Can you please help me in this regard. – Anmol Kagrecha Jun 10 '16 at 10:19
  • You're welcome. At the link you provided eg. `cv2.BackgroundSubtractorMOG([history, nmixtures, backgroundRatio[, noiseSigma]]) → ` directly there Parameters: (history – Length of the history. nmixtures – Number of Gaussian mixtures. backgroundRatio – Background ratio. noiseSigma – Noise strength.) And: Default constructor sets all parameters to default values. That looks promising to me. The operator methods and the inheritance are discribed there directly below, aren't they? HTH – Dilettant Jun 10 '16 at 10:24
  • @Dilettant Sir, I meant what were the default values, what happens when I change these parameters, what visible changes take place in the image, etc. Thank you. – Anmol Kagrecha Jun 11 '16 at 03:51
  • Maybe look them up in the source python version code and try sone variations, update the question with your findings and specific open questions? Others than me may have far mire eyperince with opencv and might jump in. – Dilettant Jun 11 '16 at 07:11

1 Answers1

-2

using these kind of parameter u can eliminate shaodw in mog2.
it is better than mog background subtractor

fgmask = fgbg.apply(frame,fgmask,0.005)
these parameters can eliminate shadow

gunadeep reddy
  • 161
  • 4
  • 14
  • can you explain for what parameter 0.005 is the value? – Anmol Kagrecha Jul 06 '16 at 02:34
  • Please explain the rationale behind your answer. We'd like to learn more about why it works, not only how to do it. (Let alone that it doesn't seem to work for me.) – Acoop Aug 17 '16 at 13:55
  • The 0.005 sets the learning rate. Learning rate values can be difficult to tune. If this value didn't work for you, then try another (e.g. 0.01, 0.1,etc.) Repeat a few times to see if one of the learning rates seem to work. – user3731622 Oct 20 '16 at 20:29