当前位置:网站首页>【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
2022-08-02 01:05:00 【小秋SLAM实战教程】
AssignFeaturesToGrid这个函数的主要目的是根据https://blog.csdn.net/qq_21950671/article/details/126084120计算的去畸变后的图像边界和网格尺寸,将去畸变后的特征点分配到对应的网格中去,这么做的目的是为了后面的特征点匹配加速。
// #define FRAME_GRID_ROWS 48
// #define FRAME_GRID_COLS 64
// Number of KeyPoints. int N;
void Frame::AssignFeaturesToGrid()
{
// Step 1 给存储特征点的网格数组 Frame::mGrid 预分配空间
// FRAME_GRID_COLS = 64,FRAME_GRID_ROWS=48
int nReserve = 0.5f*N/(FRAME_GRID_COLS*FRAME_GRID_ROWS);// 64 * 48
//开始对mGrid这个二维数组中的每一个vector元素遍历并预分配空间
for(unsigned int i=0; i<FRAME_GRID_COLS;i++)
for (unsigned int j=0; j<FRAME_GRID_ROWS;j++) {
// reserve的作用是更改vector的容量capacity, 使vector至少可以容纳n个元素
// std::vector<std::size_t> mGrid[FRAME_GRID_COLS][FRAME_GRID_ROWS]
// std::cout << "nReserve " << nReserve << std::endl;
// std::vector<std::size_t> mGrid[FRAME_GRID_COLS][FRAME_GRID_ROWS];
mGrid[i][j].reserve(nReserve);
}
// Step 2 遍历每个特征点,将每个特征点在mvKeysUn中的索引值放到对应的网格mGrid中
for(int i=0;i<N;i++)
{
//从类的成员变量中获取已经去畸变后的特征点
const cv::KeyPoint &kp = mvKeysUn[i];
//存储某个特征点所在网格的网格坐标,nGridPosX范围:[0,FRAME_GRID_COLS], nGridPosY范围:[0,FRAME_GRID_ROWS]
int nGridPosX, nGridPosY;
// 计算某个特征点所在网格的网格坐标,如果找到特征点所在的网格坐标,记录在nGridPosX,nGridPosY里,返回true,没找到返回false
if(PosInGrid(kp,nGridPosX,nGridPosY))
//如果找到特征点所在网格坐标,将这个特征点的索引添加到对应网格的数组mGrid中
mGrid[nGridPosX][nGridPosY].push_back(i);
}
}
边栏推荐
- When paying attention to the "Internet +" model, you usually only focus on the "Internet +" model itself
- PHP直播源码实现简单弹幕效果的相关代码
- 接口(第九天)
- 电商库存系统的防超卖和高并发扣减方案
- go mode tidy出现报错go warning “all“ matched no packages
- Go 1.18 的那些事——工作区、模糊测试、泛型
- 【软件工程之美 - 专栏笔记】34 | 账号密码泄露成灾,应该怎样预防?
- 设备树学习
- GO GOPROXY代理设置
- ECMAScript 2022 正式发布,有你了解过的吗?
猜你喜欢
随机推荐
flask获取post请求参数
C语言实验八 字符数组程序设计
from origin ‘null‘ has been blocked by CORS policy Cross origin requests are only supported for
【图像融合】基于加权和金字塔实现图像融合附matlab代码
三本毕业的我被腾讯拒绝了十四次,最终成功入职阿里
安全(2)
YGG 公会发展计划第 1 季总结
pcie inbound和outbound关系
Kubernetes — 核心资源对象 — 存储
管理基础知识11
"Introduction to Natural Language Processing Practice" Question Answering Robot Based on Knowledge Graph
C语言实验七 二维数组程序设计
flv.js解析与使用
电商库存系统的防超卖和高并发扣减方案
Image fusion based on weighted 】 and pyramid image fusion with matlab code
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
Can't connect to MySQL server on 'localhost3306' (10061) Simple and clear solution
NFT到底有哪些实际用途?
Two ways to pass feign exceptions: fallbackfactory and global processing Get server-side custom exceptions
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)









