Vins-Fusion代码跑通

这篇具有很好参考价值的文章主要介绍了Vins-Fusion代码跑通。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题环境背景:

首先是Ubuntu2004 电脑里面有opencv3和opencv4共存,

现象:编译的时候ros指向opencv4版本之间的不兼容导致

首先是遇到ceres库的版本问题

然后是

源码安装vins-mono算法问题整理(ROS Melodic + opencv 4.1.1) - 创客智造/爱折腾智能机器人社区

测试环境:Jetson Xavier NX+ Jetpack4.4 + Ubuntu 1804 + ROS Melodic + opencv 4.1.1
 
问题一

  •  编译时报错 error: ‘CV_GRAY2RGB’ was not declared in this scope 等
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In constructor ‘camodocal::Chessboard::Chessboard(cv::Size, cv::Mat&)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:20:38: error: ‘CV_GRAY2BGR’ was not declared in this scope
         cv::cvtColor(image, mSketch, CV_GRAY2BGR);
                                      ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:26:37: error: ‘CV_BGR2GRAY’ was not declared in this scope
         cv::cvtColor(image, mImage, CV_BGR2GRAY);
                                     ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::findChessboardCornersImproved(const cv::Mat&, const Size&, std::vector<cv::Point_<float> >&, int)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:150:43: error: ‘CV_BGR2GRAY’ was not declared in this scope
             cv::cvtColor(image, norm_img, CV_BGR2GRAY);
                                           ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:207:67: error: ‘CV_THRESH_BINARY’ was not declared in this scope
                 cv::threshold(img, thresh_img, thresh_level, 255, CV_THRESH_BINARY);
                                                                   ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In constructor ‘camodocal::Chessboard::Chessboard(cv::Size, cv::Mat&)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:20:38: error: ‘CV_GRAY2BGR’ was not declared in this scope
         cv::cvtColor(image, mSketch, CV_GRAY2BGR);
                                      ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:26:37: error: ‘CV_BGR2GRAY’ was not declared in this scope
         cv::cvtColor(image, mImage, CV_BGR2GRAY);
                                     ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: error: ‘CV_SHAPE_CROSS’ was not declared in this scope
             cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::findChessboardCornersImproved(const cv::Mat&, const Size&, std::vector<cv::Point_<float> >&, int)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:150:43: error: ‘CV_BGR2GRAY’ was not declared in this scope
             cv::cvtColor(image, norm_img, CV_BGR2GRAY);
                                           ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: note: suggested alternative: ‘CV_WRAP_AS’
             cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~~
                                                         CV_WRAP_AS
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:216:57: error: ‘CV_SHAPE_RECT’ was not declared in this scope
             cv::Mat kernel2 = cv::getStructuringElement(CV_SHAPE_RECT, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:43: error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
                          cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
                                           ^~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:207:67: error: ‘CV_THRESH_BINARY’ was not declared in this scope
                 cv::threshold(img, thresh_img, thresh_level, 255, CV_THRESH_BINARY);
                                                                   ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:61: error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
                          cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
                                                             ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: error: ‘CV_SHAPE_CROSS’ was not declared in this scope
             cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:215:57: note: suggested alternative: ‘CV_WRAP_AS’
             cv::Mat kernel1 = cv::getStructuringElement(CV_SHAPE_CROSS, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~~
                                                         CV_WRAP_AS
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:216:57: error: ‘CV_SHAPE_RECT’ was not declared in this scope
             cv::Mat kernel2 = cv::getStructuringElement(CV_SHAPE_RECT, cv::Size(3,3), cv::Point(1,1));
                                                         ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:43: error: ‘CV_TERMCRIT_EPS’ was not declared in this scope
                          cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
                                           ^~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘void camodocal::Chessboard::generateQuads(std::vector<boost::shared_ptr<camodocal::ChessboardQuad> >&, cv::Mat&, int, int, bool)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:50: error: ‘CV_RETR_CCOMP’ was not declared in this scope
     cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                  ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:320:61: error: ‘CV_TERMCRIT_ITER’ was not declared in this scope
                          cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
                                                             ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:65: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
     cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                                 ^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘void camodocal::Chessboard::generateQuads(std::vector<boost::shared_ptr<camodocal::ChessboardQuad> >&, cv::Mat&, int, int, bool)’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:50: error: ‘CV_RETR_CCOMP’ was not declared in this scope
     cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                  ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1175:65: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
     cv::findContours(image, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                                 ^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::checkChessboard(const cv::Mat&, cv::Size) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1586:72: error: ‘CV_THRESH_BINARY’ was not declared in this scope
         cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, CV_THRESH_BINARY);
                                                                        ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:55: error: ‘CV_RETR_CCOMP’ was not declared in this scope
         cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                       ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:70: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
         cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc: In member function ‘bool camodocal::Chessboard::checkChessboard(const cv::Mat&, cv::Size) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1586:72: error: ‘CV_THRESH_BINARY’ was not declared in this scope
         cv::threshold(white, thresh, threshLevel + blackWhiteGap, 255, CV_THRESH_BINARY);
                                                                        ^~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1597:56: error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope
         cv::threshold(black, thresh, threshLevel, 255, CV_THRESH_BINARY_INV);
                                                        ^~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:55: error: ‘CV_RETR_CCOMP’ was not declared in this scope
         cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                       ^~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1592:70: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
         cv::findContours(thresh, contours, hierarchy, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);
                                                                      ^~~~~~~~~~~~~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/chessboard/Chessboard.cc:1597:56: error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope
         cv::threshold(black, thresh, threshLevel, 255, CV_THRESH_BINARY_INV);

/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc: In member function ‘void camodocal::CameraCalibration::drawResults(std::vector<cv::Mat>&) const’:
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:236:40: error: ‘CV_GRAY2RGB’ was not declared in this scope
             cv::cvtColor(image, image, CV_GRAY2RGB);
                                        ^~~~~~~~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:236:40: note: suggested alternative: ‘CV_GRAPH’
             cv::cvtColor(image, image, CV_GRAY2RGB);
                                        ^~~~~~~~~~~
                                        CV_GRAPH
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:254:37: error: ‘CV_AA’ was not declared in this scope
                        5, green, 2, CV_AA, drawShiftBits);
                                     ^~~~~
/home/ubuntu/catkin_ws/src/VINS-Mono/camera_model/src/calib/CameraCalibration.cc:254:37: note: suggested alternative: ‘CV_AVX’
                        5, green, 2, CV_AA, drawShiftBits);
                                     ^~~~~
                                     CV_AVX


解决方法
 

  • 在报错文件上添加头文件 #include <opencv2/imgproc/imgproc_c.h>
  • 单独遇到CV_AA的报错时,也可以将 CV_AA 改为 cv::LINE_AA


问题二
 

  • 编译时报错 error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope 、error: ‘CV_CALIB_CB_NORMALIZE_IMAGE’ was not declared in this scope、error: ‘CV_CALIB_CB_FILTER_QUADS’ was not declared in this scope 和 error: ‘CV_CALIB_CB_FAST_CHECK’ was not declared in this scope


解决方法
 

  • 将CV_CALIB_CB_ADAPTIVE_THRESH、CV_CALIB_CB_NORMALIZE_IMAGE、CV_CALIB_CB_FILTER_QUADS和CV_CALIB_CB_FAST_CHECK修改为 cv::CALIB_CB_ADAPTIVE_THRESH 、 cv::CALIB_CB_NORMALIZE_IMAGE 、cv::CALIB_CB_FILTER_QUADS 和cv::CALIB_CB_FAST_CHECK

 
问题三
 

  • 编译时报错 error: ‘CV_RGB2GRAY’ was not declared in this scope
/home/ubuntu/catkin_ws/src/VINS-Mono/pose_graph/src/ThirdParty/DVision/BRIEF.cpp:53:32: error: ‘CV_RGB2GRAY’ was not declared in this scope cv::cvtColor(image, aux, CV_RGB2GRAY);
^~~~~~~~~~~ 
/home/ubuntu/catkin_ws/src/VINS-Mono/pose_graph/src/ThirdParty/DVision/BRIEF.cpp:53:32: note: suggested alternative: ‘CV_RGB’ cv::cvtColor(image, aux, CV_RGB2GRAY);



解决方法
 

  • 在报错文件上添加头文件 #include<opencv2/imgproc/types_c.h>


问题四
 

  • 编译时遇到报错 error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope

 
解决方法
 

  • 将报错文件上的 CV_FONT_HERSHEY_SIMPLEX 参数改为 cv::FONT_HERSHEY_SIMPLEX
问题5 

 error: 'CV_LOAD_IMAGE_GRAYSCALE' was not declared in this scope

解决办法

CV_LOAD_IMAGE_GRAYSCALE   替换成 cv::IMREAD_GRAYSCALE

 文章来源地址https://www.toymoban.com/news/detail-736861.html

到了这里,关于Vins-Fusion代码跑通的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 视觉里程计学习笔记

    一、相机 1、双目相机的 D、P、K、R矩阵 是相机标定时得到的一组重要参数,它们分别代表以下含义: D矩阵 : 畸变矫正参数矩阵 。它包含了 相机图像坐标系下的径向畸变和切向畸变系数,用于将畸变像素坐标转化为无畸变的像素坐标 。对每个相机而言都有一个D矩阵。 P矩

    2024年02月03日
    浏览(40)
  • 视觉SLAM14讲笔记-第7讲-视觉里程计2

    直接法的引出 直接法是视觉里程计另一个主要分支,它与特征点法有很大的不同。 使用特征点法估计相机运动时,我们把特征点看作固定在三维空间的不动点。根据它们在相机中的投影位置,通过 最小化重投影误差 来优化相机运动。 相对地,在直接法中,我们并不需要知

    2024年02月09日
    浏览(37)
  • SLAM-VIO视觉惯性里程计

    VIO(visual-inertial odometry)即视觉惯性里程计,有时也叫视觉惯性系统(VINS,visual-inertial system),是融合相机和IMU数据实现SLAM的算法,根据融合框架的区别又分为紧耦合和松耦合,松耦合中视觉运动估计和惯导运动估计系统是两个独立的模块,将每个模块的输出结果进行融合

    2024年02月11日
    浏览(40)
  • 2022最新!视觉SLAM综述(多传感器/姿态估计/动态环境/视觉里程计)

    目录 摘要 视觉SLAM算法的发展 相关综述 VSLAM 设置标准 传感器和数据采集 目标环境 视觉特征处理 系统评估 语义等级 基于主要目标的VSLAM方法 目标一:多传感器处理 目标二:姿态估计 目标三:现实世界可行性 目标四:资源限制 目标五:弹性化(Versatility) 目标六:视觉里

    2023年04月20日
    浏览(59)
  • 从零实战SLAM-第八课(非特征点的视觉里程计)

     在七月算法报的班,老师讲的蛮好。好记性不如烂笔头,关键内容还是记录一下吧,课程入口,感兴趣的同学可以学习一下。 ------------------------------------------------------------------------------------------------------------------------------- 特征点法流程: 1.在图像中提取特征点并计算特征

    2024年02月12日
    浏览(35)
  • IMU惯性里程计解算(附代码实现)

    一、系统概述 IMU是机器人常用的传感器之一,IMU对机器人的定位功能实现非常重要,其优点在于是内源传感器对外部环境变化不明显,输出频率高,缺点在于存在累积误差。本文主要记录一下在机器人定位中对IMU的使用和对惯性导航里程计的理解和实现。 本文代码主要依赖

    2023年04月15日
    浏览(44)
  • 如何使用imu和轮速里程计融合定位?代码怎么写

    使用IMU和轮速里程计融合定位的一般步骤如下: 将IMU和轮速里程计的数据预处理成需要的形式。 使用一种预测滤波器(例如卡尔曼滤波器或高斯滤波器)来预测机器人的位置和姿态。 使用轮速里程计的测量来校正预测的位置和姿态。 使用IMU的测量来校正预测的姿态。 下面是使

    2024年02月16日
    浏览(39)
  • 【视觉SLAM入门】5.1. (基于特征点的视觉里程计)特征提取和匹配--FAST,ORB(关键点描述子),2D-2D对极几何,本质矩阵,单应矩阵,三角测量,三角化矛盾

    为什么重要?我们是在做什么事? 特征提取和匹配: 首先是两幅图像的特征提取,然后是对应特征点的匹配。接下来的工作是根据得到的匹配点对,估计相机的运动,具体根据相机分为三种方法: 单目相机:2D-2D: 对极几何 方法 双目或者RGBD相机: 3D-3D: ICP 方法 一个3D点

    2024年02月10日
    浏览(38)
  • 基于ROS发布里程计信息

    参考文档: navigationTutorialsRobotSetupOdom 参考博客: (1)ROS机器人里程计模型 (2)ROS里程计消息nav_msgs/Odometry的可视化方法 1 常用坐标系系统模型 世界坐标系是描述机器人全局信息的坐标系;机器人坐标系是描述机器人自身信息的坐标系;传感器坐标系是描述传感器信息的坐

    2024年02月08日
    浏览(45)
  • 差速驱动机器人的车轮里程计模型

            车轮测程法是指使用旋转编码器(即连接到车轮电机以测量旋转的传感器)的测程法(即估计运动和位置)。这是轮式机器人和自动驾驶汽车定位的有用技术。         在本文中,我们将通过探索差速驱动机器人的

    2024年02月15日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包