<p>There are recent algorithms which remove backgrounds (detect foreground) far better than the standard GMM implementation in OpenCV.</p>

<p>For example, there is a block-based classifier cascade approach described in <a href="http://arxiv.org/pdf/1303.4160v1.pdf">this journal article</a>, along with its C++ based <a href="http://arma.sourceforge.net/foreground/">source code</a>.</p>
How to use cv::BackgroundSubtractorMOG in OpenCV?
<p>I'm using OpenCV2.2 to implement moving objects detection with the method of Background Subtraction. And I use the Gaussian Mixture Model(GMM) method to model the background reference image. </p>

<p>I directly get the foreground pixels(or foreground mask) by using the class cv::BackgroundSubtractorMOG provided in OpenCV2.2. It's convenient but the foreground mask returned by cv::BackgroundSubtractorMOG is not as good as I expected. In addition, it seems that cv::BackgroundSubtractorMOG performs poorer than the method of GMM wrote in C language provided in OpenCV1.0.</p>

<p>The following is my code in OpenCV2.2:</p>

<pre><code>cv::BackgroundSubtractorMOG mog;
mog(frame, fgMask, 0.01);
</code></pre>

<p>So, did I use the method in a wrong way? </p>

<p>By the way, does cv::BackgroundSubtractorMOG perform shadow removal on the foreground pixels? </p>

<p>Thank you very much.</p>