ubuntu18.04安装运行OpenVINS

一、安装依赖环境

(1)安装ROS

参照之前博客  ROS的安装_司马小妹的成长故事的博客-CSDN博客

(2)安装 opencv3.2

我之前安装的是pencv3.4与openvins不兼容,需要重新换成3.2

(1)下载OpenCV 3.2.0

在OPenCV官网下载OpenCV 3.2.0 的source包然后解压到本地(下载链接http://opencv.org/releases.html,选择sources版本)

解压下载下来的zip包:(把压缩包放在你想要的位置,然后cd到该位置,解压即可)

unzip opencv-3.2.0.zip

进入到解压后的文件包中:

 cd opencv-3.2.0


(2)安装依赖项

安装依赖库和cmake ,如果提醒需要apt-get update,那就先sudo su进入root权限,再sudo apt-get update,然后在执行下面命令

 sudo apt-get install cmake

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 libtiff5-dev libdc1394-22-dev

(处理图像所需的包)

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev

sudo apt-get install libxvidcore-dev libx264-dev

(处理视频所需的包)

sudo apt-get install libatlas-base-dev gfortran

(优化opencv功能)

sudo apt-get install ffmpeg


(3)编译安装

 cd opencv-3.2.0

mkdir build

cd build

再记录一下自己现在是装了opencv3.4.1和opencv3.2.0,为了适应大佬们的算法,需要有不同的版本,在安装和使用时需要注意的是:
在安装cmake步骤时,需要额外设置安装后的路径,因为第一个版本默认安装在usr/local下的,第二个版本就不能重复了呀!手动新建文件夹,opencv320 ,在cmake时执行

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 -D ENABLE_PRECOMPILED_HEADERS=OFF ..

(在中间会下载个东西,稍等一下就ok,没什么问题)

如果出现下载不成功的问题

(1)报错1,及解决方案

 错误如下:

-- ICV: Downloading ippicv_linux_20151201.tgz...
CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file):
  file DOWNLOAD HASH mismatch

    for file: [/home/aiko/opencv/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz]
      expected hash: [808b791a6eac9ed78d32a7666804320e]
        actual hash: [d41d8cd98f00b204e9800998ecf8427e]
             status: [35;"SSL connect error"]

Call Stack (most recent call first):
  3rdparty/ippicv/downloader.cmake:110 (_icv_downloader)
  cmake/OpenCVFindIPP.cmake:243 (include)
  cmake/OpenCVFindLibsPerf.cmake:37 (include)
  CMakeLists.txt:558 (include)


-- Configuring incomplete, errors occurred!
See also "/home/aiko/opencv/opencv-3.2.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/aiko/opencv/opencv-3.2.0/build/CMakeFiles/CMakeError.log".


 

解决办法:

(由于网络原因,可能出现ippicv_linux_20151201.tgz(无法在终端下载的情况,则可以先单独下载ippicv_linux_20151201.tgz之后,把其移动到终端所提示的路径(终端会提示该路径找不到文件),如路径/home/aiko/opencv/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz
覆盖掉没有下载成功的文件即可。

之后继续执行:

sudo make

(漫长的编译过程)

sudo make install

 (2)报错2,及解决方案

报错如下:

In file included from /home/aiko/opencv/opencv-3.2.0/modules/core/src/hal_internal.cpp:49:0:
/home/aiko/opencv/opencv-3.2.0/build/opencv_lapack.h:2:10: fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: 没有那个文件或目录
 #include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/core/CMakeFiles/opencv_core.dir/build.make:522: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o] Error 1
make[2]: *** 正在等待未完成的任务....
In member function ‘void cv::EigenvalueDecomposition::compute(cv::InputArray)’:
cc1plus: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
CMakeFiles/Makefile2:1165: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

将错误所在的文件打开,在我的目录中是:

/home/aiko/opencv/opencv-3.2.0/build/opencv_lapack.h

把第二行修改为 #include "lapacke.h" 

保存即可,

之后继续执行:

sudo make

(如果已经在新的文件夹中编译,但是还会出现之前的报错,把cmakecache.txt删了再编译就可)

(4)更改默认opencv 配置环境,添加路径

sudo make install 执行完毕后OpenCV编译过程就结束了,接下来就需要配置一些OpenCV的编译环境首先将OpenCV的库添加到路径,从而可以让系统找到:

 sudo gedit /etc/ld.so.conf.d/opencv.conf

执行此命令后打开的可能是一个空白的文件,不用管,只需要在文件末尾添加:

/usr/local/opencv320/lib

点击保存即可

执行如下命令使得刚才的配置路径生效:

sudo ldconfig

配置bash:

sudo gedit /etc/bash.bashrc

在最末尾添加:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH://usr/local/opencv320/lib/pkgconfig  
export PKG_CONFIG_PATH

点击保存即可

保存,执行如下命令使得配置生效:

source /etc/bash.bashrc  

更新:

sudo updatedb

(这一步是在更改默认使用哪一个opencv库,如果想换回opencv3.4 ,重复步骤(4)更改默认opencv 配置环境,添加路径即可)

(3)下载编译OpenVINS

mkdir -p ~/workspace/catkin_ws_ov/src/

cd ~/workspace/catkin_ws_ov/src/

git clone https://github.com/rpng/open_vins/

cd ..

catkin build -DENABLE_ARUCO_TAGS=OFF

之后报错问题1 ,如下:

catkin:未找到命令

(1)报错1,及解决方案

ubuntu18.04安装运行OpenVINS_第1张图片

我的情况是安装ROS环境后,catkin_make可以跑,但是如果跑catkin init或者catkin build就会遇到catkin:command not found。

所以只需要解决办法:

sudo apt-get update

sudo apt-get install python-catkin-tools

之后继续执行

catkin build

(2)报错2,及解决方案

ubuntu18.04安装运行OpenVINS_第2张图片

 错误原因:

Errors     << ov_data:cmake /home/aiko/workspace/catkin_ws_ov/logs/ov_data/build.cmake.001.log
CMake Error at /home/aiko/workspace/catkin_ws_ov/src/open_vins/ov_data/CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.12 or higher is required.  You are running version 3.10.2


(也就是说我的cmake版本太低,接下来我们更新cmake版本)

在不卸载ROS的前提下,升级cmake(官方就是用的cmake3.13.5,建议就用这个,之前用了3.21.0也不兼容)

tar -zxvf cmake-3.13.5.tar.gz
cd cmake-3.13.5 
./bootstrap --prefix=$HOME/cmake-install
make
make install

sudo gedit ~/.bashrc


#把下面两个命令加入~/.bashrc中
export PATH=$HOME/cmake-install/bin:$PATH
export CMAKE_PREFIX_PATH=$HOME/cmake-install:$CMAKE_PREFIX_PATH
#保存一下并运行
 

source ~/.bashrc
cmake --version 即可查看升级成功

二、运行openvins示例

(1)下在数据集

数据集地址:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets

个人下载了Vicon Room 101,得到文件 V1_01_easy.bag

(2)运行数据集

开终端1

roscore

开终端2

cd ~/workspace/catkin_ws_ov

source devel/setup.bash

roslaunch ov_msckf subscribe.launch config:=euroc_mav

开终端3

rviz

开终端4

cd ~/datasets

rosbag play V1_01_easy.bag

你可能感兴趣的:(slam,ubuntu,linux,运维)