forked from raulmur/ORB_SLAM2
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added binary version of vocabulary to speedup ORB_SLAM2 start
- Loading branch information
Showing
5 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <time.h> | ||
|
||
#include "ORBVocabulary.h" | ||
using namespace std; | ||
|
||
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_xml(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile) { | ||
clock_t tStart = clock(); | ||
voc->save(outfile); | ||
printf("Saving as xml: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); | ||
} | ||
|
||
void save_as_text(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile) { | ||
clock_t tStart = clock(); | ||
voc->saveToTextFile(outfile); | ||
printf("Saving as text: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); | ||
} | ||
|
||
void save_as_binary(ORB_SLAM2::ORBVocabulary* voc, const std::string outfile) { | ||
clock_t tStart = clock(); | ||
voc->saveToBinaryFile(outfile); | ||
printf("Saving as binary: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); | ||
} | ||
|
||
|
||
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; | ||
} |