limap.line2d.SOLD2.misc package

Submodules

limap.line2d.SOLD2.misc.geometry_utils module

limap.line2d.SOLD2.misc.geometry_utils.get_common_line_mask(line_indices, valid_mask)
limap.line2d.SOLD2.misc.geometry_utils.get_dist_mask(kp0, kp1, valid_mask, dist_thresh)
limap.line2d.SOLD2.misc.geometry_utils.keypoints_to_grid(keypoints, img_size)
limap.line2d.SOLD2.misc.geometry_utils.mask_lines(lines, valid_mask)
limap.line2d.SOLD2.misc.geometry_utils.mask_points(points, img_size)
limap.line2d.SOLD2.misc.geometry_utils.sample_line_points(lines, n)
limap.line2d.SOLD2.misc.geometry_utils.warp_points(points, homography)

limap.line2d.SOLD2.misc.train_utils module

This file contains some useful functions for train / val.

limap.line2d.SOLD2.misc.train_utils.convert_image(input_tensor, axis)

Convert single channel images to 3-channel images.

limap.line2d.SOLD2.misc.train_utils.get_latest_checkpoint(checkpoint_root, checkpoint_name, device=device(type='cuda'))

Get the latest checkpoint or by filename.

limap.line2d.SOLD2.misc.train_utils.parse_h5_data(h5_data)

Parse h5 dataset.

limap.line2d.SOLD2.misc.train_utils.remove_old_checkpoints(checkpoint_root, max_ckpt=15)

Remove the outdated checkpoints.

limap.line2d.SOLD2.misc.visualize_util module

Organize some frequently used visualization functions.

limap.line2d.SOLD2.misc.visualize_util.plot_color_line_matches(lines, correct_matches=None, lw=2, indices=(0, 1))

Plot line matches for existing images with multiple colors. :param lines: list of ndarrays of size (N, 2, 2). :param correct_matches: bool array of size (N,) indicating correct matches. :param lw: line width as float pixels. :param indices: indices of the images to draw the matches on.

limap.line2d.SOLD2.misc.visualize_util.plot_color_lines(lines, correct_matches, wrong_matches, lw=2, indices=(0, 1))

Plot line matches for existing images with multiple colors: green for correct matches, red for wrong ones, and blue for the rest. :param lines: list of ndarrays of size (N, 2, 2). :param correct_matches: list of bool arrays of size N with correct matches. :param wrong_matches: list of bool arrays of size (N,) with correct matches. :param lw: line width as float pixels. :param indices: indices of the images to draw the matches on.

limap.line2d.SOLD2.misc.visualize_util.plot_images(imgs, titles=None, cmaps='gray', dpi=100, size=6, pad=0.5)

Plot a set of images horizontally. :param imgs: a list of NumPy or PyTorch images, RGB (H, W, 3) or mono (H, W). :param titles: a list of strings, as titles for each image. :param cmaps: colormaps for monochrome images.

limap.line2d.SOLD2.misc.visualize_util.plot_junctions(input_image, junctions, junc_size=3, color=None)

input_image: can be 0~1 float or 0~255 uint8. junctions: Nx2 or 2xN np array. junc_size: the size of the plotted circles.

limap.line2d.SOLD2.misc.visualize_util.plot_keypoints(kpts, colors='lime', ps=4)

Plot keypoints for existing images. :param kpts: list of ndarrays of size (N, 2). :param colors: string, or list of list of tuples (one for each keypoints). :param ps: size of the keypoints as float.

limap.line2d.SOLD2.misc.visualize_util.plot_line_matches(kpts0, kpts1, color=None, lw=1.5, indices=(0, 1), a=1.0)

Plot matches for a pair of existing images, parametrized by their middle point. :param kpts0: corresponding middle points of the lines of size (N, 2). :param kpts1: corresponding middle points of the lines of size (N, 2). :param color: color of each match, string or RGB tuple. Random if not given. :param lw: width of the lines. :param indices: indices of the images to draw the matches on. :param a: alpha opacity of the match lines.

limap.line2d.SOLD2.misc.visualize_util.plot_line_segments(input_image, junctions, line_map, junc_size=3, color=(0, 255.0, 0), line_width=1, plot_survived_junc=True)

input_image: can be 0~1 float or 0~255 uint8. junctions: Nx2 or 2xN np array. line_map: NxN np array junc_size: the size of the plotted circles. color: color of the line segments (can be string “random”) line_width: width of the drawn segments. plot_survived_junc: whether we only plot the survived junctions.

limap.line2d.SOLD2.misc.visualize_util.plot_line_segments_from_segments(input_image, line_segments, junc_size=3, color=(0, 255.0, 0), line_width=1)
limap.line2d.SOLD2.misc.visualize_util.plot_lines(lines, line_colors='orange', point_colors='cyan', ps=4, lw=2, indices=(0, 1))

Plot lines and endpoints for existing images. :param lines: list of ndarrays of size (N, 2, 2). :param colors: string, or list of list of tuples (one for each keypoints). :param ps: size of the keypoints as float pixels. :param lw: line width as float pixels. :param indices: indices of the images to draw the matches on.

limap.line2d.SOLD2.misc.visualize_util.plot_matches(kpts0, kpts1, color=None, lw=1.5, ps=4, indices=(0, 1), a=1.0)

Plot matches for a pair of existing images. :param kpts0: corresponding keypoints of size (N, 2). :param kpts1: corresponding keypoints of size (N, 2). :param color: color of each match, string or RGB tuple. Random if not given. :param lw: width of the lines. :param ps: size of the end points (no endpoint if ps=0) :param indices: indices of the images to draw the matches on. :param a: alpha opacity of the match lines.

limap.line2d.SOLD2.misc.visualize_util.plot_subsegment_matches(lines, subsegments, lw=2, indices=(0, 1))
Plot line matches for existing images with multiple colors and

highlight the actually matched subsegments.

Parameters:
  • lines – list of ndarrays of size (N, 2, 2).

  • subsegments – list of ndarrays of size (N, 2, 2).

  • lw – line width as float pixels.

  • indices – indices of the images to draw the matches on.

Module contents