Skip to content

Commit

Permalink
added returning scores in querydb call
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoussan committed Jun 26, 2024
1 parent 2a7aef3 commit 29adb0e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ namespace sparse_mapping {
void ResetDB(VocabDB* db);

// Query similar images from database
void QueryDB(std::string const& descriptor,
VocabDB * vocab_db,
int num_similar,
cv::Mat const& descriptors,
std::vector<int> * indices);
void QueryDB(std::string const& descriptor, VocabDB* vocab_db, int num_similar, cv::Mat const& descriptors,
std::vector<int>* indices, std::vector<double>* scores);

void BuildDBforDBoW2(sparse_mapping::SparseMap* map,
std::string const& descriptor,
Expand Down
3 changes: 2 additions & 1 deletion localization/sparse_mapping/src/sparse_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ bool SparseMap::Localize(cv::Mat const& test_descriptors, Eigen::Matrix2Xd const
std::vector<Eigen::Vector2d>* inlier_observations, std::vector<int>* cid_list,
const cv::Mat& image) {
std::vector<int> indices;
std::vector<double> query_scores;
// Query the vocab tree.
if (cid_list == NULL)
sparse_mapping::QueryDB(detector_.GetDetectorName(),
Expand All @@ -738,7 +739,7 @@ bool SparseMap::Localize(cv::Mat const& test_descriptors, Eigen::Matrix2Xd const
// them below.
loc_params_.num_similar + loc_params_.num_extra_localization_db_images,
test_descriptors,
&indices);
&indices, &query_scores);
else
indices = *cid_list;
if (indices.empty()) {
Expand Down
3 changes: 2 additions & 1 deletion localization/sparse_mapping/src/tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ void MatchFeatures(const std::string & essential_file,
ff_common::PrintProgressBar(stdout, static_cast<float>(cid)
/ static_cast <float>(s->cid_to_keypoint_map_.size() - 1));
std::vector<int> indices, queried_indices;
std::vector<double> scores;
sparse_mapping::QueryDB(s->detector_.GetDetectorName(),
&s->vocab_db_, s->loc_params().num_similar,
s->cid_to_descriptor_map_[cid],
&queried_indices);
&queried_indices, &scores);

if (!queried_indices.empty()) {
// always include the next three images
Expand Down
4 changes: 3 additions & 1 deletion localization/sparse_mapping/src/vocab_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ void MatDescrToVec(cv::Mat const& mat, DBoW2::BriefDescriptor * brief) {
// at most num_similar such indices.
void QueryDB(std::string const& descriptor, VocabDB * vocab_db,
int num_similar, cv::Mat const& descriptors,
std::vector<int> * indices) {
std::vector<int> * indices, std::vector<double> * scores) {
indices->clear();
scores->clear();

if (vocab_db->binary_db != NULL) {
assert(IsBinaryDescriptor(descriptor));
Expand All @@ -398,6 +399,7 @@ void QueryDB(std::string const& descriptor, VocabDB * vocab_db,

for (size_t j = 0; j < ret.size(); j++) {
indices->push_back(ret[j].Id);
scores->push_back(ret[j].Score);
}
} else {
// no database specified
Expand Down

0 comments on commit 29adb0e

Please sign in to comment.