I want to extract foreground mask of moving human alone in a static background. How to implement this in open-CV java?
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);
}
}
}
}
im getting an error at this line.
BackgroundSubtractorMOG2 backgroundSubtractorMOG=new BackgroundSubtractorMOG2();
The constructor BackgroundSubtractorMOG2() is undefined
Couldn't find proper documentation for these methods