Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I save a video with background subtraction applied

`import numpy as np import cv2 as cv cap = cv.VideoCapture('testvid.mov') fgbg = cv.createBackgroundSubtractorMOG2() while(1): ret, frame = cap.read() fgmask = fgbg.apply(frame) cv.imshow('frame',fgmask) k = cv.waitKey(30) & 0xff if k == 27: break cap.release()

cv.destroyAllWindows()`


I have this working, however cant figure out how to save it once BGS has been applied?

click to hide/show revision 2
None

updated 2019-01-05 10:59:42 -0600

berak gravatar image

How do I save a video with background subtraction applied

`import .

import numpy as np
import cv2 as cv
cap = cv.VideoCapture('testvid.mov')
fgbg = cv.createBackgroundSubtractorMOG2()
while(1):
    ret, frame = cap.read()
    fgmask = fgbg.apply(frame)
    cv.imshow('frame',fgmask)
    k = cv.waitKey(30) & 0xff
    if k == 27:
        break
cap.release()

cap.release()

cv.destroyAllWindows()`

cv.destroyAllWindows()

I have this working, however cant figure out how to save it once BGS has been applied?