opencv cmake android,Ubuntu+Cmake-gui+OpenCV+Opencv_contrib+Android的讲解

Using Cmake-gui to build OpenCV and Opencv_contrib for Android on Ubuntu !

一、Compiler Environment & Tools Versions

1.Cmake-gui 3.18.0

2.OpenCV 4.3.0

3.Opencv_contrib 4.3.0

4.Ubuntu 18.04

二、Cmake-gui configuration

1.select source directory & output directory

7b1e7c0fd81f2f463574ec8c5985723e.png

2.Add Entry for Android

ANDROID_NDK type is PATH,enter NDK path

ANDROID_SDK type is PATH,enter SDK path

ANDROID_ABI type is STRING,default is armeabi-v7a

ANDROID_NATIVE_API_LEVEL type is STRING,default is 21

ANDROID_STL type is STRING,enter c++_static or c++_shared(default gnustl_static)

CMAKE_TOOLCHAIN_FILE type is FILEPATH,

Option1:

870c263cc2a363a447057747cb2918b9.png

a72124cf8cfd2548fc739b4caadb6e72.png

Option2: enter NDK cmake path. likeandroid-ndk-r16b/build/cmake/android.toolchain.cmake

more info can be found in xxx/opencv/platforms/android/android.toolchain.cmake

then click the button Configure in bottom. if no errors, it will be show logs as below:

Parallel framework: pthreads Trace: YES (with Intel ITT) Other third-party libraries: Custom HAL: NO Protobuf: build (3.5.1) Python (for build): /usr/bin/python3 Java: export all functions ant: NO Java wrappers: YES Java tests: NO Install to: /home/xxx/Document/player/build-opencv-for-android/opencv430/build/install ----------------------------------------------------------------- Configuring done

3.Set Configuration for OpenCV(Options)

OPENCV_EXTRA_MODULES_PATH set value:xxx/Document/player/build-opencv-for-android/opencv_contrib430/modules

BUILD_ANDROID_PROJECTS=ON Build Android projects providing APK files.

BUILD_ANDROID_EXAMPLES=OFF

BUILD_PERF_TESTS=OFF

BUILD_TESTS=OFF

BUILD_opencv_world=OFF

BUILD_SHARED_LIBS=OFF

WITH_CUDA=OFF

CMAKE_BUILD_TYPE=Release

then click the button Configure in bottom again. Also if no errors, it will be show logs as below:

GUI: Media I/O: ZLib: z (ver 1.2.3) JPEG: build-libjpeg-turbo (ver 2.0.4-62) WEBP: build (ver encoder: 0x020f) PNG: build (ver 1.6.37) TIFF: build (ver 42 - 4.0.10) JPEG 2000: build Jasper (ver 1.900.1) OpenEXR: build (ver 2.3.0) HDR: YES SUNRASTER: YES PXM: YES PFM: YES Video I/O: Parallel framework: pthreads Trace: YES (with Intel ITT) Other third-party libraries: Custom HAL: NO Protobuf: build (3.5.1) Python (for build): /usr/bin/python3 Java: export all functions ant: NO Java wrappers: YES Java tests: NO Install to: xxx/Document/player/build-opencv-for-android/opencv430/build/install ----------------------------------------------------------------- Configuring done

Finally, click the button Generate, and it will be show logs as below:

----------------------------------------------------------------- Configuring done Generating done

三、Build

Note!

Do the stuff below before building:

Copy file xfeatures2d.hpp and directory xfeatures2d

from xxx/opencv_contrib430/modules/xfeatures2d/include/opencv2

to xxx/opencv430/modules/features2d/include/opencv2

result like:

2ec9f05183afb38d1dc17a09475c0dd0.png

otherwise, will occurse error like:

In file included from /home/xxx/Document/player/build-opencv-for-android/opencv-4.3.0/modules/java/generator/src/cpp/opencv_java.cpp:8: In file included from /home/xxx/Document/player/build-opencv-for-android/opencv-4.3.0/output/modules/java_bindings_generator/gen/cpp/opencv_jni.hpp:18: /home/xxx/Document/player/build-opencv-for-android/opencv-4.3.0/output/modules/java_bindings_generator/gen/cpp/xfeatures2d.inl.hpp:12:10: fatal error: 'opencv2/xfeatures2d.hpp' file not found #include "opencv2/xfeatures2d.hpp"

1.Command line build

cd /home/xxx/Document/player/build-opencv-for-android/opencv430/build make -j8

No errors, exeute

make install

references:

Windows环境下为Android编译OpenCV4.3

Ubuntu 16.04下为Android编译OpenCV 3.2.0 Manager

build-opencv-for-android

Windows 下 OpenCV 3.4.0 + Contrib 部署文档 (VS2015 & Android)

Ubuntu16.04编译OpenCV for Android

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值