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
  • 1.What is NPU YOLOV5S?
  • 2. Analyze images and videos
  • source code path
  • Source code reference and compilation
  • tool use
  • 3. Parse local video streams
  • Hardware environment
  • Sample program testing
  • Get the sample program source code
  • Compile the source code
  • program running
  • 4. Parse the camera video stream
  • Hardware environment
  • Sample program testing
  1. K1/K1B/K3/K8(RK356x-RK3588)
  2. en
  3. 07-Linux_System_Customization

05-Linux_NPU_YOLOV5S_object_detection

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 and Alexey Bochkovskiy, among others. The YOLO family of algorithms is known for its fast real-time object detection capabilities, capable of detecting and locating multiple objects in an image or video, including the object's category and location.

YOLOv5S is a variant in the YOLOv5 family. Different versions of YOLOv5 have different performance and model complexity. In general, "S" may stand for "Small" in YOLOv5S, which means it may be a lightweight model suitable for operating in resource-constrained environments, such as mobile devices or embedded systems. YOLOv5S may trade off between speed and accuracy to suit different application scenarios.

2. Analyze images and videos

RK Linux official rknn_yolov5_demo, source code support'RK3562 ',' RK3566 ',' RK3568 ',' RK3588 ', compile tools for image analysis and video analysis

source code path

(SDK)/external/rknpu2/examples/rknn_yolov5_demo

Source code reference and compilation

configuration environment

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

SDK directory refers to, in fact, it should be replaced with its own actual directory

Compile the corresponding tool

$ cd external/rknpu2/examples/rknn_yolov5_demo/
$ ./build-linux_RK3562.sh

build-android_RK3562.sh build-android_RK3566_RK3568.sh build-android_RK3588.sh build-linux_RK3562.sh build-linux_RK3566_RK3568.sh build-linux_RK3588.sh

Select the corresponding script according to the actual IC for compilation

build tool path

rknn_yolov5_demo$ ls install/rknn_yolov5_demo_Linux/
lib  model  rknn_yolov5_demo  rknn_yolov5_video_demo

Copy to the main board to run

tool use

rknn_yolov5_demo

Usage: ./rknn_yolov5_demo <rknn model> <jpg>

Examples rknn_yolov5_demo use

$ ./rknn_yolov5_demo model/RK3588/yolov5s-640-640.rknn model/bus.jpg
post process config: box_conf_threshold = 0.25, nms_threshold = 0.45
Read model/bus.jpg ...
img width = 640, img height = 640
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, w_stride = 640, size_with_stride=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, w_stride = 0, size_with_stride=1638400, 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, w_stride = 0, size_with_stride=491520, 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, w_stride = 0, size_with_stride=163840, 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
once run use 31.119000 ms
loadLabelName ./model/coco_80_labels_list.txt
person @ (209 244 286 506) 0.884139
person @ (478 238 559 526) 0.867678
person @ (110 238 230 534) 0.824685
bus @ (94 129 553 468) 0.705055
person @ (79 354 122 516) 0.339254
loop count = 10 , average run  23.615900 ms

person @/bus @is the corresponding identification information

rknn_yolov5_video_demo

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

Note that h264/h265 code streaming video is required

Examples rknn_yolov5_video_demo use

$ ./rknn_yolov5_video_demo model/RK3588/yolov5s-640-640.rknn model/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 @is the corresponding video identification information

3. Parse local video streams

Hardware environment

Testing environment: RK3568 Debian11

Currently RK3568, RK3588 can use this demo

Sample program testing

YOLOV5S object detection sample program, built into the Debian11 file system

Go to the sample program directory

$ cd /rockchip-test/npu2/rknn_yolov5_demo_Linux/

Run the sample program

$ ./rknn_yolov5_demo model/RK356X/yolov5s-640-640.rknn model/test.mp4

Get the sample program source code

  • Program source code built-in SDK directory

$ ls external/rknpu2/examples/rknn_yolov5_video_demo/
	build  build-android_RK356X.sh  build-android_RK3588.sh  build-linux_RK356X.sh  build-linux_RK3588.sh  
	CMakeLists.txt  convert_rknn_demo  include  install  model  README.md  src

Compile the source code

  • Specify the cross-compilation toolchain path

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

Cross-compilation toolchain built-in SDK directory, the specific path can be modified by referring to the above command

  • Compile source code

$ cd external/rknpu2/examples/rknn_yolov5_video_demo/
$ ./build-linux_RK356X.sh

After the compilation is successful, execute the program to generate the directory install/rknn_yolov5_demo_Linux/

  • Copy the program to the development board

$ ls install/rknn_yolov5_demo_Linux/
	lib/              model/            rknn_yolov5_demo

Currently rknn_yolov5_demo_Linux /lib need to use the main board /rockchip-test/npu2/rknn_yolov5_demo_Linux/lib

Copy method can be used with U disk, network, etc

If you don't want to compile, you can get the executable program from the network disk directory 1-SDK Source software source code/demo/rknn_yolov5_demo_Linux .tar.gz

Run example:

$ cd rknn_yolov5_demo_Linux/
$ export LD_LIBRARY_PATH=/usr/local/opencv4/lib/
$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv4/lib/
$ export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:/usr/local/opencv4/lib/pkgconfig
$ cp /rockchip-test/npu2/rknn_yolov5_demo_Linux/lib . -rf
$ ./rknn_yolov5_demo model/RK356X/yolov5s-640-640.rknn model/test.mp4

program running

  • Program run command

$ cd rknn_yolov5_demo_Linux/
$ ./rknn_yolov5_demo model/RK356X/yolov5s-640-640.rknn model/test.mp4

RK356X can only run to 7 frames per second, and can optimize the program performance by itself

  • Program running interface

4. Parse the camera video stream

Hardware environment

Testing environment: RK3568 Debian11

Currently RK3568, RK3588 can use this demo

Sample program testing

YOLOV5S object detection sample program, built into the Debian11 file system

Go to the sample program directory

$ cd /rockchip-test/npu2/rknn_yolov5_demo_Linux/

Run the sample program

$ ./rknn_yolov5_demo model/RK356X/yolov5s-640-640.rknn /dev/video10

If the running time is too long, the process will be terminated due to insufficient memory

Get the sample program source code

Last updated 4 days ago

f8944680e7bd81aeec4cbddf2eab4b0

It is the same as parsing the local video stream using the demo, so the source code reference

parsing the local video stream