简体   繁体   中英

openCV for Android - problems in integration

I need to integrate OpenCV 2.4 in my app.First, I found that it requires OpenCV Manager for running app based on OpenCV. But, After some googling, I found another way using static initialization here and here . I tried but it isn't working:

psudo code:

    public class MainActivity extends Activity {

static {
    if (!OpenCVLoader.initDebug()) {
        Log.d(TAG,"init failed")
    }
}

        private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
            @Override
            public void onManagerConnected(int status) {
                switch (status) {
                case LoaderCallbackInterface.SUCCESS: {
                    Log.i(TAG, "OpenCV loaded successfully");
                }
                    break;
                default: {
                    super.onManagerConnected(status);
                }
                    break;
                }
            }
        };

        @Override
        public void onResume() {
            super.onResume();   
            OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, this,
                    mLoaderCallback);
        }
    }

I tried but this isn't working. It shows the same pop-up for installing openCV Manager.

I also tried to remove initAsync() in onResume and mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS) ; but the app crashes when I use this.

Can anyone guide me to the proper way? and Please do not mark as duplicate; there are tens and hundreads of questions on SO unanswered.

如果您使用的是Android Studio,请检查以下内容: https : //github.com/floatlearning/android-opencv-template然后,在Android设备上安装属性OpenCV Manager

I solved it to myself. You don't need to write .so extension after JNI libraries.

I wrote this in incorrect way:

System.loadLibrary("lib1.so");
System.loadLibrary("lib2.so");

After all, I found the correct way :

System.loadLibrary("lib1");
System.loadLibrary("lib2");

As mentioned, don't need to write .so extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM