@ 各位读者,本文嵌入式人工智能应用包含了7个章节,拆成了3个部分。
第一部分:1~3章,介绍了EAIDK-610的系统安装、使用和linux指令;
第二部分:4~6章,介绍了makefile文件制作,动态库和静态库制作和使用
第三部分: 7章, 介绍了人工智能部署和使用。
本文代码,后期笔者会整理成为一个开源模块,放在gitee上面。
本文章是基于EAIDK-610的操作入门的介绍。课程介绍linux的基本操作,opencv库的使用和常见的两种人工智能应用的部署。
由于windows上面写代码和操作更加方便,所以一般开发采用网线远程登录到EAIDK-610的开发板上面。
由于EAIDK-610支持有线通讯和无线通讯,大家根据直接的需要选择对应的耗材准备。
直连模式的耗材准备
路由器模式的耗材准备
直连有线登录模式
直连登录模式这里是指电脑通过网线直连开发板。网口对网口模式,如果没有网口的电脑,可以采用usb转网口的模式。
设置固定ip地址
(3)配置配置IPV4地址,确保开发板和电脑在同一个IP字段,且不跟开发板同一个IP地址。 譬如:192.168.1.3,掩码地址:255.255.255.0
EAIDK-610板子设定固定ip地址
(1)把鼠标和键盘连接到EAIDK-610开发板上面。
(2)输入用户名:openailab,密码openailab。
(3)选择网络设置,设置manul模式。
(4)配置IP地址。譬如 192.168.1.2 , 掩码地址 255.255.255.0
路由器模式登录
第一部分直连需要配置ip地址,如果觉得配置静态地址比较麻烦,可以把开发板的网口跟路由器链接,同时电脑也连接到同一个路由器。采用路由器转接,也很是很方便登录到系统。
动态IP地址
路由器会自动为电脑和开发板分配合适地址。通过IPSCAN软件可以扫描出来开发板的地址。
如果觉得shell指令框,操作不方便。也可以开启远程桌面。
在指令框里面输入
`[openailab@localhost ~]$ vncserver
New 'localhost.localdomain:1 (openailab)' desktop is localhost.localdomain:1 Starting applications specified in /home/openailab/.vnc/xstartup Log file is h ome/openailab/.vnc/localhost.localdomain:1.log
可以看到系统回复是localdomain:1,说明远程桌面已经启动了。
选择session,选择VNC。 输入远程桌面地址 192.168.1.2, port口选择:5901. (如果上一步localdomain :2, 则端口选择5902)
点击ok后,输入密码就可以正常显示。如果密码忘记了,可以删除在/home/openailab/.vnc/passwd。 在重新进行第一步i可以了,然后设置好登录密码,就可以正常工作。
在登录框里面输入以下指令,就可以关闭桌面了。
[openailab@localhost .vnc]$ vncserver -kill :1
Killing Xvnc process ID 25159
一般在正常情况下,使用SSH,就可以满足绝大部分开发需求了。
掌握一下的常见指令的操作,就可以很好完成基于linux程序的开发。更过的shell指令,大家可以查看你shell指令手册。
首先,大家知道一个概念 绝对地址和相对地址。
绝对地址是从根目录算起的路径叫做绝对路径。譬如:/home/openailab/Desktop/examples,这就是一个绝对地址。
相对地址是从当前所在的工作目录开始写起。譬如:如果目前在桌面上,桌面上面有一个examples文件。地址写成了 /examples, 这个就是相对地址。
其次命令的基本格式:
# 命令 [选项 ] [参数]
下面介绍一些常见指令的操作,大家熟悉后。在以后学习和工作中,逐步掌握更多的指令操作。
1 切换路径 cd-change directory
[root@localhost ~]# cd [相对路径或绝对路径]
– 1.1 进入桌面的
[openailab@localhost home]$ cd ~/Desktop
[openailab@localhost Desktop]$
– 1.2 返回到上一层
[openailab@localhost Desktop]$ cd ..
[openailab@localhost ~]$
– 1.3 进入examples
[openailab@localhost ~]$ cd /home/openailab/Desktop/examples
[openailab@localhost examples]$
2 查看当前路径 pwd-print working directory
[openailab@localhost examples]$ pwd
/home/openailab/Desktop/examples
3 查看当前目录文件 ls-list
3.1 列出当前文件
[openailab@localhost ~]$ ls
Demo Desktop Documents Downloads Music Pictures Templates usart_rt Videos wget-log
3.2 列出所有隐藏文件
[openailab@localhost ~]$ ls -a
. .bash_profile .dbus Downloads .lesshst .pip .ssh usart_rt .vnc .xsession-errors
.. .bashrc Demo .esd_auth .local .python_history .subversion Videos wget-log
.bash_history .cache Desktop .gnupg Music .python_history-02355.tmp Templates .vim .Xauthority
.bash_logout .config Documents .keras Pictures .rpmmacros .thumbnails .viminfo .xscreensaver
3.3 分组列出所有隐藏文件
openailab@localhost ~]$ ls -a -g
total 176
drwx------ 23 openailab 4096 May 11 11:41 .
drwxr-xr-x 3 root 4096 Jan 4 2019 ..
-rw------- 1 openailab 16989 May 11 11:18 .bash_history
-rw-r--r-- 1 openailab 18 Jun 18 2018 .bash_logout
-rw-r--r-- 1 openailab 193 Jun 18 2018 .bash_profile
-rw-r--r-- 1 openailab 305 Jul 17 2019 .bashrc
drwx------ 22 openailab 4096 May 11 08:23 .cache
drwx------ 20 openailab 4096 Jul 22 2019 .config
drwx------ 3 openailab 4096 Dec 19 2018 .dbus
drwxrwxr-x 4 openailab 4096 Mar 8 2019 Demo
drwxrwxr-x 7 openailab 4096 May 11 06:33 Desktop
drwxrwxr-x 2 openailab 4096 May 11 06:29 Documents
drwxr-xr-x 2 openailab 4096 Aug 15 2018 Downloads
-rw------- 1 openailab 16 Aug 15 2018 .esd_auth
drwx------ 2 openailab 4096 May 11 07:03 .gnupg
drwxrwxr-x 2 openailab 4096 May 11 06:39 .keras
-rw------- 1 openailab 35 Jul 19 2019 .lesshst
drwxrwxr-x 3 openailab 4096 Aug 15 2018 .local
drwxr-xr-x 2 openailab 4096 Aug 15 2018 Music
drwxr-xr-x 2 openailab 4096 Aug 15 2018 Pictures
drwxrwxr-x 2 openailab 4096 Jul 24 2019 .pip
-rw------- 1 openailab 1800 Jul 26 2019 .python_history
-rw------- 1 openailab 0 May 11 06:30 .python_history-02355.tmp
-rw-rw-r-- 1 openailab 92 May 11 07:02 .rpmmacros
drwx------ 2 openailab 4096 Dec 11 2018 .ssh
drwxrwxr-x 3 openailab 4096 Sep 2 2018 .subversion
drwxr-xr-x 2 openailab 4096 Aug 15 2018 Templates
drwx------ 4 openailab 4096 Nov 7 2018 .thumbnails
drwxrwxr-x 2 openailab 4096 Jul 19 2019 usart_rt
drwxr-xr-x 2 openailab 4096 Aug 15 2018 Videos
drwxr-xr-x 2 openailab 4096 Jul 25 2019 .vim
-rw------- 1 openailab 15867 May 11 07:24 .viminfo
drwxrwxr-x 2 openailab 4096 May 11 07:29 .vnc
-rw-rw-r-- 1 openailab 2295 Jul 25 2019 wget-log
-rw------- 1 openailab 266 May 11 11:41 .Xauthority
-rw-rw-r-- 1 openailab 8725 Sep 2 2018 .xscreensaver
-rw------- 1 openailab 0 May 11 08:21 .xsession-errors
4 新建文件夹 mkdir-make directories
在桌面上面创建一个project文件夹
[openailab@localhost ~]$ mkdir ~/Desktop/project
5 移除文件夹 rmdir-remove directory
[openailab@localhost ~]$ rmdir ~/Desktop/project
6 新建文件 touch
[openailab@localhost ~]$ touch ~/Desktop/main.cpp
7 移动文件或者改文件名 mv-move
7.1 更改文件名
[openailab@localhost ~]$ mv ~/Desktop/main.cpp ~/Desktop/file.cpp
7.2 移动文件到project文件夹
[openailab@localhost ~]$ mv ~/Desktop/file.cpp ~/Desktop/project
8 复制文件 cp -copy
[openailab@localhost ~]$ cp ~/Desktop/project/file.cpp ~/Desktop/project/file.cpp.bk
9 删除文件 rn- remove
9.1 删除文件
[openailab@localhost ~]$ rm ~/Desktop/project/file.cpp.bk
9.2 删除文件夹
[openailab@localhost ~]$ rm -rf ~/Desktop/project
10 查看文件 cat-concatenate
[openailab@localhost ~]$ cat ~/Desktop/class2/main/main.cpp
#include "main.hpp"
#include "iostream"
#include "face.hpp"
int main(int argc, char ** argv)
{
Image_Test();
return 1;
}
11 树状列出目录 tree
[openailab@localhost ~]$ tree ~/Desktop/class2
/home/openailab/Desktop/class2
├── build
│ ├── face.o
│ ├── main
│ ├── main.exe
│ ├── main.o
│ ├── makefile
│ ├── note.txt
│ ├── sum.o
│ └── upper.o
├── copy_image.jpg
├── inc
│ ├── face.hpp
│ ├── file.hpp
│ ├── sum.hpp
│ └── upper.hpp
├── lib
│ ├── file.cpp
│ └── libfile.so
├── main
│ ├── main.cpp
│ ├── main.hpp
│ └── makefile
├── Makefile
├── my_image.jpg
└── src
├── face.cpp
├── Makefile
├── sum.cpp
└── upper.cpp
5 directories, 24 files
12 压缩和解压缩 tar-tape archive
12.1 压缩文件, 生成一个class压缩包
[openailab@localhost ~]$ tar -czvf ~/Desktop/class.tar.gz ~/Desktop/class2
tar: Removing leading `/' from member names
/home/openailab/Desktop/class2/
/home/openailab/Desktop/class2/Makefile
/home/openailab/Desktop/class2/my_image.jpg
/home/openailab/Desktop/class2/inc/
/home/openailab/Desktop/class2/inc/upper.hpp
/home/openailab/Desktop/class2/inc/face.hpp
/home/openailab/Desktop/class2/inc/sum.hpp
/home/openailab/Desktop/class2/inc/file.hpp
/home/openailab/Desktop/class2/src/
/home/openailab/Desktop/class2/src/Makefile
/home/openailab/Desktop/class2/src/face.cpp
/home/openailab/Desktop/class2/src/sum.cpp
/home/openailab/Desktop/class2/src/upper.cpp
/home/openailab/Desktop/class2/.vscode/
/home/openailab/Desktop/class2/.vscode/settings.json
/home/openailab/Desktop/class2/copy_image.jpg
/home/openailab/Desktop/class2/main/
/home/openailab/Desktop/class2/main/main.hpp
/home/openailab/Desktop/class2/main/main.cpp
/home/openailab/Desktop/class2/main/makefile
/home/openailab/Desktop/class2/build/
/home/openailab/Desktop/class2/build/main.o
/home/openailab/Desktop/class2/build/note.txt
/home/openailab/Desktop/class2/build/main
/home/openailab/Desktop/class2/build/main.exe
/home/openailab/Desktop/class2/build/upper.o
/home/openailab/Desktop/class2/build/makefile
/home/openailab/Desktop/class2/build/sum.o
/home/openailab/Desktop/class2/build/face.o
/home/openailab/Desktop/class2/lib/
/home/openailab/Desktop/class2/lib/libfile.so
/home/openailab/Desktop/class2/lib/file.cpp
12.2 解压class压缩包到桌面上
[openailab@localhost ~]$ tar -xzvf ~/Desktop/class.tar.gz
home/openailab/Desktop/class2/
home/openailab/Desktop/class2/Makefile
home/openailab/Desktop/class2/my_image.jpg
home/openailab/Desktop/class2/inc/
home/openailab/Desktop/class2/inc/upper.hpp
home/openailab/Desktop/class2/inc/face.hpp
home/openailab/Desktop/class2/inc/sum.hpp
home/openailab/Desktop/class2/inc/file.hpp
home/openailab/Desktop/class2/src/
home/openailab/Desktop/class2/src/Makefile
home/openailab/Desktop/class2/src/face.cpp
home/openailab/Desktop/class2/src/sum.cpp
home/openailab/Desktop/class2/src/upper.cpp
home/openailab/Desktop/class2/.vscode/
home/openailab/Desktop/class2/.vscode/settings.json
home/openailab/Desktop/class2/copy_image.jpg
home/openailab/Desktop/class2/main/
home/openailab/Desktop/class2/main/main.hpp
home/openailab/Desktop/class2/main/main.cpp
home/openailab/Desktop/class2/main/makefile
home/openailab/Desktop/class2/build/
home/openailab/Desktop/class2/build/main.o
home/openailab/Desktop/class2/build/note.txt
home/openailab/Desktop/class2/build/main
home/openailab/Desktop/class2/build/main.exe
home/openailab/Desktop/class2/build/upper.o
home/openailab/Desktop/class2/build/makefile
home/openailab/Desktop/class2/build/sum.o
home/openailab/Desktop/class2/build/face.o
home/openailab/Desktop/class2/lib/
home/openailab/Desktop/class2/lib/libfile.so
home/openailab/Desktop/class2/lib/file.cpp
有了前面基础介绍,这一章节,我们开始C++程序编程。我们通过案例方式逐一介绍其中操作。
首先,在桌面上面新建一个project文件夹,然后在文件里面新建一个main.cpp
[openailab@localhost Desktop]$ mkdir project
[openailab@localhost Desktop]$ ls
class2 class3 examples image project Tengine-master
[openailab@localhost Desktop]$ cd project
[openailab@localhost project]$ touch main.cpp
[openailab@localhost project]$ ls
main.cpp
在Linux,编辑文档的工具有很多种。在这里介绍用比较常见的编程工具VIM。
[openailab@localhost project]$ vim main.cpp
#include "iostream"
int main(int argc, char **argv)
{
std::cout<<"hello,my world"<<std::endl;
}
显示内容如下
-按esc退出编辑模式,然后依次按下“:wq”,退出保存当前编辑的内容。
如果不想保存,可以依次按下:q!, 强制退出当前Vim。
[openailab@localhost project]$ g++ -g -o main main.cpp
[openailab@localhost project]$ ls
main main.cpp
[openailab@localhost project]$ ./main
hello,my world
有时候,程序运行并不会一帆风顺。遇到代码有困难,需要对代码进行调试。广泛使用的调试软件是GDB,下面就GDB基本操作进行介绍。
[openailab@localhost project]$ gdb
GNU gdb (GDB) Fedora 8.1-19.fc28
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb)
(gdb) file main
Reading symbols from main...done.
(gdb) run
Starting program: /home/openailab/Desktop/project/main
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.27-19.fc28.aarch64
hello,my world
[Inferior 1 (process 7828) exited normally]
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.1.1-1.fc28.aarch64 libstdc++-8.0.1-0.20.fc28.aarch64
(gdb) list
1 #include "iostream"
2
3 int main(int argc, char **argv)
4 {
5
6 std::cout<<"hello,my world"<<std::endl;
7 }
(gdb)
(gdb) break 6
Breakpoint 1 at 0x4008b4: file main.cpp, line 6.
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004008b4 in main(int, char**) at main.cpp:6
(gdb) run
Starting program: /home/openailab/Desktop/project/main
Breakpoint 1, main (argc=1, argv=0x7ffffff028) at main.cpp:6
6 std::cout<<"hello,my world"<<std::endl;
(gdb) step
hello,my world
7 }
(gdb) continue
Continuing.
[Inferior 1 (process 18769) exited normally]
(gdb) quit
[openailab@localhost project]$
[第4部分到6部分,在part two]