Opencv 3.3.0 on Mac10.13.1编译

============= openCV 编译========================

step 1: 下载OpenCV:https://opencv.org/releases.html

https://github.com/opencv/opencv/archive/3.3.0.zip

1.下载好之后就unzip解压

2.cd 到目录下

3.cd platforms 下

4.需要修改ABI 里面的linux的版本好,基本都需要4.9(到自己的ndk目录下,toolchains 查看对应的平台的编译版本)

step 2: 安装环境

(1)安装python,本人使用的2.7.10

(2)安装NDK   (这里面坑比较多,自己之前用安卓stdio下载的会出现问题2,问题3看下面)

(3)安装SDK(也是安卓stdio下载的,这个会出现问题2)

(4)配置Cmake的变量

        注意:Cmake配置的位置在在sdk下面的cmake的bin中的位置如sdk/cmake/bin

出现的bug

问题1:

-- Build files have been written to: /Users/water/opencv/opencv-3.3.0/platforms/android/build_service_armeabi-v7a

Check dir /Users/water/opencv/opencv-3.3.0/platforms/android/build_service_armeabi-v7a/platforms/android/service/engine/.build/res/xml (create: True, clean: False)

Check dir /Users/water/opencv/opencv-3.3.0/platforms/android/build_service_armeabi-v7a/platforms/android/service/engine/.build/libs/armeabi-v7a (create: True, clean: False)

Adding libraries from /Users/water/opencv/opencv-3.3.0/platforms/android/o4a/lib

Executing: ['ninja', 'opencv_engine']

ninja: error: unknown target 'opencv_engine'

Traceback (most recent call last):

File "./build_sdk.py", line 312, in

builder.build_engine(abi, engdest)

File "./build_sdk.py", line 191, in build_engine

execute(["ninja", "opencv_engine"])

File "./build_sdk.py", line 20, in execute

raise Fail("Child returned: %s" % retcode)

__main__.Fail: Child returned: 1

问题一解决方式:

需要下载

安装 brew install ant

不装会报

Executing: ['ninja', 'opencv_engine']

ninja: error: unknown target 'opencv_engine'

这样的东西

还要装 brew install ninja

问题2.

出现The "android" command is deprecated.

For manual SDK, AVD, and project management, please use Android Studio.

For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager

Invalid or unsupported command "update project -p ."

Supported commands are:

android list target

android list avd

android list device

android create avd

android move avd

android delete avd

android list sdk

android update sdk

问题原因:

Android Stdio 的官网sdkMannager提到 AndroidSDK Tolls <25.2.3>

提供了sdkmanager command-line tools 以及舍弃Android命令。

解决方式:更换tool文件夹,下载地址:

http://pan.baidu.com/s/1bpfLIur

问题3:

CMake Error at /Users/water/opencv/opencv-3.3.0/platforms/android/android.toolchain.cmake:313 (file):

file STRINGS file

"/Users/water/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm64/usr/include/android/api-level.h"

cannot be read.

问题原因:发现ndk platform里面没有include头文件

解决方式:下载新的ndk替换没有头文件的对应的platforms文件

step3:运行脚本

./build_sdk.py --ndk_path $ANDROID_NDK_ROOT --sdk_path $ANDROID_HOME work-path opencv-path. work-path opencv-path

./build_sdk.py --ndk_path $ANDROID_DNK_ROOT --sdk_path$=ANDROID_HOME  .  ../../

注解:出现权限错误

注解: NDK_ROOT是NDK 的安装目录, ANDROID_HOME是SDK 的按照目录

work-path 是工作的目录,一般是当前

opencv-path 代码的目录

android update sdk

step4:

1: *.a  20个.a

2种: .so

o -》打包 .a  然后再调用SDK 生成 .so

基本就可以ok了。一路不容易。。。。

最后欣赏下成果


你可能感兴趣的:(Opencv 3.3.0 on Mac10.13.1编译)