尝试在PreProcessorFactory.getCroppedImage(Mat)

时间:2019-07-19 11:50:45

标签: java android opencv

我想使用参数“ Bitmap”而不是“ CameraBridgeViewBase.CvCameraViewFrame inputFrame”调用onCameraFrame()方法来处理来自UVC USB摄像机的位图。 但是它向我展示了PreProcessorFactory.getCroppedImage(matImage);中的NullPointer异常。

实际代码:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    Mat imgRgba = inputFrame.rgba();
    Mat img = new Mat();
    imgRgba.copyTo(img);

    List<Mat> images = ppF.getCroppedImage(img);
    Rect[] faces = ppF.getFacesForRecognition();
}

我的代码:

public Mat onCameraFrame(Bitmap bitmapFrame) {

    Mat imgRgba = new Mat();
    Utils.bitmapToMat(bitmapFrame, imgRgba);
    Mat img = new Mat();

    imgRgba.copyTo(img);

    List<Mat> images = ppF.getCroppedImage(imgRgba);
    Rect[] faces = ppF.getFacesForRecognition();
}

错误是:

java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Listch.zhaw.facerecognitionlibrary.PreProcessor.PreProcessorFactory.getCroppedImage(org.opencv.core.Mat)' on a null object reference

0 个答案:

没有答案