Kickpi-Book
  • KICKPI Document
  • K5/K5C(A133)
    • A133中文文档
      • 01-主板介绍
        • 01-KICKPI-K5硬件介绍
        • 02-KICKPI-K5C硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-扩展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-SD卡烧录
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK源码编译
        • 03-ANDROID_SDK源码编译
      • 05-外设驱动
        • LCD功能调试
        • LRADC按键配置
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
      • 07-LINUX系统定制
        • 02-Linux常用系统定制
      • 08-进阶
        • K5C主板供电
        • 安卓休眠唤醒
        • 13-硬件工厂测试
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K5_Hardware_Introduction
        • 02-KICKPI-K5C_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-How_to_Get_Image_File
        • 02-SD Card Burning
        • 03-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • ADB_Tutorial
  • K2B/K2C(H618)
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K2B_Hardware_Introduction
        • 02-KICKPI-K2B_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-SD_Card_Flashing
        • 02-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 05-Drivers_Development
        • RTC
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • 01-Linux_Common_System_Customization
      • 08-Advanced_Topics
        • Hardware_Factory_Testing
        • Keybox
    • zh
      • 01-主板介绍
        • 01-KICKPI-K2B硬件介绍
        • 02-KICKPI-K2C硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-扩展引脚
      • 03-镜像烧录
        • 01-SD卡烧录
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK源码编译
        • 2. Android SDK编译
      • 05-外设驱动
        • RTC
      • 06-Android系统定制
        • Android常用系统定制
      • 07-Linux系统定制
        • 01-Linux常用系统定制
        • 02-Linux_QT开发环境搭建
      • 08-进阶
        • Keybox
        • Secure Boot
        • Windows_QT开发环境搭建
        • 扩展引脚功能定制
        • 硬件工厂测试
  • K1/K1B/K3/K8(RK356x-RK3588)
    • en
      • 01-Development_board_Introduction
        • 01-RK_Chip_Comparison_Introduction
        • 02-KICKPI-K1_Hardware_Introduction
        • 03-KICKPI-K1B_Hardware_Introduction
        • 04-KICKPI-K3_Hardware_Introduction
        • 05-KICKPI-K8_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-Cloud_Storage_Directory_Description
        • 02-K1-Quick_Start_Guide
        • 02-K1B-Quick_Start_Guide
        • 02-K3-Quick_Start_Guide
        • 02-K8-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins
      • 03-Image_Flashing_Guide
        • 01-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-LINUX_SDK_Compilation
        • 03-ANDROID_SDK_Compilation
      • 05-Drivers_Development
        • GPIO
        • Kernel
        • LCD
        • PWM
        • RTC
      • 06-Android_System_Customization
        • 01-Common_Android_System_Customizations
        • 01-Common_Android_System_Customizations
      • 07-Linux_System_Customization
        • 01-Common_Linux_System_Customization
        • 02-Installing_VNC_on_Linux
        • 03-Linux_Docker
        • 04-Linux_QT_Environment_Setup
        • 05-Linux_NPU_YOLOV5S_object_detection
      • 08-Advanced_Topics
        • 01-Hardware_Factory_Test
        • 02-Hardware_Aging_Test
        • 03-Firmware_Unpacking_and_Packing
    • zh
      • 01-主板介绍
        • 01-RK芯片对比介绍
        • 02-KICKPI-K1硬件介绍
        • 03-KICKPI-K1B硬件介绍
        • 04-KICKPI-K3硬件介绍
        • 05-KICKPI-K8硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-K1-快速使用
        • 02-K1B-快速使用
        • 02-K3-快速使用
        • 02-K8-快速使用
        • 03-功能测试
        • 04-拓展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-LINUX_SDK编译
        • 03-ANDROID_SDK编译
      • 05-外设驱动
        • GPIO
        • Kernel
        • LCD
        • PWM
        • RTC
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
        • 07-Android NPU YOLOV5 目标检测
      • 07-LINUX系统定制
        • 01-Linux常用系统定制
        • 02-Linux安装VNC
        • 03-Linux Docker环境搭建
        • 04-Linux QT环境搭建
        • 05-Linux NPU YOLOV5S 目标检测
      • 08-进阶
        • 01-硬件工厂测试
        • 02-硬件老化测试
        • 03-固件解包和打包
  • K7(RK3576)
    • en
      • 01-Development_board_Introduction
        • 01-KICKPI-K7_Hardware_Introduction
      • 02-Getting_Started_Guide
        • 01-KICKPI_Cloud_Storage_Introduction
        • 02-Quick_Start_Guide
        • 03-Functional_Testing
        • 04-Expansion_Pins_Testing
      • 03-Image_Flashing_Guide
        • 01-How_to_Get_Image_File
        • 02-USB_Cable_Flashing
      • 04-SDK_Compilation_Guide
        • 01-Compilation_Environment_Setup
        • 02-Linux_SDK_Compilation
        • 03-Android_SDK_Compilation
      • 05-Drivers_Development
        • ADC
        • PWM
      • 06-Android_System_Customization
        • 01-Android_Common_System_Customization
      • 07-Linux_System_Customization
        • 01-Linux_Common_System_Customization
        • 02-Linux_Docker_Environment_Setup
        • 03-Linux_NPU_YOLOv5s_Object_Detection
        • 04-Linux_DeepSeek_Large_Model
        • 05-Linux_VNC_Remote_Control
      • 08-Advanced_Topics
        • Advanced_Testing
    • zh
      • 01-主板介绍
        • 01-KICKPI-K7硬件介绍
      • 02-入门必读
        • 01-网盘目录说明
        • 02-快速使用
        • 03-功能测试
        • 04-拓展引脚
      • 03-镜像烧录
        • 01-获取镜像文件
        • 02-USB线烧录
      • 04-SDK编译
        • 01-编译环境搭建
        • 02-Linux_SDK编译
        • 03-Android_SDK编译
      • 05-外设驱动
        • ADC
        • PWM
      • 06-ANDROID系统定制
        • 01-Android常用系统定制
      • 07-LINUX系统定制
        • 01-Linux常用系统定制
        • 02-Linux Docker环境搭建
        • 03-Linux NPU YOLOV5S 目标检测
        • 04-Linux_Deepseek大模型
        • 05-Linux_VNC远程控制
      • 08-进阶
        • 进阶测试
  • K4B(T113-S3)
    • T113-S3中文文档
      • 01-KICKPI-K4B硬件介绍
      • 10-系统镜像烧录
      • 11-SDK源码编译
      • 12-硬件功能测试
      • 13-硬件工厂测试
      • LCD功能调试
      • 20-Ubuntu20.04系统定制
      • Buildroot_QT5配置
      • Buildroot系统定制
  • common
    • en
      • adb
        • ADB_Tutorial
      • allwinner_burnning
        • SD_Card_Flashing
        • USB_Cable_Flashing
      • debug
        • 01 - Log Collection
      • display
        • FPC_Interface_Introduction
      • linux
        • SSH
    • zh
      • adb
        • ADB教程
      • android
        • qt
      • debug
        • 01-日志抓取
        • 常见问题
      • display
        • FPC接口介绍
      • linux
        • SSH
        • VNC
        • qt
      • 全志烧录
        • SD卡烧录
        • USB线烧录
Powered by GitBook
On this page
  • Symbol Explanation
  • 1. What is NPU YOLOV5S
  • 2. Image and Video Parsing
  • Network Disk Path
  • Source Code Path
  • Source Code Reference and Compilation
  • Tool Usage
  1. K7(RK3576)
  2. en
  3. 07-Linux_System_Customization

03-Linux_NPU_YOLOv5s_Object_Detection

Last updated 3 days ago

Symbol Explanation

  • SDK$: Refers to the source code path.

  • console$: Generally refers to the command-line console of the motherboard.

  • ADB$: Android Debug Bridge command-line tool, generally refers to an environment where ADB can be run.

1. What is NPU YOLOV5S

YOLOV5S is an object detection algorithm in computer vision. It is part of the YOLO (You Only Look Once) series, developed by Joseph Redmon, Alexey Bochkovskiy, and others. The YOLO algorithm series is known for its fast real-time object detection capabilities, which can detect and locate multiple objects in images or videos, including the object's category and position.

YOLOv5S is a variant in the YOLOv5 series. Different versions of YOLOv5 have different performance and model complexities. Usually, the "S" in YOLOv5S may stand for "Small", which means it might be a lightweight model suitable for running in resource-constrained environments, such as mobile devices or embedded systems. YOLOv5S may make a trade-off between speed and accuracy to adapt to different application scenarios.

2. Image and Video Parsing

RK Linux officially provides the rknn_yolov5_demo. The source code supports RK3576. You can download it from the network disk or compile the corresponding tools for image and video parsing.

Network Disk Path

3-SoftwareData/Linux_rknn_yolov5/rknn_yolov5_demo_Linux_rk3576.zip
3-SoftwareData/Linux_rknn_yolov5/yolov5_test.h264

Source Code Path

(SDK)/external/rknpu2/examples/rknn_yolov5_demo

Source Code Reference and Compilation

Configure the environment.

The toolchain path is (SDk)/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/.

(SDK)$ export TOOL_CHAIN=(SDK)/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/
(SDK)$ export GCC_COMPILER=(SDK)/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu

SDK refers to the Linux source code path. For details, see 11-SDK Source Code Compilation.

For example:

rk3576-linux$ pwd

/home/test/rk3576-linux (SDK Linux source code path)

Compile the corresponding tools.

(SDK)$ cd external/rknpu2/examples/rknn_yolov5_demo/
rknn_yolov5_demo$ ./build-linux.sh -t rk3576 -a aarch64 -b Release

The path of the generated tools.

rknn_yolov5_demo$ ls install/rknn_yolov5_demo_Linux/
lib  model  rknn_yolov5_demo  rknn_yolov5_video_demo

Copy rknn_yolov5_demo_Linux/ to the motherboard for use.

You need to add execution permissions when running.

​ chmod +x rknn_yolov5_demo

​ chmod +x rknn_yolov5_video_demo

Tool Usage

rknn_yolov5_demo

Usage: ./rknn_yolov5_demo <rknn model> <input_image_path> <resize/letterbox> <output_image_path>

Example of using rknn_yolov5_demo.

(console)$ export LD_LIBRARY_PATH=./lib
(console)$ ./rknn_yolov5_demo model/RK3576/yolov5s-640-640.rknn model/bus.jpg
post process config: box_conf_threshold = 0.25, nms_threshold = 0.45
Loading mode...
sdk version: 2.0.0b0 (35a6907d79@2024-03-24T10:31:14) driver version: 0.9.7
model input num: 1, output num: 3
  index=0, name=images, n_dims=4, dims=[1, 640, 640, 3], n_elems=1228800, size=1228800, w_stride = 640, size_with_stride=1228800, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=0, name=output0, n_dims=4, dims=[1, 255, 80, 80], n_elems=1632000, size=1632000, w_stride = 0, size_with_stride=1638400, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=1, name=286, n_dims=4, dims=[1, 255, 40, 40], n_elems=408000, size=408000, w_stride = 0, size_with_stride=491520, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=2, name=288, n_dims=4, dims=[1, 255, 20, 20], n_elems=102000, size=102000, w_stride = 0, size_with_stride=163840, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
model is NHWC input fmt
model input height=640, width=640, channel=3
Read model/bus.jpg ...
img width = 640, img height = 640
once run use 48.461000 ms
loadLabelName ./model/coco_80_labels_list.txt
person @ (209 243 286 510) 0.879723
person @ (479 238 560 526) 0.870588
person @ (109 237 232 534) 0.828112
bus @ (93 129 553 464) 0.700761
person @ (79 353 122 517) 0.307297
save detect result to ./out.jpg
loop count = 10 , average run  53.093000 ms

person @ / bus @ are the corresponding recognition information.

The recognized image out.jpg is generated.

(console)$ ls *.jpg
out.jpg

rknn_yolov5_video_demo

Usage: ./rknn_yolov5_video_demo <rknn_model> <video_path> <video_type 264/265>

Note that you need to use a video with h264/h265 codec stream.

Example of using rknn_yolov5_video_demo.

(console)$ ./rknn_yolov5_video_demo model/RK3576/yolov5s-640-640.rknn yolov5_test.h264 264
Loading mode...
sdk version: 1.5.2 (c6b7b351a@2023-08-23T15:28:22) driver version: 0.9.2
model input num: 1, output num: 3
  index=0, name=images, n_dims=4, dims=[1, 640, 640, 3], n_elems=1228800, size=1228800, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=0, name=output, n_dims=4, dims=[1, 255, 80, 80], n_elems=1632000, size=1632000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003860
  index=1, name=283, n_dims=4, dims=[1, 255, 40, 40], n_elems=408000, size=408000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003922
  index=2, name=285, n_dims=4, dims=[1, 255, 20, 20], n_elems=102000, size=102000, fmt=NCHW, type=INT8, qnt_type=AFFINE, zp=-128, scale=0.003915
model is NHWC input fmt
model input height=640, width=640, channel=3
mpi_dec_test start mpi_dec_test decoder test start mpp_type 7 app_ctx=0x7fc1305278 decoder=0x23ad0100
read video size=720664
receive packet size=8192 receive packet size=8192 receive packet size=8192 receive packet size=8192 receive packet size=8192 receive packet size=8192 receive packet size=8192 decoder require buffer w:h [1280:720] stride [1280:720] buf_size 1843200 pts=0 dts=0 decode_get_frame get info changed found receive packet size=8192 receive packet size=8192 decoder require buffer w:h [1280:720] stride [1280:720] buf_size 1843200 pts=0 dts=0 get one frame 1687102942317 data_vir=0x7f80024000 fd=13 0x24133340 encoder test start w 1280 h 720 type 7
input image 1280x720 stride 1280x720 format=2560
resize with RGA!
rga_api version 1.9.1_[4]
once run use 26.630000 ms
post process config: box_conf_threshold = 0.25, nms_threshold = 0.45
loadLabelName ./model/coco_80_labels_list.txt
car @ (380 412 438 461) 0.868004
car @ (532 362 574 399) 0.866127
car @ (496 328 530 354) 0.736625
car @ (564 311 592 331) 0.729147
car @ (860 433 928 497) 0.695733
car @ (676 306 704 327) 0.642370
car @ (738 402 792 457) 0.611211
car @ (202 441 296 498) 0.610788
bus @ (748 272 806 329) 0.527151
car @ (440 322 474 347) 0.526350
car @ (514 310 540 326) 0.507014
car @ (280 666 444 720) 0.347807
car @ (670 288 696 302) 0.271905
car @ (540 289 566 307) 0.176622
car @ (494 297 516 312) 0.168131
car @ (702 263 716 273) 0.163944

car @ / bus @ are the corresponding video recognition information.

The recognized video out.h264 is generated.

(console)$ ls *.h264
out.h264
yolov5_out
yolov5_video
Mainboard Command-line Console