how to do Background Subtraction in opencv (opencv-master) python -


i using enthought canopy ide(python opencv-masters), want background subtraction, problem is, webcam(window starts webcam) not responding if run code. code is:

import cv2 import numpy 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  

i have no idea whether can achieve background subtraction in other ways.

thanks!

if f==true , if(cv2.waitkey(27)!=-1) should inside while loop, works fine

import cv2 import numpy 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  

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -