Skip to content

Instantly share code, notes, and snippets.

@habakan
Created December 12, 2019 13:50
Show Gist options
  • Save habakan/bd1b351ece75a6ce578400419fccc4fd to your computer and use it in GitHub Desktop.
Save habakan/bd1b351ece75a6ce578400419fccc4fd to your computer and use it in GitHub Desktop.
subtract_background
import cv2
def main():
cap = cv2.VideoCapture(0)
bgObj = cv2.bgsegm.createBackgroundSubtractorMOG()
while(True):
ret, frame = cap.read()
fgmask = bgObj.apply(frame)
cv2.imshow('frame',fgmask)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment