我想使用tow extern
库来构建跟踪对象的android应用程序和冲浪算法,所以我使用了这个教程Using OpenCV Nonfree Module (SIFT, SURF) in Android NDK Projects
第一个库是libobjtrack_opencv_jni.so
(用于跟踪)另外两个是libopencv_java.so和libobjtrack_opencv_jni.so
我结束了得到这个结果:
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)
构建成功了,我得到了test_sift12.so
,但是当我运行.apk
时却无法工作..我认为问题在于PREBUILT_SHARED_LIBRARY
中使用android.mk
档案。
我需要你的帮助
答案 0 :(得分:0)
加载库,您希望在活动中使用该库。
就像这样
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");
}
}
我建议你改变以下的名字
LOCAL_MODULE := sift_prebuilt
到
LOCAL_MODULE := nonfree
和
LOCAL_MODULE := opencv_java_prebuilt
到
LOCAL_MODULE := opencv_java
请记住,不要忘记修改LOCAL_SHARED_LIBRARIES