Skip to content

Instantly share code, notes, and snippets.

@canburak
Created May 7, 2013 11:03
Show Gist options
  • Save canburak/5531845 to your computer and use it in GitHub Desktop.
Save canburak/5531845 to your computer and use it in GitHub Desktop.
Background mask with opencv
import cv2
bgs = cv2.BackgroundSubtractorMOG(99, 1, 0.5, 99)
capture = cv2.VideoCapture("VIDEO_2013-04-13_14-59-22.avi")
#cv2.namedWindow("input")
a = 0
while(True):
f, img = capture.read()
fgmask = bgs.apply(img)
#cv2.imshow("input", fgmask)
#cv2.waitKey(1)
cv2.imwrite("./pngs/image-"+str(a).zfill(5)+".png", fgmask)
a = a + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment