环境
系统:Ubuntu20.04
OpenCV:4.5.2
Eigen:3.4
问题1 OpenCV版本问题
解决方法:在CMakeLists.txt中将find_package( OpenCV3.0 REQUIRED )中的3.0改为对应版本或者直接去掉3.0
问题2 CV_IMAGE_COLOR was not declared
/home/xu/code/slambook/ch7/feature_extraction.cpp:18:31: error: ‘CV_IMREAD_COLOR’ was not declared in this scope
18 | Mat img_1 = imread(argv[1], CV_IMREAD_COLOR);
解决方法:直接替换
CV_LOAD_IMAGE_UNCHANGED = -1 ( = cv::IMREAD_UNCHANGED),
CV_LOAD_IMAGE_GRAYSCALE = 0 ( = cv::IMREAD_GRAYSCALE),
CV_LOAD_IMAGE_COLOR = 1 ( = cv::IMREAD_COLOR),
CV_LOAD_IMAGE_ANYDEPTH = 2 ( = cv::IMREAD_ANYDEPTH),
问题3 CV_FM_8P0INT was not declared
home/xu/code/slambook/ch7/triangulation.cpp:154:65: error: ‘CV_FM_8POINT’ was not declared in this scope
154 | fundamental_matrix = findFundamentalMat ( points1, points2, CV_FM_8POINT );
解决:将CV_FM_8P0INT改为cv::FM_8P0INT
问题4
/home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp: In function ‘int main(int, char**)’:
/home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*&)’
Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器
^
In file included from /usr/local/include/g2o/core/block_solver.h:199:0,
from /home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp:4:
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: candidate: g2o::BlockSolver<Traits>::BlockSolver(std::unique_ptr<typename Traits::LinearSolverType>) [with Traits = g2o::BlockSolverTraits<3, 1>; typename Traits::LinearSolverType = g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >]
BlockSolver<Traits>::BlockSolver(std::unique_ptr<LinearSolverType> linearSolver)
^
/usr/local/include/g2o/core/block_solver.hpp:40:1: note: no known conversion for argument 1 from ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType* {aka g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >*}’ to ‘std::unique_ptr<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> >, std::default_delete<g2o::LinearSolver<Eigen::Matrix<double, 3, 3> > > >’
/home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp:79:103: error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)’
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );
^
In file included from /home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp:5:0:
/usr/local/include/g2o/core/optimization_algorithm_levenberg.h:47:16: note: candidate: g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(std::unique_ptr<g2o::Solver>)
explicit OptimizationAlgorithmLevenberg(std::unique_ptr<Solver> solver);
^
/usr/local/include/g2o/core/optimization_algorithm_levenberg.h:47:16: note: no known conversion for argument 1 from ‘Block* {aka g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >*}’ to ‘std::unique_ptr<g2o::Solver>’
CMakeFiles/curve_fitting.dir/build.make:62: recipe for target 'CMakeFiles/curve_fitting.dir/main.cpp.o' failed
make[2]: *** [CMakeFiles/curve_fitting.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/curve_fitting.dir/all' failed
make[1]: *** [CMakeFiles/curve_fitting.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
解决:重新一下3rdparty文件夹中的g2o
需要将原先的删除
sudo rm -r /usr/local/include/g2o
sudo rm -r /usr/local/lib/libg2o*
sudo rm -r /usr/local/bin/g2o*
问题5
/usr/local/include/g2o/core/base_fixed_sized_edge.h:174:32: error: ‘index_sequence’ is not a member of ‘std’
174 | struct HessianTupleType<std::index_sequence<Ints...>> {
解决方法:需要在Cmakelists中更新至c++14