编译运行tengine示例

Tengine_khadas_app 源码仓库是khadas基于tengine API制作的一个简易demo仓库

注意

tengine-lite v.14(即NPU6.4.4.3)之后,demo仅支持在板子上进行本地编译

获取源码

源码仓库位于khadas的github上,clone到板子上

1
2
3
4
5
6
$ mkdir ${workspace}
$ cd ${workspace}
$ git clone https://github.com/khadas/tengine_khadas_app.git
$ cd tengine_khadas_app
$ ls
yolov3-camera yolov3-picture

yolov3-camerayolov3-picture分别基于opencv的摄像头识别和图片识别的demo

安装opencv4

1
$ sudo apt install libopencv-dev python3-opencv

编译

yolov3-picture:

1
2
3
4
5
$ cd ${workspace}/tengine_khadas_app/yolov3-picture
$ ./build-cv4.sh
COMPILE ${workspace}/tengine_khadas_app/yolov3-picture/tengine_khadas_yolov3_picture.cpp
$ ls cv3_output/
tengine_khadas_yolov3_picture tengine_khadas_yolov3_picture.o

yolov3-camera:

1
2
3
4
5
$ cd ${workspace}/tengine_khadas_app/yolov3-camera
$ ./build-cv3.sh
COMPILE ${workspace}/tengine_khadas_app/yolov3-camera/tengine_khadas_yolov3_camera.cpp
$ ls cv3_output/
tengine_khadas_yolov3_camera tengine_khadas_yolov3_camera.o

其中tengine_khadas_yolov3_picturetengine_khadas_yolov3_camera就是编译出来的可执行文件

运行

  1. 获取tmfile

请参考Tengine SDK使用说明

  1. 运行
1
2
$ ./tengine_khadas_yolov3_camera -m path/to/yolov3_uint8_t_timfile -i path/to/picture
$ ./tengine_khadas_yolov3_camera -m path/to/yolov3_uint8_t_timfile -d /dev/videoX