当前位置:网站首页>ORB SLAM3加载Vocabulary更快ORBvoc.bin
ORB SLAM3加载Vocabulary更快ORBvoc.bin
2022-08-02 20:16:00 【My.科研小菜鸡】
ORBSLAM3_1.0版本词袋还是ORBvoc.txt,加载时间比较慢,这里教你修改成ORBvoc.bin加载,1秒内完成加载。
将ORBvoc.bin拷贝到Vocabulary文件夹下,ORBvoc.bin百度云盘下载地址 密码idr0,记得解压缩。
修改ORB_SLAM3/src的System.cc的82行:
mpVocabulary = new ORBVocabulary();
//bool bVocLoad = mpVocabulary->loadFromTextFile(strVocFile); //txt加载
bool bVocLoad = mpVocabulary->loadFromBinaryFile(strVocFile); //bin加载
- ORB_SLAM3/Thirdparty/DBoW2/DBoW2/的TemplatedVocabulary.h里增加函数:
/**函数声明 * Loads the vocabulary from a binary file * @param filename */
bool loadFromBinaryFile(const std::string &filename);
// --------------------------------------------------------------------------
//函数定义,可以放在对应的loadFromTextFile函数下面
template<class TDescriptor, class F>
bool TemplatedVocabulary<TDescriptor,F>::loadFromBinaryFile(const std::string &filename) {
fstream f;
f.open(filename.c_str(), ios_base::in|ios::binary);
unsigned int nb_nodes, size_node;
f.read((char*)&nb_nodes, sizeof(nb_nodes));
f.read((char*)&size_node, sizeof(size_node));
f.read((char*)&m_k, sizeof(m_k));
f.read((char*)&m_L, sizeof(m_L));
f.read((char*)&m_scoring, sizeof(m_scoring));
f.read((char*)&m_weighting, sizeof(m_weighting));
createScoringObject();
m_words.clear();
m_words.reserve(pow((double)m_k, (double)m_L + 1));
m_nodes.clear();
m_nodes.resize(nb_nodes+1);
m_nodes[0].id = 0;
char buf[size_node]; int nid = 1;
while (!f.eof()) {
f.read(buf, size_node);
m_nodes[nid].id = nid;
// FIXME
const int* ptr=(int*)buf;
m_nodes[nid].parent = *ptr;
//m_nodes[nid].parent = *(const int*)buf;
m_nodes[m_nodes[nid].parent].children.push_back(nid);
m_nodes[nid].descriptor = cv::Mat(1, F::L, CV_8U);
memcpy(m_nodes[nid].descriptor.data, buf+4, F::L);
m_nodes[nid].weight = *(float*)(buf+4+F::L);
if (buf[8+F::L]) {
// is leaf
int wid = m_words.size();
m_words.resize(wid+1);
m_nodes[nid].word_id = wid;
m_words[wid] = &m_nodes[nid];
}
else
m_nodes[nid].children.reserve(m_k);
nid+=1;
}
f.close();
return true;
}
- 之后重新编译DBoW2和整个ORBSLAM3程序需要注意的是只编译ros模块不行。
边栏推荐
- 第一次进入前20名
- 2022年金九银十,Android面试中高频必问的问题汇总
- 广东省数字经济发展指引 1.0之建成数据安全保障体系
- Informatics Olympiad All-in-One (1260: [Example 9.4] Intercepting Missiles (Noip1999))
- SQL Server安装教程
- js如何获取浏览器缩放比例
- 汉源高科千兆4光4电工业级网管型智能环网冗余以太网交换机防浪涌防雷导轨式安装
- 信息学奥赛一本通(1258:【例9.2】数字金字塔)
- 李沐动手学深度学习V2-BERT预训练和代码实现
- Informatics orsay a tong (1258: 【 9.2 】 digital pyramid)
猜你喜欢

如何解决图像分类中的类别不均衡问题?不妨试试分开学习表征和分类器

KDD 2022 | 深度图神经网络中的特征过相关:一个新视角

Implement fashion_minst clothing image classification

iframe------------frame-

信息学奥赛一本通(1258:【例9.2】数字金字塔)

Flutter 常见异常分析

开关、电机、断路器、电热偶、电表接线图大全

「每周译Go」这次我们来点不一样的!--《How to Code in Go》系列上线

汉源高科2光12电千兆导轨式网管型工业以太网交换机双光自愈保护式以太网光交换机
![Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)](/img/a2/6d548909341a65129db2e69b90e5bf.png)
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)
随机推荐
LM小型可编程控制器软件(基于CoDeSys)笔记二十五:plc的数据存储区(数字量输入通道部分)
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)
博客主页rrs代码
汉源高科2光12电千兆导轨式网管型工业以太网交换机双光自愈保护式以太网光交换机
开关、电机、断路器、电热偶、电表接线图大全
SQL Server安装教程
ECCV 2022 | 通往数据高效的Transformer目标检测器
Parse common methods in the Collection interface that are overridden by subclasses
[21 Days Learning Challenge] Bubble Sort and Insertion Sort
训练双塔检索模型,可以不用query-doc样本了?明星机构联合发文
9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)
五大维度解读软件测试分类
「 每日一练,快乐水题 」1374. 生成每种字符都是奇数个的字符串
.NET性能优化-你应该为集合类型设置初始大小
浅议.NET遗留应用改造
C语言中变量在内存中的保存与访问
太魔人招新啦|快来加入我们吧!
Bena's life cycle
Li Mu hands-on learning deep learning V2-bert and code implementation