limap.util package

Shared utilities: the basic value types, the KD-tree used across the pipelines, configuration loading and file I/O.

Types

limap.util.Color: tuple[float, float, float]

An RGB color triplet. The 2D helpers use the [0, 255] range expected by OpenCV, the 3D ones the [0, 1] range expected by Open3D.

limap.util.Ranges: tuple[numpy.ndarray, numpy.ndarray]

An axis-aligned 3D bounding box, as its minimum and maximum corner.

class limap.util.KDTree
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: limap._limap._util.KDTree) -> None

  2. __init__(self: limap._limap._util.KDTree, arg0: collections.abc.Sequence[typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[3, 1]”]]) -> None

  3. __init__(self: limap._limap._util.KDTree, arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[3, 3]”]) -> None

load(self: limap._limap._util.KDTree, arg0: str) None
point_distance(self: limap._limap._util.KDTree, arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) float
query_nearest(self: limap._limap._util.KDTree, arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']
save(self: limap._limap._util.KDTree, arg0: str) None

Configuration

YAML configuration files under cfgs/ are resolved with base_config_file inheritance and then overridden by unknown --key.subkey value command line arguments.

limap.util.config.load_config(config_file, default_path=None)
limap.util.config.update_config(cfg, unknown, shortcuts)
limap.util.config.update_recursive(dict1, dictinfo)
limap.util.config.update_recursive_deepcopy(dict1, dictinfo)

File I/O

limap.util.io.check_directory(fname)
limap.util.io.check_makedirs(folder)
limap.util.io.check_path(fname)
limap.util.io.delete_folder(folder)
limap.util.io.exists_txt_segments(folder, img_id)
limap.util.io.load_obj(fname)
limap.util.io.read_all_segments_from_folder(folder)
limap.util.io.read_npy(fname)
limap.util.io.read_npz(fname)
limap.util.io.read_ply(fname)
limap.util.io.read_txt_imname_dict(fname)
limap.util.io.read_txt_imname_list(fname)
limap.util.io.read_txt_metainfos(fname)

Read in .txt for neighbors and ranges

limap.util.io.read_txt_segments(folder, img_id)
limap.util.io.save_npy(fname, nparray)
limap.util.io.save_npz(fname, dic)
limap.util.io.save_obj(fname, lines)
limap.util.io.save_ply(fname, points)
limap.util.io.save_txt_imname_dict(fname, imname_dict)
limap.util.io.save_txt_imname_list(fname, imname_list)
limap.util.io.save_txt_metainfos(fname, neighbors, ranges)

Write out .txt for neighbors and ranges

limap.util.io.save_txt_segments(folder, img_id, segs)

Model weights

Location and download of pretrained model weights.

Weights default to a per-user cache directory rather than to the installed package. __file__ points inside site-packages for a non-editable install, which is often read-only and is wiped on upgrade.

Override the root with the weight_path option of a detector / matcher, or globally with the LIMAP_WEIGHTS_PATH environment variable.

limap.util.model_weights.download_weights(url: str, path) Path

Fetch url into path, unless it is already there.

Downloads through torch rather than shelling out to wget, which is not a declared dependency and is missing on many systems.

limap.util.model_weights.resolve_weight_path(weight_path, *parts) Path

Full path of a checkpoint, under weight_path or the default root.

Parameters:
  • weight_path – root to use, or None for weights_root()

  • parts – per-module layout, e.g. (“line2d”, “DeepLSD”, “deeplsd_md.tar”)

limap.util.model_weights.weights_root() Path

Default root directory for cached weights.