OpenCV CascadeClassifier error

前端 未结 2 1501
走了就别回头了
走了就别回头了 2021-01-20 11:26

i\'m trying to do face detection through a webcam, but i got an error, cascadeclassifier error.

After do some testing, i found this line of code generate the error <

相关标签:
2条回答
  • 2021-01-20 11:59

    Try initialising CascadeClassifier objects in BaseLoaderCallBack. The OpenCV needs to load completely before initialising the CasCadeClassifier objects.

    Place this in onCreate() or onResume():

    if (!OpenCVLoader.initDebug())
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION, this, baseCallBack);
    else
        baseCallBack.onManagerConnected(LoaderCallbackInterface.SUCCESS);
    

    define baseCallBack as:

    private BaseLoaderCallback baseCallBack = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            if (status == SUCCESS) {
                try {
                    initClassifiers(); // initialise here
                } catch (IOException e) {
                    e.printStackTrace();
                }
                Log.d("OpenCVLoad", "OpenCV Loaded");
            } else {
                super.onManagerConnected(status);
            }
        }
    };
    
    0 讨论(0)
  • 2021-01-20 12:01

    finally i found the answer,

    i should load the library before use the cascadeclassifier. so just put this code

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    

    before the cascadeclassifier.

    0 讨论(0)
提交回复
热议问题