0

I want to use tow extern library to build android application of tracking object with surf algorithm so I used this tutorial Using OpenCV Nonfree Module (SIFT, SURF) in Android NDK Projects

the first library is libobjtrack_opencv_jni.so (using for tracking) an the 2 others are libopencv_java.so and libobjtrack_opencv_jni.so I finished To Get this result:

Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := sift_prebuilt
LOCAL_SRC_FILES := libnonfree.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE    := opencv_java_prebuilt
LOCAL_SRC_FILES := libopencv_java.so
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE    := objtrack_opencv_jni
LOCAL_SRC_FILES := libobjtrack_opencv_jni.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
OPENCV_LIB_TYPE        := STATIC
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=off
include C:/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_C_INCLUDES:= C:/OpenCV-2.4.5-android-sdk/sdk/native/jni/include
LOCAL_MODULE    := test_sift12
LOCAL_CFLAGS    := -Werror -O3 -ffast-math
LOCAL_LDLIBS    += -llog -ldl
LOCAL_SHARED_LIBRARIES := sift_prebuilt opencv_java_prebuilt objtrack_opencv_jni
LOCAL_SRC_FILES := test_sift.cpp
include $(BUILD_SHARED_LIBRARY)

build is succeeded and i got test_sift12.so but is not work when i run the .apk .. I think that the problem is with the use of PREBUILT_SHARED_LIBRARY in android.mk file . i need your help

4

1 回答 1

0

load library, where you want to use that libraries in the activity.

like in this way

public class YourClassName extends Activity {

.....

//add the following code at the end of the class


  static 
  {
      System.loadlibrary("opencv_java");
      System.loadlibrary("objtrack_opencv_jni");
      System.loadlibrary("nonfree");
      System.loadlibrary("test_sift12");
   }
}

I suggest you change you names of following

LOCAL_MODULE    := sift_prebuilt

to

LOCAL_MODULE    := nonfree

and

LOCAL_MODULE    := opencv_java_prebuilt

to

LOCAL_MODULE    := opencv_java

Remember don't forget to modify the names in LOCAL_SHARED_LIBRARIES

于 2013-11-30T19:26:03.220 回答