当前位置:网站首页>【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);
}
}
边栏推荐
猜你喜欢
浅谈国产ERP的“横纵竖”三向发展态势
MInIO入门-03 秒传+大文件分片上传
flyway的快速入门教程
Flex layout in detail
【目标检测】FCOS: Fully Convolutional One-Stage Object Detection
go版本升级
Flink_CDC construction and simple use
from origin ‘null‘ has been blocked by CORS policy Cross origin requests are only supported for
Image fusion based on weighted 】 and pyramid image fusion with matlab code
C语言:打印整数二进制的奇数位和偶数位
随机推荐
5年自动化测试经验的一些感悟:做UI自动化一定要跨过这10个坑
【目标检测】FCOS: Fully Convolutional One-Stage Object Detection
html+css+php+mysql实现注册+登录+修改密码(附完整代码)
Flink_CDC construction and simple use
canal实现mysql数据同步
datagrip 报错 “The specified database userpassword combination is rejected...”的解决方法
Flex layout in detail
Rust P2P网络应用实战-1 P2P网络核心概念及Ping程序
哪里有期货开户的正规途径?
iframe使用
MySQL——增删查改操作
PowerBI商学院佐罗BI真经连续剧
哈希表
ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘解决方法
Pytorch seq2seq model architecture to achieve English translation tasks
大话西游无法登陆解决
严格模式,use strict
Redis和MySQL数据一致性问题,有没有好的解决方案?
牛顿定理和相关推论
S/4中究竟有多少个模块,你对这些模块了解多少