Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
std::make_unique<loc::successor_manager::SuccessorManager>(
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
std::make_unique<loc::successor_manager::SuccessorManager>(
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,
Expand Down
12 changes: 6 additions & 6 deletions src/localization/online_localizer/online_localizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -315,7 +315,7 @@ std::vector<PathElement> 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);
Expand Down Expand Up @@ -362,7 +362,7 @@ std::vector<PathElement> 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);
Expand Down
4 changes: 2 additions & 2 deletions src/localization/online_localizer/online_localizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class OnlineLocalizer {
using AccCostsMap = std::unordered_map<int, std::unordered_map<int, double>>;

OnlineLocalizer(successor_manager::SuccessorManager *successorManager,
double expansionRate, double nonMatchingCost);
double expansionRate, double matchingThreshold);
~OnlineLocalizer() {}

Matches findMatchesTill(int queryId);
Expand All @@ -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<Node> frontier_;
// stores parent for each node
Expand Down
10 changes: 5 additions & 5 deletions src/localization/tools/config_parser/config_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -165,8 +165,8 @@ bool ConfigParser::parseYaml(const std::string &yamlFile) {
if (config["fanOut"]) {
fanOut = config["fanOut"].as<int>();
}
if (config["nonMatchCost"]) {
nonMatchCost = config["nonMatchCost"].as<double>();
if (config["matchingThreshold"]) {
matchingThreshold = config["matchingThreshold"].as<double>();
}
if (config["expansionRate"]) {
expansionRate = config["expansionRate"].as<double>();
Expand Down
6 changes: 3 additions & 3 deletions src/localization/tools/config_parser/config_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion src/python/matching_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down