2.在代码中分析VINS---图解特征点管理(feature_manager.h)

这篇博客主要讲解VINS中特征点的管理,它主要涉及3个类,位于feature_manager.h中的FeaturePerFrame、FeaturePerId、FeatureManager

1.特征点管理示意图


上图中有两个路标特征点P1,P2,分别被帧1~2,2~4观测到。

2.FeaturePerId

就特征点P1来说,它被两个帧观测到,第一次观测到P1的帧为frame1,即start_frame=1,最后一次观测到P1的帧为frame2,即endframe()=2,并把start_frame~endframe() 对应帧的属性存储起来,对应的示意图如下:

上述对应的代码为:

class FeaturePerId//管理一个特征点
{
  public:
    const int feature_id;//特征点id
    int start_frame;//第一次出现该特征点的帧号
    vector<FeaturePerFrame> feature_per_frame;//管理对应帧的属性
    int used_num;//出现的次数
    double estimated_depth;//逆深度
    int solve_flag; // 0 haven't solve yet; 1 solve succ; 2 solve fail;该特征点的状态,是否被三角化
    Vector3d gt_p;
    FeaturePerId(int _feature_id, int _start_frame)//以feature_id为索引,并保存了出现该角点的第一帧的id
        : feature_id(_feature_id), start_frame(_start_frame),
          used_num(0), estimated_depth(-1.0), solve_flag(0)
    {
    }
    int endFrame();//得到该特征点最后一次跟踪到的帧号
};

3.FeaturePerFrame

在上面提到对应帧的属性这个概念,它指的是空间特征点P1映射到frame1或frame2上对应的图像坐标、特征点的跟踪速度、空间坐标等属性都封装到类FeaturePerFrame中,对应的示意图如下:

它对应的代码为:

class FeaturePerFrame//一个特征点的属性
{
  public:
    FeaturePerFrame(const Eigen::Matrix<double, 7, 1> &_point, double td)
    {
        point.x() = _point(0);
        point.y() = _point(1);
        point.z() = _point(2);
        uv.x() = _point(3);
        uv.y() = _point(4);
        velocity.x() = _point(5); 
        velocity.y() = _point(6); 
        cur_td = td;
    }
    double cur_td;//imu-camera的不同步时的相差时间
    Vector3d point;//特征点空间坐标
    Vector2d uv;//特征点映射到该帧上的图像坐标
    Vector2d velocity;//特征点的跟踪速度
    double z;
    bool is_used;
    double parallax;
    MatrixXd A;
    VectorXd b;
    double dep_gradient;
};

4.FeaturePerId

上述是对一个特征点讨论的,如果是对所有的特征点进行讨论的话,则可以构建list容器,存储每一个特征点,对应的示意图如下:

对应代码为:

class FeatureManager//管理所有i特征点
{
list<FeaturePerId> feature;//存储每一个特征点,及其对应的每帧的属性
}

5.说明

前面只是对特征点的管理做了一个最简单的概述,其实真实特征点的管理很复杂,还得考虑特征点的三角化、两帧之间的视差处理等等。

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务