Thinkpad T470p配置MYNT EYE Camera开发环境

新电脑为Thinkpad T470p(自带940mx显卡),为SLAM系统开发配置环境,使用MYNT EYE Camera。

Ubuntu 16.04

系统安装

官网下载Ubuntu16.04系统ISO镜像。 使用Rufus创建启动盘。 rufus

安装系统。

换源
1
2
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
sudo gedit /etc/apt/sources.list

填入:

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse

终端:

1
2
sudo apt-get update
sudo apt-get upgrade
1
sudo apt-get install build-essential vim

安装NVIDIA驱动

查看Linux内核版本:

1
2
uname -r
4.13.0-36-generic

本来想安装CUDA 9.1,但它自带的387.26驱动不支持当前的内核版本(4.13),如果降低内核版本(4.4),则会导致很多其他的硬件驱动问题。

所以使用APT安装1

1
2
3
4
5
sudo apt-get remove --purge nvidia*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FCAE110B1118213C
sudo apt-get update
sudo apt-get install nvidia-396
测试

重启电脑,终端执行:

1
ls /dev/nvidia*

应出现如:

1
/dev/nvidia0  /dev/nvidiactl  /dev/nvidia-modeset /dev/nvidia-uvm

如出现"/dev/nvidia*: No such file or directory"错误,按这里提示修复。

终端执行:

1
2
3
4
cat /proc/driver/nvidia/version

NVRM version: NVIDIA UNIX x86_64 Kernel Module 396.24 Thu Apr 26 00:10:09 PDT 2018
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

安装CUDA 9.1

官网下载CUDA cuda_9.1.85_387.26_linux.run。

1
2
chmod +x cuda_9.1.85_387.26_linux.run
sudo sh ./cuda_9.1.85_387.26_linux.run

只安装CUDA 9.1 Toolkit。

重启,配置环境:

1
sudo gedit ~/.bashrc

添加:

1
2
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

刷新:

1
source /etc/profile

重启:

1
2
3
4
5
6
nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Building Samples (optional)

1
2
3
4
cd <sample_dir>
make

./1_Utilities/deviceQuery/deviceQuery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce 940MX"
CUDA Driver Version / Runtime Version 9.2 / 9.1
CUDA Capability Major/Minor version number: 5.0
Total amount of global memory: 2004 MBytes (2101870592 bytes)
( 3) Multiprocessors, (128) CUDA Cores/MP: 384 CUDA Cores
GPU Max Clock rate: 1189 MHz (1.19 GHz)
Memory Clock rate: 2505 Mhz
Memory Bus Width: 64-bit
L2 Cache Size: 1048576 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Supports Cooperative Kernel Launch: No
Supports MultiDevice Co-op Kernel Launch: No
Device PCI Domain ID / Bus ID / location ID: 0 / 2 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.2, CUDA Runtime Version = 9.1, NumDevs = 1

安装OpenCV 3.4.0

官网下载sources。

1
2
3
4
5
6
7
8
9
10
sudo apt-get install build-essential git cmake git yasm libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev python-dev python-numpy python-tk libtbb2 libtbb-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libdc1394-22-dev libswscale-dev libopenexr-dev libeigen2-dev libeigen3-dev libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_GTK_2_X=ON ..
make -j8
sudo make install

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

安装 ROS Kinetic2

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full

sudo rosdep init
rosdep update

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

sudo apt-get install python-rosinstall

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc之后,系统的opencv版本会变成Kinetic自带的3.3版本,所以必要时不要添加此句。

配置MYNT EYE Camera

下载mynteye-1.8-linux-x64-gcc5-opencv-3.4.0.tar.gz

1
2
3
4
5
sudo apt-get install libssl-dev libv4l-dev v4l-utils

cd <sdk directory>
sudo ./install.sh
source ~/.bashrc

重启电脑。

测试
1
2
3
echo $MYNTEYE_SDK_ROOT

/home/cvte/Documents/software/mynteye-1.8-linux-x64-gcc5-opencv-3.4.0
1
./samples/bin/camera [name id]

  1. https://blog.csdn.net/soulmeetliang/article/details/78429197↩︎

  2. http://wiki.ros.org/kinetic/Installation/Ubuntu↩︎