72、结合无人机进行rk3588oak-lite跟踪目标物体进行识别、跟踪、保持距离
基本思想:
搭建仿真转换模型环境,主要python版本和我下载的rknn2的版本
(rk3588) ubuntu@ubuntu:~/Downloads/rknn-toolkit2-1.5.0/packages$ python3
Python 3.8.0 (default, Nov 6 2019, 21:49:08)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rknn
>>> exit()
截取shape节点,输出模型
其中安装的whl版本
from rknn.api import RKNN
ONNX_MODEL = '/home/ubuntu/yolov7/runs/train/exp3/weights/best.onnx'
RKNN_MODEL = '/home/ubuntu/yolov7/runs/train/exp3/weights/best.rknn'
if __name__ == '__main__':
# Create RKNN object
rknn = RKNN(verbose=True)
# pre-process config
print('--> config model')
rknn.config(mean_values=[[0, 0, 0]], std_values=[[255, 255, 255]],
target_platform='rk3588',
quantized_dtype='asymmetric_quantized-8')
print('done')
print('--> Loading model')
ret = rknn.load_onnx(model=ONNX_MODEL, outputs=["/model.77/Reshape_2_output_0", "/model.77/Reshape_1_output_0",
"/model.77/Reshape_output_0"])
if ret != 0:
print('Load model failed!')
exit(ret)
print('done')
# Build model
print('--> Building model')
ret = rknn.build(do_quantization=True, dataset='dataset.txt') # ,pre_compile=True
if ret != 0:
print('Build yolov5s failed!')
exit(ret)
print('done')
# Export rknn model
print('--> Export RKNN model')
ret = rknn.export_rknn(RKNN_MODEL)
if ret != 0:
print('Export yolov5s.rknn failed!')
exit(ret)
print('done')
rknn.release()
so库也要对应转模型的whl
连接开发板
neardi 用户密码:lindikeji 或 neardi
ubuntu@ubuntu:~$ ssh neardi@192.168.2.29
neardi@192.168.2.29's password:
Welcome to Ubuntu 20.04.5 LTS (GNU/Linux 5.10.110 aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
neardi@LPA3588:~$ sudo apt-get install cmake gcc g++ ffmpeg
测试一下代码
cmakelists.txt
mian.cpp
参考
Ubuntu新手入门 — Neardi Linux 用户手册 v1.1.2 documentation