在笔记本上安装CUDA8 & ZED Stereo Camera

ZED双目摄像头其实买到手的只是2个摄像头硬件,需要配合GPU才能运行使用SDK,记经过多次失败,成功在笔记本上运行了ZED的Demo。官方的安装步骤如下:

Make sure the latest USB 3.0 drivers are installed.Install CUDA 8 and latest NVIDIA drivers.[Linux] Compile and install OpenCV 3.1, more information here.Run the ZED SDK setup tool to install the ZED driver, tools and samples.

比较麻烦的是CUDA8的安装,另外在wiki上有详细的版本要求,支持Ubuntu16和CUDA8也是最近才有的事。

1. 安装CUDA8

目标系统是Ubuntu16-64bit,经过多次尝试,只有deb安装方式可行,其他的方式没有成功过。注意:最好是新系统安装,如果以前安装过NIVIDA笔记本显卡的驱动就要先卸载,安装CUDA时会自动安装相应的驱动,更方便可靠。首先是下载相应的deb文件,然后是参考安装手册安装deb文件:

第一步命令补全自己下载的deb文件名称,第三步添加路径时可以在home文件夹隐藏文件.bashrc中添加下列语句(“Ctrl+H可以显示隐藏文件”),直接修改即可,需要在文件最后添加的语句,然后重启一下

<span style="font-size:14px;">$ export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}</span>

之后就是按照第4步编译一个例子,看能不能运行,如果可以,表示CUDA的环境安装好了。


2. 安装OpenCV3.1

OpenCV官网下载源码,一定要是opencv3.1的,先修改源码的一个BUG:opencv3中有个模块在CUDA8.0中被抛弃了,编译会不通过,下载源码后,需要在opencv / modules / cudalegacy / src / graphcuts.cpp 中修改:(也就是在红色部分添加 || (CUDART_VERSION >=8000)    

编译方法:

先更新系统,安装依赖项:

<span style="font-size:14px;">sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential 
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
</span>

然后解压下载的opencv文件,进入目录后编译并安装:

<span style="font-size:14px;">cmake .
sudo make -j4
sudo make install
</span>

最后是构建路径:

<span style="font-size:14px;">sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'  
sudo ldconfig</span>

编译opencv自带的samples:

<span style="font-size:14px;">cd  xxxxxxxxx(你的opencv文件目录)/samples/
sudo cmake .
sudo make -j4
</span>


使用人脸检测测试一下安装的opencv,进入上述samples文件夹下的cpp文件夹:

<span style="font-size:14px;">cd xxxxxxxxx/cpp/
./cpp-example-facedetect faces.jpg</span>

成功安装,opencv!


3. 安装ZED driver

这部分很简单,下载对应的SDK,安装即可。ROS里面有ZED的wrapper:https://github.com/stereolabs/zed-ros-wrapper,安装方法见:http://wiki.ros.org/zed-ros-wrapper

需要注意的是:安装包文件件的名字必须与节点一致(比如文件名字改成zed_wrapper),launch文件的参数列表如下:

Parameter Description Value
svo_file SVO filename path to an SVO file
resolution ZED Camera resolution '0': HD2K
_ _ '1': HD1080
_ _ '2': HD720
_ _ '3': VGA
quality Disparity Map quality '0': NONE
_ _ '1': PERFORMANCE
_ _ '2': MEDIUM
_ _ '3': QUALITY
sensing_mode Depth sensing mode '0': FILL
_ _ '1': STANDARD
openni_depth_mode Convert depth to 16bit in millimeters '0': 32bit float meters
_ _ '1': 16bit uchar millimeters
zed_id ZED Camera ID, ignore if SVO file given int, default '0'
gpu_id GPU device ID, define which CUDA device will handle the computation int, default '-1' (best device found)
frame_rate Rate at which images are published int
rgb_topic Topic to which rgb==default==left images are published string
rgb_cam_info_topic Topic to which rgb==default==left camera info are published string
rgb_frame_id ID specified in the rgb==default==left image message header string
left_topic Topic to which left images are published string
left_cam_info_topic Topic to which left camera info are published string
left_frame_id ID specified in the left image message header string
right_topic Topic to which right images are published string
right_cam_info_topic Topic to which right camera info are published string
right_frame_id ID specified in the right image message header string
depth_topic Topic to which depth map images are published string
depth_cam_info_topic Topic to which depth camera info are published string
depth_frame_id ID specified in the depth image message header string
point_cloud_topic Topic to which point clouds are published string
cloud_frame_id ID specified in the point cloud message header string
odometry_topic Topic to which odometry is published string
odometry_frame_id ID specified in the odometry message header string
odometry_transform_frame_id Name of the transformation following the odometry string

最后一个ZED深度图效果图:


阅读更多
文章标签: ROS ubuntu cuda
个人分类: ROS
上一篇TensorFlow学习笔记(8)----CNN分类CIFAR-10数据集
下一篇笔记本建立Tensorflow(GPU)环境
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭