ct.sanity¶
Functions for sanity checking inputs.
- ct.sanity.assert_numpy(x, name=None)[source]¶
Assert that x is a numpy array.
- Parameters:
x – Input to check
name – Optional name of the variable for error message
- Raises:
ValueError – If x is not a numpy array
- ct.sanity.assert_K(K)[source]¶
Assert that K is a valid 3x3 camera intrinsic matrix.
The intrinsic matrix K follows the standard form:
[[fx, s, cx], [ 0, fy, cy], [ 0, 0, 1]]
- where:
fx, fy: focal lengths in pixels
cx, cy: principal point coordinates
s: skew coefficient (usually 0)
- Parameters:
K (Float[ndarray, '3 3']) – Camera intrinsic matrix to validate
- Raises:
ValueError – If K is not a 3x3 matrix
- ct.sanity.assert_T(T)[source]¶
Assert that T is a valid 4x4 camera extrinsic matrix (world-to-camera transformation).
- Parameters:
T (Float[ndarray, '4 4']) – Camera extrinsic matrix to validate
- Raises:
ValueError – If T is not a 4x4 matrix or bottom row is not [0, 0, 0, 1]
- ct.sanity.assert_pose(pose)[source]¶
Assert that pose is a valid 4x4 camera pose matrix (camera-to-world transformation).
- Parameters:
pose (Float[ndarray, '4 4']) – Camera pose matrix to validate
- Raises:
ValueError – If pose is not a 4x4 matrix or bottom row is not [0, 0, 0, 1]
- ct.sanity.assert_shape(x, shape, name=None)[source]¶
Assert that an array has the expected shape.
The shape pattern can contain None values to indicate that dimension can be any size. For example:
(None, 3) matches any 2D array where the second dimension is 3
(3, None, 3) matches any 3D array where first and last dimensions are 3
- Parameters:
- Raises:
ValueError – If array dimensions don’t match the expected shape pattern
- ct.sanity.assert_shape_ndim(x, ndim, name=None)[source]¶
Assert that x has exactly ndim dimensions.
- Parameters:
- Raises:
ValueError – If array doesn’t have exactly ndim dimensions
- ct.sanity.assert_shape_nx3(x, name=None)[source]¶
Assert that x is a 2D array with shape (N, 3).
This is commonly used for arrays of 3D points or vectors.
- ct.sanity.assert_shape_nx2(x, name=None)[source]¶
Assert that x is a 2D array with shape (N, 2).
This is commonly used for arrays of 2D points or vectors.
- ct.sanity.assert_shape_4x4(x, name=None)[source]¶
Assert that x is a 4x4 matrix.
This is commonly used for transformation matrices like T or pose.
- ct.sanity.assert_shape_3x4(x, name=None)[source]¶
Assert that x is a 3x4 matrix.
This is commonly used for camera projection matrices.
- ct.sanity.assert_shape_3x3(x, name=None)[source]¶
Assert that x is a 3x3 matrix.
This is commonly used for rotation matrices or intrinsic matrices.
- ct.sanity.assert_shape_3(x, name=None)[source]¶
Assert that x is a 1D array with 3 elements.
This is commonly used for 3D vectors or points.