5.配置Opencv sdk路径,并引入Opencv lib库
a.依次点击 project->properties->c/c++ Build->Environment->add 添加NDK路径和OpenCV SDK路径,如图所示。
b.依次点击 project->properties->c/c++ General->Paths and Symbols->GNU C++,选中${ProjDirPath}/../../sdk/native/jni/include,然后点击Edit,将此项改为${OPENCVSDKROOT}/sdk/native/jni/include
c.如果是非windows系统(Linux or MAC),导入工程后,会显示编译错误。去掉ndk-build.cmd后面的".cmd"
d.编译报错
jni/Android.mk:5: ../../sdk/native/jni/OpenCV.mk: No such file or directory
打开Android.mk文件,将
include ../../sdk/native/jni/OpenCV.mk 改成
include ${OPENCVSDKROOT}/sdk/native/jni/OpenCV.mk.编译OK
e.java文件仍然报错,原因是未引入opencv的库文件
依次选择project->properties->Android,移除掉报错的library,然后点击add,选择OpenCV Library - 2.4.10,点击OK,库文件导入成功
6.运行samples里面的示例程序,首次运行会提示安装OpenCV Manager。
点击YES,如果不能自动安装(Package installation failed!),则需要手动安装:
进入终端或dos,运行命令:
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.10_Manager_2.19_armv7a-neon.apk
如果adb环境配置好了,直接运行adb install /Applications/android/OpenCV-2.4.10-android-sdk/apk/OpenCV_2.4.10_Manager_2.19_armv7a-neon.apk
如果没有配好,则需先cd到
<Android SDK path>/platform-tools/
然后再运行adb install命令
安装完毕后,重新运行sample。
本文参考 :
http://opencv.org/android
http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html#o4a-sdk