From: @liuxiao78 Reviewed-by: @hangangqiang,@zhanghaibo5 Signed-off-by: @hangangqiangtags/v1.2.0-rc1
| @@ -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. | 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.) | - 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 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. | |||||
|  | |||||
|  | |||||
| 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. | Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device. | ||||
|  |  | ||||
| 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. | 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: | |||||
| 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. | |||||
| | | Warning | Solution | | |||||
| | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | | |||||
| | 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.properties:ndk.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. | | |||||
| - 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) | |||||
|  |  | ||||
| 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. | |||||
|  | |||||
| 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 | ## 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). | 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). | ||||
| @@ -1,39 +1,37 @@ | |||||
| ## MindSpore Lite 端侧图像分类demo(Android) | |||||
| # MindSpore Lite 端侧图像分类demo(Android) | |||||
| 本示例程序演示了如何在端侧利用MindSpore Lite C++ API(Android JNI)以及MindSpore Lite 图像分类模型完成端侧推理,实现对设备摄像头捕获的内容进行分类,并在App图像预览界面中显示出最可能的分类结果。 | 本示例程序演示了如何在端侧利用MindSpore Lite C++ API(Android JNI)以及MindSpore Lite 图像分类模型完成端侧推理,实现对设备摄像头捕获的内容进行分类,并在App图像预览界面中显示出最可能的分类结果。 | ||||
| ### 运行依赖 | |||||
| ## 运行依赖 | |||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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会自动下载MindSpore Lite、模型文件等相关依赖项,编译过程需做耐心等待。 | ||||
| > | |||||
| > Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| > | |||||
| > 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
|  |  | ||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | ||||
|  |  | ||||
| @@ -42,16 +40,32 @@ | |||||
|  |  | ||||
| 4. Android Studio 配置问题解决方案可参考下表: | |||||
| 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) | |||||
|  | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
| 4.3 Android Studio版本问题: | |||||
| 在`工具栏-help-Checkout for Updates`中更新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 | 重新构建 | | |||||
| 4.4 Gradle下依赖项安装过慢问题: | |||||
|  | |||||
| 如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`,修改classpath为4.0.0,点击`sync`进行同步。下载完成后,将classpath版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | ## 示例程序详细说明 | ||||
| @@ -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. | 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.) | - 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 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. | |||||
|  | |||||
|  | |||||
| 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. | Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device. | ||||
|  |  | ||||
| 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. | 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: | |||||
|  | |||||
| 4. The solutions of configuration problems: | |||||
| 4.1 Problems of NDK, CMake, JDK Tools: | |||||
| | | Warning | Solution | | |||||
| | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | | |||||
| | 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.properties:ndk.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. | | |||||
| 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) | |||||
|  |  | ||||
| 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. | |||||
|  | |||||
| 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 | ## 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). | 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). | ||||
| @@ -1,53 +1,71 @@ | |||||
| ## MindSpore Lite 端侧图像分割demo(Android) | |||||
| # MindSpore Lite 端侧图像分割demo(Android) | |||||
| 本示例程序演示了如何在端侧利用MindSpore Lite Java API 以及MindSpore Lite 图像分割模型完成端侧推理,实现对设备摄像头捕获的内容进行分割,并在App图像预览界面中显示出最可能的分割结果。 | 本示例程序演示了如何在端侧利用MindSpore Lite Java API 以及MindSpore Lite 图像分割模型完成端侧推理,实现对设备摄像头捕获的内容进行分割,并在App图像预览界面中显示出最可能的分割结果。 | ||||
| ### 运行依赖 | |||||
| ## 运行依赖 | |||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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会自动下载MindSpore Lite、模型文件等相关依赖项,编译过程需做耐心等待。 | ||||
| > | |||||
| > Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| > | |||||
| > 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
|  |  | ||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | ||||
|  |  | ||||
| 4. Android Studio 配置问题解决方案可参考下表: | |||||
| 如下图所示,识别出的概率最高的物体是植物。 | |||||
|  | |||||
| 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) | |||||
|  | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
| 4.3 Android Studio版本问题: | |||||
| 在`工具栏-help-Checkout for Updates`中更新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 | 重新构建 | | |||||
| 4.4 Gradle下依赖项安装过慢问题: | |||||
|  | |||||
| 如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`,修改classpath为4.0.0,点击`sync`进行同步。下载完成后,将classpath版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | ## 示例程序详细说明 | ||||
| @@ -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. | 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 | |||||
| ## Running Dependencies | |||||
| The following section describes how to build and execute an on-device object detecion task on MindSpore Lite. | |||||
| - Android Studio 3.2 or later (Android 4.0 or later is recommended.) | |||||
| ### Running Dependencies | |||||
| ## Building and Running | |||||
| - 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) | |||||
| 1. Load the sample source code to Android Studio. | |||||
| ### 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.) | |||||
| 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. | |||||
|  | |||||
|  | |||||
| 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 object detection 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. | |||||
| Connect to the Android device through a USB cable for debugging. Click `Run 'app'` to run the sample project on your device. | |||||
|  | |||||
|  | |||||
| 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. | 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 configuration problems: | |||||
| 4. The solutions of Android Studio configuration problems: | |||||
| 4.1 Problems of NDK, CMake, JDK Tools: | |||||
| | | Warning | Solution | | |||||
| | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ | | |||||
| | 1 | Gradle sync failed: NDK not configured. | Specify the installed ndk directory in local.properties:ndk.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. | | |||||
| 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) | |||||
|  |  | ||||
| 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. | |||||
|  | |||||
| 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 | ## 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 . | 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 . | ||||
| @@ -5,49 +5,67 @@ | |||||
| ## 运行依赖 | ## 运行依赖 | ||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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调试模型”。 | |||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
|  | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | ||||
|  |  | ||||
| 如下图所示,检测出图中内容是鼠标。 | |||||
| 如下图所示,识别出的概率最高的物体是植物。 | |||||
|  | |||||
| 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) | |||||
|  | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
|  | |||||
| 4.3 Android Studio版本问题: | |||||
| 4. Android Studio 配置问题解决方案可参考下表: | |||||
| 在`工具栏-help-Checkout for Updates`中更新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 | 重新构建 | | |||||
| 4.4 Gradle下依赖项安装过慢问题: | |||||
|  | |||||
| 如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`,修改classpath为4.0.0,点击`sync`进行同步。下载完成后,将classpath版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | ## 示例程序详细说明 | ||||
| @@ -5,52 +5,65 @@ This sample application demonstrates how to use the MindSpore Lite API and skele | |||||
| ## Running Dependencies | ## Running Dependencies | ||||
| - Android Studio 3.2 or later (Android 4.0 or later is recommended.) | - 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 | ## 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 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. | |||||
|  | |||||
|  | |||||
| 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. | 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. | |||||
|  |  | ||||
| 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. | 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. | ||||
|  | |||||
|  | |||||
| 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: | |||||
|  | |||||
| 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) | |||||
|  |  | ||||
| 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. | |||||
|  | |||||
| 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 Application | ## 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. | 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. | ||||
| @@ -5,51 +5,67 @@ | |||||
| ## 运行依赖 | ## 运行依赖 | ||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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会自动下载MindSpore Lite、模型文件等相关依赖项,编译过程需做耐心等待。 | ||||
| > | |||||
| > Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| > | |||||
| > 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
|  |  | ||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | ||||
|  |  | ||||
| 使用骨骼检测模型的输出如图: | |||||
| 如下图所示,识别出的概率最高的物体是植物。 | |||||
|  | |||||
| 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) | |||||
|  | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 蓝色标识点检测人体面部的五官分布及上肢、下肢的骨骼走势。此次推理置信分数0.98/1,推理时延66.77ms。 | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
|  | |||||
| 4.3 Android Studio版本问题: | |||||
| 4. Android Studio 配置问题解决方案可参考下表: | |||||
| 在`工具栏-help-Checkout for Updates`中更新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 | 重新构建 | | |||||
| 4.4 Gradle下依赖项安装过慢问题: | |||||
|  | |||||
| 如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`,修改classpath为4.0.0,点击`sync`进行同步。下载完成后,将classpath版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | ## 示例程序详细说明 | ||||
| @@ -5,43 +5,64 @@ This sample application demonstrates how to use the MindSpore Lite C++ API (Andr | |||||
| ## Running Dependencies | ## Running Dependencies | ||||
| - Android Studio 3.2 or later (Android 4.0 or later is recommended.) | - 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 | ## 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 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. | |||||
|  | |||||
|  | |||||
| 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. | | |||||
|  | |||||
| 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. | 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. | |||||
|  |  | ||||
| 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. | 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 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) | |||||
|  | |||||
| 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. | |||||
|  | |||||
| 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 Application | ## Detailed Description of the Sample Application | ||||
| @@ -1,53 +1,73 @@ | |||||
| ## MindSpore Lite 端侧场景检测demo(Android) | |||||
| # MindSpore Lite 端侧场景检测demo(Android) | |||||
| 本示例程序演示了如何在端侧利用MindSpore Lite C++ API(Android JNI)以及MindSpore Lite 场景检测模型完成端侧推理,对设备摄像头捕获的内容进行检测,并在App图像预览界面中显示连续目标检测结果。 | 本示例程序演示了如何在端侧利用MindSpore Lite C++ API(Android JNI)以及MindSpore Lite 场景检测模型完成端侧推理,对设备摄像头捕获的内容进行检测,并在App图像预览界面中显示连续目标检测结果。 | ||||
| ### 运行依赖 | |||||
| ## 运行依赖 | |||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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设备,运行该应用程序。 | |||||
|  | |||||
| 通过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调试模型”。 | |||||
|  |  | ||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| 3. 在Android设备上,点击“继续安装”。完成之后即可在手机上体验场景检测功能。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | |||||
|  |  | ||||
| ## 示例程序详细说明 | |||||
| 如下图所示,识别出的概率最高的物体是植物。 | |||||
|  | |||||
| 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) | |||||
| 端侧场景检测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开发基础知识。 | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
| 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版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | |||||
| ### 示例程序结构 | ### 示例程序结构 | ||||
| @@ -5,55 +5,64 @@ This sample application demonstrates how to use the MindSpore Lite API and MindS | |||||
| ## Running Dependencies | ## Running Dependencies | ||||
| - Android Studio 3.2 or later (Android 4.0 or later is recommended.) | - 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 | ## 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 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. | |||||
|  | |||||
|  | |||||
| 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. | 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. | |||||
|  |  | ||||
| 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. | |||||
|  | |||||
|  | |||||
| 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: | |||||
|  | |||||
| 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: | |||||
| - 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) | |||||
|  | |||||
|  | |||||
| 4. The following table lists solutions to Android Studio configuration errors. | |||||
| 4.2 NDK version does not match: | |||||
| | | 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. | | |||||
| Open `Android SDK`, click `Show Package Details`, and select the appropriate NDK version according to the error message. | |||||
|  | |||||
|  | |||||
| 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 Application | ## Detailed Description of the Sample Application | ||||
| @@ -88,7 +97,7 @@ The style transfer sample application on the Android device uses the Android Cam | |||||
| ### Downloading and Deploying the Model File | ### 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). | > 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). | ||||
| @@ -5,55 +5,67 @@ | |||||
| ## 运行依赖 | ## 运行依赖 | ||||
| - Android Studio >= 3.2 (推荐4.0以上版本) | - 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中加载本示例源码。 | |||||
|  |  | ||||
| 启动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。 | |||||
|  | |||||
|  | |||||
| 使用过程中若出现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会自动下载MindSpore Lite、模型文件等相关依赖项,编译过程需做耐心等待。 | ||||
| > | |||||
| > Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| > | |||||
| > 手机需开启“USB调试模式”,Android Studio 才能识别到手机。 华为手机一般在设置->系统和更新->开发人员选项->USB调试中开始“USB调试模型”。 | |||||
|  |  | ||||
| Android Studio连接设备调试操作,可参考<https://developer.android.com/studio/run/device?hl=zh-cn>。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到推理结果。 | |||||
| 3. 在Android设备上,点击“继续安装”,安装完即可查看到设备摄像头捕获的内容和推理结果。 | |||||
|  |  | ||||
| 使用风格迁移demo时,用户可先导入或拍摄自己的图片,然后选择一种预置风格,得到推理后的新图片,最后使用还原或保存新图片功能。 | |||||
| 如下图所示,识别出的概率最高的物体是植物。 | |||||
|  | |||||
| 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) | |||||
| 原始图片: | |||||
|  | |||||
|  | |||||
| 4.2 NDK版本不匹配问题: | |||||
| 风格迁移后的新图片: | |||||
| 打开`Android SDK`,点击`Show Package Details`,根据报错信息选择安装合适的NDK版本。 | |||||
|  | |||||
|  | |||||
| 4.3 Android Studio版本问题: | |||||
| 4. Android Studio 配置问题解决方案可参考下表: | |||||
| 在`工具栏-help-Checkout for Updates`中更新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 | 重新构建 | | |||||
| 4.4 Gradle下依赖项安装过慢问题: | |||||
|  | |||||
| 如图所示, 打开Demo根目录下`build.gradle`文件,加入华为镜像源地址:`maven {url 'https://developer.huawei.com/repo/'}`,修改classpath为4.0.0,点击`sync`进行同步。下载完成后,将classpath版本复原,再次进行同步。 | |||||
|  | |||||
| ## 示例程序详细说明 | ## 示例程序详细说明 | ||||
| @@ -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)。 | > 若下载失败请手动下载模型文件,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)。 | ||||