1 | initial version |
You are re-creating the background subtractor every frame. You need to create it once and run many frames through it. The background subtractor learns what the background looks like over many frames. What you are seeing is just it's first attempt at guessing what's there.
I also suspect that the output mask is black with grey and no white. The grey is the estimated shadows, while white is the object. That way you can ignore any shadows or include them as you need. That's not your problem though.