高翔slam14讲中ch7代码中的一些修改

目录

  • 问题1: opencv版本问题,编译出错。
  • 问题2: ../ch7/pose_estimation_3d2d.cpp:43:35: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
  • 问题3: 编译2d2d.cpp时, 报错:CV_FM_8POINT was not declared in this scope
  • 问题4: 这个是g2o库更新导致用法改变
  • 主要参考:

章节:高翔slam14讲中ch7
使用系统:Ubuntu18.04,opencv4.1.0

问题1: opencv版本问题,编译出错。

解决方法:在CMakeLists.txt中将find_package( OpenCV3.0 REQUIRED )中的3.0改为对应版本或者直接去掉3.0

问题2: …/ch7/pose_estimation_3d2d.cpp:43:35: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope

解决方法:将所有.cpp文件中出现的CV_LOAD_IMAGE_xxxx用对应的flag值代替,具体代替值如下

   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),

注:pose_estimation_2d2d.cpp;pose_estimation_3d3d.cpp中也同样修改。

问题3: 编译2d2d.cpp时, 报错:CV_FM_8POINT was not declared in this scope

解决方法:将CV_去掉再编译就可以通过。(此处Learning OpenCV3中有关于findFundamentalMat()函数中method选择的说明)

问题4: 这个是g2o库更新导致用法改变

运行pose_estimation_3d2d.cpp (3d3d同样如下)时错误如下:

error: no matching function for call to ‘g2o::BlockSolver >::BlockSolver(g2o::BlockSolver >::LinearSolverType*&)’DirectBlock* solver_ptr = new DirectBlock ( linearSolver );

error: no matching function for call to ‘g2o::OptimizationAlgorithmLevenberg::OptimizationAlgorithmLevenberg(Block*&)’

原代码:

Block* solver_ptr = new Block( linearSolver );      // 矩阵块求解器

g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );

修改如下

Block* solver_ptr = new Block( unique_ptr(linearSolver) );      // 矩阵块求解器

g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( unique_ptr(solver_ptr) );

主要参考:

  1. https://blog.csdn.net/weixin_43988000/article/details/84856917
  2. https://blog.csdn.net/unlimitedai/article/details/86546368
  3. https://blog.csdn.net/robinhjwy/article/details/78084210
  4. Kaehler A, et al. Learning OpenCV 3

你可能感兴趣的:(slam)