SLAM十四讲ch13学习记录

SLAM十四讲ch13学习实践

提示:无 编译、运行 相关


(1)将关键帧以外的地图点保留

找到map.cpp,在最下方,注释掉相关代码如下图,
再在Map::RemoveOldKeyframe函数下注释掉//CleanMap();,在该函数下的最后一行

// void Map::CleanMap() {
//     int cnt_landmark_removed = 0;
//     for (auto iter = active_landmarks_.begin();iter != active_landmarks_.end();) 
//     {
//         if (iter->second->observed_times_ == 0) {
//             iter = active_landmarks_.erase(iter);
//             cnt_landmark_removed++;
//         } else {
//             ++iter;
//         }
//     }
//     LOG(INFO) << "Removed " << cnt_landmark_removed << " active landmarks";
// }

}  // namespace myslam

(2)课后作业,将原来的GFTT角点换成其他角点:

看了一下角点提取的代码,发现改为FAST角点还是比较简单的。并且,GFTT角点跑出来的效果其实并不好,换了角点后竟然提升了不少

首先,在前端代码中进行修改

Frontend::Frontend() 
{
     //gftt_ =
    //     //GFTT特征点检测 cv::GFTTDetector::creat(最大角点数量, 角点最小特征值, 角点间的最小距离)
        // cv::GFTTDetector::create(Config::Get<int>("num_features"), 0.01, 20);    
    fast_ = cv::FastFeatureDetector::create(15);


    num_features_init_ = Config::Get<int>("num_features_init");
    num_features_ = Config::Get<int>("num_features");
}

然后在下面的Frontend::DetectFeatures() 中把原来的gftt注释掉,换成现在的fast

int Frontend::DetectFeatures() {
    cv::Mat mask(current_frame_->left_img_.size(), CV_8UC1, 255);
    for (auto &feat : current_frame_->features_left_) {
        cv::rectangle(mask, feat->position_.pt - cv::Point2f(10, 10),
                      feat->position_.pt + cv::Point2f(10, 10), 0, CV_FILLED);
    }

    std::vector<cv::KeyPoint> keypoints;
    //gftt_->detect(current_frame_->left_img_, keypoints, mask);
    fast_->detect(current_frame_->left_img_, keypoints, mask);
    int cnt_detected = 0;
    for (auto &kp : keypoints) {
        current_frame_->features_left_.push_back(
            Feature::Ptr(new Feature(current_frame_, kp)));
        cnt_detected++;
    }

    LOG(INFO) << "Detect " << cnt_detected << " new features";
    return cnt_detected;
}

使用的是opencv内部的封装好的函数,不过是换了一个函数调用

最后去头文件中声明一下,在frontend.h中,基本上在最底部,如图注释与修改

    // utilities
    //cv::Ptr<cv::GFTTDetector> gftt_;  // feature detector in opencv
    cv::Ptr<cv::FastFeatureDetector> fast_;

实现效果

在这里插入图片描述

个人学习,理性参考

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值