MCPcopy
hub / github.com/cvg/Hierarchical-Localization / import_matches

Function import_matches

hloc/triangulation.py:72–100  ·  view source on GitHub ↗
(image_ids: Dict[str, int],
                   database_path: Path,
                   pairs_path: Path,
                   matches_path: Path,
                   min_match_score: Optional[float] = None,
                   skip_geometric_verification: bool = False)

Source from the content-addressed store, hash-verified

70
71
72def import_matches(image_ids: Dict[str, int],
73 database_path: Path,
74 pairs_path: Path,
75 matches_path: Path,
76 min_match_score: Optional[float] = None,
77 skip_geometric_verification: bool = False):
78 logger.info('Importing matches into the database...')
79
80 with open(str(pairs_path), 'r') as f:
81 pairs = [p.split() for p in f.readlines()]
82
83 db = COLMAPDatabase.connect(database_path)
84
85 matched = set()
86 for name0, name1 in tqdm(pairs):
87 id0, id1 = image_ids[name0], image_ids[name1]
88 if len({(id0, id1), (id1, id0)} & matched) > 0:
89 continue
90 matches, scores = get_matches(matches_path, name0, name1)
91 if min_match_score:
92 matches = matches[scores > min_match_score]
93 db.add_matches(id0, id1, matches)
94 matched |= {(id0, id1), (id1, id0)}
95
96 if skip_geometric_verification:
97 db.add_two_view_geometry(id0, id1, matches)
98
99 db.commit()
100 db.close()
101
102
103def estimation_and_geometric_verification(database_path: Path,

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 4

get_matchesFunction · 0.85
connectMethod · 0.80
add_matchesMethod · 0.80
add_two_view_geometryMethod · 0.80

Tested by

no test coverage detected