Matchers

Page under construction...

MatcherBase

Base class for matchers. It defines the basic interface for matchers and basic functionalities that are shared among all matchers, in particular the match method. It must be subclassed to implement a new matcher.

Attributes:
  • general_conf (dict) –

    Default configuration for general settings.

  • default_conf (dict) –

    Default configuration for matcher-specific settings.

  • required_inputs (list) –

    List of required input parameters.

  • min_inliers_per_pair (int) –

    Minimum number of matches required.

  • min_matches_per_tile (int) –

    Minimum number of matches required per tile.

  • max_feat_no_tiling (int) –

    Maximum number of features without tiling.

  • tile_preselection_size (int) –

    Maximum resize dimension for preselection.

__init__(custom_config)

Initializes the MatcherBase object.

Parameters:
  • custom_config (dict) –

    Options for the matcher.

Raises:
  • TypeError

    If custom_config is not a dictionary.

match(feature_path, matches_path, img0, img1, try_full_image=False)

Match features between two images.

Parameters:
  • feature_path (Path) –

    Path to the feature file.

  • matches_path (Path) –

    Path to save the matches.

  • img0 (Path) –

    Path to the first image.

  • img1 (Path) –

    Path to the second image.

  • try_full_image (bool, default: False ) –

    Flag to attempt matching on full images. Defaults to False.

Raises:
  • RuntimeError

    If there are too many features to match on full images.

Returns:
  • ndarray

    np.ndarray: Array containing the indices of matched keypoints.

viz_matches(feature_path, matchings_path, img0, img1, save_path=None, fast_viz=True, interactive_viz=False, **kwargs)

_match_pairs(feats0, feats1) abstractmethod

Perform matching between two sets of features. This method must be implemented by subclasses. It takes in two dictionaries containing the features of the two images and returns the matches between keypoints and descriptors in those images.

Parameters:
  • feats0 (dict) –

    Features of the first image.

  • feats1 (dict) –

    Features of the second image.

Raises:
  • NotImplementedError

    Subclasses must implement _match_pairs() method.

Returns:
  • ndarray

    np.ndarray: Array containing the indices of matched keypoints.

_match_by_tile(img0, img1, features0, features1, method=TileSelection.PRESELECTION, select_unique=True)

Match features between two images using a tiling approach.

Parameters:
  • img0 (Path) –

    Path to the first image.

  • img1 (Path) –

    Path to the second image.

  • features0 (FeaturesDict) –

    Features of the first image.

  • features1 (FeaturesDict) –

    Features of the second image.

  • method (TileSelection, default: PRESELECTION ) –

    Tile selection method. Defaults to TileSelection.PRESELECTION.

  • select_unique (bool, default: True ) –

    Flag to select unique matches. Defaults to True.

Returns:
  • ndarray

    np.ndarray: Array containing the indices of matched keypoints.

DetectorFreeMatcherBase

Base class for matchers. It defines the basic interface for matchers and basic functionalities that are shared among all matchers, in particular the match method. It must be subclassed to implement a new matcher.

Attributes:
  • general_conf (dict) –

    Default configuration for general settings.

  • default_conf (dict) –

    Default configuration for matcher-specific settings.

  • required_inputs (list) –

    List of required input parameters.

  • min_inliers_per_pair (int) –

    Minimum number of matches required.

  • min_matches_per_tile (int) –

    Minimum number of matches required per tile.

  • max_feat_no_tiling (int) –

    Maximum number of features without tiling.

  • tile_preselection_size (int) –

    Maximum resize dimension for preselection.

__init__(custom_config)

Initializes the MatcherBase object.

Parameters:
  • custom_config (dict) –

    Options for the matcher.

Raises:
  • TypeError

    If custom_config is not a dictionary.

match(feature_path, matches_path, img0, img1, try_full_image=False)

Match features between two images.

Parameters:
  • feature_path (Path) –

    Path to the feature file.

  • matches_path (Path) –

    Path to save the matches.

  • img0 (Path) –

    Path to the first image.

  • img1 (Path) –

    Path to the second image.

  • try_full_image (bool, default: False ) –

    Flag to attempt matching on full images. Defaults to False.

Raises:
  • RuntimeError

    If there are too many features to match on full images.

Returns:
  • ndarray

    np.ndarray: Array containing the indices of matched keypoints.

viz_matches(feature_path, matchings_path, img0, img1, save_path=None, fast_viz=True, interactive_viz=False, **config)

_match_pairs(feature_path, img0_path, img1_path) abstractmethod

Perform matching between two images using a detector-free matcher. It takes the path to two images, and returns the matches between keypoints and descriptors in those images. It also saves the updated features to the specified h5 file. This method must be implemented by subclasses.

Parameters:
  • feature_path (Path) –

    Path to the h5 feature file where to save the updated features.

  • img0_path (Path) –

    Path to the first image.

  • img1_path (Path) –

    Path to the second image.

Returns:
  • np.ndarray: Array containing the indices of matched keypoints.

Raises:
  • NotImplementedError

    Subclasses must implement _match_pairs() method.

  • OutOfMemoryError

    If an out-of-memory error occurs while matching images.

_match_by_tile(feature_path, img0, img1, method=TileSelection.PRESELECTION, select_unique=True) abstractmethod

Match features between two images using a tiling approach. This method must be implemented by subclasses.

Parameters:
  • img0 (Path) –

    Path to the first image.

  • img1 (Path) –

    Path to the second image.

  • features0 (FeaturesDict) –

    Features of the first image.

  • features1 (FeaturesDict) –

    Features of the second image.

  • method (TileSelection, default: PRESELECTION ) –

    Tile selection method. Defaults to TileSelection.PRESELECTION.

  • select_unique (bool, default: True ) –

    Flag to select unique matches. Defaults to True.

Returns:
  • ndarray

    np.ndarray: Array containing the indices of matched keypoints.