From d7657c54d6b3f05f04f0899635bd0a7080003f50 Mon Sep 17 00:00:00 2001 From: Olga Date: Mon, 30 Jun 2025 15:19:19 +0200 Subject: [PATCH] renamed nonMatchingCost to matchingThreshold --- .../cost_matrix_no_hashing.cpp | 2 +- .../online_localizer_lsh.cpp | 2 +- .../online_localizer/online_localizer.cpp | 12 ++++++------ src/localization/online_localizer/online_localizer.h | 4 ++-- .../tools/config_parser/config_parser.cpp | 10 +++++----- src/localization/tools/config_parser/config_parser.h | 6 +++--- src/python/matching_scripts.py | 2 +- ...ize_matching_result.py => store_image_matches.py} | 0 8 files changed, 19 insertions(+), 19 deletions(-) rename src/python/{visualize_matching_result.py => store_image_matches.py} (100%) diff --git a/src/apps/cost_matrix_based_matching/cost_matrix_no_hashing.cpp b/src/apps/cost_matrix_based_matching/cost_matrix_no_hashing.cpp index 4663d1c..e8f9673 100644 --- a/src/apps/cost_matrix_based_matching/cost_matrix_no_hashing.cpp +++ b/src/apps/cost_matrix_based_matching/cost_matrix_no_hashing.cpp @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { std::make_unique( database.get(), relocalizer.get(), parser.fanOut); loc::online_localizer::OnlineLocalizer localizer{ - successorManager.get(), parser.expansionRate, parser.nonMatchCost}; + successorManager.get(), parser.expansionRate, parser.matchingThreshold}; const loc::online_localizer::Matches imageMatches = localizer.findMatchesTill(parser.querySize); loc::online_localizer::storeMatchesAsProto(imageMatches, diff --git a/src/apps/cost_matrix_based_matching/online_localizer_lsh.cpp b/src/apps/cost_matrix_based_matching/online_localizer_lsh.cpp index 975de22..d2e3a44 100644 --- a/src/apps/cost_matrix_based_matching/online_localizer_lsh.cpp +++ b/src/apps/cost_matrix_based_matching/online_localizer_lsh.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) { std::make_unique( database.get(), relocalizer.get(), parser.fanOut); loc::online_localizer::OnlineLocalizer localizer{ - successorManager.get(), parser.expansionRate, parser.nonMatchCost}; + successorManager.get(), parser.expansionRate, parser.matchingThreshold}; const loc::online_localizer::Matches imageMatches = localizer.findMatchesTill(parser.querySize); loc::online_localizer::storeMatchesAsProto(imageMatches, diff --git a/src/localization/online_localizer/online_localizer.cpp b/src/localization/online_localizer/online_localizer.cpp index 36d9b4c..9915ba5 100644 --- a/src/localization/online_localizer/online_localizer.cpp +++ b/src/localization/online_localizer/online_localizer.cpp @@ -48,17 +48,17 @@ const float kMaxLostNodesRatio = 0.8; // 80% OnlineLocalizer::OnlineLocalizer( successor_manager::SuccessorManager *successorManager, double expansionRate, - double nonMatchingCost) { + double matchingThreshold) { CHECK(successorManager) << "Successor manager is not set."; CHECK(expansionRate > 0 && expansionRate <= 1) << "Graph expansion rate should be in [0,1]. Obtained: " << expansionRate; - CHECK(nonMatchingCost > 0) - << "Non matching cost should be > 0. Obtained: " << nonMatchingCost; + CHECK(matchingThreshold > 0) + << "Matching threshold should be > 0. Obtained: " << matchingThreshold; successorManager_ = successorManager; expansionRate_ = expansionRate; - nonMatchingCost_ = nonMatchingCost; + matchingThreshold_ = matchingThreshold; pred_[kSourceNode.quId][kSourceNode.refId] = kSourceNode; Node source = kSourceNode; @@ -315,7 +315,7 @@ std::vector OnlineLocalizer::getCurrentPath() const { source_reached = true; continue; } - NodeState state = pred.idvCost > nonMatchingCost_ ? HIDDEN : REAL; + NodeState state = pred.idvCost > matchingThreshold_ ? HIDDEN : REAL; PathElement pathEl(pred.quId, pred.refId, state); path.push_back(pathEl); pred = pred_.at(pred.quId).at(pred.refId); @@ -362,7 +362,7 @@ std::vector OnlineLocalizer::getLastNmatches(int N) const { source_reached = true; continue; } - NodeState state = pred.idvCost > nonMatchingCost_ ? HIDDEN : REAL; + NodeState state = pred.idvCost > matchingThreshold_ ? HIDDEN : REAL; PathElement pathEl(pred.quId, pred.refId, state); path.push_back(pathEl); pred = pred_.at(pred.quId).at(pred.refId); diff --git a/src/localization/online_localizer/online_localizer.h b/src/localization/online_localizer/online_localizer.h index 9a95d42..c3616d6 100644 --- a/src/localization/online_localizer/online_localizer.h +++ b/src/localization/online_localizer/online_localizer.h @@ -46,7 +46,7 @@ class OnlineLocalizer { using AccCostsMap = std::unordered_map>; OnlineLocalizer(successor_manager::SuccessorManager *successorManager, - double expansionRate, double nonMatchingCost); + double expansionRate, double matchingThreshold); ~OnlineLocalizer() {} Matches findMatchesTill(int queryId); @@ -73,7 +73,7 @@ class OnlineLocalizer { int kSlidingWindowSize_ = 5; // frames bool needReloc_ = false; double expansionRate_ = -1.0; - double nonMatchingCost_ = -1.0; + double matchingThreshold_ = -1.0; std::priority_queue frontier_; // stores parent for each node diff --git a/src/localization/tools/config_parser/config_parser.cpp b/src/localization/tools/config_parser/config_parser.cpp index fba2395..d2cb637 100644 --- a/src/localization/tools/config_parser/config_parser.cpp +++ b/src/localization/tools/config_parser/config_parser.cpp @@ -65,9 +65,9 @@ bool ConfigParser::parse(const std::string &iniFile) { ss >> querySize; } - if (header == "nonMatchCost") { + if (header == "matchingThreshold") { ss >> header; // reads "=" - ss >> nonMatchCost; + ss >> matchingThreshold; continue; } @@ -129,7 +129,7 @@ void ConfigParser::print() const { printf("== Path2ref: %s\n", path2ref.c_str()); printf("== Query size: %d\n", querySize); - printf("== NonMatchCost: %3.4f\n", nonMatchCost); + printf("== matchingThreshold: %3.4f\n", matchingThreshold); printf("== Expansion Rate: %3.4f\n", expansionRate); printf("== FanOut: %d\n", fanOut); @@ -165,8 +165,8 @@ bool ConfigParser::parseYaml(const std::string &yamlFile) { if (config["fanOut"]) { fanOut = config["fanOut"].as(); } - if (config["nonMatchCost"]) { - nonMatchCost = config["nonMatchCost"].as(); + if (config["matchingThreshold"]) { + matchingThreshold = config["matchingThreshold"].as(); } if (config["expansionRate"]) { expansionRate = config["expansionRate"].as(); diff --git a/src/localization/tools/config_parser/config_parser.h b/src/localization/tools/config_parser/config_parser.h index b089ea6..b9316b5 100644 --- a/src/localization/tools/config_parser/config_parser.h +++ b/src/localization/tools/config_parser/config_parser.h @@ -50,7 +50,7 @@ class ConfigParser { int querySize = -1; int fanOut = -1; int bufferSize = -1; - double nonMatchCost = -1.0; + double matchingThreshold = -1.0; double expansionRate = -1.0; }; @@ -96,9 +96,9 @@ class ConfigParser { \brief number of image features to be cached. Speeds up the computation for feature_based matching. Irrelevant for cost_matrix_based matching. */ -/*! \var double ConfigParser::nonMatchCost +/*! \var double ConfigParser::matchingThreshold \brief maximum boundary for the matching cost to still be considered as a - match. For example, if `nonMatchCost = 5.0` then every smaller cost should + match. For example, if `matchingThreshold = 5.0` then every smaller cost should represent the fact that 2 images match and every higher cost represents the fact that 2 image descriptors do not represent the same place. (sensitive parameter, depends on the matched trajectories). diff --git a/src/python/matching_scripts.py b/src/python/matching_scripts.py index bf45780..9beeabc 100644 --- a/src/python/matching_scripts.py +++ b/src/python/matching_scripts.py @@ -14,7 +14,7 @@ class RunParameters: matchingResultImage: str = None expansionRate: float = 0.3 fanOut: int = 5 - nonMatchCost: float = 3.7 + matchingThreshold: float = 3.7 querySize: int = None bufferSize: int = 100 diff --git a/src/python/visualize_matching_result.py b/src/python/store_image_matches.py similarity index 100% rename from src/python/visualize_matching_result.py rename to src/python/store_image_matches.py