Mask for BackgroundSubtractorMOG2

How can I tell BackgroundSubtractorMOG2 which pixels will be updated in the background and which pixels should not.

I ran into a problem when an object entered the scene and stopped for a few seconds, the object will be absorbed by the background model.

I wanted to reduce the speed of learning or stop learning around a specific stopped object, but how can I do this? Does BackgroundSubtractorMOG2 support using a mask in its update function?

I am using OpenCV 2.4.1.

Thanks, Alvin.

+7
source share
2 answers

BackgroundSubtractorMOG2 does not support input masking. But if you know which pixels you want to mask, you can mask the output: let's say you called subtractor(input, fg, learningRate); , and you somehow know where the object is (maybe you tracked it using the average shift or pattern recognition) just fg |= mask; where mask is where, as you know from some other source, an object.

+3
source

You can accomplish this by setting the learning speed to the lowest level.

t

 mog(input, output, 0.00000001); 
+2
source

All Articles