I tried to use BackgroundSubtractorMOG to remove the background but there are some object that already left the frame but the result from BackgroundSubtractorMOG.apply() still show that the object is still on the scene.
Here is my code
inputVideo = cv2.VideoCapture('input.avi')
fgbg = cv2.BackgroundSubtractorMOG()
while inputVideo.isOpened():
retVal, frame = inputVideo.read()
fgmask = fgbg.apply(frame)
cv2.imshow('Foreground', fgmask)
cv2.imshow('Original', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
I've also tried BackgroundSubtractorMOG with custom parameters (history = 200, nmixtures = 5, ratio = 0.8) but result is the same. Did I do something wrong or any recommedation? Please help.