Background subtraction image

I’m new for OpenCV and have a question for background subtraction.
Is there a way to display how background model looks like?
The 3rd line ends up with an error because the model isn’t an image object.
However, the 1st line creates a static image like stationary objects (e.g. streets and buildings) without cars, I assume. Your feedback would be really helpful.

backSub = cv2.createBackgroundSubtractorMOG2 # create background model
print(type(backSub)) # it returns <class ‘cv2.BackgroundSubtractorMOG2’>
cv2.imshow(‘BG Mask’, backSub) # end up an error

indeed, if you take a look at the docs :slight_smile: you’ll find the
getBackgroundImage()
method.
however, this is sythesized at runtime, thus quite expensive !

note that’s a visualization and likely represents just part of the model’s state.

if you need to persist the entire model state, you should be able to use read, write, save methods.

1 Like

The method returns what I wanted to see. Thanks!

not really (unfortunately).
i’ll save the parameters, but not the model state