0

I have been trying for hours to try to get either the OpenCV Manager application on Samsung Galaxy S5 to work or a static import of the opencv library and neither have worked. I am using OpenCv 2.4.11.

For the static import I get the following error:

    04-18 20:49:08.591 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: Trying to get library list
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: Library list: ""
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: First attempt to load libs
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: Trying to init OpenCV libs
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: Trying to load library opencv_java
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: Cannot load library "opencv_java"
04-18 20:49:08.601 15911-15911/com.example.jsupp.myapplication W/System.err: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.jsupp.myapplication-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_java.so"
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.Runtime.loadLibrary(Runtime.java:366)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.System.loadLibrary(System.java:989)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:66)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at com.example.jsupp.myapplication.CalcMatches.<clinit>(CalcMatches.java:55)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.reflect.Constructor.newInstance(Native Method)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.Class.newInstance(Class.java:1650)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.ActivityThread.access$900(ActivityThread.java:172)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.os.Looper.loop(Looper.java:145)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5832)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
04-18 20:49:08.611 15911-15911/com.example.jsupp.myapplication D/OpenCV/StaticHelper: First attempt to load libs fails
04-18 20:49:08.691 15911-15911/com.example.jsupp.myapplication V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/ic_dialog_email.png
04-18 20:49:08.731 15911-15911/com.example.jsupp.myapplication V/BitmapFactory: DecodeImagePath(decodeResourceStream3) : res/drawable-xxhdpi-v4/abc_ic_ab_back_mtrl_am_alpha.png
04-18 20:49:08.751 15911-15911/com.example.jsupp.myapplication I/art: Alloc sticky concurrent mark sweep GC freed 2055(202KB) AllocSpace objects, 0(0B) LOS objects, 9% free, 76MB/84MB, paused 273us total 5.724ms
04-18 20:49:08.781 15911-15911/com.example.jsupp.myapplication I/art: Alloc partial concurrent mark sweep GC freed 309(25KB) AllocSpace objects, 2(60MB) LOS objects, 50% free, 15MB/31MB, paused 414us total 32.850ms
04-18 20:49:08.991 15911-15911/com.example.jsupp.myapplication E/art: No implementation found for long org.opencv.core.Mat.n_Mat(int, int, int) (tried Java_org_opencv_core_Mat_n_1Mat and Java_org_opencv_core_Mat_n_1Mat__III)

For the static implementation I simply used the openCV.initDebug method:

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

And I copied the Libs folders over but Android Studio does not seem to be able to find the library or include the libs folder in the application on the phone.

I have also tried to use the openCV manager application by following this tutorial: http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html#application-development-with-static-initialization which does not return anything to indicate that the initialization has worked.

What am I doing wrong? Any help would be appreciated!

Juppal
  • 89
  • 2
  • 11

1 Answers1

0

I figured out the issue it was basically just a matter of changing the location of some lines of code. I was executing a line of code: Mat testMat = new Mat(); in the onCreate method therefore not allowing the application to reach the OpenCV initialization method. This is a link to the page that helped me find the solution:

UnsatisfiedLinkError: n_Mat while using opencv2.4.3 with android 4.0

Community
  • 1
  • 1
Juppal
  • 89
  • 2
  • 11