diff --git a/docs/en/01-how-to-build/android.md b/docs/en/01-how-to-build/android.md index 6562a78bb..cf2c0f5ae 100644 --- a/docs/en/01-how-to-build/android.md +++ b/docs/en/01-how-to-build/android.md @@ -40,12 +40,12 @@ This doc is only for how to build SDK using android toolchain on linux. - ANDROID NDK 19+ - **Make sure android ndk version >= 19.0**. If not, you can follow instructions below to install android ndk r23b. For more versions of android ndk, please refer to [android ndk website](https://developer.android.com/ndk/downloads). + **Make sure android ndk version >= 19.0**. If not, you can follow instructions below to install android ndk r23c. For more versions of android ndk, please refer to [android ndk website](https://developer.android.com/ndk/downloads). ```bash - wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip - unzip android-ndk-r23b-linux.zip - cd android-ndk-r23b + wget https://dl.google.com/android/repository/android-ndk-r23c-linux.zip + unzip android-ndk-r23c-linux.zip + cd android-ndk-r23c export NDK_PATH=${PWD} ``` @@ -67,7 +67,7 @@ You can skip this chapter if only interested in model converter.
-export OPENCV_VERSION=4.5.4
+export OPENCV_VERSION=4.6.0
wget https://github.com/opencv/opencv/releases/download/${OPENCV_VERSION}/opencv-${OPENCV_VERSION}-android-sdk.zip
unzip opencv-${OPENCV_VERSION}-android-sdk.zip
export OPENCV_ANDROID_SDK_DIR=${PWD}/OpenCV-android-sdk
@@ -78,18 +78,23 @@ export OPENCV_ANDROID_SDK_DIR=${PWD}/OpenCV-android-sdk
ncnn
A high-performance neural network inference computing framework supporting for android.
- Now, MMDeploy supports v20220216 and has to use git clone
to download it.
+ Now, MMDeploy supports 20220721 and has to use git clone
to download it. For supported android ABI, see here .
-git clone -b 20220216 https://github.com/Tencent/ncnn.git
+git clone -b 20220721 https://github.com/Tencent/ncnn.git
cd ncnn
git submodule update --init
export NCNN_DIR=${PWD}
-mkdir -p build
-cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-30 -DNCNN_VULKAN=ON -DNCNN_DISABLE_EXCEPTION=OFF -DNCNN_DISABLE_RTTI=OFF ..
-make install
+
+export ANDROID_ABI=arm64-v8a
+
+mkdir -p build\_${ANDROID_ABI}
+cd build\_${ANDROID_ABI}
+
+cmake -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${ANDROID_ABI}" -DANDROID_PLATFORM=android-30 -DNCNN_VULKAN=ON -DNCNN_DISABLE_EXCEPTION=OFF -DNCNN_DISABLE_RTTI=OFF ..
+make -j$(nproc) install
-
+
+
OpenJDK
@@ -151,14 +156,14 @@ make install
Enabling inference engine.
By default, no target inference engine is set, since it highly depends on the use case.
Only ncnn backend is supported for android platform now.
After specifying the inference engine, it's package path has to be passed to cmake as follows,
1. ncnn: ncnn. ncnn_DIR
is needed.
--Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn
+-Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn
MMDEPLOY_CODEBASES
{"mmcls", "mmdet", "mmseg", "mmedit", "mmocr", "all"}
N/A
- Enable codebase's postprocess modules. It MUST be set by a semicolon separated list of codebase names. The currently supported codebases are 'mmcls', 'mmdet', 'mmedit', 'mmseg', 'mmocr'. Instead of listing them one by one, you can also pass all
to enable them all, i.e., -DMMDEPLOY_CODEBASES=all
+ Enable codebase's postprocess modules. It MUST be set by a semicolon separated list of codebase names. The currently supported codebases are 'mmcls', 'mmdet', 'mmedit', 'mmseg', 'mmocr'. Instead of listing them one by one, you can also pass all
to enable them all, i.e., -DMMDEPLOY_CODEBASES=all
Please manually edit csrc/mmdeploy/apis/java/native/CMakeLists.txt
to avoid compilation errors.
MMDEPLOY_SHARED_LIBS
@@ -175,18 +180,19 @@ MMDeploy provides a recipe as shown below for building SDK with ncnn as inferenc
- cpu + ncnn
```Bash
+ export ANDROID_ABI=arm64-v8a
cd ${MMDEPLOY_DIR}
- mkdir -p build && cd build
+ mkdir -p build_${ANDROID_ABI} && cd build_${ANDROID_ABI}
cmake .. \
-DMMDEPLOY_BUILD_SDK=ON \
-DMMDEPLOY_BUILD_SDK_JAVA_API=ON \
- -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-arm64-v8a \
- -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn \
+ -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-${ANDROID_ABI} \
+ -Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn \
-DMMDEPLOY_TARGET_BACKENDS=ncnn \
-DMMDEPLOY_CODEBASES=all \
- -DMMDEPLOY_SHARED_LIBS=OFF \
+ -DMMDEPLOY_SHARED_LIBS=ON \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- -DANDROID_ABI=arm64-v8a \
+ -DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-30 \
-DANDROID_CPP_FEATURES="rtti exceptions"
@@ -196,14 +202,16 @@ MMDeploy provides a recipe as shown below for building SDK with ncnn as inferenc
#### Build Demo
```Bash
-cd ${MMDEPLOY_DIR}/build/install/example
+export ANDROID_ABI=arm64-v8a
+
+cd ${MMDEPLOY_DIR}/build_${ANDROID_ABI}/install/example
mkdir -p build && cd build
cmake .. \
- -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-arm64-v8a \
- -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn \
- -DMMDeploy_DIR=${MMDEPLOY_DIR}/build/install/lib/cmake/MMDeploy \
+ -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-${ANDROID_ABI} \
+ -Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn \
+ -DMMDeploy_DIR=${MMDEPLOY_DIR}/build_${ANDROID_ABI}/install/lib/cmake/MMDeploy \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- -DANDROID_ABI=arm64-v8a \
+ -DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-30
make -j$(nproc)
```
diff --git a/docs/zh_cn/01-how-to-build/android.md b/docs/zh_cn/01-how-to-build/android.md
index 09f5dcb05..4e55384e2 100644
--- a/docs/zh_cn/01-how-to-build/android.md
+++ b/docs/zh_cn/01-how-to-build/android.md
@@ -40,12 +40,12 @@ MMDeploy 的交叉编译分为两步:
- ANDROID NDK 19+
- **保证 android ndk 的版本 >= 19.0**. 如果不是,可以参考以下命令安装 r23b 版本. 如要获取其他版本,请参考 [这里](https://developer.android.com/ndk/downloads)
+ **保证 android ndk 的版本 >= 19.0**. 如果不是,可以参考以下命令安装 r23c 版本. 如要获取其他版本,请参考 [这里](https://developer.android.com/ndk/downloads)
```bash
- wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
- unzip android-ndk-r23b-linux.zip
- cd android-ndk-r23b
+ wget https://dl.google.com/android/repository/android-ndk-r23c-linux.zip
+ unzip android-ndk-r23c-linux.zip
+ cd android-ndk-r23c
export NDK_PATH=${PWD}
```
@@ -67,7 +67,7 @@ MMDeploy 的交叉编译分为两步:
OpenCV
(>=3.0)
-export OPENCV_VERSION=4.5.4
+export OPENCV_VERSION=4.6.0
wget https://github.com/opencv/opencv/releases/download/${OPENCV_VERSION}/opencv-${OPENCV_VERSION}-android-sdk.zip
unzip opencv-${OPENCV_VERSION}-android-sdk.zip
export OPENCV_ANDROID_SDK_DIR=${PWD}/OpenCV-android-sdk
@@ -78,18 +78,24 @@ export OPENCV_ANDROID_SDK_DIR=${PWD}/OpenCV-android-sdk
ncnn
ncnn 是支持 android 平台的高效神经网络推理计算框架
- 目前, MMDeploy 支持 ncnn 的 20220216 版本, 且必须使用git clone
下载源码的方式安装
+ 目前, MMDeploy 支持 ncnn 的 20220721 版本, 且必须使用git clone
下载源码的方式安装。请到 这里 查询 ncnn 支持的 android ABI。
+
-git clone -b 20220216 https://github.com/Tencent/ncnn.git
+git clone -b 20220721 https://github.com/Tencent/ncnn.git
cd ncnn
git submodule update --init
export NCNN_DIR=${PWD}
-mkdir -p build
-cd build
-cmake -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-30 -DNCNN_VULKAN=ON -DNCNN_DISABLE_EXCEPTION=OFF -DNCNN_DISABLE_RTTI=OFF ..
-make install
+
+export ANDROID_ABI=arm64-v8a
+
+mkdir -p build_${ANDROID_ABI}
+cd build_${ANDROID_ABI}
+
+cmake -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${ANDROID_ABI}" -DANDROID_PLATFORM=android-30 -DNCNN_VULKAN=ON -DNCNN_DISABLE_EXCEPTION=OFF -DNCNN_DISABLE_RTTI=OFF ..
+make -j$(nproc) install
-
+
+
OpenJDK
@@ -120,6 +126,12 @@ make install
OFF
MMDeploy SDK 编译开关
+
+ MMDEPLOY_BUILD_SDK_PYTHON_API
+ {ON, OFF}
+ OFF
+ MMDeploy SDK Python API的编译开关
+
MMDEPLOY_BUILD_SDK_JAVA_API
{ON, OFF}
@@ -145,14 +157,14 @@ make install
设置推理后端.
默认情况下,SDK不设置任何后端, 因为它与应用场景高度相关.
Android 端目前只支持ncnn一个后端
构建时,几乎每个后端,都需传入一些路径变量,用来查找依赖包.
1. ncnn: 表示 ncnn. 需要设置ncnn_DIR
.
--Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn
+-Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn
MMDEPLOY_CODEBASES
{"mmcls", "mmdet", "mmseg", "mmedit", "mmocr", "all"}
N/A
- 用来设置 SDK 后处理组件,加载 OpenMMLab 算法仓库的后处理功能. 已支持的算法仓库有'mmcls','mmdet','mmedit','mmseg'和'mmocr'. 如果选择多个codebase,中间使用分号隔开. 比如, 'mmcls', 'mmdet', 'mmedit', 'mmseg', 'mmocr'. 也可以通过 all
的方式, 加载所有codebase, 即 -DMMDEPLOY_CODEBASES=all.
+ 用来设置 SDK 后处理组件,加载 OpenMMLab 算法仓库的后处理功能. 已支持的算法仓库有'mmcls','mmdet','mmedit','mmseg'和'mmocr'. 如果选择多个codebase,中间使用分号隔开. 比如, 'mmcls', 'mmdet', 'mmedit', 'mmseg', 'mmocr'. 也可以通过 all
的方式, 加载所有codebase, 即 -DMMDEPLOY_CODEBASES=all.
。请同时手动编辑 csrc/mmdeploy/apis/java/native/CMakeLists.txt
以避免编译错误。
MMDEPLOY_SHARED_LIBS
@@ -169,18 +181,19 @@ make install
- cpu + ncnn
```Bash
+ export ANDROID_ABI=arm64-v8a
cd ${MMDEPLOY_DIR}
- mkdir -p build && cd build
+ mkdir -p build_${ANDROID_ABI} && cd build_${ANDROID_ABI}
cmake .. \
-DMMDEPLOY_BUILD_SDK=ON \
-DMMDEPLOY_BUILD_SDK_JAVA_API=ON \
- -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-arm64-v8a \
- -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn \
+ -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-${ANDROID_ABI} \
+ -Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn \
-DMMDEPLOY_TARGET_BACKENDS=ncnn \
-DMMDEPLOY_CODEBASES=all \
- -DMMDEPLOY_SHARED_LIBS=OFF \
+ -DMMDEPLOY_SHARED_LIBS=ON \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- -DANDROID_ABI=arm64-v8a \
+ -DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-30 \
-DANDROID_CPP_FEATURES="rtti exceptions"
@@ -190,14 +203,16 @@ make install
#### 编译 Demo
```Bash
-cd ${MMDEPLOY_DIR}/build/install/example
+export ANDROID_ABI=arm64-v8a
+
+cd ${MMDEPLOY_DIR}/build_${ANDROID_ABI}/install/example
mkdir -p build && cd build
cmake .. \
- -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-arm64-v8a \
- -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn \
- -DMMDeploy_DIR=${MMDEPLOY_DIR}/build/install/lib/cmake/MMDeploy \
+ -DOpenCV_DIR=${OPENCV_ANDROID_SDK_DIR}/sdk/native/jni/abi-${ANDROID_ABI} \
+ -Dncnn_DIR=${NCNN_DIR}/build_${ANDROID_ABI}/install/lib/cmake/ncnn \
+ -DMMDeploy_DIR=${MMDEPLOY_DIR}/build_${ANDROID_ABI}/install/lib/cmake/MMDeploy \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
- -DANDROID_ABI=arm64-v8a \
+ -DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_PLATFORM=android-30
make -j$(nproc)
```