修改orbslam2代码,加载二进制词典文件,加速词典加载速度

ThisarticledemonstrateshowtomodifyORB_SLAM2codetospeedupdictionaryfileloadingbyconvertingfromtexttobinaryformatandbenchmarkstheprocess.

修改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) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值