精读VINS-FUSION源码之feature_tracker.h

由于笔者本人的方向从图像做起,所以选择从特征提取的部分开始阅读,代码批注尽量详细,特别明显的没有写上去,如果有错误请大家及时反馈,讨论:
(精读的是港科大的vinsFuison代码;
github地址: https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.
文件位置位于:VINS-Fusion/vins_estimator/src/featureTracker/feature_tracker.h)

bool inBorder(const cv::Point2f &pt);
void reduceVector(vector<cv::Point2f> &v, vector<uchar> status);
void reduceVector(vector<int> &v, vector<uchar> status);

class FeatureTracker
{
public:
    FeatureTracker();
    //使用稀疏光流法进行追踪函数,包含了单目双目的处理情况
    map<int, vector<pair<int, Eigen::Matrix<double, 7, 1>>>> trackImage(double _cur_time, const cv::Mat &_img, const cv::Mat &_img1 = cv::Mat());
    void setMask();
    //读取相机的内参
    void readIntrinsicParameter(const vector<string> &calib_file);
    void showUndistortion(const string &name);
    void rejectWithF();//使用FM矩阵进行点的筛选,但是具体好像没有使用,使用了反追踪光流去筛选点
    void undistortedPoints();   //对获得点集去畸变
    vector<cv::Point2f> undistortedPts(vector<cv::Point2f> &pts, camodocal::CameraPtr cam);
    //计算特征点的速度,具体可以参考SLAM14讲的稀疏光流法
    vector<cv::Point2f> ptsVelocity(vector<int> &ids, vector<cv::Point2f> &pts, 
                                    map<int, cv::Point2f> &cur_id_pts, map<int, cv::Point2f> &prev_id_pts);
    void showTwoImage(const cv::Mat &img1, const cv::Mat &img2, 
                      vector<cv::Point2f> pts1, vector<cv::Point2f> pts2);
    //绘制特征点,有一部分是点的数量决定颜色
    void drawTrack(const cv::Mat &imLeft, const cv::Mat &imRight, 
                                   vector<int> &curLeftIds,
                                   vector<cv::Point2f> &curLeftPts, 
                                   vector<cv::Point2f> &curRightPts,
                                   map<int, cv::Point2f> &prevLeftPtsMap);
    void setPrediction(map<int, Eigen::Vector3d> &predictPts);//设置预测点
    double distance(cv::Point2f &pt1, cv::Point2f &pt2);//两点的欧式距离
    void removeOutliers(set<int> &removePtsIds);//去除外点
    cv::Mat getTrackImage(); //返回的画好特征的图像
    bool inBorder(const cv::Point2f &pt);

    int row, col;
    cv::Mat imTrack; //单目就是左图加特征点,双目就是左右图合成加特征点
    cv::Mat mask;//模板
    cv::Mat fisheye_mask;//鱼眼相机的模板
    cv::Mat prev_img, cur_img; //前帧图像和当前图像
    vector<cv::Point2f> n_pts;
    vector<cv::Point2f> predict_pts;//预测点的点集
    vector<cv::Point2f> predict_pts_debug;
    vector<cv::Point2f> prev_pts, cur_pts, cur_right_pts;//前帧点,当前帧点,和当前右图点
    vector<cv::Point2f> prev_un_pts, cur_un_pts, cur_un_right_pts;//去畸变的前帧点,当前帧点,和当前右图点
    vector<cv::Point2f> pts_velocity, right_pts_velocity;//特征点的速度,看光流法克制,右图
    vector<int> ids, ids_right;//特征点的id
    vector<int> track_cnt;//追踪到点的数量
    map<int, cv::Point2f> cur_un_pts_map, prev_un_pts_map;//这几个哈希表在去畸变的时候用到了,但是没有找到填充数据的地方,是空映射有点疑惑
    map<int, cv::Point2f> cur_un_right_pts_map, prev_un_right_pts_map;
    map<int, cv::Point2f> prevLeftPtsMap;
    vector<camodocal::CameraPtr> m_camera;//相机参数和工具
    double cur_time;//当前帧时间
    double prev_time;//前一帧时间
    bool stereo_cam;//是否双目的标志位
    int n_id;//帧的id
    bool hasPrediction;//是否有预测点信息的标志位
};
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值