0

I used this SO answer as a guide, and did the following, but when I copy the app's .apk file from its bin directory, transfer it to a phone which doesn't have OpenCV Manager installed, it prompts and requires to install it first

The OpenCV4Android library project is already in my Workspace in Eclipse. The application I am talking about does have a reference of the OpenCV library, as it was running on a device which had OpenCV Manager installed.

Now, the SO answer which I referred to provides a link to this tutorial. In the tutorial, at this point, it is stated,

If your application project doesn’t have a JNI part, just copy the corresponding OpenCV native libs from <OpenCV-2.4.11-android-sdk>/sdk/native/libs/<target_arch> to your project directory to folder libs/.

In case of the application project with a JNI part,...

I believe my app does Not have a JNI part, because I don't even know what JNI is. It is a simple, basic app which doesn't do much.

I am confused about the <target_arch> part of the path given. In my computer, I copied the following directory to my project's libs folder:

D:\Android\OpenCVv2.4.11\OpenCV-android-sdk\sdk\native\libs\x86

And lastly, in my MainActivity.java, I do initialize the library like:

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

@Override
    public void onCreate(Bundle savedInstanceState) {
        ...
        setContentView(R.layout.activity_main);
        openCvCameraBridge = (CameraBridgeViewBase) findViewById(R.id.mainActivity_javaCameraView);
        openCvCameraBridge.setCvCameraViewListener(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, baseLoaderCallback);
    }
Community
  • 1
  • 1
Solace
  • 8,612
  • 22
  • 95
  • 183

1 Answers1

0

I don't have all the answers but I can hopefully clarify a few things for you here.

I believe my app does Not have a JNI part, because I don't even know what JNI is

JNI is a folder which Android projects have when they chose to also run Native C/C++ code (Android ndk). If you have no .c or .cpp files in your project then you absolutely do not have a JNI part to your project. If you do (that you wrote) it should be in /project/jni (possibly capitalized I cannot remember). As a note I would say that you will very likely as time goes on want to have a JNI part so it may benefit you to just follow that part of the tutorial.

I am confused about the target_arch part of the path given.

This is the target architecture for what you are developing for. This is generally something you would see with cross compiling (which you may be doing). This is asking what architecture is the phone,tablet,etc... you are developing for using. Without the specific device you are programming for I cannot tell you whether you got this right or not but it should be clearly listed if you lookup your phone/tablet.

transfer it to a phone which doesn't have OpenCV Manager installed

I know you didn't ask anything about this but I would like to state that this is an absolute necessity for openCV development on Android. When openCV4Android first came out the library was compiled into the project, hence why some guides do not mention it. However, this created huge projects which seemed very unneeded, so the openCV people created the manager program which has all the openCV libraries in it. That way your program doesn't need to compile the entirety of openCV into it so until the manager your program will either fail to load or be much bulkier then it needs to be.

Hopefully this clears some things up.

arduic
  • 659
  • 3
  • 12