Visualization functions

imshow_cv2(img, win_name=None, convert_RGB2BRG=True)

Wrapper for visualizing an image with OpenCV

Parameters:
  • img (ndarray) –

    Input image.

  • win_name (str, default: None ) –

    Name of the window. Default is None.

  • convert_RGB2BRG (bool, default: True ) –

    Whether to convert RGB to BGR. Default is True.

Returns:
  • None( None ) –

    This function does not return anything.

plot_image_pair(imgs, dpi=100, size=6, pad=0.5)

Plot a pair of images.

Parameters:
  • imgs (List[ndarray]) –

    A list containing two images.

  • dpi (int, default: 100 ) –

    Dots per inch. Default is 100.

  • size (float, default: 6 ) –

    Figure size. Default is 6.

  • pad (float, default: 0.5 ) –

    Padding between subplots. Default is 0.5.

Returns:
  • figure

    plt.figure: Figure object of the plotted images.

plot_matches(image0, image1, pts0, pts1, color=[0, 255, 0], point_size=1, line_thickness=1, path=None, fast_viz=False)

Plot matching points between two images.

Parameters:
  • image0

    The first image.

  • image1

    The second image.

  • pts0

    List of 2D points in the first image.

  • pts1

    List of 2D points in the second image.

  • color (List[int], default: [0, 255, 0] ) –

    RGB color of the matching lines.

  • point_size

    Size of the circles representing the points.

  • line_thickness

    Thickness of the lines connecting the points.

  • path

    Path to save the output image.

  • fast_viz (bool, default: False ) –

    If True, use OpenCV to display the image.

Returns:
  • Union[ndarray, Figure]

    Union[np.ndarray, plt.Figure]: The output image if fast_viz is True, otherwise the figure object.

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

Plot matching points between two images using OpenCV.

Parameters:
  • image0

    The first image.

  • image1

    The second image.

  • pts0

    List of 2D points in the first image.

  • pts1

    List of 2D points in the second image.

  • pts_col

    RGB color of the points.

  • point_size

    Size of the circles representing the points.

  • line_col

    RGB color of the matching lines.

  • line_thickness

    Thickness of the lines connecting the points.

  • path

    Path to save the output image.

  • margin

    Margin between the two images in the output.

Returns:
  • ndarray

    np.ndarrya: The output image.

plot_points(image, points, title=None, ax=None, save_path=None, hide_fig=False, zoom_to_features=False, window_size=50, **kwargs)

plot_points Plot points on input image.

Parameters:
  • image (ndarray) –

    A numpy array with RGB channels.

  • points (ndarray) –

    An nx2 float32 array of 2D image coordinates of the features to plot.

  • title (str, default: None ) –

    The title of the plot. Defaults to None.

  • ax (axes, default: None ) –

    The axis in which to make the plot. If None, the function will create a new figure and axes. Defaults to None.

  • save_path (Union[str, Path], default: None ) –

    The path to save the plot. Defaults to None.

  • hide_fig (bool, default: False ) –

    Indicates whether to close the figure after plotting. Defaults to False.

  • zoom_to_features (bool, default: False ) –

    Indicates whether to zoom in to the features in the plot. Defaults to False.

  • window_size (int, default: 50 ) –

    The size of the zoom window. Defaults to 50.

  • **kwargs

    additional keyword arguments for plotting characteristics (e.g. s, c, marker, etc.). Refer to matplotlib.pyplot.scatter documentation for more information https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html.

Returns:
  • Axes

    plt.Axes: matplotlib axis

plot_features(image, features, title=None, ax=None, save_path=None, hide_fig=False, **kwargs)

Wrapper around plot_points to work if the input is a Features object

plot_feature(image, feature, title=None, ax=None, save_path=None, hide_fig=False, zoom_to_feature=False, window_size=50, **kwargs)

Wrapper around plot_points to work if the input is a single Feature object

plot_projections(points3d, camera, image, title=None, ax=None)

Project 3D points to a camera and plot their projections on an image.

Parameters:
  • points3d

    numpy.ndarray Array of shape (n, 3) containing 3D points in object space.

  • camera (Camera) –

    Camera object Camera object containing exterior and interior orientation.

  • image

    numpy.ndarray Image with BGR channels in OpenCV standard.

  • title (str, default: None ) –

    str, optional Title of the axes of the plot.

  • ax

    matplotlib axes, optional Axis in which to make the plot. If nothing is given, the function creates a new figure and axes.

Returns:
  • None

    None

plot_projection_error(projections, projection_error, image, title=None, ax=None, convert_BRG2RGB=True)

Plot the projection error of 3D points on an image.

Parameters:
  • projections

    numpy.ndarray Array of shape (n, 2) containing the projections of 3D points on an image.

  • projection_error

    numpy.ndarray Array of shape (n,) containing the projection error for each point.

  • image

    numpy.ndarray Image with BGR channels in OpenCV standard.

  • title (str, default: None ) –

    str, optional Title of the plot.

  • ax

    matplotlib axes, optional Axis in which to make the plot. If nothing is given, the function creates a new figure and axes.

  • convert_BRG2RGB

    bool, optional Whether to convert the image from BGR to RGB.

Returns:
  • None

    None