Ask Your Question

Revision history [back]

Android: Why can't I initialize BackgroundSubtractor with Video.createBackgroundSubtractorMOG2()?

I implemented my class with CameraBridgeViewBase.CvCameraViewListener2. And here is my onCameraFrame() method that does the processing after frame grabbing before rendering the frame on screen:

   @Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat frame=(Mat)inputFrame;
    Mat fgMask=new Mat();
    BackgroundSubtractor bs=Video.createBackgroundSubtractorMOG2();
    bs.apply(frame,fgMask);
    //return 4 channel as rgba or 1 channel as gray scale
    return inputFrame.rgba();
}

I learn the syntax from here.

The problem is that Android Studio says 'Cannot resolve method createBackgroundSubtractorMOG2()' after I imported the Video class.