The bpu on the X3 Pai has 5 T of computing power, which is really wasted, and a variety of examples of neural network deployment on the X3 Pai are introduced in the official Horizon Robot Development Platform User Manual. Looking at the code, I found that the code here is implemented on the horizon tROS framework. Some people may not need to use the ROS framework for their needs, so I have separated the use of DNNS from the tROS framework in the code to make it easier to use.
The official neural network code provided by Horizon is mainly in the Boxs algorithm repository, one of the most important code is dnn_node. This code addresses can be found at Sign in · GitLab. This code encapsulates the use of the bpu and provides a base class called DnnNode that users can inherit to do what they want. Usage is shown in Figure 1:
Figure 1. Usage of DnnNode
See the official documents for specific usage. Here did I do to code a simple cleaning and split the ROS part, to set up a project, project address: https://github.com/softdream/sunrise\_X3\_BPU/tree/master/dnn\_node\_lib, the use of the project as follows:
git clone https://github.com/softdream/sunrise_X3_BPU/tree/master/dnn_node_lib
cd dnn_node_lib
mkdir build & cd build
cmake ..
make
When compiled, a dynamic library named libdnn_node.so is generated in the build directory. This dynamic library can then be used directly.
Here is an application example to show how to use this library: using the x3 PI bpu to implement human detection. Reference horizon official routine Sign in · GitLab code. The same due to its routine here is based on the tROS, here on the modification, engineering links can be found in https://github.com/softdream/sunrise\_X3\_BPU/tree/master/dnn\_body\_detect
The modified project directory is shown in Figure 2:
Figure 2. Modified project directory
The include directory stores the header files of users and those in the preceding dnn_node_lib directory; the.cpp file is stored in the src directory; and the dynamic library files compiled in the preceding dnn_node_lib directory are stored in the lib directory. The model file is stored in Model, and the test picture file is stored in test_data.
The method of use of the project:
git clone https://github.com/softdream/sunrise_X3_BPU/tree/master/dnn_body_detect
cd dnn_body_detect
mkdir build & cd build
cmake ..
make
After compiling, the executable body_detect file will be generated in the build directory. Run: sudo./body_detect to see the effect as shown in Figure 3:
Figure 3. Human detection results
The usage code of other applications will be updated in the future, including non-ROS implementation of gesture recognition, fall detection and other functions.


