This documentation will introduce how to compile the application source code.
Note
- Only support local compile on VIM3/3L
- Only support OpenCV4
Install OpenCV4
1 | sudo apt update |
Get Source Code
1 | cd {workspace} |
Source Description
Directory structure description
1 | cd {workspace}/aml_npu_app |
- DDK_xxx - Different versions of library source code
- detect_library - Application layer source code. detect_library/model_code link to the latest version of DDK
- NN_SLT - Separate source code directory for DnCnn model (no longer maintained)
- LICENSE - LICENSE file
Library Description
Enter the directory of the library source code, which is the directory of the DDK.
1 | cd {workspace}/aml_npu_app/detect_library/model_code |
Except for detect_mtcnn
, each directory represents a different model, and each model will be compiled into a library.
- detect_yoloface - yoloface model, used to detect faces
- detect_yolo_v2 - yolov2 model, for object detection
- detect_yolo_v3 - yolov3 model, for object detection
- detect_yolo_v3_tiny - yolov3-tiny model, for object detection
- detect_yolo_v4 - yolov4 model, used to detect faces
Take detect_yolo_v3
as an example to illustrate the structure of each directory
1 | cd {workspace}/aml_npu_app/detect_library/model_code/detect_yolo_v3 |
Main content description:
- build_vx.sh - Compile script
- include - The corresponding header files and all definitions will be placed in this directory
- Makefile - Makefile file
- makefile.linux - Make environment configuration file
- vnn_yolov3.c - SDK The converted model processing file is mainly used to interface with the nb file
- yolo_v3.c - Specify the called nb file, and define all the interfaces of the model call
- yolov3_process.c - Mainly defines the pre-processing and post-processing of the model
Application Description
Enter the application source code directory
1 | cd {workspace}/aml_npu_app/detect_library |
Except model_code
link to the leastest DDK, every other directory will compile a demo of the upper application
- source_code - Compile libnn_detect.so. as a bridge to connect different libraries and different application demos
- sample_demo_fb - Compile detect_demo_fb of the aml_npu_demo_binaries repository for image recognition under framebuffer
- sample_demo_x11 - Compile detect_demo_x11 of the aml_npu_demo_binaries repository for image recognition under X11
- yolo_demo_gst_uvc_fb - Compile the detect_demo_uvc_fb of the aml_npu_demo_binaries repository for dynamic recognition of the USB camera under the framebuffer
- yolo_demo_mipi_fb - Compile detect_demo_mipi_fb of the aml_npu_demo_binaries repository for dynamic recognition of mipi camera under framebuffer
- yolo_demo_x11 - Compile detect_demo_x11 of the aml_npu_demo_binaries repository for dynamic camera recognition under X11
Here is an example of sample_demo_x11
1 | cd {workspace}/aml_npu_app/detect_library/sample_demo_x11 |
Here is an explanation of the main files,
- build_vx.sh - Compile script
- makefile.linux - Respectively, the compilation scripts need to specify the makefile.linux file when compiling
- main.cpp - Is the main source code of the application demo.
- xxx.h - The definition related header files that the application layer needs to use
Compile
Compile Library
To compile the library, just enter the directory of the corresponding library and compile it. Here is yolov3 as an example
1 | cd {workspace}/aml_npu_app/detect_library/model_code/detect_yolo_v3 |
You can see the generated library in the output directory bin_r
1 | cd {workspace}/aml_npu_app/detect_library/model_code/detect_yolo_v3/bin_r |
Compile The Application
When compiling the application, first compile libnn_detect.so
. This is one of the dependent libraries for compiling other applications.
Compile libnn_detect.so
Enter the source_code
directory and compile libnn_detect.so
1 | cd {workspace}/aml_npu_app/detect_library/source_code |
In the bin_r
directory, libnn_detect.so
will be generated
1 | cd {workspace}/aml_npu_app/detect_library/source_code/bin_r |
Compile Application Demo
Here is sample_demo_x11 as an example
1 | ./build_vx.sh |
In the bin_r_cv4
directory, you will see the generated detect_demo
file
1 | cd {workspace}/aml_npu_app/detect_library/sample_demo_x11/bin_r_cv4 |
To compile the opencv4 version, just use the build_vx_cv4.sh
script to compile.