ORB-SLAM2在OpenCV4.1.1下的编译问题

      之前迫不得已在jetson nano上编译orb-slam2,由于之前以及编译安装好了opencv4.1.1,所以直接编译orb-slam2时会出现一堆错误,这里简单记录一下遇到的问题和解决方法。

我的环境是Jetson Nano,Ubuntu 1804, ROS Melodic, OpenCV4.1.1

1.没有glew

sudo apt-get install libglew-dev

2.没有xkbcommon

sudo apt-get install libxkbcommon-x11-dev

3.没有libuvc

sudo apt install ros-$ROS_DISTRO-rgbd-launch ros-$ROS_DISTRO-libuvc ros-$ROS_DISTRO-libuvc-camera ros-$ROS_DISTRO-libuvc-ros

4.FATAL_ERROR "OpenCV > 2.4.3 not found."的错误
      修改cmakelist.txt,将opencv3.0改为4.1,我遇到两个地方,一个是orbslam2文件夹,另一个好像是DBoW2文件夹,可以根据错误信息查看。

 find_package(OpenCV 4.1 QUIET)
 if(NOT OpenCV_FOUND)
    find_package(OpenCV 2.4.3 QUIET)
    if(NOT OpenCV_FOUND)
       message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
    endif()
 endif()

5.多个文件出现#include 的错误
      这个问题主要是opencv4更换了一些定义,需要替换为:

#include
#include 

6.CV_LOAD_IMAGE_UNCHANGED的错误
      同样的,在opencv4中名称也改了不少,对应处替换为:

cv::IMREAD_UNCHANGED

7.undefined reference to symbol '_ZN5boost6system15system_categoryEv’的报错
      需要在cmakelists.txt中增加-lboost_system,如下所示:

set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
-lboost_system
)

8.在./build.sh过程中卡死
      修改build.sh文件,将最后一行的make -j改为make -j3(我用的是Jetson Nano,所以改的较低)。

9.运行rosrun ORB_SLAM2 RGBD xxxxxxx时出现Failed to load module "canberra-gtk-module"的错误

sudo apt-get install libcanberra-gtk-module

编译的主要流程可以参考这一篇博文:

https://blog.csdn.net/qq_41990294/article/details/104859046

你可能感兴趣的:(ORB-SLAM2在OpenCV4.1.1下的编译问题)