设备:zed2
系统:ubuntu18.04
目标:在Agv上实现目标检测与跟踪,即需要知道相机坐标系下目标的三维坐标位置,为实现该功能,拟使用zed-yolo先完成目标检测,与Ros发布的消息结合,用于agv控制所需的目标点
这篇主要介绍一下所需安装的环境和中间出现的一些需要注意的点
花了一上午时间解决cuda和cudnn的版本问题
因为从zed-yolo的read me 中似乎对版本没有要求,笔记本系统本来装的是cuda11.0的版本,cudnn是v8的版本,但后续安装Darknet发现
* both Windows and Linux
* both OpenCV 2.x.x and OpenCV <= 3.4.0 (3.4.1 and higher isn't supported)
* both cuDNN v5-v7
* CUDA >= 7.5
* also create SO-library on Linux and DLL-library on Windows
重新安装了cuda10.2和cudnn7.6.5
cuda在官网下载:https://developer.nvidia.com/cuda-downloads
历史各种版本:
https://developer.nvidia.com/cuda-toolkit-archive
选择 runfile(local)安装
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
添加环境变量(并没有去卸载cuda11.0,多个版本cuda是可以共存的)
1.gedit ~/.bashrc
2.export CUDA_HOME=/usr/local/cuda
3.export PATH=$PATH:$CUDA_HOME/bin
4.export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
如果像我一样,原来有装过cuda,将bash.rc文件中的11.0改为10.2即可,最后别忘了
source ~/.bashrc
https://developer.nvidia.com/rdp/cudnn-download cudnn的下载官网,但需要注册后才能下载
下载 cuDNN Library for linux
sudo tar -zxvf cudnn-10.2-linux-x64-v7.6.5.32.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
替换完成后,一定要建立一下新版本的软链接,尤其像我这样之前装了其他版本的cuda和cudnn(或者也在cuda-10.2文件夹中也进行如下操作)
cd /usr/local/cuda/lib64/
sudo chmod +r libcudnn.so.7.6.5
sudo ln -sf libcudnn.so.7.6.5 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so
sudo ldconfig
更换完成后可以查看cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
进入网站https://www.stereolabs.com/developers/release/
根据你的ubuntu版本和cuda版本下载sdk
ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
chmod +x ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
./ZED_SDK_Ubuntu18_cuda10.2_v3.5.0.run
[ZED Python 3 wrapper](https://github.com/stereolabs/zed-python)
python -m pip install cython numpy
python -m pip install opencv-python pyopengl
$ cd "/usr/local/zed/"
$ python get_python_api.py
# The script displays the detected platform versions
CUDA 10.0
Platform ubuntu18
ZED 3.1
Python 3.7
# Downloads the whl package
Downloading python package from https://download.stereolabs.com/zedsdk/3.1/ubuntu18/cu100/py37 ...
# Gives instruction on how to install the downloaded package
File saved into pyzed-3.1-cp37-cp37m-linux_x86_64.whl
To install it run :
python3 -m pip install pyzed-3.1-cp37-cp37m-linux_x86_64.whl
```
按要求装即可,最好conda环境创建时是Python3.6版本,用Python3.8时中间有出现错误,最后
$ python3 -m pip install pyzed-3.1-cp37-cp37m-linux_x86_64.whl
出现
Processing ./pyzed-3.1-cp37-cp37m-linux_x86_64.whl
Installing collected packages: pyzed
Successfully installed pyzed-3.1
```
即表示安装成功
cd libdarknet
make -j4
若前面环境装的没有问题,这一步应该不会出错
先下载
wget https://pjreddie.com/media/files/yolov3-tiny.weights
To launch the ZED with YOLO simply run the script :(运行这一步)
python3 darknet_zed.py
The input parameters can be changed using the command line :
python3 darknet_zed.py -c -w -m -t -s
For instance :
python3 darknet_zed.py -c cfg/yolov3.cfg -w yolov3.weights -m cfg/coco.data -t 0.5
To display the help :
python3 darknet_zed.py -h
其实目前我还是存在一些问题,打开后出现核心转储的错误,可能检测两秒就自动关闭了,正在想办法调整