If you want to use Java
API for OpenCV, then you may have a look at this post.
However, if you want to use pre-built OpenCV static libs with C/C++
code on NDK side then only you will require Android.mk
and Application.mk
. In my version of these .mk
files, I dynamically load the required pre-built libraries from a location on my drive, So while building, .mk
files will load the required static libs.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Location of SDK on my drive
OPENCVROOT := ${HOME}/opencv-sdk-android
OPENCV_CAMERA_MODULES := off
OPENCV_INSTALL_MODULES := on
OPENCV_LIB_TYPE := STATIC
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
# Load your local .cpp and .h files here.
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -lm -llog -ldl -lz
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11
LOCAL_LDFLAGS += -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS += -fexceptions -frtti -std=c++11 -D__STDC_CONSTANT_MACROS
APP_ABI := all
APP_PLATFORM=android-14