forked from dorian3d/DBoW2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add binary and text read of vocabularies as done in raulmur/ORB_SLAM2#21
- Loading branch information
Showing
4 changed files
with
273 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
/tools/bin_vocabulary |
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 "../include/DBoW2/DBoW2.h" | ||
using namespace std; | ||
|
||
bool load_as_text(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(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(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(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(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(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; | ||
OrbVocabulary* voc = new OrbVocabulary(); | ||
|
||
load_as_text(voc, "ORBvoc.txt"); | ||
save_as_binary(voc, "ORBvoc.bin"); | ||
|
||
return 0; | ||
} |