10 #include <orb_slam/Converter.h>
54 catch (std::exception& e)
56 std::string err =
"WAIOrbVocabulary::loadFromFile: failed to load vocabulary " +
57 strVocFile +
", exception:" + e.what();
58 throw std::runtime_error(err);
61 bool bVocLoad =
_vocabulary->loadFromBinaryFile(strVocFile);
65 std::string err =
"WAIOrbVocabulary::loadFromFile: failed to load vocabulary " + strVocFile;
67 throw std::runtime_error(err);
74 for (
int i = 0; i < wid.size(); i++)
79 data.insert(std::pair<uint32_t, fbow::_float>(wid[i], v));
81 data.insert(std::pair<DBoW2::WordId, DBoW2::WordValue>(wid[i], values[i]));
91 if (descriptors.rows == 0)
97 vector<cv::Mat> vCurrentDesc = ORB_SLAM2::Converter::toDescriptorVector(descriptors);
105 return fbow::fBow::score(bow1.
data, bow2.
data);
123 fbow::VocabularyCreator vc;
124 fbow::VocabularyCreator::Params p;
131 std::cout <<
"Creating a " << p.k <<
"^" << p.L <<
" vocabulary..." << std::endl;
135 std::cout <<
"... done!" << std::endl;
137 const DBoW2::WeightingType weight = DBoW2::TF_IDF;
138 const DBoW2::ScoringType
score = DBoW2::L1_NORM;
140 std::vector<std::vector<cv::Mat>> feats;
141 feats.resize(features.size());
143 cout <<
"Creating a " << k <<
"^" << l <<
" vocabulary..." << endl;
144 for (
int i = 0; i < features.size(); i++)
146 feats[i].resize(features[i].rows);
147 for (
int j = 0; j < features[i].rows; j++)
148 feats[i].push_back(features[i].row(j));
154 cout <<
"... done!" << endl;
fbow::Vocabulary * _vocabulary
void transform(const cv::Mat &descriptors, WAIBowVector &bow, WAIFeatVector &feat)
void create(std::vector< cv::Mat > &features, int k, int l)
void loadFromFile(std::string strVocFile)
void save(std::string path)
WAIOrbVocabulary(int layer=2)
double score(WAIBowVector &bow1, WAIBowVector &bow2)
void log(const char *tag, const char *format,...)
logs a formatted string platform independently