I tried using BackgroundSubtractorMOG to remove the background, but there are some objects that have already left the frame, but the result of BackgroundSubtractorMOG.apply () still shows 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 also tried BackgroundSubtractorMOG with custom parameters (history = 200, nmixtures = 5, ratio = 0.8), but the result is the same. Did I do something wrong or any decision? Please, help.
source share