基本思想:测试rk3399 pro开发板系统和测试npu
第一步:进行硬件连线,参考手册,先引针连线,然后安装驱动和usb直连开发板
左上第二个,左下第三个使用引针串联起来,进入debug模式(刷机模式)
1.在电脑上选择好烧录镜像
2.短接14,15口
3.连接烧录口和电脑端
4.连接电源,点击升级
第二、使用固件1进行刷机
1)LZ110X16_00_RL_LB1_0311A.tar.bz2
2)使用固件2 刷机版本 LZ110X64_00_BB_LB_0517A.tar
刷机方式同上硬件:LPA3399PRO
系统:最新版Ubuntu18.04
Ubuntu18.04 系统默认安装了Python3.6版本,推荐基于Python3.7搭建;
第三步、搜索同一网段
C:\Users\Administrator>for /L %i IN (1,1,254) DO ping -w 2 -n 1 192.168.10.%i
产生ip地址
C:\Users\Administrator>arp -a
Interface: 192.168.10.171 --- 0x8
Internet Address Physical Address Type
192.168.10.1 02-81-c1-21-49-bb dynamic
192.168.10.37 02-81-c1-21-49-bb dynamic
192.168.10.76 02-81-c1-21-49-bb dynamic
192.168.10.233 02-81-c1-21-49-bb dynamic
192.168.10.150 02-81-c1-21-49-bb dynamic
192.168.10.152 02-81-c1-21-49-bb dynamic
192.168.10.255 02-81-c1-21-49-bb static
224.0.0.22 01-00-5e-00-00-16 static
224.0.0.251 02-81-c1-21-49-bb static
224.0.0.252 02-81-c1-21-49-bb static
224.9.234.121 01-00-5e-09-ea-79 static
224.149.203.115 02-81-c1-21-49-bb static
225.96.85.110 02-81-c1-21-49-bb static
225.138.111.106 02-81-c1-21-49-bb static
226.96.85.110 01-00-5e-60-55-6e static
231.96.85.110 01-00-5e-60-55-6e static
231.252.216.115 01-00-5e-7c-d8-73 static
232.96.85.110 01-00-5e-60-55-6e static
233.96.85.110 01-00-5e-60-55-6e static
234.62.83.49 02-81-c1-21-49-bb static
234.96.85.110 01-00-5e-60-55-6e static
235.96.85.110 01-00-5e-60-55-6e static
235.169.186.202 01-00-5e-29-ba-ca static
236.58.182.123 01-00-5e-3a-b6-7b static
236.96.85.110 01-00-5e-60-55-6e static
237.133.42.175 01-00-5e-05-2a-af static
238.79.97.123 01-00-5e-4f-61-7b static
238.93.203.115 01-00-5e-5d-cb-73 static
239.255.255.250 01-00-5e-7f-ff-fa static
255.255.255.255 ff-ff-ff-ff-ff-ff static
第四步:连接可用的ip,测试demo,
1)固件1的基础上,直接使用npu即可,npu的速度还是蛮不错的
2)在固件2的基础上,进行环境配置,
安装Python3.7,18.04没有Python3.5的包,无法直接apt install安装,先要导入ppa的源;安装命令
linaro@bionic:~$ sudo apt update
linaro@bionic:~$ sudo apt install software-properties-common
linaro@bionic:~$ sudo add-apt-repository ppa:deadsnakes/ppa
linaro@bionic:~$ sudo apt install python3.7-dev
2、安装virtualenv
linaro@bionic:~$ sudo apt install virtualenv
3、创建Python3.7 虚拟环境
linaro@bionic:~$ virtualenv -p /usr/bin/python3.7 rknn
linaro@bionic:~$ source rknn/bin/activate
4、安装依赖包
linaro@bionic:~$ sudo apt-get install cmake gcc g++ libprotobuf-dev protobuf-compiler
linaro@bionic:~$ sudo apt-get install liblapack-dev libjpeg-dev zlib1g-dev
linaro@bionic:~$ sudo apt-get install python3-dev python3-pip python3-scipy
linaro@bionic:~$ sudo apt-get install python3-opencv python3-numpy python3-lmd bpython3-h5py
linaro@bionic:~$ sudo apt-get build-dep python3-h5py
5、安装rknntoolkit依赖包
linaro@bionic:~$ pip3 install h5py
linaro@bionic:~$ pip3 install gluoncv
linaro@bionic:~$ pip3 install mxnet
linaro@bionic:~$ pip3 install google-pasta
linaro@bionic:~$ pip3 install absl-py
6、安装rknn_toolkit-1.7.1
linaro@bionic:~$ git clone https://github.com/rockchip-linux/rknn-toolkit
Cloning into 'rknn-toolkit'...
remote: Enumerating objects: 1135, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 1135 (delta 13), reused 12 (delta 12), pack-reused 1116
Receiving objects: 100% (1135/1135), 1020.98 MiB | 16.18 MiB/s, done.
Resolving deltas: 100% (389/389), done.
Checking out files: 100% (187/187), done.
linaro@bionic:~$ cd rknn-toolkit/
linaro@bionic:~/rknn-toolkit$ ls
LICENSE QQGroupQRCode.png README.md doc examples packages platform-tools rknn-toolkit-lite
linaro@bionic:~/rknn-toolkit$ cd packages/
linaro@bionic:~/rknn-toolkit/packages$ ls
README.md packages.md5sum requirements-cpu.txt requirements-gpu.txt
linaro@bionic:~/rknn-toolkit/packages$ cd ..
linaro@bionic:~/rknn-toolkit$ cd rknn-toolkit-lite/
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite$ ls
examples packages
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite$ cd packages/
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ ls
packages.md5sum rknn_toolkit_lite-1.7.1-cp36-cp36m-win_amd64.whl
rknn_toolkit_lite-1.7.1-cp35-cp35m-linux_aarch64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_aarch64.whl
rknn_toolkit_lite-1.7.1-cp35-cp35m-linux_x86_64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_armv7l.whl
rknn_toolkit_lite-1.7.1-cp36-cp36m-linux_x86_64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-macosx_10_15_x86_64.whl
rknn_toolkit_lite-1.7.1-cp36-cp36m-macosx_10_15_x86_64.whl
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ pip3 install ^C
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ source rknn/bin/activate
-bash: rknn/bin/activate: No such file or directory
linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ cd
linaro@bionic:~$ source rknn/bin/activate
(rknn) linaro@bionic:~$ cd ~/rknn-toolkit/rknn-toolkit-lite/packages
(rknn) linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ ls
packages.md5sum rknn_toolkit_lite-1.7.1-cp36-cp36m-win_amd64.whl
rknn_toolkit_lite-1.7.1-cp35-cp35m-linux_aarch64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_aarch64.whl
rknn_toolkit_lite-1.7.1-cp35-cp35m-linux_x86_64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_armv7l.whl
rknn_toolkit_lite-1.7.1-cp36-cp36m-linux_x86_64.whl rknn_toolkit_lite-1.7.1-cp37-cp37m-macosx_10_15_x86_64.whl
rknn_toolkit_lite-1.7.1-cp36-cp36m-macosx_10_15_x86_64.whl
(rknn) linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ pip3 install rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_aarch64.wh
^CERROR: Operation cancelled by user
(rknn) linaro@bionic:~/rknn-toolkit/rknn-toolkit-lite/packages$ pip3 install rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_aarch64.whl
Processing ./rknn_toolkit_lite-1.7.1-cp37-cp37m-linux_aarch64.whl
7、安装python驱动
(rknn) linaro@bionic:~$ git clone https://gitee.com/neardi01/npu-driver.git
Cloning into 'npu-driver'...
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 20 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (20/20), done.
(rknn) linaro@bionic:~$ cd npu-driver/
(rknn) linaro@bionic:~/npu-driver$ ls
librknn_api.so npu_update.sh v1.7.0 v1.7.1
(rknn) linaro@bionic:~/npu-driver$ sudo ./npu_update.sh
'./v1.7.1/MiniLoaderAll.bin' -> '/usr/share/npu_fw_pcie/MiniLoaderAll.bin'
'./v1.7.1/boot.img' -> '/usr/share/npu_fw_pcie/boot.img'
'./v1.7.1/parameter.txt' -> '/usr/share/npu_fw_pcie/parameter.txt'
'./v1.7.1/trust.img' -> '/usr/share/npu_fw_pcie/trust.img'
'./v1.7.1/uboot.img' -> '/usr/share/npu_fw_pcie/uboot.img'
'./librknn_api.so' -> '/usr/lib/aarch64-linux-gnu/librknn_api.so'
reboot system to make the modification effective
(rknn) linaro@bionic:~/npu-driver$ sudo reboot
测试结果
第四步:测试AHD摄像头
测试视频命令行为:
gst-launch-1.0 -v v4l2src device=/dev/video5 ! video/x-raw, format=NV12,width=1280,height=720,framerate=30/1 ! fpsdisplaysink sync=false text-overlay=false
测试视频的代码
/*
* Copyright (C) 2019 Kaspter Ju <camus@rtavs.com>
* SPDX-License-Identifier: Apache-2.0
*/
#include <signal.h>
#include <stdio.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
//v4l2src device=/dev/video5 ! video/x-raw, format=NV12,width=1280,height=720,framerate=30/1 ! fpsdisplaysink sync=false text-overlay=false
static std::string vidsrc =
"v4l2src device=/dev/video5 ! video/x-raw, framerate=30/1, width=1280, height=720 ! queue ! videoconvert ! appsink";
static std::string preview =
"appsrc ! queue ! videoconvert ! video/x-raw, framerate=30/1, width=1280, height=720 ! queue ! autovideosink sync=false";
static std::string record =
"appsrc is-live=rue do-timestamp=true ! queue ! videoconvert ! video/x-raw, format=NV12, framerate=30/1, "
"width=1280, height=720 ! queue ! mpph264enc ! queue ! h264parse ! mp4mux ! filesink location=./1440p.mp4 sync=false";
static bool quit = false;
static void signal_callback(int signum)
{
printf("Caught signal %d\n", signum);
quit = true;
}
int main(int argc, char *argv[])
{
int use_concat = 0;
if (argc > 1) {
use_concat = atoi(argv[1]);
}
std::cout << cv::getBuildInformation() << std::endl;
cv::VideoCapture cap;
cv::VideoWriter writer;
cap.open(vidsrc);
if (!cap.isOpened()) {
printf("can't create capture\n");
return -1;
}
cap.set(cv::CAP_PROP_FRAME_WIDTH, 1280);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 720);
double fps = 30.0;
writer.open(preview, 0, fps, cv::Size(1280, 720), true);
//writer.open(record, 0, fps, cv::Size(1280, 720), true);
if (!writer.isOpened()) {
printf("can't create writer\n");
return -1;
}
cv::TickMeter tm;
cv::Mat frame;
signal(SIGINT, signal_callback);
while (!quit) {
tm.reset();
tm.start();
cap >> frame;
if (frame.empty()) {
printf("no frame\n");
break;
}
tm.stop();
int fps = 1000.0 / tm.getTimeMilli();
cv::putText(frame, std::to_string(fps) + "FPS", cv::Point(20, 45), 4, 1, cv::Scalar(0, 0, 125));
writer << frame;
//imshow("camera", frame);
if (cv::waitKey(1) == 27) {
break;
}
}
writer.release();
cv::destroyAllWindows();
}
本项目是工业项目,源码不提供,最后实现了水下鱼类的目标检测和跟踪且都在npu上执行,抱歉源码不对外公开,附加配置和检测模型转换,36、ubuntu20.04搭建瑞芯微的npu仿真环境和测试rv1126的Debain系统下的yolov5+npu检测功能以及RKNN推理部署_sxj731533730的博客-CSDN博客追踪代码不提供
36、rk3399 pro 环境搭建和yolov5 c++修改使用opencv开发使用_sxj731533730的博客-CSDN博客
淘宝链接
https://item.taobao.com/item.htm?spm=a230r.1.14.16.57887aa2sl42xB&id=624438344531&ns=1&abbucket=3#detail
————————————————
版权声明:本文为CSDN博主「sxj731533730」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/sxj731533730/article/details/124483403