构建opencv android ndk项目

时间:2014-06-09 20:43:49

标签: android opencv android-ndk

我正在尝试构建opencv android ndk项目。我查看了opencv文件夹中的示例,Android.mk看起来像那样:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_LIB_TYPE:=STATIC
OPENCV_INSTALL_MODULES:=on

include ../includeOpenCV.mk
ifeq ("$(wildcard $(OPENCV_MK_PATH))","")
    #try to load OpenCV.mk from default install location
    include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk
else
    include $(OPENCV_MK_PATH)
endif

LOCAL_MODULE    := native_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)

看起来我需要改变路径以适应我的电脑,但我不确定这部分是什么意思:

include ../includeOpenCV.mk
ifeq ("$(wildcard $(OPENCV_MK_PATH))","")
    #try to load OpenCV.mk from default install location
    include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk
else
    include $(OPENCV_MK_PATH)
endif

我有一个cpp文件,其中我使用了opencv函数。

1 个答案:

答案 0 :(得分:0)

您必须将包含路径更改为已解压缩opencv-android sdk的目录。

变化

OPENCV_LIB_TYPE:=STATIC
OPENCV_INSTALL_MODULES:=on

include ../includeOpenCV.mk
ifeq ("$(wildcard $(OPENCV_MK_PATH))","")
    #try to load OpenCV.mk from default install location
    include $(TOOLCHAIN_PREBUILT_ROOT)/user/share/OpenCV/OpenCV.mk
else
    include $(OPENCV_MK_PATH)
endif

 OPENCV_LIB_TYPE:=STATIC
 OPENCV_INSTALL_MODULES:=on

// Location in which you have extracted your opencv-android-sdk 

 include C:\OpenCV-2.4.6-android-sdk-r2\OpenCV-2.4.6-android-sdk\sdk\native\jni\OpenCV.mk

 // remove this previously existing macro once you have set your absolute path