由于OpenCV开源图像处理代码简单,因此常用于各种平台中。采用NDK编程可以方便的使用OpenCV资源。
OpenCV的动态库已经有了,且编译对版本有较高的要求,需要加入其它动态库的时候需要在Android.mk修改实现。
LOCAL_PATH:=$(call my-dir)
#添加OpenCV
include $(CLEAR_VARS)
OpenCV_INSTALL_MODULES := on
OpenCV_CAMERA_MODULES := off
OPENCV_LIB_TYPE :=STATIC
# change this folder path to yours
include /home/zzw/AndroidStudioProjects/opencv_face/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk
# add mylib 自己的lib
LOCAL_C_INCLUDES += /home/zzw/AndroidStudioProjects/mylib/build-android2/install/include
LOCAL_LDLIBS += -L/home/zzw/AndroidStudioProjects/mylib/build-android/install/lib -lmylib
#生成模型文件的名字
LOCAL_MODULE := JNIpart
#添加其它可编辑的文件,如ShapeConverter.cpp ,XmlReadSave.cpp
LOCAL_SRC_FILES := squeeze_jni.cpp ShapeConverter.cpp XmlReadSave.cpp
LOCAL_CFLAGS := -O2 -fvisibility=hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math
LOCAL_CPPFLAGS := -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math
LOCAL_LDFLAGS += -Wl,--gc-sections
LOCAL_CFLAGS += -fopenmp
LOCAL_CPPFLAGS += -fopenmp
LOCAL_LDFLAGS += -fopenmp
#andorid 系统库
LOCAL_LDLIBS += -llog -lGLESv2 -lEGL -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Application.mk文件采用常用的编写方式:ndkr15版本以下,切记NDK的版本不能太高了
# APP_STL := stlport_static
APP_STL := gnustl_static
# APP_ABI := armeabi armeabi-v7a
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions
#选择平台
APP_ABI := armeabi-v7a
APP_PLATFORM := android-14
#NDK_TOOLCHAIN_VERSION := 10