Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Static Initialization opencv 3.0 Cannot load library "opencv_java3"

Using Android ADT am trying to static initialize openCV so it included in the app build and users don't have to download openCV Manager from the Android playstore.

Am using openCV v3 (http://opencv.org/downloads.html)

At the stage just trying to add static initialization to one of the samples in OpenCV-android-sdk\samples\face-detection.

I have followed the example (http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html)

Looked at lots of examples but as yet come up with no solution to getting it working. Very much hope someone might be able to help.

I did think might be due to libopencv_java3.so not being in the folder libs/armeabi-v7a/ When i copy and paste it from OpenCV-android-sdk\sdk\native\libs\armeabi-v7a it disappears. I believe this could be something to do with the way the ndk is setup. Of course the issue could be something completely different.

LogCat gives this:

11-26 16:36:33.647: D/OpenCV/StaticHelper(13993): Trying to load library opencv_java3 
11-26 16:36:33.647: D/OpenCV/StaticHelper(13993): Cannot load library "opencv_java3" 
11-26 16:36:33.647: W/System.err(13993): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java3 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.facedetect-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.facedetect-1, /vendor/lib, /system/lib, /vendor/lib]]]: findLibrary returned null 
11-26 16:36:33.767: D/OpenCV/StaticHelper(13993): Trying to load library opencv_java3 
11-26 16:36:33.767: D/OpenCV/StaticHelper(13993): Cannot load library "opencv_java3" 
11-26 16:36:33.767: W/System.err(13993): java.lang.UnsatisfiedLinkError: Couldn't load opencv_java3 from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.opencv.samples.facedetect-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.opencv.samples.facedetect-1, /vendor/lib, /system/lib, /vendor/lib]]]: findLibrary returned null
like image 812
Garry Dunicazzz Avatar asked Nov 26 '15 16:11

Garry Dunicazzz


2 Answers

incase someone comes across this issue and uses AndroidStudio. You can fix it by simply copying the folder OpenCV-android-sdk\sdk\native\libs

into your OpenCvProject/openCVLibrary310/source/main and rename it to jniLibs. So that the final structure looks like this: OpenCvProject/openCVLibrary310/source/main/jniLibs/ enter image description here

If you already ran your project out of AndroidStudio make sure to delete it first from the device. Otherwise AndroidStudio might not redeploy it and because of that might not copy over the libs.

It might also work if you copy the libs into your actual project and not into the openCVLibrary folder but I didn't try that.

like image 169
Thor_Bux Avatar answered Oct 18 '22 01:10

Thor_Bux


Ensure you have the option to install modules set to "ON" before including Opencv.mk:

OPENCV_INSTALL_MODULES:=on
include ${OPENCV_ANDROID_SDK}/${ANDROID_SDK_JNI}/OpenCV.mk

I already set my variables in my makefile

see: http://docs.opencv.org/2.4/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html

like image 30
I L Avatar answered Oct 17 '22 23:10

I L