title: OpenCV - Fixing foreground in Background subtractor MOG
body: <p>How can we fix foreground using mog background subtractor in opencv-python? I'm trying to have a more stable foreground that can keep showing foreground once it could correctly subtract foreground from background (for example fix foreground for about 5 seconds) 
  here is my code: </p>
  
  <pre><code>cap = cv2.VideoCapture(0)
  history = 500   # or whatever you want it to be
  accelerate = 5
  
  fgbg = cv2.createBackgroundSubtractorMOG2(history=500,  varThreshold=20,  detectShadows=True)
  
  count=0
  while(1):
      for i in (1, accelerate):
          ret, frame = cap.read()
      fgmask = fgbg.apply(frame, learningRate=1.0/history)
      imageproc(fgmask,count)
  
  #    time.sleep(5)
      k = cv2.waitKey(0) &amp; 0xff
      if k == 27:
          break   
  cap.release()
  cv2.destroyAllWindows()
  </code></pre>