Implement background subtraction in opencv java for video input from webcam?
<p>I want to extract foreground mask of moving human alone in a static background. How to implement this in open-CV java?</p>

<pre><code>package com.java.opencv;

import org.opencv.core.Mat;
import org.opencv.video.BackgroundSubtractor;
import org.opencv.video.BackgroundSubtractorMOG2;
import org.opencv.videoio.VideoCapture;

public class HelloCV {
    public static void main(String[] args){
        VideoCapture capture = new VideoCapture(0);
          Mat camImage = new Mat();
          BackgroundSubtractorMOG2 backgroundSubtractorMOG=new BackgroundSubtractorMOG2();
            if (capture.isOpened()) {
                while (true) {
                    capture.read(camImage);


                    Mat fgMask=new Mat();
                    backgroundSubtractorMOG.apply(camImage, fgMask,0.1);

                    Mat output=new Mat();
                    camImage.copyTo(output,fgMask);

                    //displayImageOnScreen(output);
                   }
                }
    }
}
</code></pre>

<p>im getting an error at this line. </p>

<pre><code>BackgroundSubtractorMOG2 backgroundSubtractorMOG=new BackgroundSubtractorMOG2();
</code></pre>

<blockquote>
  <p>The constructor BackgroundSubtractorMOG2() is undefined</p>
</blockquote>

<p>Couldn't find proper documentation for these methods</p>