1. orb-slam2文件下与其thirdparty/DBoW2文件下的cmakelist.txt中的opencv3.0等修改为你所使用的opencv版本,我使用的是opencv4.4,所以都修改成4.4
2.orb_slam2中的include/ORBextractor.h文件打开#include <opencv/cv.h>
替换为
#include "opencv2/imgcodecs/legacy/constants_c.h"
#include <opencv2/highgui/highgui_c.h>
3. 在orb_slam2/include中的LoopClosing.h文件
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
修改为
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
Eigen::aligned_allocator<std::pair<KeyFrame *const, g2o::Sim3> > > KeyFrameAndPose;
4. 出现error: ‘CV_LOAD_IMAGE_UNCHANGED’ was not declared in this scope错误
将CV_LOAD_IMAGE_UNCHANGED换成IMREAD_UNCHANGED并在代码头文件下面添加命名空间using namespace cv;
需要的文件有:
Examples/Monocular/mono_euroc.cc
Examples/Monocular/mono_kitti.cc
Examples/Monocular/mono_tum.cc
Examples/Stereo/stereo_euroc.cc
Examples/Stereo/stereo_kitti.cc
Examples/RGB-D/rgbd_tum.cc
需要增加#include <unistd.h>的文件有:
Examples/Monocular/mono_euroc.cc
Examples/Monocular/mono_kitti.cc
Examples/Monocular/mono_tum.cc
Examples/RGB-D/rgbd_tum.cc
Examples/Stereo/stereo_euroc.cc
Examples/Stereo/stereo_kitti.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/System.cc
src/Tracking.cc
src/Viewer.cc
这些都是在slam3中的文件进行修改,只要把以上修改完成之后就能够往后运行基本不会出错。