This is an old revision of the document!
This document mainly describes how to compile executable files from application source code.
Only support local compile on VIM3/3L Only support OpenCV4
$ sudo apt update $ sudo apt install libopencv-dev python3-opencv
$ mkdir{workspace} && cd {workspace} $ git clone https://github.com/khadas/aml_npu_app
$ cd {workspace}/aml_npu_app $ ls DDK_6.3.2 DDK_6.3.2.3 DDK_6.3.2.5 DDK_6.3.3.4 DDK_6.4.0.3 DDK_6.4.3 detect_library LICENSE NN_SLT
$ cd {workspace}/aml_npu_app/detect_library $ ls densenet_ctc_demo_picture inception model_code retinaface_demo_x11_usb sample_demo_fb sample_demo_x11 source_code yolo_demo_fb_mipi yolo_demo_fb_usb yolo_demo_x11_mipi yolo_demo_x11_usb yolov7_tiny_demo_x11_usb yolov8n_demo_x11_usb
Enter the directory of the library model_code, which is the directory of the DDK.
$ cd {workspace}/aml_npu_app/detect_library/model_code $ ls densenet_ctc detect_mtcnn detect_retinaface detect_yoloface detect_yolo_v2 detect_yolo_v3 detect_yolo_v3_tiny detect_yolo_v4 detect_yolo_v7_tiny detect_yolov8n facenet
Except for detect_mtcnn
, each directory represents a different model, and each model will be compiled into a library.
Take detect_yolo_v3
as an example to illustrate the structure of each directory.
$ cd {workspace}/aml_npu_app/detect_library/model_code/detect_yolo_v3 $ ls build_vx.sh include Makefile makefile.linux makefile.linux.def vnn_yolov3.c yolo_v3.c yolov3_process.c
Main content description:
Enter the directory of the source_code.
$ cd {workspace}/aml_npu_app/detect_library/source_code $ ls build_vx.sh detect.c detect_log.c include Makefile makefile.linux makefile.linux.def
Main content description:
Enter the directory of the yolo_demo_x11_usb.
$ cd {workspace}/aml_npu_app/detect_library/yolo_demo_x11_usb $ ls build_vx.sh detect.h main.cpp makefile.linux makefile.linux.def makefile.target_name nn_detect_common.h nn_detect.h nn_detect_utils.h
Compile model_code you need. Here still take detect_yolo_v3
as an example.
$ cd {workspace}/aml_npu_app/detect_library/model_code/detect_yolo_v3 $ ls build_vx.sh include Makefile makefile.linux makefile.linux.def vnn_yolov3.c yolo_v3.c yolov3_process.c $ bash build_vx.sh $ ls bin_r build_vx.sh include linux_build_sample.log makefile.linux makefile.linux.def makefile.target_name vnn_yolov3.c yolo_v3.c yolov3_process.c
The compiled library, libnn_yolo_v3.so
, is generated in bin_r folder. Put the library into /usr/lib.
$ sudo cp -r bin_r/libnn_yolo_v3.so /usr/lib
Compile source_code and put library into /usr/lib, too.
$ cd {workspace}/aml_npu_app/detect_library/source_code $ ls build_vx.sh detect.c detect_log.c include Makefile makefile.linux makefile.linux.def $ bash build_vx.sh $ ls bin_r build_vx.sh detect.c detect_log.c include Makefile makefile.linux makefile.linux.def $ sudo cp -r bin_r/libnn_detect.so /usr/lib
Compile main function.
$ cd {workspace}/aml_npu_app/detect_library/yolo_demo_x11_usb $ ls build_vx.sh detect.h main.cpp makefile.linux makefile.linux.def makefile.target_name nn_detect_common.h nn_detect.h nn_detect_utils.h $ bash build_vx.sh $ ls bin_r_cv4 build_vx.sh detect.h linux_build_sample.log main.cpp makefile.linux makefile.linux.def makefile.target_name nn_detect_common.h nn_detect.h nn_detect_utils.h
Build a folder named nn_data
under bin_r_cv4 and put yolov3_88.nb
into it.
$ cd bin_r_cv4 $ mkdir nn_data $ cp -r {path}/yolov3_88.nb nn_data/ $ ls detect_demo_x11_usb main.o nn_data
Run inference.
$ ./detect_demo_x11_usb -m 2 -d /dev/video1
The parameter -m
means the inference model and 2
stands for yolov3. Here are the all available model and these serial number.
If you use the model that input is picture, change -d
to -p
. Here example is densenet_ctc.
$ ./densenet_ctc_picture -m 15 -p ../KhadasTeam.png