Python cv2.BackgroundSubtractorMOG2 history parameter doesn't work
I'm using opencv 2.4.11 with python 2.7.12.
The BackgroundSubtractorMOG2 works (i.e. background subtraction results are ok), but I wanted to tune the parameters.
However, changing the history parameter is not showing any changes the in the background subtraction results.
Here is the code snippet:
history = 30 #I've also tried 2,5,20,200
varThreshold = 16
bShadowDetection = False
bgSub = cv2.BackgroundSubtractorMOG2(history, varThreshold, bShadowDetection)
learningRate = 0.1
for currentFrame in allFrames: #assume allFrames is a list containing the images
fgMask = bgSub.apply(currentFrame, None, learningRate)
I've also tried setting the history using the setInt
method:
history = 30 #I've also tried 2,5,20,200
varThreshold = 16
bShadowDetection = False
bgSub = cv2.BackgroundSubtractorMOG2(history, varThreshold, bShadowDetection)
bgSub.setInt('history',30)
learningRate = 0.1
for currentFrame in allFrames: #assume allFrames is a list containing the images
fgMask = bgSub.apply(currentFrame, None, learningRate)
Has anyone else had this problem or know what's going on?
scale problem. try 500, 2000, 5000 (and then, wait)
how many images do you have ?
again, background subtraction is supposed to run on streaming video data, you probably do not have enough images to make it work properly.
I have 200 images. However, I don't think the number of images was the issue. I'll post the solution.