Ask Your Question

Revision history [back]

face tracker sample not working: libopencv_java3.so not found

I am trying to run OpenCV Face Detection sample on my android device(redmi note 2) and I am getting the same crash.

I've installed all the needed things for openCV that were in this tutorial(sdk,ndk, adt, tegra and about 9000 other things), I've set all the needed project settings, got rid of all build errors, copied OpenCV-android-sdk\sdk\native\libs\ folders into OpenCV-android-sdk\samples\face-detection\libs even though I could not find such step in the tutorial mentioned above, googled about 9000 topics on such problem and tried every single solution, but nearly nothing helped.

Here is the device log at the moment of crash:

04-26 16:41:51.084: I/OCVSample::Activity(1983): OpenCV loaded successfully
04-26 16:41:51.086: E/art(1983): dlopen("/data/app/org.opencv.samples.facedetect-2/lib/arm64/libdetection_based_tracker.so", RTLD_LAZY) failed: dlopen failed: could not load library "libopencv_java3.so" needed by "/data/app/org.opencv.samples.facedetect-2/lib/arm64/libdetection_based_tracker.so"; caused by library "libopencv_java3.so" not found
04-26 16:41:51.086: D/AndroidRuntime(1983): Shutting down VM
04-26 16:41:51.087: E/AndroidRuntime(1983): FATAL EXCEPTION: main
04-26 16:41:51.087: E/AndroidRuntime(1983): Process: org.opencv.samples.facedetect, PID: 1983
04-26 16:41:51.087: E/AndroidRuntime(1983): java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "libopencv_java3.so" needed by "/data/app/org.opencv.samples.facedetect-2/lib/arm64/libdetection_based_tracker.so"; caused by library "libopencv_java3.so" not found
04-26 16:41:51.087: E/AndroidRuntime(1983):     at java.lang.Runtime.loadLibrary(Runtime.java:371)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at java.lang.System.loadLibrary(System.java:989)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at org.opencv.samples.facedetect.FdActivity$1.onManagerConnected(FdActivity.java:67)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:319)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1256)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1273)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.os.Handler.handleCallback(Handler.java:815)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.os.Handler.dispatchMessage(Handler.java:104)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.os.Looper.loop(Looper.java:194)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at android.app.ActivityThread.main(ActivityThread.java:5546)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at java.lang.reflect.Method.invoke(Native Method)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at java.lang.reflect.Method.invoke(Method.java:372)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
04-26 16:41:51.087: E/AndroidRuntime(1983):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

Interesting thing is that even when I am not trying to run my eclipse project but just run the app I installed from a ready apk file(OpenCV-android-sdk\samples\example-face-detection.apk), I get exactly the same error and crash. All other sample projects(except mixed processing) work fine both from ready apk files and my eclipse projects.

my Application.mk file in face detection sample project:

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := arm64-v8a
APP_PLATFORM := android-9

my Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

#OPENCV_CAMERA_MODULES:=off
#OPENCV_INSTALL_MODULES:=on
#OPENCV_LIB_TYPE:=SHARED
ifdef OPENCV_ANDROID_SDK
  ifneq ("","$(wildcard $(OPENCV_ANDROID_SDK)/OpenCV.mk)")
    include ${OPENCV_ANDROID_SDK}/OpenCV.mk
  else
    include ${OPENCV_ANDROID_SDK}/sdk/native/jni/OpenCV.mk
  endif
else
  include ../../sdk/native/jni/OpenCV.mk
endif

LOCAL_SRC_FILES  := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS     += -llog -ldl

LOCAL_MODULE     := detection_based_tracker

include $(BUILD_SHARED_LIBRARY)

Help, please.