title: Cannot set user parameters in BackgroundSubtractorMOG2
body: <p>OpenCV library version 2.42. I'd like to set a parameter in <code>BackgroundSubtractorMOG2</code> object, e.g.</p>
  
  <pre><code>BackgroundSubtractorMOG2 bgr;  
  
  // the following doesn't work because 'nmixtures', 'backgroundRatio' 
  // and 'fVarMin' are a protected members.
  bgr.nmixtures = 3;   
  bgr.backgroundRatio = 0.9;
  bgr.fVarMin = 5; 
  
  // the following works 
  bgr.set('nmixtures', 3); 
  
  // both of the following lines will give a run-time error 
  // `Access violation reading location 0x0000000000000008.`
  bgr.set("backgroundRatio", 0.9);  
  bgr.set("fVarMin", 5);     
  </code></pre>
  
  <p><code>backgroundRatio</code> and <code>fVarMin</code> are parameters that control the algorithm. User should be able to change these parameters according to the <a href="http://docs.opencv.org/modules/video/doc/motion_analysis_and_object_tracking.html?highlight=backgroundsubtractormog2#backgroundsubtractormog2" rel="nofollow">documentation</a>. </p>
  
  <p>How can I set the parameters of <code>BackgroundSubtractorMOG2</code>?</p>
  
  <p><strong>EDIT</strong> As correctly mentioned in the answer below, this was a bug in OpenCV. The bug was fixed in OpenCV version 2.4.6.</p>