当前位置:   article > 正文

视觉SLAM十四讲-第八讲调试笔记及问题解决(LK光流)_-- configuring incomplete, errors occurred! slam

-- configuring incomplete, errors occurred! slam

编译过程中,cmake ..报错如下:

  1. CMake Error at CMakeLists.txt:8 (find_package):
  2. Could not find a configuration file for package "OpenCV" that is compatible
  3. with requested version "4".
  4. The following configuration files were considered but not accepted:
  5. /usr/share/OpenCV/OpenCVConfig.cmake, version: 3.2.0
  6. -- Configuring incomplete, errors occurred!
  7. See also "/home/nanorobot/slambook2_1/ch8/build/CMakeFiles/CMakeOutput.log".

定位到这句提示:Could not find a configuration file for package "OpenCV" that is compatible

with requested version "4".

原因在于:代码中的一些函数是opencv4中的函数。因此,我们要安装opencv4。

安装opencv4步骤:

OpenCV4的安装与错误解决-linux_Canminem的博客-CSDN博客

安装opencv4后,再次执行cmake ..,提示如下,说明opencv的问题已经解决:

  1. nanorobot@ubuntu:~/slambook2_1/ch8/build$ cmake ..
  2. -- Found OpenCV: /usr/local (found suitable version "4.5.0", minimum required is "4")
  3. -- Configuring done
  4. -- Generating done
  5. -- Build files have been written to: /home/nanorobot/slambook2_1/ch8/build

接下来,make编译, optical_flow.cpp出现报错:

  1. nanorobot@ubuntu:~/slambook2_1/ch8/build$ make
  2. Scanning dependencies of target optical_flow
  3. [ 25%] Building CXX object CMakeFiles/optical_flow.dir/optical_flow.cpp.o
  4. /home/nanorobot/slambook2_1/ch8/optical_flow.cpp: In function ‘int main(int, char**)’:
  5. /home/nanorobot/slambook2_1/ch8/optical_flow.cpp:143:37: error: ‘CV_GRAY2BGR’ was not declared in this scope
  6. cv::cvtColor(img2, img2_single, CV_GRAY2BGR);
  7. ^~~~~~~~~~~
  8. CMakeFiles/optical_flow.dir/build.make:62: recipe for target 'CMakeFiles/optical_flow.dir/optical_flow.cpp.o' failed
  9. make[2]: *** [CMakeFiles/optical_flow.dir/optical_flow.cpp.o] Error 1
  10. CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/optical_flow.dir/all' failed
  11. make[1]: *** [CMakeFiles/optical_flow.dir/all] Error 2
  12. Makefile:83: recipe for target 'all' failed
  13. make: *** [all] Error 2

此错误原因出在代码上,原因在于opencv4把CV_GRAY2BGR改为了COLOR_GRAY2BGR,我们定位到CV_GRAY2BGR,将CV_GRAY2BGR,更新为COLOR_GRAY2BGR(direct_method.cpp也要修改)。改正保存即可。再次编译,出现direct_method.cpp依然报错,如下:

  1. nanorobot@ubuntu:~/slambook2_1/ch8/build$ make
  2. Scanning dependencies of target optical_flow
  3. [ 25%] Building CXX object CMakeFiles/optical_flow.dir/optical_flow.cpp.o
  4. [ 50%] Linking CXX executable optical_flow
  5. [ 50%] Built target optical_flow
  6. Scanning dependencies of target direct_method
  7. [ 75%] Building CXX object CMakeFiles/direct_method.dir/direct_method.cpp.o
  8. /home/nanorobot/slambook2_1/ch8/direct_method.cpp: In function ‘void DirectPoseEstimationSingleLayer(const cv::Mat&, const cv::Mat&, const VecVector2d&, std::vector<double, std::allocator<double> >, Sophus::SE3d&)’:
  9. /home/nanorobot/slambook2_1/ch8/direct_method.cpp:206:35: error: ‘CV_GRAY2BGR’ was not declared in this scope
  10. cv::cvtColor(img2, img2_show, CV_GRAY2BGR);
  11. ^~~~~~~~~~~
  12. CMakeFiles/direct_method.dir/build.make:62: recipe for target 'CMakeFiles/direct_method.dir/direct_method.cpp.o' failed
  13. make[2]: *** [CMakeFiles/direct_method.dir/direct_method.cpp.o] Error 1
  14. CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/direct_method.dir/all' failed
  15. make[1]: *** [CMakeFiles/direct_method.dir/all] Error 2
  16. Makefile:83: recipe for target 'all' failed
  17. make: *** [all] Error 2

解决方法:

在direct_method.cpp加入:

using namespace cv;

代码片段如下:

  1. #include <opencv2/opencv.hpp>
  2. #include <sophus/se3.hpp>
  3. #include <boost/format.hpp>
  4. #include <pangolin/pangolin.h>
  5. using namespace std;
  6. using namespace cv;
  7. typedef vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d>> VecVector2d;

再次编译,问题解决。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/292837
推荐阅读
相关标签
  

闽ICP备14008679号