new demo version

new demo version

new demo version

new demo version

new dome version

new demo version en

 new demo version en

new demo version

fix ci
This commit is contained in:
liuxiao78 2021-01-11 19:55:28 +08:00
parent 21addb331d
commit 5221721c5e
36 changed files with 481 additions and 287 deletions

View File

@ -1,52 +1,67 @@
## Demo of Image Classification
# Demo of Image Classification
The following describes how to use the MindSpore Lite C++ APIs (Android JNIs) and MindSpore Lite image classification models to perform on-device inference, classify the content captured by a device camera, and display the most possible classification result on the application's image preview screen.
### Running Dependencies
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- Native development kit (NDK) 21.3
- CMake 3.10.2 [CMake](https://cmake.org/download)
- Android software development kit (SDK) 26 or later
- JDK 1.8 or later
### Building and Running
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding SDK. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
2. Connect to an Android device and runs the image classification application.
2. Connect to an Android device and runs this application.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
![run_app](images/run_app.PNG)
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings > system and update > developer Options > USB debugging.
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
![result](images/app_result.jpg)
4. The solutions of Android Studio configuration problems:
4. The solutions of configuration problems:
| | Warning | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.propertiesndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download corresponding [NDK Version](https://developer.android.com/ndk/downloads)and specify the sdk directory in Project Structure - Android NDK location.You can refer to the figure below. |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Update Android Studio Version in Tools - help - Checkout for Updates. |
| 4 | SSL peer shut down incorrectly | Run this demo again. |
4.1 Problems of NDK, CMake, JDK Tools:
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
## Detailed Description of the Sample Program
This image classification sample program on the Android device includes a Java layer and a JNI layer. At the Java layer, the Android Camera 2 API is used to enable a camera to obtain image frames and process images. At the JNI layer, the model inference process is completed in [Runtime](https://www.mindspore.cn/tutorial/lite/en/master/use/runtime.html).

View File

@ -1,39 +1,37 @@
## MindSpore Lite 端侧图像分类demoAndroid
# MindSpore Lite 端侧图像分类demoAndroid
本示例程序演示了如何在端侧利用MindSpore Lite C++ APIAndroid JNI以及MindSpore Lite 图像分类模型完成端侧推理实现对设备摄像头捕获的内容进行分类并在App图像预览界面中显示出最可能的分类结果。
### 运行依赖
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26
- JDK >= 1.8
### 构建与运行
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考第4项解决。
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
2. 连接Android设备运行图像分类应用程序。
2. 连接Android设备运行应用程序。
通过USB连接Android设备调试,点击`Run 'app'`即可在您的设备上运行本示例项目。
通过USB连接Android手机。待成功识别到设备后,点击`Run 'app'`即可在您的手机上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
@ -42,16 +40,32 @@
![result](images/app_result.jpg)
4. Android Studio 配置问题解决方案可参考下表:
4. Demo部署问题解决方案。
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
4.1 NDK、CMake、JDK等工具问题
![project_structure](images/project_structure.png)
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@ -1,50 +1,69 @@
## Demo of Image Segmentation
# Demo of Image Segmentation
The following describes how to use the MindSpore Lite JAVA APIs and MindSpore Lite image segmentation models to perform on-device inference, classify the content captured by a device camera, and display the most possible segmentation result on the application's image preview screen.
### Running Dependencies
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- Native development kit (NDK) 21.3
- CMake 3.10.2 [CMake](https://cmake.org/download)
- Android software development kit (SDK) 26 or later
- JDK 1.8 or later
### Building and Running
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding SDK. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
If you have any Android Studio configuration problem when trying this demo, please refer to item 5 to resolve it.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
2. Connect to an Android device and runs the image segmentation application.
2. Connect to an Android device and runs this application.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
![run_app](images/run_app.PNG)
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings > system and update > developer Options > USB debugging.
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
4. The solutions of Android Studio configuration problems:
![result](images/app_result.jpg)
| | Warning | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.propertiesndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download corresponding [NDK Version](https://developer.android.com/ndk/downloads)and specify the sdk directory in Project Structure - Android NDK location.You can refer to the figure below. |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Update Android Studio Version in Tools - help - Checkout for Updates. |
| 4 | SSL peer shut down incorrectly | Run this demo again. |
4. The solutions of configuration problems:
4.1 Problems of NDK, CMake, JDK Tools:
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
![maven](images/maven.jpg)
## Detailed Description of the Sample Program
This image segmentation sample program on the Android device is implemented through Java. At the Java layer, the Android Camera 2 API is used to enable a camera to obtain image frames and process images. Then Java API is called to infer.[Runtime](https://www.mindspore.cn/tutorial/lite/en/master/use/runtime.html).

View File

@ -1,53 +1,71 @@
## MindSpore Lite 端侧图像分割demoAndroid
# MindSpore Lite 端侧图像分割demoAndroid
本示例程序演示了如何在端侧利用MindSpore Lite Java API 以及MindSpore Lite 图像分割模型完成端侧推理实现对设备摄像头捕获的内容进行分割并在App图像预览界面中显示出最可能的分割结果。
### 运行依赖
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26
- JDK >= 1.8
### 构建与运行
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考第4项解决。
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
2. 连接Android设备运行图像分割应用程序。
2. 连接Android设备运行应用程序。
通过USB连接Android设备调试,点击`Run 'app'`即可在您的设备上运行本示例项目。
通过USB连接Android手机。待成功识别到设备后,点击`Run 'app'`即可在您的手机上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
4. Android Studio 配置问题解决方案可参考下表:
如下图所示,识别出的概率最高的物体是植物。
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
![result](images/app_result.jpg)
![project_structure](images/project_structure.png)
4. Demo部署问题解决方案。
4.1 NDK、CMake、JDK等工具问题
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@ -2,49 +2,68 @@
The following describes how to use the MindSpore Lite C++ APIs (Android JNIs) and MindSpore Lite object detection models to perform on-device inference, detect the content captured by a device camera, and display the most possible detection result on the application's image preview screen.
## Deploying an Application
The following section describes how to build and execute an on-device object detecion task on MindSpore Lite.
### Running Dependencies
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- Native development kit (NDK) 21.3
- CMake 3.10.2
- Android software development kit (SDK) 26 or later
- OpenCV 4.0.0 or later (included in the sample code)
### Building and Running
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
![start_home](images/home.png)
If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
2. Connect to an Android device and runs the object detection application.
![start_sdk](images/sdk_management.jpg)
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
![run_app](images/project_structure.png)
2. Connect to an Android device and runs this application.
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device>.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
![run_app](images/run_app.PNG)
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
![result](images/object_detection.png)
![result](images/app_result.jpg)
4. The solutions of Android Studio configuration problems:
4. The solutions of configuration problems:
| | Warning | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.propertiesndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download corresponding [NDK Version](https://developer.android.com/ndk/downloads)and specify the sdk directory in Project Structure - Android NDK location.You can refer to the figure below. |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Update Android Studio Version in Tools - help - Checkout for Updates. |
| 4 | SSL peer shut down incorrectly | Run this demo again. |
4.1 Problems of NDK, CMake, JDK Tools:
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
![maven](images/maven.jpg)
## Detailed Description of the Sample Program
This object detection sample program on the Android device includes a Java layer and a JNI layer. At the Java layer, the Android Camera 2 API is used to enable a camera to obtain image frames and process images. At the JNI layer, the model inference process is completed .

View File

@ -5,49 +5,67 @@
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10
- Android SDK >= 26
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考第4项解决。
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
2. 连接Android设备运行目标检测示例应用程序。
2. 连接Android设备运行应用程序。
通过USB连接Android设备调试点击`Run 'app'`即可在你的设备上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
通过USB连接Android手机。待成功识别到设备后点击`Run 'app'`即可在您的手机上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
如下图所示,检测出图中内容是鼠标
如下图所示,识别出的概率最高的物体是植物
![result](images/object_detection.png)
![result](images/app_result.jpg)
4. Android Studio 配置问题解决方案可参考下表:
4. Demo部署问题解决方案。
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
4.1 NDK、CMake、JDK等工具问题
![project_structure](images/project_structure.png)
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@ -5,52 +5,65 @@ This sample application demonstrates how to use the MindSpore Lite API and skele
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- NDK 21.3
- CMake 3.10
- Android software development kit (SDK) 26 or later
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding SDK. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
If an Android Studio configuration error occurs, solve it by referring to the following solution table in item 4.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
2. Connect to an Android device and run the skeleton detection sample application.
2. Connect to an Android device and runs this application.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
> During the building, Android Studio automatically downloads dependencies related to MindSpore Lite and model files. Please wait.
![run_app](images/run_app.PNG)
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device>.
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
![install](images/install.jpg)
![result](images/app_result.jpg)
The following figure shows the output of the skeletal detection model.
4. The solutions of configuration problems:
The blue points are used to detect facial features and limb bone movement trends. The confidence score of this inference is 0.98/1, and the inference delay is 66.77 ms.
4.1 Problems of NDK, CMake, JDK Tools:
![sult](images/posenet_detection.png)
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
4. The following table lists solutions to Android Studio configuration errors.
| | Error | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the NDK installation directory in the local.properties file: ndk.dir={NDK installation directory} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download the corresponding [NDK version](https://developer.android.com/ndk/downloads) and specify the SDK location in the `Android NDK location` field (see the following figure). |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Choose `Help` > `Checkout for Updates` on the toolbar to update the version. |
| 4 | SSL peer shut down incorrectly | Rebuild. |
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
![maven](images/maven.jpg)
## Detailed Description of the Sample Application
The skeleton detection sample application on the Android device uses the Android Camera 2 API to enable a camera to obtain image frames and process images, as well as using [runtime](https://www.mindspore.cn/tutorial/lite/en/master/use/runtime.html) to complete model inference.

View File

@ -5,51 +5,67 @@
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10
- Android SDK >= 26
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考第4项解决。
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
2. 连接Android设备运行骨骼检测示例应用程序。
2. 连接Android设备运行该应用程序。
通过USB连接Android手机。待成功识别到设备后点击`Run 'app'`即可在您的手机上运行本示例项目。
通过USB连接Android设备调试点击`Run 'app'`即可在你的设备上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
使用骨骼检测模型的输出如图:
如下图所示,识别出的概率最高的物体是植物。
蓝色标识点检测人体面部的五官分布及上肢、下肢的骨骼走势。此次推理置信分数0.98/1推理时延66.77ms。
![result](images/app_result.jpg)
![sult](images/posenet_detection.png)
4. Demo部署问题解决方案。
4. Android Studio 配置问题解决方案可参考下表
4.1 NDK、CMake、JDK等工具问题
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
![project_structure](images/project_structure.png)
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@ -5,43 +5,64 @@ This sample application demonstrates how to use the MindSpore Lite C++ API (Andr
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- NDK 21.3
- CMake 3.10
- Android software development kit (SDK) 26 or later
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding SDK. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
If an Android Studio configuration error occurs, solve it by referring to the following table.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
| | Error | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the NDK installation directory in the local.properties file: ndk.dir={NDK installation directory} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download the corresponding [NDK version](https://developer.android.com/ndk/downloads) and specify the SDK location in the `Android NDK location` field (see the following figure). |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Choose `Help` > `Checkout for Updates` on the toolbar to update the version. |
| 4 | SSL peer shut down incorrectly | Rebuild. |
![project_structure](images/project_structure.png)
2. Connect to an Android device and run the scene detection sample application.
2. Connect to an Android device and runs this application.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
> During the building, Android Studio automatically downloads dependencies related to MindSpore Lite and model files. Please wait.
![run_app](images/run_app.PNG)
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device>.
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
![install](images/install.jpg)
![result](images/app_result.jpg)
4. The solutions of configuration problems:
4.1 Problems of NDK, CMake, JDK Tools:
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
![maven](images/maven.jpg)
## Detailed Description of the Sample Application

View File

@ -1,54 +1,74 @@
## MindSpore Lite 端侧场景检测demoAndroid
# MindSpore Lite 端侧场景检测demoAndroid
本示例程序演示了如何在端侧利用MindSpore Lite C++ APIAndroid JNI以及MindSpore Lite 场景检测模型完成端侧推理对设备摄像头捕获的内容进行检测并在App图像预览界面中显示连续目标检测结果。
### 运行依赖
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10
- Android SDK >= 26
### 构建与运行
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考下表解决
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
2. 连接Android设备运行该应用程序。
![project_structure](images/project_structure.png)
通过USB连接Android手机。待成功识别到设备后点击`Run 'app'`即可在您的手机上运行本示例项目。
2. 连接Android设备运行场景检测示例应用程序。
通过USB连接Android设备调试点击`Run 'app'`即可在你的设备上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
3. 在Android设备上点击“继续安装”。完成之后即可在手机上体验场景检测功能。
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
如下图所示,识别出的概率最高的物体是植物。
![result](images/app_result.jpg)
4. Demo部署问题解决方案。
4.1 NDK、CMake、JDK等工具问题
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明
端侧场景检测Android示例程序分为JAVA层和JNI层其中JAVA层主要通过Android Camera 2 API实现摄像头获取图像帧以及相应的图像处理针对推理结果画框等功能JNI层在[Runtime](https://www.mindspore.cn/tutorial/lite/zh-CN/master/use/runtime.html)中完成模型推理的过程。
> 此处详细说明示例程序的JNI层实现JAVA层运用Android Camera 2 API实现开启设备摄像头以及图像帧处理等功能需读者具备一定的Android开发基础知识。
### 示例程序结构
```text

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

View File

@ -5,56 +5,65 @@ This sample application demonstrates how to use the MindSpore Lite API and MindS
## Running Dependencies
- Android Studio 3.2 or later (Android 4.0 or later is recommended.)
- NDK 21.3
- CMake 3.10
- Android software development kit (SDK) 26 or later
## Building and Running
1. Load the sample source code to Android Studio and install the corresponding SDK. (After the SDK version is specified, Android Studio automatically installs the SDK.)
1. Load the sample source code to Android Studio.
![start_home](images/home.png)
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding SDK. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
Start Android Studio, click `File > Settings > System Settings > Android SDK`, and select the corresponding `SDK Tools`. As shown in the following figure, select an SDK and click `OK`. Android Studio automatically installs the SDK.
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
If an Android Studio configuration error occurs, solve it by referring to the following solution table in item 4.
> Android SDK Tools is the default installation. You can see this by unchecking the `Hide Obsolete Packages`box.
>
> If you have any Android Studio configuration problem when trying this demo, please refer to item 4 to resolve it.
2. Connect to an Android device and run the style transfer sample application.
2. Connect to an Android device and runs this application.
Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device.
> During the building, Android Studio automatically downloads dependencies related to MindSpore Lite and model files. Please wait.
![run_app](images/run_app.PNG)
For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device>.
> Android Studio will automatically download MindSpore Lite, model files and other dependencies during the compilation process. Please be patient during this process.
>
> For details about how to connect the Android Studio to a device for debugging, see <https://developer.android.com/studio/run/device?hl=zh-cn>.
>
> The mobile phone needs to be turn on "USB debugging mode" before Android Studio can recognize the mobile phone. Huawei mobile phones generally turn on "USB debugging model" in Settings -> system and update -> developer Options -> USB debugging.
3. Continue the installation on the Android device. After the installation is complete, you can view the inference result.
3. Continue the installation on the Android device. After the installation is complete, you can view the content captured by a camera and the inference result.
![install](images/install.jpg)
![result](images/app_result.jpg)
When using the style transfer demo, you can import or take a photo, select a built-in style to obtain a new photo after inference, and then restore or save the new photo.
4. The solutions of configuration problems:
Before style transfer:
4.1 Problems of NDK, CMake, JDK Tools:
![sult](images/style_transfer_demo.png)
If the tools installed in Android Studio are not recognized, you can re-download and install them from the corresponding official website, and configure the path.
After style transfer:
![sult](images/style_transfer_result.png)
4. The following table lists solutions to Android Studio configuration errors.
| | Error | Solution |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | Specify the NDK installation directory in the local.properties file: ndk.dir={NDK installation directory} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | Manually download the corresponding [NDK version](https://developer.android.com/ndk/downloads) and specify the SDK location in the `Android NDK location` field (see the following figure). |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | Choose `Help` > `Checkout for Updates` on the toolbar to update the version. |
| 4 | SSL peer shut down incorrectly | Rebuild. |
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
![project_structure](images/project_structure.png)
4.2 NDK version does not match:
Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message.
![NDK_version](images/NDK_version.jpg)
4.3 Problem of Android Studio version:
Update the Android Studio version in `Toolbar - Help - Checkout for Updates`.
4.4 Gradle dependencies installed too slowly:
As shown in the picture, open the Demo root directory `build. Gradle` file, then add huawei mirror source address: `maven {url 'https://developer.huawei.com/repo/'}`, modify the classpath to 4.0.0 and click ` sync ` . Once the download is complete, restore the classpath version and synchronize it again.
![maven](images/maven.jpg)
## Detailed Description of the Sample Application
The style transfer sample application on the Android device uses the Android Camera 2 API to enable a camera to obtain image frames and process images, as well as using [runtime](https://www.mindspore.cn/tutorial/lite/en/master/use/runtime.html) to complete model inference.
@ -88,7 +97,7 @@ The style transfer sample application on the Android device uses the Android Cam
### Downloading and Deploying the Model File
Download the model file from MindSpore Model Hub. The objective detection model file used in this sample application is `posenet_model.ms`, which is automatically downloaded during app building using the `download.gradle` script and stored in the `app/src/main/assets` project directory.
Download the model file from MindSpore Model Hub. The objective detection model file used in this sample application is `style_predict_quant.ms` and `style_transfer_quant.ms`, which is automatically downloaded during app building using the `download.gradle` script and stored in the `app/src/main/assets` project directory.
> If the download fails, manually download the model files [style_predict_quant.ms](https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_predict_quant.ms) and [style_transfer_quant.ms](https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_transfer_quant.ms).

View File

@ -5,55 +5,67 @@
## 运行依赖
- Android Studio >= 3.2 (推荐4.0以上版本)
- NDK 21.3
- CMake 3.10
- Android SDK >= 26
## 构建与运行
1. 在Android Studio中加载本示例源码并安装相应的SDK指定SDK版本后由Android Studio自动安装
1. 在Android Studio中加载本示例源码。
![start_home](images/home.png)
启动Android Studio后点击`File->Settings->System Settings->Android SDK`勾选相应的SDK。如下图所示勾选后点击`OK`Android Studio即可自动安装SDK。
启动Android Studio后点击`File->Settings->System Settings->Android SDK`,勾选相应的`SDK Tools`。如下图所示,勾选后,点击`OK`Android Studio即可自动安装SDK。
![start_sdk](images/sdk_management.png)
![start_sdk](images/sdk_management.jpg)
使用过程中若出现Android Studio配置问题可参考第4项解决。
> Android SDK Tools为默认安装项取消`Hide Obsolete Packages`选框之后可看到。
>
> 使用过程中若出现问题可参考第4项解决。
2. 连接Android设备运行应用程序。
2. 连接Android设备运行该应用程序。
通过USB连接Android手机。待成功识别到设备后点击`Run 'app'`即可在您的手机上运行本示例项目。
通过USB连接Android设备调试点击`Run 'app'`即可在你的设备上运行本示例项目。
> 编译过程中Android Studio会自动下载MindSpore Lite、模型文件等相关依赖项编译过程需做耐心等待。
>
> Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
>
> 手机需开启“USB调试模式”Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。
![run_app](images/run_app.PNG)
Android Studio连接设备调试操作可参考<https://developer.android.com/studio/run/device?hl=zh-cn>
3. 在Android设备上点击“继续安装”安装完即可查看到推理结果。
3. 在Android设备上点击“继续安装”安装完即可查看到设备摄像头捕获的内容和推理结果。
![install](images/install.jpg)
使用风格迁移demo时用户可先导入或拍摄自己的图片然后选择一种预置风格得到推理后的新图片最后使用还原或保存新图片功能
如下图所示,识别出的概率最高的物体是植物
原始图片:
![result](images/app_result.jpg)
![sult](images/style_transfer_demo.png)
4. Demo部署问题解决方案。
风格迁移后的新图片
4.1 NDK、CMake、JDK等工具问题
![sult](images/style_transfer_result.png)
如果Android Studio内安装的工具出现无法识别等问题可重新从相应官网下载和安装并配置路径。
4. Android Studio 配置问题解决方案可参考下表:
- NDK >= 21.3 [NDK](https://developer.android.google.cn/ndk/downloads?hl=zh-cn)
- CMake >= 3.10.2 [CMake](https://cmake.org/download)
- Android SDK >= 26 [SDK](https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk/)
- JDK >= 1.8 [JDK](https://www.oracle.com/cn/java/technologies/javase/javase-jdk8-downloads.html)
| | 报错 | 解决方案 |
| ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| 1 | Gradle sync failed: NDK not configured. | 在local.properties中指定安装的ndk目录ndk.dir={ndk的安装目录} |
| 2 | Requested NDK version did not match the version requested by ndk.dir | 可手动下载相应的[NDK版本](https://developer.android.com/ndk/downloads?hl=zh-cn)并在Project Structure - Android NDK location设置中指定SDK的位置可参考下图完成 |
| 3 | This version of Android Studio cannot open this project, please retry with Android Studio or newer. | 在工具栏-help-Checkout for Updates中更新版本 |
| 4 | SSL peer shut down incorrectly | 重新构建 |
![project_structure](images/project_structure.png)
![project_structure](images/project_structure.png)
4.2 NDK版本不匹配问题
打开`Android SDK`,点击`Show Package Details`根据报错信息选择安装合适的NDK版本。
![NDK_version](images/NDK_version.jpg)
4.3 Android Studio版本问题
在`工具栏-help-Checkout for Updates`中更新Android Studio版本。
4.4 Gradle下依赖项安装过慢问题
如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`修改classpath为4.0.0,点击`sync`进行同步。下载完成后将classpath版本复原再次进行同步。
![maven](images/maven.jpg)
## 示例程序详细说明
@ -88,7 +100,7 @@
### 下载及部署模型文件
从MindSpore Model Hub中下载模型文件本示例程序中使用的目标检测模型文件为`posenet_model.ms`,同样通过`download.gradle`脚本在APP构建时自动下载并放置在`app/src/main/assets`工程目录下。
从MindSpore Model Hub中下载模型文件本示例程序中使用的目标检测模型文件为`style_predict_quant.ms`、`style_transfer_quant.ms`,同样通过`download.gradle`脚本在APP构建时自动下载并放置在`app/src/main/assets`工程目录下。
> 若下载失败请手动下载模型文件style_predict_quant.ms [下载链接](https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_predict_quant.ms)以及style_transfer_quant.ms [下载链接](https://download.mindspore.cn/model_zoo/official/lite/style_lite/style_transfer_quant.ms)。

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB