diff --git a/README_CN.md b/README_CN.md index eb0b8e723..32b9fb3c3 100644 --- a/README_CN.md +++ b/README_CN.md @@ -41,29 +41,29 @@ - 🔥 [**【三日部署直播课回放】**](https://aistudio.baidu.com/aistudio/course/introduce/27800) - **社区交流** - + - **Slack**:Join our [Slack community](https://join.slack.com/t/fastdeployworkspace/shared_invite/zt-1hhvpb279-iw2pNPwrDaMBQ5OQhO3Siw) and chat with other community members about ideas - + - **微信**:扫描二维码,填写问卷加入技术社区,与社区开发者探讨部署的痛点与方案 - +
- 🔥 **2022.11.23:Release FastDeploy [release v0.8.0](https://github.com/PaddlePaddle/FastDeploy/tree/release/0.8)** - + - **🖥️ 服务端部署:支持更多的模型,推理性能进一步提升** - + - 新增 PIPNet、FaceLandmark1000 [人脸对齐模型](./examples/vision/facealign)的部署支持; - 新增[视频超分系列模型](./examples/vision/sr) PP-MSVSR、EDVR、BasicVSR 部署示例; - 升级[YOLOv7部署代码](https://github.com/PaddlePaddle/FastDeploy/pull/611),支持 predict 及 batch_predict; - 新增 [UIE服务化部署](./examples/text/uie) 案例; - [测试功能] 新增OpenVINO后端Device设置,支持集显/独立显卡的调用; - + - **📲 移动端和端侧部署:支持更多模型** - + - 新增Android图像分类、目标检测、语义分割、OCR、人脸检测 APK工程及示例. - + | 图像分类 | 目标检测 | 语义分割 | 文字识别 | 人脸检测 | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [工程代码](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification) | [工程代码](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection) | [工程代码](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/segmentation) | [工程代码](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/ocr) | [工程代码](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet) | @@ -75,61 +75,61 @@ ## 目录 *
📖 文档教程(点击可收缩)
- + - 安装文档 - + - [预编译库下载安装](docs/cn/build_and_install/download_prebuilt_libraries.md) - [GPU部署环境编译安装](docs/cn/build_and_install/gpu.md) - [CPU部署环境编译安装](docs/cn/build_and_install/cpu.md) - [IPU部署环境编译安装](docs/cn/build_and_install/ipu.md) - [Jetson部署环境编译安装](docs/cn/build_and_install/jetson.md) - [Android平台部署环境编译安装](docs/cn/build_and_install/android.md) - + - 快速使用 - + - [Python部署示例](docs/cn/quick_start/models/python.md) - [C++部署示例](docs/cn/quick_start/models/cpp.md) - [Runtime Python使用示例](docs/cn/quick_start/runtime/python.md) - [Runtime C++使用示例](docs/cn/quick_start/runtime/cpp.md) - + - API文档(进行中) - + - [Python API文档](https://www.paddlepaddle.org.cn/fastdeploy-api-doc/python/html/) - [C++ API文档](https://www.paddlepaddle.org.cn/fastdeploy-api-doc/cpp/html/) - + - 性能调优 - + - [量化加速](docs/cn/quantize.md) - + - 常见问题 - + - [1. 如何配置模型部署的推理后端](docs/cn/faq/how_to_change_backend.md) - [2. Windows上C++ SDK如何使用](docs/cn/faq/use_sdk_on_windows.md) - - [3. Android上如何使用FastDeploy](docs/cn/faq/use_sdk_on_android.md)(进行中) + - [3. Android上如何使用FastDeploy](java/android/README.md) - [4. TensorRT使用中的一些技巧](docs/cn/faq/tensorrt_tricks.md) - [5. 如何增加新的模型](docs/cn/faq/develop_a_new_model.md)(进行中) - + - 更多FastDeploy部署模块 - + - [服务化部署](./serving) - + - [Benchmark测试](./benchmark) - +
* **🖥️ 服务器端部署** - + * [Python SDK快速开始](#fastdeploy-quick-start-python) * [C++ SDK快速开始](#fastdeploy-quick-start-cpp) * [服务端模型支持列表](#fastdeploy-server-models) * **📲 移动端和端侧部署** - + * [Paddle Lite NPU部署](#fastdeploy-edge-sdk-npu) * [端侧模型支持列表](#fastdeploy-edge-models) * **🌐 Web和小程序部署** - + * [Web端模型支持列表](#fastdeploy-web-models) * [**社区交流**](#fastdeploy-community) @@ -180,7 +180,7 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000 ``` * 测试推理结果 - + ```python # GPU/TensorRT部署参考 examples/vision/detection/paddledetection/python import cv2 diff --git a/README_EN.md b/README_EN.md index df7d2d884..593314a36 100644 --- a/README_EN.md +++ b/README_EN.md @@ -40,29 +40,29 @@ Including image classification, object detection, image segmentation, face detec ## 📣 Recent Updates - **Community** - + - **Slack**:Join our [Slack community](https://join.slack.com/t/fastdeployworkspace/shared_invite/zt-1hhvpb279-iw2pNPwrDaMBQ5OQhO3Siw) and chat with other community members about ideas. - + - **WeChat**:Scan the QR code below using WeChat, follow the PaddlePaddle official account and fill out the questionnaire to join the WeChat group. - +
- 🔥 **2022.11.23:Release FastDeploy [release v0.8.0](https://github.com/PaddlePaddle/FastDeploy/tree/release/0.8.0)**
- + - **🖥️ Server-side and Cloud Deployment: Support more CV models, improve deployment performance** - + - Support [PIPNet](./examples/vision/facealign/pipnet), [FaceLandmark1000](./examples/vision/facealign/face_landmark_1000) face alignment models deployment; - Support [Video Super-Resolution](./examples/vision/sr) series model PP-MSVSR、EDVR、BasicVSR; - Upgrade YOLOv7 deployment code to add `batch_predict` deployment; - Support [UIE service-based](./examples/text/uie) deployment; - Add Python API to_dlpack interface for FDTensor to support copyless transfer of FDTensor between frameworks. - + - **📱 Mobile and Edge Device Deployment: support more CV model** - + - Support Android image classification, target detection, semantic segmentation, OCR, face detection APK projects and examples. - + | Image Classification | Object Detection | Semantic Segmentation | OCR | Face Detection | |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | [Project Code](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification) | [Project Code](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection) | [Project Code](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/segmentation) | [Project Code](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/ocr) | [Project Code](https://github.com/PaddlePaddle/FastDeploy/tree/develop/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet) | @@ -74,60 +74,60 @@ Including image classification, object detection, image segmentation, face detec ## Contents *
📖 Tutorials(click to fold)
- + - Install - + - [Install FastDeploy Prebuilt Libraries](docs/en/build_and_install/download_prebuilt_libraries.md) - [Build and Install FastDeploy Library on GPU Platform](docs/en/build_and_install/gpu.md) - [Build and Install FastDeploy Library on CPU Platform](docs/en/build_and_install/cpu.md) - [Build and Install FastDeploy Library on IPU Platform](docs/en/build_and_install/ipu.md) - [Build and Install FastDeploy Library on Nvidia Jetson Platform](docs/en/build_and_install/jetson.md) - [Build and Install FastDeploy Library on Android Platform](docs/en/build_and_install/android.md) - + - A Quick Start - Demos - + - [Python Deployment Demo](docs/en/quick_start/models/python.md) - [C++ Deployment Demo](docs/en/quick_start/models/cpp.md) - [A Quick Start on Runtime Python](docs/en/quick_start/runtime/python.md) - [A Quick Start on Runtime C++](docs/en/quick_start/runtime/cpp.md) - + - API (To be continued) - + - [Python API](https://baidu-paddle.github.io/fastdeploy-api/python/html/) - [C++ API](https://baidu-paddle.github.io/fastdeploy-api/cpp/html/) - + - Performance Optimization - + - [Quantization Acceleration](docs/en/quantize.md) - + - Frequent Q&As - + - [1. How to Change Inference Backends](docs/en/faq/how_to_change_backend.md) - [2. How to Use FastDeploy C++ SDK on Windows Platform](docs/en/faq/use_sdk_on_windows.md) - - [3. How to Use FastDeploy C++ SDK on Android Platform](docs/en/faq/use_sdk_on_android.md)(To be Continued) + - [3. How to Use FastDeploy C++ SDK on Android Platform](java/android/README_EN.md)(To be Continued) - [4. Tricks of TensorRT](docs/en/faq/tensorrt_tricks.md) - [5. How to Develop a New Model](docs/en/faq/develop_a_new_model.md)(To be Continued) - + - More FastDeploy Deployment Module - + - [deployment AI Model as a Service](./serving) - + - [Benchmark Testing](./benchmark)
* **🖥️ Server-side and Cloud Deployment** - + * [A Quick Start for Python SDK](#fastdeploy-quick-start-python) * [A Quick Start for C++ SDK](#fastdeploy-quick-start-cpp) * [Supported Server-side and Cloud Model List](#fastdeploy-server-models) * **📱 Mobile and Edge Device Deployment** - + * [Supported Mobile and Edge Model List](#fastdeploy-edge-models) * **🌐 Browser and Mini Program Deployment** - + * [Supported Web and Mini Program Model List](#fastdeploy-web-models) * [**Community**](#fastdeploy-community) diff --git a/docs/cn/faq/use_cpp_sdk_on_android.md b/docs/cn/faq/use_cpp_sdk_on_android.md index bdea635b4..03f6dcad2 100644 --- a/docs/cn/faq/use_cpp_sdk_on_android.md +++ b/docs/cn/faq/use_cpp_sdk_on_android.md @@ -44,9 +44,9 @@ public class PicoDet { } } ``` -这些被标记为native的接口是需要通过JNI的方式实现,并在Java层供PicoDet类调用。完整的PicoDet Java代码请参考 [PicoDet.java](../../../examples/vision/detection/paddledetection/android/app/src/main/java/com/baidu/paddle/fastdeploy/vision/detection/PicoDet.java) 。各个函数说明如下: +这些被标记为native的接口是需要通过JNI的方式实现,并在Java层供PicoDet类调用。完整的PicoDet Java代码请参考 [PicoDet.java](../../../java/android/fastdeploy/src/main/java/com/baidu/paddle/fastdeploy/vision/detection/PicoDet.java) 。各个函数说明如下: - `bindNative`: C++层初始化模型资源,如果成功初始化,则返回指向该模型的指针(long类型),否则返回0指针 -- `predictNative`: 通过已经初始化好的模型指针,在C++层执行预测代码,如果预测成功则返回指向预测结果的指针,否则返回0指针。注意,该结果指针在当次预测使用完之后需要释放,具体操作请参考 [PicoDet.java](../../../examples/vision/detection/paddledetection/android/app/src/main/java/com/baidu/paddle/fastdeploy/vision/detection/PicoDet.java) 中的predict函数。 +- `predictNative`: 通过已经初始化好的模型指针,在C++层执行预测代码,如果预测成功则返回指向预测结果的指针,否则返回0指针。注意,该结果指针在当次预测使用完之后需要释放,具体操作请参考 [PicoDet.java](../../../java/android/fastdeploy/src/main/java/com/baidu/paddle/fastdeploy/vision/detection/PicoDet.java) 中的predict函数。 - `releaseNative`: 根据传入的模型指针,在C++层释放模型资源。 ## Android Studio 生成JNI函数定义 @@ -70,89 +70,96 @@ Android Studio 生成 JNI 函数定义: 鼠标停留在Java中定义的native函 以下为PicoDet JNI层实现的示例,相关的辅助函数不在此处赘述,完整的C++代码请参考 [android/app/src/main/cpp](../../../examples/vision/detection/paddledetection/android/app/src/main/cpp/). ```C++ +// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #include // NOLINT -#include "fastdeploy_jni.h" // NOLINT +#include "fastdeploy_jni/convert_jni.h" // NOLINT +#include "fastdeploy_jni/assets_loader_jni.h" // NOLINT +#include "fastdeploy_jni/runtime_option_jni.h" // NOLINT +#include "fastdeploy_jni/vision/results_jni.h" // NOLINT +#include "fastdeploy_jni/vision/detection/detection_utils_jni.h" // NOLINT + +namespace fni = fastdeploy::jni; +namespace vision = fastdeploy::vision; +namespace detection = fastdeploy::vision::detection; #ifdef __cplusplus extern "C" { #endif -// 绑定C++层的模型 JNIEXPORT jlong JNICALL Java_com_baidu_paddle_fastdeploy_vision_detection_PicoDet_bindNative( - JNIEnv *env, jclass clazz, jstring model_file, jstring params_file, - jstring config_file, jint cpu_num_thread, jboolean enable_lite_fp16, - jint lite_power_mode, jstring lite_optimized_model_dir, - jboolean enable_record_time_of_runtime, jstring label_file) { - std::string c_model_file = fastdeploy::jni::ConvertTo(env, model_file); - std::string c_params_file = fastdeploy::jni::ConvertTo(env, params_file); - std::string c_config_file = astdeploy::jni::ConvertTo(env, config_file); - std::string c_label_file = fastdeploy::jni::ConvertTo(env, label_file); - std::string c_lite_optimized_model_dir = fastdeploy::jni::ConvertTo(env, lite_optimized_model_dir); - auto c_cpu_num_thread = static_cast(cpu_num_thread); - auto c_enable_lite_fp16 = static_cast(enable_lite_fp16); - auto c_lite_power_mode = static_cast(lite_power_mode); - fastdeploy::RuntimeOption c_option; - c_option.UseCpu(); - c_option.UseLiteBackend(); - c_option.SetCpuThreadNum(c_cpu_num_thread); - c_option.SetLitePowerMode(c_lite_power_mode); - c_option.SetLiteOptimizedModelDir(c_lite_optimized_model_dir); - if (c_enable_lite_fp16) { - c_option.EnableLiteFP16(); + JNIEnv *env, jobject thiz, jstring model_file, jstring params_file, + jstring config_file, jobject runtime_option, jstring label_file) { + auto c_model_file = fni::ConvertTo(env, model_file); + auto c_params_file = fni::ConvertTo(env, params_file); + auto c_config_file = fni::ConvertTo(env, config_file); + auto c_label_file = fni::ConvertTo(env, label_file); + auto c_runtime_option = fni::NewCxxRuntimeOption(env, runtime_option); + auto c_model_ptr = new detection::PicoDet( + c_model_file, c_params_file, c_config_file, c_runtime_option); + INITIALIZED_OR_RETURN(c_model_ptr) + +#ifdef ENABLE_RUNTIME_PERF + c_model_ptr->EnableRecordTimeOfRuntime(); +#endif + if (!c_label_file.empty()) { + fni::AssetsLoader::LoadDetectionLabels(c_label_file); } - // 如果您实现的是其他模型,比如PPYOLOE,请注意修改此处绑定的C++类型 - auto c_model_ptr = new fastdeploy::vision::detection::PicoDet( - c_model_file, c_params_file, c_config_file, c_option); - // Enable record Runtime time costs. - if (enable_record_time_of_runtime) { - c_model_ptr->EnableRecordTimeOfRuntime(); - } - // Load detection labels if label path is not empty. - if ((!fastdeploy::jni::AssetsLoaderUtils::IsDetectionLabelsLoaded()) && - (!c_label_file.empty())) { - fastdeploy::jni::AssetsLoaderUtils::LoadDetectionLabels(c_label_file); - } - // WARN: need to release manually in Java ! - return reinterpret_cast(c_model_ptr); // native model context + vision::EnableFlyCV(); + return reinterpret_cast(c_model_ptr); } -// 通过传入的模型指针在C++层进行预测 -JNIEXPORT jlong JNICALL +JNIEXPORT jobject JNICALL Java_com_baidu_paddle_fastdeploy_vision_detection_PicoDet_predictNative( - JNIEnv *env, jclass clazz, jlong native_model_context, - jobject argb8888_bitmap, jboolean saved, jstring saved_image_path, - jfloat score_threshold, jboolean rendering) { - if (native_model_context == 0) { - return 0; + JNIEnv *env, jobject thiz, jlong cxx_context, jobject argb8888_bitmap, + jboolean save_image, jstring save_path, jboolean rendering, + jfloat score_threshold) { + if (cxx_context == 0) { + return NULL; } cv::Mat c_bgr; - if (!fastdeploy::jni::ARGB888Bitmap2BGR(env, argb8888_bitmap, &c_bgr)) { - return 0; + if (!fni::ARGB888Bitmap2BGR(env, argb8888_bitmap, &c_bgr)) { + return NULL; } - auto c_model_ptr = reinterpret_cast( - native_model_context); - auto c_result_ptr = new fastdeploy::vision::DetectionResult(); - t = fastdeploy::jni::GetCurrentTime(); - if (!c_model_ptr->Predict(&c_bgr, c_result_ptr)) { - delete c_result_ptr; - return 0; + auto c_model_ptr = reinterpret_cast(cxx_context); + vision::DetectionResult c_result; + auto t = fni::GetCurrentTime(); + c_model_ptr->Predict(&c_bgr, &c_result); + PERF_TIME_OF_RUNTIME(c_model_ptr, t) + + if (rendering) { + fni::RenderingDetection(env, c_bgr, c_result, argb8888_bitmap, save_image, + score_threshold, save_path); } - // ... - return reinterpret_cast(c_result_ptr); // native result context + + return fni::NewJavaResultFromCxx(env, reinterpret_cast(&c_result), + vision::ResultType::DETECTION); } -// 在C++层释放模型资源 JNIEXPORT jboolean JNICALL Java_com_baidu_paddle_fastdeploy_vision_detection_PicoDet_releaseNative( - JNIEnv *env, jclass clazz, jlong native_model_context) { - if (native_model_context == 0) { + JNIEnv *env, jobject thiz, jlong cxx_context) { + if (cxx_context == 0) { return JNI_FALSE; } - auto c_model_ptr = reinterpret_cast( - native_model_context); - // ... + auto c_model_ptr = reinterpret_cast(cxx_context); + PERF_TIME_OF_RUNTIME(c_model_ptr, -1) + delete c_model_ptr; + LOGD("[End] Release PicoDet in native !"); return JNI_TRUE; } @@ -184,6 +191,11 @@ android { version '3.10.2' } } + sourceSets { + main { + jniLibs.srcDirs = ['libs'] + } + } ndkVersion '20.1.5948944' } ``` @@ -192,7 +204,8 @@ android { cmake_minimum_required(VERSION 3.10.2) project("fastdeploy_jni") -set(FastDeploy_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/fastdeploy-android-0.4.0-shared") +# 其中 xxx 表示对应C++ SDK的版本号 +set(FastDeploy_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/fastdeploy-android-xxx-shared") find_package(FastDeploy REQUIRED) @@ -221,7 +234,7 @@ target_link_libraries( ${log-lib} ) ``` -完整的工程示例,请参考 [android/app/src/main/cpp/CMakelists.txt](../../../examples/vision/detection/paddledetection/android/app/src/main/cpp/) 以及 [android/app/build.gradle](../../../examples/vision/detection/paddledetection/android/app/build.gradle). +完整的工程示例,请参考 [CMakelists.txt](../../../java/android/fastdeploy/src/main/cpp/CMakeLists.txt) 以及 [build.gradle](../../../java/android/fastdeploy/build.gradle). ## 更多FastDeploy Android 使用案例
diff --git a/docs/cn/faq/use_java_sdk_on_android.md b/docs/cn/faq/use_java_sdk_on_android.md deleted file mode 100644 index 832ca1909..000000000 --- a/docs/cn/faq/use_java_sdk_on_android.md +++ /dev/null @@ -1,2 +0,0 @@ -## 在 Android 中使用 FastDeploy Java SDK -- TODO diff --git a/docs/cn/faq/use_sdk_on_android.md b/docs/cn/faq/use_sdk_on_android.md deleted file mode 100644 index 0add916ce..000000000 --- a/docs/cn/faq/use_sdk_on_android.md +++ /dev/null @@ -1,3 +0,0 @@ -# Android平台使用FastDeploy部署 - -进行中... diff --git a/docs/en/build_and_install/android.md b/docs/en/build_and_install/android.md index 043cc667e..4d44777da 100644 --- a/docs/en/build_and_install/android.md +++ b/docs/en/build_and_install/android.md @@ -1,3 +1,97 @@ -# How to Build Android Deployment Library +# How to Build FastDeploy Android C++ SDK -coming soon... +FastDeploy supports Paddle-Lite backend on Android. It supports both armeabi-v7a and arm64-v8a cpu architectures, and supports fp16 precision inference on the armv8.2 architecture. The relevant compilation options are described as follows: + +|Option|Default|Description|Remark| +|:---|:---|:---|:---| +|ENABLE_LITE_BACKEND|OFF|It needs to be set to ON when compiling the Android library| - | +|WITH_OPENCV_STATIC|OFF|Whether to use the OpenCV static library| - | +|WITH_LITE_STATIC|OFF|Whether to use the Paddle-Lite static library| NOT Support now | + +Please reference [FastDeploy Compile Options](./README.md) for more details. + +## Build Android C++ SDK + +Prerequisite for Compiling on Android: + +- Android SDK API >= 21 +- Android NDK >= 20 (Only support clang toolchain now) +- cmake >= 3.10.0 + +Please check if the Android SDK and NDK is ready or not before building: +```bash +➜ echo $ANDROID_SDK +/Users/xxx/Library/Android/sdk +➜ echo $ANDROID_NDK +/Users/xxx/Library/Android/sdk/ndk/25.1.8937393 +``` +It is recommended to use NDK>=20 for cross compilation, the compilation command is as follows: +```bash +# Download the latest source code +git clone https://github.com/PaddlePaddle/FastDeploy.git +cd FastDeploy + +# Setting up Android toolchanin +ANDROID_ABI=arm64-v8a # 'arm64-v8a', 'armeabi-v7a' +ANDROID_PLATFORM="android-21" # API >= 21 +ANDROID_STL=c++_shared # 'c++_shared', 'c++_static' +ANDROID_TOOLCHAIN=clang # 'clang' only +TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake + +# Create build directory +BUILD_ROOT=build/Android +BUILD_DIR=${BUILD_ROOT}/${ANDROID_ABI}-api-21 +FASDEPLOY_INSTALL_DIR="${BUILD_DIR}/install" +mkdir build && mkdir ${BUILD_ROOT} && mkdir ${BUILD_DIR} +cd ${BUILD_DIR} + +# CMake configuration with Android toolchain +cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DANDROID_ABI=${ANDROID_ABI} \ + -DANDROID_NDK=${ANDROID_NDK} \ + -DANDROID_PLATFORM=${ANDROID_PLATFORM} \ + -DANDROID_STL=${ANDROID_STL} \ + -DANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN} \ + -DENABLE_LITE_BACKEND=ON \ + -DENABLE_VISION=ON \ + -DCMAKE_INSTALL_PREFIX=${FASDEPLOY_INSTALL_DIR} \ + -Wno-dev ../../.. + +# Build FastDeploy Android C++ SDK +make -j8 +make install +``` +After the compilation is complete, the Android C++ SDK is saved in the `build/Android/arm64-v8a-api-21/install` directory, the directory structure is as follows: +```bash +➜ tree . -d -L 3 +. +├── examples +├── include +│   └── fastdeploy # FastDeploy headers +├── lib +│   └── arm64-v8a # FastDeploy Android libs +└── third_libs # Third parties libs + └── install + ├── opencv + ├── flycv + └── paddlelite +``` +You can check the Android C++ SDK use cases in the examples/vision directory: +```bash +. +├── classification +│   ├── paddleclas +│   │   ├── android # classification demo for Android +│   │   ├── cpp +... +├── detection +│   ├── paddledetection +│   │   ├── android # object detection demo for Android +│   │   ├── cpp +... +``` +About How to use FastDeploy Android C++ SDK, Please refer to the use case documentation: +- [Image Classification Android Documentation](../../../examples/vision/classification/paddleclas/android/README.md) +- [Object Detection Android Documentation](../../../examples/vision/detection/paddledetection/android/README.md) +- [Using FastDeploy C++ SDK in Android via JNI](../../en/faq/use_cpp_sdk_on_android.md) diff --git a/docs/en/faq/use_sdk_on_android.md b/docs/en/faq/use_cpp_sdk_on_android.md similarity index 100% rename from docs/en/faq/use_sdk_on_android.md rename to docs/en/faq/use_cpp_sdk_on_android.md diff --git a/java/android/README_EN.md b/java/android/README_EN.md new file mode 100644 index 000000000..f7942a716 --- /dev/null +++ b/java/android/README_EN.md @@ -0,0 +1 @@ +- TODO