Skip to content

Commit

Permalink
Add match_mask parameter to pairs from retrieval for loop closure
Browse files Browse the repository at this point in the history
  • Loading branch information
pablovela5620 committed Dec 2, 2024
1 parent 75a97e9 commit 2313e42
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hloc/pairs_from_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def main(
db_list=None,
db_model=None,
db_descriptors=None,
match_mask=None,
):
logger.info("Extracting image pairs from a retrieval database.")

Expand Down Expand Up @@ -108,8 +109,15 @@ def main(
query_desc = get_descriptors(query_names, descriptors)
sim = torch.einsum("id,jd->ij", query_desc.to(device), db_desc.to(device))

# Avoid self-matching
self = np.array(query_names)[:, None] == np.array(db_names)[None]
if match_mask is None:
# Avoid self-matching
self = np.array(query_names)[:, None] == np.array(db_names)[None]
else:
assert match_mask.shape == (
len(query_names),
len(db_names),
), "mask shape must match size of query and database images!"
self = match_mask
pairs = pairs_from_score_matrix(sim, self, num_matched, min_score=0)
pairs = [(query_names[i], db_names[j]) for i, j in pairs]

Expand Down

0 comments on commit 2313e42

Please sign in to comment.