在原来的基础上做出一些改动:
1. 在源码C++文件中添加添加头文件 :
#include <opencv2/imgcodecs/legacy/constants_c.h>
原来出现的错误:
error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
2. 使用eigen3.3.9,eigen3.2.10不兼容
3. 将CMakeLists文件里的:
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")
改为:
set(CMAKE_CXX_FLAGS "-std=c++14 -O2 ${SSE_FLAGS} -msse4")
因为Ubuntu20.04默认安装的是c++14。
4. SLAM十四讲 ch7 orb_self.cpp中cv::DMatch m{i1, 0, 256}报错:
warning: narrowing conversion of ‘i’ from ‘size_t {aka long unsigned int}’ to ‘int’ inside { } [-Wnarrowing]
进行强制类型转换,将变量 i 强制转换为int型:
for (size_t i1 = 0; i1 < desc1.size(); ++i1) {
if (desc1[i1].empty()) continue;
cv::DMatch m{static_cast<int>(i1), 0, 256};
5. 将pose_estimation_2d2d.cpp第144行代码修改为:
fundamental_matrix = findFundamentalMat(points1, points2, FM_8POINT);
原来报错:
error: ‘CV_FM_8POINT’ was not declared in this scope
6. CMakeList.txt文件中,target_link_libraries(pose_estimation_3d3d)和target_link_libraries(pose_estimation_3d2d)中加fmt。
参考:
1.SLAM十四讲 ch7 orb_self.cpp中402行代码:cv::DMatch m{i1, 0, 256}报错_Eric Downey的博客-CSDN博客_slam 代码有多少行