Cameras, poses, and images

class limap.base.Camera
Camera model, inherits COLMAP’s camera model.
COLMAP camera models:
0, SIMPLE_PINHOLE
1, PINHOLE
2, SIMPLE_RADIAL
3, RADIAL
4, OPENCV
5, OPENCV_FISHEYE
6, FULL_OPENCV
7, FOV
8, SIMPLE_RADIAL_FISHEYE
9, RADIAL_FISHEYE
10, THIN_PRISM_FISHEYE
ImageToWorld(self: _limap._base.Camera, arg0: numpy.ndarray[numpy.float64[2, 1]]) numpy.ndarray[numpy.float64[2, 1]]
InitializeParams(self: _limap._base.Camera, focal_length: float, width: int, height: int) None

Initialize the intrinsics using focal length, width, and height

Parameters:
  • focal_length (double) –

  • width (int) –

  • height (int) –

IsInitialized(self: _limap._base.Camera) bool
Returns:

True if the camera parameters are initialized

Return type:

bool

IsUndistorted(self: _limap._base.Camera) bool
Returns:

True if the camera model is without distortion

Return type:

bool

K(self: _limap._base.Camera) numpy.ndarray[numpy.float64[3, 3]]
Returns:

Camera’s intrinsic matrix

Return type:

np.array of shape (3, 3)

K_inv(self: _limap._base.Camera) numpy.ndarray[numpy.float64[3, 3]]
Returns:

Inverse of the intrinsic matrix

Return type:

np.array of shape (3, 3)

WorldToImage(self: _limap._base.Camera, arg0: numpy.ndarray[numpy.float64[2, 1]]) numpy.ndarray[numpy.float64[2, 1]]
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: _limap._base.Camera) -> None

  2. __init__(self: _limap._base.Camera, model_id: int, params: List[float], cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  3. __init__(self: _limap._base.Camera, model_name: str, params: List[float], cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  4. __init__(self: _limap._base.Camera, K: numpy.ndarray[numpy.float64[3, 3]], cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  5. __init__(self: _limap._base.Camera, model_id: int, K: numpy.ndarray[numpy.float64[3, 3]], cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  6. __init__(self: _limap._base.Camera, model_name: str, K: numpy.ndarray[numpy.float64[3, 3]], cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  7. __init__(self: _limap._base.Camera, dict: dict) -> None

  8. __init__(self: _limap._base.Camera, cam: _limap._base.Camera) -> None

  9. __init__(self: _limap._base.Camera, model_id: int, cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

  10. __init__(self: _limap._base.Camera, model_name: str, cam_id: int = -1, hw: Tuple[int, int] = (-1, -1)) -> None

as_dict(self: _limap._base.Camera) dict
Returns:

Python dict representation of this Camera

Return type:

dict

cam_id(self: _limap._base.Camera) int
Returns:

Camera ID

Return type:

int

h(self: _limap._base.Camera) int
Returns:

Image height in pixels

Return type:

int

model_id(self: _limap._base.Camera) int
Returns:

COLMAP camera model ID

Return type:

int

num_params(self: _limap._base.Camera) int
Returns:

Number of the paramters for minimal representation of intrinsic

Return type:

int

params(self: _limap._base.Camera) List[float]
Returns:

Minimal representation of intrinsic paramters, length varies according to camera model

Return type:

list (float)

resize(self: _limap._base.Camera, width: int, height: int) None

Resize camera’s width and height.

Parameters:
  • width (int) –

  • height (int) –

set_cam_id(self: _limap._base.Camera, camera_id: int) None

Set the camera ID.

set_max_image_dim(self: _limap._base.Camera, val: int) None

Set the maximum image dimension, the camera will be resized if the longer dimension of width or height is larger than this value.

Parameters:

val (int) –

w(self: _limap._base.Camera) int
Returns:

Image width in pixels

Return type:

int

class limap.base.CameraImage

This class associates the ID of a Camera, a CameraPose, and an image file

R(self: _limap._base.CameraImage) numpy.ndarray[numpy.float64[3, 3]]
Returns:

The rotation matrix of the camera pose

Return type:

np.array of shape (3, 3)

T(self: _limap._base.CameraImage) numpy.ndarray[numpy.float64[3, 1]]
Returns:

The translation vector of the camera pose

Return type:

np.array of shape (3,)

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: _limap._base.CameraImage) -> None

  2. __init__(self: _limap._base.CameraImage, cam_id: int, image_name: str = ‘none’) -> None

  3. __init__(self: _limap._base.CameraImage, camera: _limap._base.Camera, image_name: str = ‘none’) -> None

  4. __init__(self: _limap._base.CameraImage, cam_id: int, pose: _limap._base.CameraPose, image_name: str = ‘none’) -> None

  5. __init__(self: _limap._base.CameraImage, camera: _limap._base.Camera, pose: _limap._base.CameraPose, image_name: str = ‘none’) -> None

  6. __init__(self: _limap._base.CameraImage, dict: dict) -> None

  7. __init__(self: _limap._base.CameraImage, camimage: _limap._base.CameraImage) -> None

as_dict(self: _limap._base.CameraImage) dict
Returns:

Python dict representation of this CameraImage

Return type:

dict

image_name(self: _limap._base.CameraImage) str
Returns:

The image file name

Return type:

str

set_camera_id(self: _limap._base.CameraImage, cam_id: int) None

Set the camera ID.

Parameters:

cam_id (int) –

set_image_name(self: _limap._base.CameraImage, image_name: str) None

Set the name of the image file.

Parameters:

image_name (str) –

property cam_id

int, the camera ID

property pose

CameraPose, the camera pose

class limap.base.CameraPose

Representing the world-to-cam pose (R, t) with a quaternion and a translation vector. The quaternion convention is (w, x, y, z) (real part first).

R(self: _limap._base.CameraPose) numpy.ndarray[numpy.float64[3, 3]]
Returns:

The rotation matrix

Return type:

np.array of shape (3, 3)

T(self: _limap._base.CameraPose) numpy.ndarray[numpy.float64[3, 1]]
Returns:

The translation vector

Return type:

np.array of shape (3,)

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: _limap._base.CameraPose, initialized: bool = False) -> None

    Default constructor: identity pose

  2. __init__(self: _limap._base.CameraPose, campose: _limap._base.CameraPose) -> None

    Copy constructor

  3. __init__(self: _limap._base.CameraPose, qvec: numpy.ndarray[numpy.float64[4, 1]], tvec: numpy.ndarray[numpy.float64[3, 1]], initialized: bool = True) -> None

    Constructor from a quaternion vector and a translation vector

  4. __init__(self: _limap._base.CameraPose, R: numpy.ndarray[numpy.float64[3, 3]], tvec: numpy.ndarray[numpy.float64[3, 1]], initialized: bool = True) -> None

    Constructor from a rotation matrix and a translation vector

  5. __init__(self: _limap._base.CameraPose, dict: dict) -> None

    Constructor from a Python dict

as_dict(self: _limap._base.CameraPose) dict
Returns:

Python dict representation of this CameraPose

Return type:

dict

center(self: _limap._base.CameraPose) numpy.ndarray[numpy.float64[3, 1]]
Returns:

World-space coordinate of the camera

Return type:

np.array of shape (3,)

projdepth(self: _limap._base.CameraPose, p3d: numpy.ndarray[numpy.float64[3, 1]]) float
Parameters:

p3d (np.array) – World-space coordinate of a 3D point

Returns:

The projection depth of the 3D point viewed from this camera pose

Return type:

float

property initialized

Flag indicating whether the pose has been initialized

Type:

bool

property qvec

The quaternion vector (w, x, y, z)

Type:

np.array of shape (4,)

property tvec

The translation vector

Type:

np.array of shape (3,)

class limap.base.CameraView

Inherits CameraImage, incorporating the Camera model and its parameters for projection/unprojection between 2D and 3D.

K(self: _limap._base.CameraView) numpy.ndarray[numpy.float64[3, 3]]
Returns:

The intrinsic matrix of the camera

Return type:

np.array of shape (3, 3)

K_inv(self: _limap._base.CameraView) numpy.ndarray[numpy.float64[3, 3]]
Returns:

The inverse of the camera’s intrinsic matrix

Return type:

np.array of shape (3, 3)

R(self: _limap._base.CameraView) numpy.ndarray[numpy.float64[3, 3]]
Returns:

The rotation matrix of the camera pose

Return type:

np.array of shape (3, 3)

T(self: _limap._base.CameraView) numpy.ndarray[numpy.float64[3, 1]]
Returns:

The translation vector of the camera pose

Return type:

np.array of shape (3,)

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: _limap._base.CameraView) -> None

  2. __init__(self: _limap._base.CameraView, camera: _limap._base.Camera, image_name: str = ‘none’) -> None

  3. __init__(self: _limap._base.CameraView, camera: _limap._base.Camera, pose: _limap._base.CameraPose, image_name: str = ‘none’) -> None

  4. __init__(self: _limap._base.CameraView, dict: dict) -> None

  5. __init__(self: _limap._base.CameraView, camview: _limap._base.CameraView) -> None

as_dict(self: _limap._base.CameraView) dict
Returns:

Python dict representation of this CameraView

Return type:

dict

get_direction_from_vp(self: _limap._base.CameraView, vp: numpy.ndarray[numpy.float64[3, 1]]) numpy.ndarray[numpy.float64[3, 1]]
Parameters:

vp (np.array) – The coordinate of a vanishing point

Returns:

The direction from the vanishing point

Return type:

np.array of shape (3,)

get_initial_focal_length(self: _limap._base.CameraView) Tuple[float, bool]

Try to get the focal length information from the image’s EXIF data. If not available in image EXIF, the focal length is estimated by the max dimension of the image.

Returns:

Initial focal length and a flag indicating if the value is read from image’s EXIF data.

Return type:

tuple[double, bool]

h(self: _limap._base.CameraView) int
Returns:

Image height in pixels

Return type:

int

image_name(self: _limap._base.CameraView) str
Returns:

The image file name

Return type:

str

matrix(self: _limap._base.CameraView) numpy.ndarray[numpy.float64[m, n]]
Returns:

The projection matrix P = K[R|T]

Return type:

np.array of shape (3, 4)

projection(self: _limap._base.CameraView, p3d: numpy.ndarray[numpy.float64[3, 1]]) numpy.ndarray[numpy.float64[2, 1]]
Parameters:

p3d (np.array) – World-space coordinate of a 3D point

Returns:

The 2D pixel-space coordinate of the point’s projection on image

Return type:

np.array of shape (2,)

ray_direction(self: _limap._base.CameraView, p2d: numpy.ndarray[numpy.float64[2, 1]]) numpy.ndarray[numpy.float64[3, 1]]
Parameters:

p2d (np.array) – Pixel-space coordinate of a 2D point on the image

Returns:

The world-space direction of the camera ray passing the 2D point

Return type:

np.array of shape (3,)

read_image(self: _limap._base.CameraView, set_gray: bool = False) numpy.ndarray[numpy.uint8]

Read image data from the image file.

Parameters:

set_gray (bool) – Whether to convert the image to gray. Default False.

Returns:

The image data matrix

Return type:

np.array

set_image_name(self: _limap._base.CameraView, image_name: str) None

Set the name of the image file.

Parameters:

image_name (str) –

w(self: _limap._base.CameraView) int
Returns:

Image width in pixels

Return type:

int

property cam

Camera, the camera model

property pose

CameraPose, the camera pose

class limap.base.ImageCollection

A flexible class that consists of cameras and images in a scene or dataset. In each image stores the corresponding ID of the camera, making it easy to extend to single/multiple sequences or unstructured image collections. The constructor arguments input_cameras and input_images can be either list of Camera and CameraImage or python dict mapping integer IDs to Camera and CameraImage.

IsUndistorted(self: _limap._base.ImageCollection) bool
Returns:

True if all cameras in the collection are without distortion, see IsUndistorted().

Return type:

bool

IsUndistortedCameraModel(self: _limap._base.ImageCollection) bool
Returns:

True if all camera models are undistorted.

Return type:

bool

NumCameras(self: _limap._base.ImageCollection) int
Returns:

The number of cameras in the collection

Return type:

int

NumImages(self: _limap._base.ImageCollection) int
Returns:

The number of images in the collection

Return type:

int

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: _limap._base.ImageCollection) -> None

  2. __init__(self: _limap._base.ImageCollection, input_cameras: Dict[int, _limap._base.Camera], input_images: Dict[int, _limap._base.CameraImage]) -> None

  3. __init__(self: _limap._base.ImageCollection, input_cameras: List[_limap._base.Camera], input_images: Dict[int, _limap._base.CameraImage]) -> None

  4. __init__(self: _limap._base.ImageCollection, input_cameras: Dict[int, _limap._base.Camera], input_images: List[_limap._base.CameraImage]) -> None

  5. __init__(self: _limap._base.ImageCollection, input_cameras: List[_limap._base.Camera], input_images: List[_limap._base.CameraImage]) -> None

  6. __init__(self: _limap._base.ImageCollection, camviews: List[_limap._base.CameraView]) -> None

  7. __init__(self: _limap._base.ImageCollection, dict: dict) -> None

  8. __init__(self: _limap._base.ImageCollection, imagecols: _limap._base.ImageCollection) -> None

apply_similarity_transform(self: _limap._base.ImageCollection, transform: _limap._base.SimilarityTransform3) _limap._base.ImageCollection

Apply similarity transform to all image poses.

Parameters:

transform (limap.base.SimilarityTransform3) –

as_dict(self: _limap._base.ImageCollection) dict
Returns:

Python dict representation of this ImageCollection

Return type:

dict

cam(self: _limap._base.ImageCollection, cam_id: int) _limap._base.Camera
Parameters:

cam_id (int) –

Returns:

The camera with cam_id

Return type:

Camera

camimage(self: _limap._base.ImageCollection, img_id: int) _limap._base.CameraImage
Parameters:

img_id (int) –

Returns:

The image with img_id

Return type:

CameraImage

campose(self: _limap._base.ImageCollection, img_id: int) _limap._base.CameraPose
Parameters:

img_id (int) –

Returns:

The camera pose of the image

Return type:

CameraPose

camview(self: _limap._base.ImageCollection, img_id: int) _limap._base.CameraView
Parameters:

img_id (int) –

Returns:

The CameraView from the image

Return type:

CameraView

change_camera(self: _limap._base.ImageCollection, cam_id: int, cam: _limap._base.Camera) None

Change the camera model of a specific camera.

Parameters:
  • cam_id (int) –

  • cam (Camera) –

change_image(self: _limap._base.ImageCollection, img_id: int, camimage: _limap._base.CameraImage) None

Change an image.

Parameters:
change_image_name(self: _limap._base.ImageCollection, img_id: int, new_name: str) None

Change the file name of an image.

Parameters:
  • img_id (int) –

  • new_name (str) –

exist_cam(self: _limap._base.ImageCollection, cam_id: int) bool
Parameters:

cam_id (int) –

Returns:

True if the camera with cam_id exists in the collection

Return type:

bool

exist_image(self: _limap._base.ImageCollection, img_id: int) bool
Parameters:

img_id (int) –

Returns:

True if the image with img_id exists in the collection

Return type:

bool

get_cam_ids(self: _limap._base.ImageCollection) List[int]
Returns:

IDs of all cameras in the collection

Return type:

list[int]

get_camera_pose(self: _limap._base.ImageCollection, img_id: int) _limap._base.CameraPose

Get the camera pose of a specific image.

Parameters:

img_id (int) –

Returns:

CameraPose

get_cameras(self: _limap._base.ImageCollection) List[_limap._base.Camera]
Returns:

All cameras in the collection

Return type:

list[Camera]

get_camviews(self: _limap._base.ImageCollection) List[_limap._base.CameraView]
Returns:

The associated CameraView from all the images and their cameras in the collection

Return type:

list[CameraView]

get_first_image_id_by_camera_id(self: _limap._base.ImageCollection, cam_id: int) int

Get the ID of the first image captured with a specific camera.

Parameters:

cam_id (int) – The camera ID

Returns:

The image ID.

Return type:

int

get_image_name_dict(self: _limap._base.ImageCollection) Dict[int, str]
Returns:

Mapping of image IDs to the file names

Return type:

dict[int -> str]

get_image_name_list(self: _limap._base.ImageCollection) List[str]
Returns:

All the image file names

Return type:

list[str]

get_images(self: _limap._base.ImageCollection) List[_limap._base.CameraImage]
Returns:

All images in the collection

Return type:

list[CameraImage]

get_img_ids(self: _limap._base.ImageCollection) List[int]
Returns:

IDs of all images in the collection

Return type:

list[int]

get_locations(self: _limap._base.ImageCollection) List[numpy.ndarray[numpy.float64[3, 1]]]
Returns:

The world-space locations of the camera for all images in the collection, each of shape (3, )

Return type:

list[np.array]

get_map_camviews(self: _limap._base.ImageCollection) Dict[int, _limap._base.CameraView]
Returns:

Mapping of image IDs to their associated CameraView

Return type:

dict[int -> CameraView]

get_map_locations(self: _limap._base.ImageCollection) Dict[int, numpy.ndarray[numpy.float64[3, 1]]]
Returns:

Mapping of image IDs to their camera locations in world-space

Return type:

dict[int -> np.array]

image_name(self: _limap._base.ImageCollection, img_id: int) str
Parameters:

img_id (int) –

Returns:

The file name of the image

Return type:

str

init_uninitialized_cameras(self: _limap._base.ImageCollection) None

Initialize all uninitialized cameras by InitializeParams().

read_image(self: _limap._base.ImageCollection, img_id: int, set_gray: bool = False) numpy.ndarray[numpy.uint8]

Read an image, calls read_image().

Parameters:
  • img_id (int) – The image ID

  • set_gray (bool) – Whether to convert the image to gray. Default False.

Returns:

The image data matrix

Return type:

np.array

set_camera_pose(self: _limap._base.ImageCollection, img_id: int, pose: _limap._base.CameraPose) None

Set the camera pose for a specific image.

Parameters:
set_max_image_dim(self: _limap._base.ImageCollection, val: int) None

Set the maximum image dimension for all cameras using set_max_image_dim().

Parameters:

val (int) –

subset_by_camera_ids(self: _limap._base.ImageCollection, valid_camera_ids: List[int]) _limap._base.ImageCollection

Filter the images using camera IDs.

Parameters:

valid_camera_ids (list[int]) – Images from camera with these IDs are kept in the filtered subset

Returns:

The filtered subset collection

Return type:

ImageCollection

subset_by_image_ids(self: _limap._base.ImageCollection, valid_image_ids: List[int]) _limap._base.ImageCollection

Filter the images using image IDs.

Parameters:

valid_image_ids (list[int]) – IDs of images to be kept in the filtered subset

Returns:

The filtered subset collection

Return type:

ImageCollection

subset_initialized(self: _limap._base.ImageCollection) _limap._base.ImageCollection

Filter the images to create a subset collection containing only images with initialized camera poses.

Returns:

The filtered subset collection

Return type:

ImageCollection

uninitialize_intrinsics(self: _limap._base.ImageCollection) None

Uninitialize intrinsics for all cameras.

uninitialize_poses(self: _limap._base.ImageCollection) None

Uninitialize camera poses for all images, set them to identity poses and remove the initialized flag.

update_neighbors(self: _limap._base.ImageCollection, arg0: Dict[int, List[int]]) Dict[int, List[int]]

Update the neighbor information among images (e.g. after filtering). Remove neighboring images that are not in the image collection.

Parameters:

neighbors (dict[int -> list[int]]) – The input neighbor information

Returns:

Updated neighbor information

Return type:

dict[int -> list[int]]