当前位置:网站首页>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模块不行。
边栏推荐
- Axure9的元件用法
- 李沐动手学深度学习V2-bert和代码实现
- Meta 与苹果的元宇宙碰撞
- C#异步和多线程
- WPF development through practical 】 【 automatic production management platform
- ssdp协议搜索GB28181设备
- 【数据分析】:什么是数据分析?
- LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路
- ECCV 2022 | 通往数据高效的Transformer目标检测器
- ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)
猜你喜欢
随机推荐
Triacetin是什么化学材料
PLC工作原理动画
基于 outline 实现头像剪裁以及预览
Likou Question of the Day - Day 46 - 344. Reverse Strings
10 种最佳 IDE 软件 ,你更忠爱哪一个?
基本语法(三)
谷歌竞价机器学习如何去理解?
训练双塔检索模型,可以不用query-doc样本了?明星机构联合发文
【手撕AHB-APB Bridge】~ AMBA总线 之 APB
Details in C# you don't know
Fiddle设置接口数据用指定工具查看;Sublime Text设置json数据格式化转换
一款免费的容器安全 SaaS 平台使用记录
什么是 IDE
浅议.NET遗留应用改造
Which thread pool does Async use?
How to use windbg check c # a thread stack size?
信息学奥赛一本通(1257:Knight Moves)
js Fetch返回数据res.json()报错问题
"Weekly Translate Go" This time we have something different!-- "How to Code in Go" series launched
接口测试常用工具及测试方法(入门篇)








