一、基礎(chǔ)環(huán)境
硬件:KV260視覺入門套件
攝像頭:???20P USB攝像頭(因?yàn)椴渴餠itis AI之后懶得poweroff插MIPI camera了,直接USB上)
軟件:Ubuntu 22.04 + Vitis AI v3.0
root@kria:~# uname -a
Linux kria 5.15.0-1020-xilinx-zynqmp #22-Ubuntu SMP Fri Feb 2414:14:20 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
root@kria:~#
二、初步體驗(yàn)
Vitis AI 3.0的用戶手冊(cè)如下,基本概念和指南很清晰,只需要一步一步照著做即可。
Vitis AI — Vitis? AI 3.0 documentation (xilinx.github.io)
先拿smartcam來開刀,展示下具體流程,先apt update/upgrade 全部走一遍。
(一)Docker安裝&配置
Vitis AI v3.0通過Docker部署,故需要安裝&配置Docker環(huán)境。
apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
隨后驗(yàn)證安裝是否成功:
因?yàn)橐恢眗oot,所以可以忽略Docker用戶權(quán)限。
之后添加國(guó)內(nèi)Docker鏡像源,否則2.4G的smartcam鏡像一晚上根本下不完。
先在/etc/docker/ 目錄下增加daemon.json文件,將國(guó)內(nèi)鏡像源加進(jìn)去,文件內(nèi)容如下:
{
"registry-mirrors": [
"https://ccr.ccs.tencentyun.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://registry.docker-cn.com"
]
}
之后service docker restart 重啟Docker服務(wù),再docker info 檢查是否OK,差不多就是下面的樣子:
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
runc version: v1.1.8-0-g82f18fe
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.0-1023-xilinx-zynqmp
Operating System: Ubuntu 22.04.3 LTS
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 3.814GiB
Name: kria
ID: d0241500-7aff-4090-bba3-e961db7c1818
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://ccr.ccs.tencentyun.com/
https://docker.mirrors.ustc.edu.cn/
https://hub-mirror.c.163.com/
https://mirror.baidubce.com/
https://registry.docker-cn.com/
Live Restore Enabled: false
(二)配置Vitis AI
先添加Xilinx軟件包源,通過add-apt-repository ppa:xilinx-apps/ppa 和add-apt-repository ppa:ubuntu-xilinx/updates 兩個(gè)cmd設(shè)置額外的apt repository。
之后,apt update 更新所有package。
root@kria:~/Vitis-AI# apt update
Hit:1 https://download.docker.com/linux/ubuntu jammy InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports jammy InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
Hit:4 http://oem.archive.canonical.com/updates jammy-limerick InRelease
Hit:5 https://ppa.launchpadcontent.net/ubuntu-xilinx/sdk/ubuntu jammy InRelease
Hit:6 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
Hit:7 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease
Hit:8 https://ppa.launchpadcontent.net/ubuntu-xilinx/updates/ubuntu jammy InRelease
Hit:9 https://ppa.launchpadcontent.net/xilinx-apps/ppa/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@kria:~/Vitis-AI# apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
python2.7-minimal libjs-jquery-ui libopenexr25 libavcodec58 libavutil56
libswscale5 libswresample3 libavformat58 python2.7 libpython2.7-minimal
libpython2.7-stdlib
Learn more about Ubuntu Pro at https://ubuntu.com/pro
The following packages have been kept back:
gjs libgjs0g libsmbclient libwbclient0 samba-libs
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
后續(xù),繼續(xù)apt install xlnx-firmware-kv260-smartcam 下載smartcam固件。
root@kria:~/Vitis-AI# apt install xlnx-firmware-kv260-smartcam
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
xlnx-firmware-kv260-smartcam
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 2973 kB of archives.
After this operation, 7921 kB of additional disk space will be used.
Get:1 https://ppa.launchpadcontent.net/xilinx-apps/ppa/ubuntu jammy/main arm64 xlnx-firmware-kv260-smartcam arm64 0.9-0xlnx1 [2973 kB]
Fetched 2973 kB in 4s (727 kB/s)
Scanning processes...
Restarting services...ocessor microcode upgrades.
Package configuration
通過xmutil命令xmutil listapps 查看:
Active_slot為0的表示正在運(yùn)行,可以xmutil unloadapp 停止掉,這之前還要xmutil desktop_disable 禁用桌面,奇怪的是xmutil unloadapp運(yùn)行后,風(fēng)扇狂轉(zhuǎn),按理來說停止服務(wù)應(yīng)該資源消耗變小了,可是fan那么激動(dòng)做啥?
還有個(gè)提醒memory leak的ERROR,有知道的大佬嗎?
root@kria:~/Vitis-AI# xmutil unloadapp
[ 8191.766515] OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/zyxclmm_drm
[ 8191.781699] OF: ERROR: memory leak before free overlay changeset, /axi/isp_vcap_csi/ports/port@0/endpoint
[ 8191.793445] OF: ERROR: memory leak, expected refcount 1 instead of -1073741824, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/isp_vcap_csi/ports/port@0/endpoint
[ 8191.811821] OF: ERROR: memory leak before free overlay changeset, /axi/scaler@b0100000/ports/port@1/endpoint
[ 8191.821849] OF: ERROR: memory leak, expected refcount 1 instead of -1073741824, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/scaler@b0100000/ports/port@1/endpoint
[ 8191.840101] OF: ERROR: memory leak before free overlay changeset, /axi/scaler@b0100000/ports/port@0/endpoint
[ 8191.850111] OF: ERROR: memory leak, expected refcount 1 instead of -1073741824, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/scaler@b0100000/ports/port@0/endpoint
[ 8191.868361] OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/scaler@b0100000/ports
[ 8191.884328] OF: ERROR: memory leak before free overlay changeset, /axi/csiss@80000000/ports/port@1/endpoint
[ 8191.894253] OF: ERROR: memory leak, expected refcount 1 instead of -1073741824, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/csiss@80000000/ports/port@1/endpoint
[ 8191.912406] OF: ERROR: memory leak before free overlay changeset, /axi/csiss@80000000/ports/port@0/endpoint
[ 8191.922328] OF: ERROR: memory leak, expected refcount 1 instead of -1073741824, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/csiss@80000000/ports/port@0/endpoint
[ 8191.940542] OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry: attach overlay node /axi/i2c@80030000/i2c-mux@74/i2c@0/isp@3c/sensors/sensor@0
remove from slot 0 returns: 0 (Ok)
(三)啟動(dòng)Docker
先下載xilinx/smartcam的Docker IMG,通過docker pull xilinx/smartcam 命令。
root@kria:~/Vitis-AI# docker pull xilinx/smartcam
Using default tag: latest
latest: Pulling from xilinx/smartcam
00f50047d606: Pull complete
d7951c234d55: Pull complete
05265a2d1f35: Pull complete
90b46a25b424: Pull complete
80e164c37cc5: Pull complete
3d8f42a1f194: Pull complete
b98fe3f03a5b: Pull complete
59a6d05de11d: Pull complete
c3201d2e9455: Pull complete
5a86aa1eda97: Pull complete
1c16e9132328: Pull complete
d5655ba163b7: Pull complete
3044adb41328: Pull complete
f5dc15e1f4ef: Pull complete
Digest: sha256:da2e52629011aeec332152a0f468d3ff156917dba9b596cf6d0de958d5dc29d7
Status: Downloaded newer image for xilinx/smartcam:latest
docker.io/xilinx/smartcam:latest
用了國(guó)內(nèi)的源,速度就是快,很快就下載完成。再看看imgs:
root@kria:~/Vitis-AI# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest b038788ddb22 4 months ago 9.14kB
xilinx/smartcam latest aa0270aef908 11 months ago 1.41GB
通過命令啟動(dòng)xilinx/smartcam鏡像,
此時(shí)root@xlnx-docker:/# 提示進(jìn)入Docker環(huán)境。
三、運(yùn)行
如文章之初所說,因?yàn)椴渴餠itis AI之后懶得poweroff插MIPI camera了(直接帶電插MIPI camera又感覺有風(fēng)險(xiǎn)),那就直接USB camera上吧。
先確定USB camera的名字,通過拔插USB攝像頭確定是/dev/media1,為什么不是/dev/video*?一個(gè)問號(hào)。
root@xlnx-docker:/# ls /dev/media*
/dev/media0 /dev/media1
本來想smartcam --usb=1 -W 640 -H 480 --target=dp ,接上HDMI顯示器后不能顯示,貌似顯示器不支持這個(gè)分辨率,為什么是640X480這個(gè)奇葩的分辨率,是因?yàn)楹?礥SB攝像頭為720P,所以選了個(gè)攝像頭支持的分辨率。
root@xlnx-docker:/# smartcam --usb=1 -W 640 -H 480 --target=dp
Resize: mean_r=128.000000
Resize: mean_g=128.000000
Resize: mean_b=128.000000
Resize: scale_r=1.000000
Resize: scale_g=1.000000
Resize: scale_b=1.000000
[ 9484.157137] zynqmp-display fd4a0000.display: Layer width:height must be 640:480
[ 9484.187386] zynqmp-display fd4a0000.display: Layer width:height must be 640:480
[ 9484.202081] zynqmp-display fd4a0000.display: Layer width:height must be 640:480
[ 9484.224098] zynqmp-display fd4a0000.display: Layer width:height must be 640:480
[ 9484.264872] zynqmp-display fd4a0000.display: Layer width:height must be 640:480
那就RTSP吧,smartcam --usb=1 -W 640 -H 480 --target=rtsp 伺候:
root@xlnx-docker:/# smartcam --usb=1 -W 640 -H 480 --target=rtsp
stream ready at:
rtsp://172.17.0.1:554/test
rtsp://192.168.99.238:554/test
用支持RTSP的播放器再同一網(wǎng)段內(nèi)連接,本人頭像就不照了,剛好在刷抖音,刷個(gè)人臉來看看。
效果不錯(cuò),最后,來一張合影,基本上各種線纜都接上了。
|
評(píng)論