Ask Your Question

Revision history [back]

BackgroundSubtractorMOG() with images not providing good results

So I am trying to use backgroundSubtractorMOG with images instead of a video stream.

My setup:

I have a static camera. The background never changes. However, I do have foreign objects ( people ) that appear in front of the background ( imagine a camera at a cafe and when the cafe is empty, that's the background, and when people go and sit in the cafe, they are the foreign objects that need to be detected).

I am trying to detect the foreign objects in the image. I am trying to use BackGroundSubractorMOG() to basically run through a set of sample images simulating a "video" stream and then at the end of my set of images, I apply the backgroundsubtractor to the image that I am trying to detect the foreign objects in.

So far my tries have not been very successful. I was only able to detect a couple of foreign objects from among 10. My lighting in the pictures does differ sometimes. It also detects some objects that are actually part of the background and have never changed.

Question:

1) I am wondering if there is a way to pre-process the images to better detect the foreign objects

2) Should I first run a set of only background images through the backgroundSubtractorMOG() and then run an image with foreign objects, or should I simply use images with both foreign objects and without. What is the number of data set I need to run through to get good results?

3) Is there any way to setup a backgroundSubtractorMOG() to not have to run through a set of "default" images every single time before I apply it to my specific image?