title: how to do Background Subtraction in opencv (opencv-master) python
body: <p>I am using Enthought Canopy as my IDE(python with opencv-masters), i want to do Background Subtraction, but the problem is, the webcam(window which starts with webcam) is not responding if I run the code.
  My code is:</p>
  
  <pre><code>import cv2
  import numpy as np
  cam=cv2.VideoCapture(0)
  fgbg = cv2.BackgroundSubtractorMOG()
  while(cam.isOpened): 
     f,img=cam.read()
  if f==True:
       #img=cv2.flip(img,1)
       #img=cv2.medianBlur(img,3)
       fgmask = fgbg.apply(img)
       cv2.imshow('track',fgmask)
  if(cv2.waitKey(27)!=-1):
     cam.release()
     cv2.destroyAllWindows()
     #break 
  </code></pre>
  
  <p>I have no idea whether I can achieve this Background Subtraction in any other ways.</p>
  
  <p>Thanks!</p>