0

I'm writing to ask about openCV to you.

First of all, I'm a student studying about openCV and I'd like to use openCV in Android Applications.

Until now, I have to download 'openCV Manager App' when I ran some applications..

Actually, I don't want to download other applications such a 'openCV Manager App' when I run application.

So, I searched about those problem on the Internet.. and basically, I followed below link's suggestion,

http://docs.opencv.org/trunk/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html#application-development-with-static-initialization

And..

I tried to modify onResum callback method as follows ..


public void onResume()
{
    super.onResume();
    // OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
    mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}

Also, I tried to this way, (Actually, I don't know where this code is inserted..)


static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
}

But, 'UnsatisfiedLinkError' is always occured when I run Application.

I think the reason of this problem is environment setting..

I already tried below processes

  1. NDK download and setting the environment variable
  2. Download openCV library
  3. Setting the project target
  4. execute ways to OnResume() as above

I had a problem about this error for weeks, I seriously need help .

Thanks in advance.

Nallath
  • 2,100
  • 20
  • 37
  • possible duplicate of [How to integrate OpenCV Manager in Android App](http://stackoverflow.com/questions/20259309/how-to-integrate-opencv-manager-in-android-app) – kiranpradeep May 04 '15 at 04:45
  • Possible duplicate of [How to run OpenCV code without OpenCv Manager](http://stackoverflow.com/questions/40681578/how-to-run-opencv-code-without-opencv-manager) – Sneh Pandya Feb 13 '17 at 20:17

1 Answers1

0

I got stuck around this too. This is how I do it. In the static part of your Main Activity,

static {
    if (!OpenCVLoader.initDebug()) {
        // Handle initialization error
    }
    else {
        System.loadLibrary("jni_part"); // load other native libraries
    }
}

Don't keep anything in onResume() or anything else. This is sufficient.

And in the Android.mk file,

OPENCV_CAMERA_MODULES:=on # If you want Camera module
OPENCV_INSTALL_MODULES:=on

This worked for me. But this also has some issues. Static calling makes it a lot slower. I used CvCameraBridgeViewBase and got around 5-6 fps max. In Dynamic linking it was around 15-18 fps. So I stopped using OpenCV in Java part. Now I Use Android sdk camera, previewCallback and send buffers to jni where I use OpenCV utilities. If you're planning to do that, you no londer need OpenCV.intiDebug(). You just need to load the native so file.

Froyo
  • 17,947
  • 8
  • 45
  • 73