当前位置:网站首页>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模块不行。
边栏推荐
- js Fetch返回数据res.json()报错问题
- 信息学奥赛一本通(1257:Knight Moves)
- golang源码分析之geoip2-golang
- 汉源高科2光12电千兆导轨式网管型工业以太网交换机双光自愈保护式以太网光交换机
- "Weekly Translate Go" This time we have something different!-- "How to Code in Go" series launched
- 顺序查找和折半查找,看这篇就够了
- Bena的生命周期
- Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
- 框架设计:PC 端单页多页框架如何设计与落地
- 【SLAM】DM-VIO(ros版)安装和论文解读
猜你喜欢

谷歌竞价机器学习如何去理解?

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

ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)

TodoList案例

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

PG's SQL execution plan

Parse common methods in the Collection interface that are overridden by subclasses

.NET性能优化-你应该为集合类型设置初始大小

数字孪生助力智慧城市可视化建设

Wiring diagrams of switches, motors, circuit breakers, thermocouples, and meters
随机推荐
setup语法糖 defineProps defineEmits defineExpose
OP-5,输入/输出信号范围-一信号处理能力
Golang source code analysis: time/rate
56.【全局变量和局部变量专题】
PyTorch分布式backends
线程安全(上)
golang 源码分析:juju/ratelimit
js Fetch返回数据res.json()报错问题
交 叉 数 组
实现fashion_minst服装图像分类
ECCV 2022 | 通往数据高效的Transformer目标检测器
成为黑客不得不学的语言,看完觉得你们还可吗?
Day12 接口和协议
有效解决MySQL报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES)
Qt提升自定义控件,找不到头文件
Xcode13.1 run engineering error fatal error: 'IFlyMSC/IFly h' file not found
Solve the docker mysql can't write Chinese
并发与并行
TodoList案例
Parse common methods in the Collection interface that are overridden by subclasses