简体   繁体   中英

If you build an app using OpenCV4Android, do your users need to download the openCV manager/libraries?

I'm reading up on using OpenCV for Android applications, and I'm unsure whether or not the libraries come connected to the app itself upon launch, or if the openCV library has to be downloaded for each user.

Is this something I should consider? Should I use another method, or am I completely misunderstanding this article: http://www.embedded.com/design/programming-languages-and-tools/4406164/2/Developing-OpenCV-computer-vision-apps-for-the-Android-platform

Linking dynamically the OpenCv library to your app is a best practice of developing with OpenCv so whenever there is a new Update of the library it will be automatically updated in you app too,

But if you don't to and you wanna have one fixed opencv library you can do it but it's deprecated as an approach chech this step by step guide OpenCV4Android

There are two ways you can develop the app with OpenCV dependency.

First, is to ask the user to download the OpenCV Manager from the Play Store (async initialization).

Second is static initialization.

Let me explain the static initialization first. In static initialization, you include the library in your project. That means, whatever library the user needs, you will package it with your application. You can do that by following this steps in brief.

1) If your application project doesn't have a JNI part, just copy the corresponding OpenCV native libs from /sdk/native/libs/ to your project directory to folder libs/.

2) In case of the application project with a JNI part, instead of manual libraries copying you need to modify your Android.mk file: add the following two code lines after the "include $(CLEAR_VARS)" and before "include path_to_OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk"

For the full instruction, you can see at http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

The second way, is to load the library at runtime. The library will be loaded by an external application provided by OpenCV called OpenCV Manager. The code snippets are as follows [also taken from http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html] :

    public class Sample1Java extends Activity implements CvCameraViewListener {

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

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

    ...
   }

The line OpenCVLoader.initAsync will asynchronously load the library using the OpenCV Manager. If it is not installed, the user will be redirected to the Play Store.

The asynchronous initialization is the generally recommended way by those who wrote the OpenCV guide as by doing so, you don't need to include the library for each architecture and the library will be updated too. It kinda breaks the user experience; the flow of the program.

Anyway, just keep in mind that in async initialization, you can only start using any codes associated with OpenCV after the library is loaded whereby after you received the SUCCESS status. So, design your application accordingly.

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