Problem with Background Subtraction KNN in android studio
I am trying to do background subtraction using android phone camera with android studio. I installed OpenCV4Android 3.4.7 and try to use Backgorund Subtraction KNN. I give the camera permission in manifests and can launch the camera correctly. However, I only got white(or blank) screen after run this App on my mobilephone. Here is my part of code:
import org.opencv.video.BackgroundSubtractorKNN;
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
Mat frame = inputFrame.rgba();
Mat fgMask = new Mat();
BackgroundSubtractorKNN backSub = Video.createBackgroundSubtractorKNN();
Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGBA2GRAY);
backSub.apply(frame, fgMask,-1);
return fgMask;}
Anyone can help me ? Many thanks !