title: OpenCV Python cv2.BackgroundSubtractor parameters
body: <h2>Summary</h2>
  
  <p>It seems like changing the parametes of BackgroundSubtractorMOG doesn't affect the results of the algorithm.</p>
  
  <p>I'm usign Python: 2.7.6 |Anaconda 2.1.0 (64-bit)<br>
  OpenCV: '2.4.10'<br>
  OS: Windows 7 x64</p>
  
  <p>The default parameters for the algorithm are: </p>
  
  <pre><code>history=200, nmixtures=5, backgroundRatio=0.7
  </code></pre>
  
  <p>So, creating the background subtractor with different parameters should give different results. But I always get the same result (foreground mask) with default parameters and with custom parameters.</p>
  
  <hr>
  
  <h2>Reproducing the problem</h2>
  
  <p>First, Create two background subtractor objects with different parameters:</p>
  
  <pre><code>bg1 = cv2.BackgroundSubtractorMOG()
  bg2 = cv2.BackgroundSubtractorMOG(history=3, nmixtures=5, backgroundRatio=0.0001)
  </code></pre>
  
  <p>Create 2 "VideoCaptrue" objects:</p>
  
  <pre><code>cap = cv2.VideoCapture('video.mp4')
  cap2 = cv2.VideoCapture('different_video.mp4')
  </code></pre>
  
  <p>Test the results:</p>
  
  <pre><code># Get a frame from the first capturing object:
  frame = cap.read()[1]
  
  # Get the foreground mask from both background subtractors:
  fg1 = bg1.apply(frame)
  fg2 = bg2.apply(frame)
  
  # Show both results and the difference between them:
  cv2.imshow('Window name', np.hstack((fg1, fg2, fg1 - fg2)))
  cv2.waitKey(30)
  </code></pre>
  
  <p>After running that block of code for some frames, the window shows results from the first background subtractor, results from the second and the difference of the two.</p>
  
  <p>Because both masks are the same, the result of their difference (the third pane) is a full black frame:</p>
  
  <p><img src="https://i.stack.imgur.com/sKtah.png" alt="2 BackgroundSubtractorMOG and difference"></p>
  
  <p>Then, suddenly change the source of the video (the second VideoCapture object):</p>
  
  <pre><code># Get a frame from the second capturing object:
  frame = cap2.read()[1]
  
  # Get the foreground mask from both background subtractors:
  fg1 = bg1.apply(frame)
  fg2 = bg2.apply(frame)
  
  # Show both results and the difference between them:
  cv2.imshow('Window name', np.hstack((fg1, fg2, fg1 - fg2)))
  cv2.waitKey(30)
  </code></pre>
  
  <p>And after running that block of code for some frames you get:</p>
  
  <p><img src="https://i.stack.imgur.com/Sau4z.png" alt="2 BackgroundSubtractorMOG and difference with new video"></p>
  
  <p>The two foreground masks look the same, and that's why the third pane is a full black frame.</p>
  
  <p>But after running the last block of code for more than 3 frames the results of the second pane should become blacker again (because of the <code>history=3</code> in the creation of the <code>bg2</code> object). But both background subtractors keep getting the same results (as shown by the third full black pane).</p>
  
  <hr>
  
  <h2>Alternatives</h2>
  
  <p>I have also tried modifying their parameters with:</p>
  
  <pre><code>bg2.setInt('history')
  </code></pre>
  
  <p>But I get the same results.</p>
  
  <p>And I always get the paremeters I did "set" (e.g.):</p>
  
  <pre><code>&gt;&gt;&gt;bg2.getInt('history')
  3
  </code></pre>
  
  <hr>
  
  <p>Is there anything I'm missing?</p>