修改orbslam2代码,加载二进制词典文件,加速词典加载速度
0.在ORB_SLAM2下创建tools文件夹,放入bin_vocabulary.cc程序
#include <time.h>
#include "ORBVocabulary.h"
using namespace std;
bool load_as_text(ORB_SLAM2::ORBVocabulary* voc, const std::string infile);
void load_as_xml(ORB_SLAM2::ORBVocabulary* voc, const std::string infile);
void load_as_binary(ORB_SLAM2::ORBVocabulary* voc, const std::string infile);
void save_as_text(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile);
void save_as_xml(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile);
void save_as_binary(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile);
int main(int argc, char **argv) {
cout << "BoW load/save benchmark" << endl;
ORB_SLAM2::ORBVocabulary* voc = new ORB_SLAM2::ORBVocabulary();
load_as_text(voc, "Vocabulary/ORBvoc.txt");
save_as_binary(voc, "Vocabulary/ORBvoc.bin");
return 0;
}
bool load_as_text(ORB_SLAM2::ORBVocabulary* voc, const std::string infile) {
clock_t tStart = clock();
bool res = voc->loadFromTextFile(infile);
printf("Loading fom text: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
return res;
}
void load_as_xml(ORB_SLAM2::ORBVocabulary* voc, const std::string infile) {
clock_t tStart = clock();
voc->load(infile);
printf("Loading fom xml: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
}
void load_as_binary(ORB_SLAM2::ORBVocabulary* voc, const std::string infile) {
clock_t tStart = clock();
voc->loadFromBinaryFile(infile);
printf("Loading fom binary: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
}
void save_as_text(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile)

ThisarticledemonstrateshowtomodifyORB_SLAM2codetospeedupdictionaryfileloadingbyconvertingfromtexttobinaryformatandbenchmarkstheprocess.
最低0.47元/天 解锁文章
3017

被折叠的 条评论
为什么被折叠?



