Base line matcher
- class limap.line2d.base_matcher.BaseMatcher(extractor, options=BaseMatcherOptions(topk=10, n_neighbors=20, n_jobs=1, weight_path=None))
Bases:
object
Virtual class for line matcher
- get_match_filename(matches_folder, idx)
Return the filename of the matches specified by an image id
- Parameters:
matches_folder (str) – The output matching folder
idx (int) – image id
- get_matches_folder(output_folder)
Return the folder path to the output matches
- Parameters:
output_folder (str) – The output folder
- Returns:
The path to the saved matches
- Return type:
path_to_matches (str)
- get_module_name()
Virtual method (need to be implemented) - return the name of the module
- match_all_exhaustive_pairs(output_folder, image_ids, descinfo_folder, skip_exists=False)
Match all images exhaustively
- Parameters:
output_folder (str) – The output folder
image_ids (list[int]) – list of image ids
descinfo_folder (str) – The folder storing all the descriptors
skip_exists (bool) – Whether to skip already processed images
- Returns:
The output matching folder
- Return type:
matches_folder
- match_all_neighbors(output_folder, image_ids, neighbors, descinfo_folder, skip_exists=False)
Match all images with its visual neighbors
- Parameters:
output_folder (str) – The output folder
image_ids (list[int]) – list of image ids
neighbors (dict[int -> list[int]]) – visual neighbors for each image
descinfo_folder (str) – The folder storing all the descriptors
skip_exists (bool) – Whether to skip already processed images
- Returns:
The output matching folder
- Return type:
matches_folder
- match_pair(descinfo1, descinfo2)
Virtual method (need to be implemented) - match two set of lines based on the descriptors
- read_match(matches_folder, idx)
Read the matches for one image with its neighbors
- Parameters:
matches_folder (str) – The output matching folder
idx (int) – image id
- Returns:
The output matches for each neighboring image, each with shape (N, 2)
- Return type:
matches (dict[int ->
np.array
])
- save_match(matches_folder, idx, matches)
Save the output matches from one image to its neighbors
- Parameters:
matches_folder (str) – The output matching folder
idx (int) – image id
matches (dict[int ->
np.array
]) – The output matches for each neighboring image, each with shape (N, 2)
- namedtuple limap.line2d.base_matcher.BaseMatcherOptions(topk: int = 10, n_neighbors: int = 20, n_jobs: int = 1, weight_path: str | None = None)
Bases:
NamedTuple
Base options for the line matcher
- Fields:
topk (
int
) – number of top matches for each line (if equal to 0, do mutual nearest neighbor matching)n_neighbors (
int
) – number of visual neighbors, only for naming the output foldern_jobs (
int
) – number of jobs at multi-processing (please make sure not to exceed the GPU memory limit with learning methods)weight_path (
str
) – specify path to load weights (at default, weights will be downloaded to ~/.local)
- static __new__(_cls, topk: int = 10, n_neighbors: int = 20, n_jobs: int = 1, weight_path: str | None = None)
Create new instance of BaseMatcherOptions(topk, n_neighbors, n_jobs, weight_path)