Deploy yolov5 to the mobile phone through Android Studio (2023 latest version suitable for newbies)

Deploy yolov5 to the mobile phone through Android Studio (2023 latest version suitable for newbies)

java17 installation

Downloadjava17

Java Downloads | Oracle

image-20230822232854998

Configure environment variables

This is the path after I installed it, copy this path

image-20230822233126273

Set environment variables

image-20230822233252757

image-20230822233337178

Click New in System Variables

image-20230822233522493

image-20230822233549524

JAVA_HOME
%JAVA_HOME17%

Continue to create a new

image-20230822233749359

CLASSPATH
.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

Continue to create a new

image-20230822233845476

JAVA_HOME17
自己的java17路径

After the new creation is completed, click OK

image-20230822234002150

Test Java17

image-20230822234139174

java -version

Successful installation! ! ! !

Android studio installation

Android Studio download

Download link: Download Android Studio & App Tools - Android Developers (google.cn)

The current version is: | 2022.3.1 Patch 1

image-20230822234643138

start installation

image-20230822234949504

image-20230822235003626

Remember to change the path, don’t put it in the c drive

image-20230822235117248

image-20230822235205255

image-20230822235301281

image-20230822235317781

basic configuration

  1. After opening, the system will prompt to import the Android Studio configuration, select Do not import settings , and then click OK .

img

  1. Set up data sharing and select Don't send

img

  1. When prompted to update the plug-in, you can click Update to update, or ignore it.

img

  1. Click: Next to enter the next step

img

  1. Select the installation type: Standard (default) or Custom (custom), click: Next to proceed to the next step

img

  1. Select the Android SDK component to be installed and the installation location. The default component is sufficient. Check all the boxes below. I have already installed it here. You can choose the installation location by yourself (don’t put it on the c drive). Click: Next to enter the next step . .

image-20230822235905294

  1. Emulator Settings emulator memory allocation, allocate the required memory (this step is not skipped directly)

img

8. Click Finish to install the components selected above.

img

  1. Wait for the download and installation to complete.

img

10. Click Finish to complete the installation.

img

yolo configuration

Download the following two yolo links: (I guess you need to use an accelerator here, otherwise it will be slower)

First:

Releases · Tencent/ncnn (github.com)

image-20230823000948029

the second:

nihui/ncnn-android-yolov5: The YOLOv5 object detection android example (github.com)

image-20230823001110653

After downloading the two files, unzip them

image-20230823001225869

After opening the vulkan file, copy and paste it into ncnn-android-yolov5-master\app\src\main\jni

copy:

image-20230823001512878

Paste location:

image-20230823001706280

Use Android studio to open ncnn-android-yolov5-master (don't open the wrong path here, otherwise it will be difficult to install)

image-20230823003806175

Then modify the directory at the same level and change the variable value CMakeLists.txtin it toncnn_DIR

set(ncnn_DIR ${CMAKE_SOURCE_DIR}/${ANDROID_ABI}/lib/cmake/ncnn)

Insert image description here

Continue to modify the file, open ncnn-android-yolov5-master/build.gradle, and replace the red box with 7.3.0 (you can also open the file with android studio)

image-20230823010705004

image-20230823010221110

Continue to modify the file, open ncnn-android-yolov5-master\gradle\wrapper, and replace the red box with 7.4 (you can also use android studio to open the file)

image-20230823010404758

image-20230823010454527

sdk configuration

Open settings

image-20230823010821618

image-20230823011045940

image-20230823011209872

Pay attention to the installation of cmake here, click on show package in the lower right corner...

image-20230823011355054

Then click apply

image-20230823011430311

After the sdk download is completed, open the following file with Android Studio and wait for compilation

image-20230823012159887

image-20230823012113773

Install the app on your phone

image-20230823012508563

Connect the computer to the data cable and plug it into the phone. Turn on the developer mode on the phone (the location may be different for different phones), turn on USB debugging, and USB installation. Android Studio will recognize the mobile device.

image-20230823013102530

My mobile device

image-20230823012715456

Click to run

image-20230823013225731

After running, the software will be installed on the phone:

image-20230823013343846

running result:

image-20230823013411763

Guess you like

Origin blog.csdn.net/qq_60943902/article/details/132440203