欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Ubuntu 16.04 CUDA9.0 安装ORB_SLAM(上)(原创)

程序员文章站 2022-03-16 17:46:58
...

3 安装Pangolin,用于可视化和用户接口
3.1 安装依赖库
3.2 下载Pangolin并配置环境

cd ~/catkin_ws/src

git clone https://github.com/stevenlovegrove/Pangolin

cd ..

catkin_make

source ~/catkin-ws/devel/setup.bash

此步骤执行到catkin_make时,报错:(暂时未解决,先执行下一步)

-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - pangolin (plain cmake)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkin_workspace.cmake:95 (message):
  This workspace contains non-catkin packages in it, and catkin cannot build
  a non-homogeneous workspace without isolation.  Try the
  'catkin_make_isolated' command instead.
Call Stack (most recent call first):
  CMakeLists.txt:63 (catkin_workspace)


-- Configuring incomplete, errors occurred!
See also "/home/l/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/l/catkin_ws/build/CMakeFiles/CMakeError.log".

3.3 编译并安装Pangolin

cd Pangolin

mkdir build

cd build

cmake ..

make -j8

sudo make install

4 安装OpenCV
4.1 官网下载OpenCV
建议版本2.4.13,3以上的版本未测试。
4.2 安装编译工具

sudo apt-get install build-essential -y

4.3 安装依赖包

sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y

4.4 安装可选包

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -y 
sudo apt-get install libgtk2.0-dev -y 
sudo apt-get install pkg-config -y

4.5 进入安装目录 ~/catkin_ws/src ,OpenCV解压至当前目录下。

wget https://github.com/Itseez/opencv/archive/2.4.13.zip

unzip 2.4.13.zi

4.6 编译安装OpenCV源码

cd opencv-2.4.13/

mkdir build

cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 

make

sudo make install

CMAKE后的信息为:

-- -----------------------------------------------------------------
CMake Warning at cmake/OpenCVPackaging.cmake:23 (message):
  CPACK_PACKAGE_VERSION does not match version provided by version.hpp
  header!
Call Stack (most recent call first):
  CMakeLists.txt:1105 (include)


-- Configuring done
-- Generating done
-- Build files have been written to: /home/l/catkin_ws/src/opencv-2.4.13/build

MAKE后报错:(此处问题一直解决不了…)

nvcc fatal   : Unsupported gpu architecture 'compute_20'
CMake Error at cuda_compile_generated_matrix_operations.cu.o.cmake:208 (message):
  Error generating
  /home/l/catkin_ws/src/opencv-2.4.13/build/modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/./cuda_compile_generated_matrix_operations.cu.o


modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/cuda_compile_generated_matrix_operations.cu.o' failed
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/cuda_compile_generated_matrix_operations.cu.o] Error 1
CMakeFiles/Makefile2:890: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

解决过程:
方法一:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..

输出:

CMake Warning at cmake/OpenCVPackaging.cmake:23 (message):
  CPACK_PACKAGE_VERSION does not match version provided by version.hpp
  header!
Call Stack (most recent call first):
  CMakeLists.txt:1105 (include)


-- Configuring done
-- Generating done
-- Build files have been written to: /home/l/catkin_ws/src/opencv-2.4.13/build

MAKE后报错:

[ 98%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/nvidia/TestTranspose.cpp.o
[ 98%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/nvidia/TestIntegralImage.cpp.o
[ 98%] Linking CXX executable ../../bin/opencv_perf_gpu
[ 98%] Built target opencv_perf_gpu
[ 98%] Linking CXX executable ../../bin/opencv_test_gpu
[ 98%] Built target opencv_test_gpu
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2


/home/l/catkin_ws/src/opencv-2.4.13/modules/contrib/src/rgbdodometry.cpp:65:47: **fatal error:** unsupported/Eigen/MatrixFunctions: No such file or directory
compilation terminated.
modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:374: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o' failed
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o] Error 1

报错eigen相关,所以就先安装eigen了:
5 安装Eigen3
5.1 最低要求版本为3.1.0。在http://eigen.tuxfamily.org 下载 Eigen3.2.10 压缩文件,并解压。
下载并解压 Eigen3.2.10 到~/catkin_ws/src


 1.    wget https://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
 2.    tar -xjf 3.2.10.tar.bz2

编译安装:

cd eigen-3.2.10/

mkdir build

cd build

cmake ..

make

sudo make install

Eigen顺利安装完成。

此时,在回到opencv的build目录下,重新make,
此时,比上次make顺利很多,没有那么多warning和note,但是,仍然报错:

[ 87%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o
/home/l/catkin_ws/src/opencv-2.4.13/modules/contrib/src/rgbdodometry.cpp:65:47: fatal error: unsupported/Eigen/MatrixFunctions: No such file or directory
compilation terminated.
modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:374: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o' failed
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o] Error 1
CMakeFiles/Makefile2:5942: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/all' failed
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

编译顺利多了,但问题对比了一下,还是没变。
fatal error: unsupported/Eigen/MatrixFunctions: No such file or directory
compilation terminated.

解决方案是将对应的文件夹复制到/usr/include/下,举例Eigen安装到了/usr/include/eigen3/,则执行:

$ cd /usr/include/eigen3/
$ sudo cp -r unsupported/ ..
$ sudo cp -r Eigen/ ..

之后重新make OpenCV,结果显示:

[ 96%] Linking CXX executable ../../bin/opencv_perf_superres
[ 96%] Built target opencv_perf_superres
[ 97%] Built target opencv_videostab_pch_dephelp
[ 98%] Built target pch_Generate_opencv_videostab
[ 98%] Linking CXX shared library ../../lib/libopencv_videostab.so
[ 98%] Built target opencv_videostab
[ 99%] Built target opencv_haartraining_engine
[ 99%] Linking CXX executable ../../bin/opencv_performance
[ 99%] Built target opencv_performance
[ 99%] Linking CXX executable ../../bin/opencv_createsamples
[ 99%] Built target opencv_createsamples
[ 99%] Linking CXX executable ../../bin/opencv_haartraining
[ 99%] Built target opencv_haartraining
[ 99%] Linking CXX executable ../../bin/opencv_traincascade
[100%] Built target opencv_traincascade
[100%] Linking CXX executable ../../bin/opencv_annotation
[100%] Built target opencv_annotation
[100%] Linking CXX executable ../../bin/opencv_visualisation
[100%] Built target opencv_visualisation

看来这种方法是有效的!

相关标签: SLAM