关于ORB-SLAM2、VI_ORB_SLAM2的编译问题 Opencv4.4.0
1.关于Opencv4.4
报错:
OpenCV > 2.4.3 not found.
– Configuring incomplete, errors occurred!
修改cmakelist.txt,将opencv3.0改为4.4,一个是orbslam2文件夹,另一个是DBoW2文件夹。
find_package(OpenCV 4.4 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()
2.缺少头文件
报错:
error: ’usleep’ was not declared in this scope
可能还有一些关于usleep的错误
报错的文件包括:mono_euroc.cc、mono_kitti.cc、mono_tum.cc、rgbd_tum.cc、stereo_euroc.cc、stereo_kitti.cc、LoopClosing.cc、System.cc、Viewer.cc
在报错的文件上添加:
#include <unistd.h>
3、头文件失效
报错:
fatal error: opencv/cv.h: 没有那个文件或目录
#include <opencv/cv.h>
报错文件:ORBextractor.h
将
#include <opencv/cv.h>
替换为
#include<opencv2/imgproc/imgproc_c.h>
#include <opencv2/highgui/highgui_c.h>
4、Opencv定义更换
报错:
error:'CV_LOAD_IMAGE_UNCHANGED' was not declared in this scope
报错的文件包括:mono_euroc.cc、mono_kitti.cc、mono_tum.cc、rgbd_tum.cc、stereo_euroc.cc、stereo_kitti.cc
将
CV_LOAD_IMAGE_UNCHANGED
替换为
cv::IMREAD_UNCHANGED
5、
报错:
/usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator
122 | static_assert(is_same<typename _Alloc::value_type, value_type>::value,
^~~~~
报错文件: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;