当前位置:网站首页>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模块不行。
边栏推荐
猜你喜欢
基于 outline 实现头像剪裁以及预览
美国爱荷华州立大学| Improving Distantly Supervised Relation Extraction by Natural Language Inference(通过自然语言推理改进远程监督关系提取)
Day35 LeetCode
汉源高科2光12电千兆导轨式网管型工业以太网交换机双光自愈保护式以太网光交换机
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
信息学奥赛一本通(1258:【例9.2】数字金字塔)
Informatics orsay a tong (1258: 【 9.2 】 digital pyramid)
广东省数字经济发展指引 1.0之建成数据安全保障体系
「 每日一练,快乐水题 」1374. 生成每种字符都是奇数个的字符串
Triacetin是什么化学材料
随机推荐
Likou Question of the Day - Day 46 - 344. Reverse Strings
postgresql autovaccum自动清理
iframe------------frame-
php 单引号 双引号 -> => return echo
ssdp协议搜索GB28181设备
callback prototype __proto__
奥特学园ROS笔记--7(289-325节)
WPF development through practical 】 【 automatic production management platform
setup语法糖 defineProps defineEmits defineExpose
Day35 LeetCode
Fiddle设置接口数据用指定工具查看;Sublime Text设置json数据格式化转换
Golang source code analysis: juju/ratelimit
数据库分析与优化
go——内存分配机制
顺序查找和折半查找,看这篇就够了
如何解决图像分类中的类别不均衡问题?不妨试试分开学习表征和分类器
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
Geoip2 - golang golang source code analysis
Common tools and test methods for interface testing (Introduction)
ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)