Matching

You can import icepy4d matching module by

from icepy4d import matching

ImageMatcherBase

Bases: ImageMatcherABC

__init__(opt={})

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.

Parameters:
  • opt (dict, default: {} ) –

    Options for the matcher.

Raises:
  • TypeError

    If opt is not a dictionary.

match(image0, image1, quality=Quality.HIGH, tile_selection=TileSelection.NONE, **config)

Matches images and performs geometric verification.

Parameters:
  • image0 (ndarray) –

    The first input image as a NumPy array.

  • image1 (ndarray) –

    The second input image as a NumPy array.

  • quality (Quality, default: HIGH ) –

    The quality level for resizing images (default: Quality.HIGH).

  • tile_selection (TileSelection, default: NONE ) –

    The method for selecting tiles for matching (default: TileSelection.NONE).

  • **config

    Additional keyword arguments for customization.

Returns:
  • bool

    A boolean indicating the success of the matching process.

reset()

Reset the matcher by clearing the features and matches

save_mkpts_as_txt(savedir, delimiter=',', header='x,y')

Save keypoints in a .txt file

viz_matches_cv2(image0, image1, pts0, pts1, save_path=None, pts_col=(0, 0, 255), point_size=2, line_col=(0, 255, 0), line_thickness=1, margin=10)

Plot matching points between two images using OpenCV.

Parameters:
  • image0 (ndarray) –

    The first image.

  • image1 (ndarray) –

    The second image.

  • pts0 (ndarray) –

    List of 2D points in the first image.

  • pts1 (ndarray) –

    List of 2D points in the second image.

  • pts_col (Tuple[int], default: (0, 0, 255) ) –

    RGB color of the points.

  • point_size (int, default: 2 ) –

    Size of the circles representing the points.

  • line_col (Tuple[int], default: (0, 255, 0) ) –

    RGB color of the matching lines.

  • line_thickness (int, default: 1 ) –

    Thickness of the lines connecting the points.

  • path

    Path to save the output image.

  • margin (int, default: 10 ) –

    Margin between the two images in the output.

Returns:
  • ndarray

    np.ndarrya: The output image.

LOFTRMatcher

Bases: ImageMatcherBase

__init__(opt={})

Initializes a LOFTRMatcher with Kornia object with the given options dictionary.

LightGlueMatcher

Bases: ImageMatcherBase

__init__(opt={})

Initializes a LightGlueMatcher with Kornia

SuperGlueMatcher

Bases: ImageMatcherBase

__init__(opt)

Initializes a SuperGlueMatcher object with the given options dictionary.

The options dictionary should contain the following keys:

  • 'weights': defines the type of the weights used for SuperGlue inference. It can be either "indoor" or "outdoor". Default value is "outdoor".
  • 'keypoint_threshold': threshold for the SuperPoint keypoint detector
  • 'max_keypoints': maximum number of keypoints to extract with the SuperPoint detector. Default value is 0.001.
  • 'match_threshold': threshold for the SuperGlue feature matcher
  • 'force_cpu': whether to force using the CPU for inference
Parameters:
  • opt (dict) –

    a dictionary of options for configuring the SuperGlueMatcher object

Raises:
  • KeyError

    if one or more required options are missing from the options dictionary

  • FileNotFoundError

    if the specified SuperGlue model weights file cannot be found

viz_matches(image0, image1, path, fast_viz=False, show_keypoints=False, opencv_display=False)

Visualize the matching result between two images.

Args: - path (str): The output path to save the visualization. - fast_viz (bool): Whether to use preselection visualization method. - show_keypoints (bool): Whether to show the detected keypoints. - opencv_display (bool): Whether to use OpenCV for displaying the image.

Returns: - None

TODO: replace make_matching_plot with native a function implemented in icepy4D