ct.normalize

Functions for normalizing points and cameras.

ct.normalize.compute_normalize_mat(points)[source]
Parameters:

points (Float[ndarray, 'n 3']) – (N, 3) numpy array.

Returns:

Returns normalize_mat, where normalize_mat @ points_homo is centered at the origin and is scaled within the unit sphere (max norm equals 1).

Return type:

Float[ndarray, ‘4 4’]

Examples

# You can check the correctness of compute_normalize_mat by:
normalize_mat = ct.normalize.compute_normalize_mat(points)
points_normalized = ct.transform.transform_points(points, normalize_mat)
ct.stat.report_points_range(points_normalized)

# Typically, we also scale the camera after normalizing points. Given
# the camera parameter `K` and `T`, we can calculate `K_new` and `T_new`:
K_new = K
C = ct.convert.T_to_C(T)
C_new = ct.transform.transform_points(C.reshape((-1, 3)), normalize_mat).flatten()
pose_new = np.linalg.inv(T)
pose_new[:3, 3] = C_new
T_new = np.linalg.inv(pose_new)
ct.normalize.report_points_range(points)[source]

Report statistics about the points.

Parameters:

points (Float[ndarray, 'n 3']) – (N, 3) numpy array.

Prints:
  • Center of the points

  • Maximum radius with respect to center

  • Maximum radius with respect to origin

  • Range of points (min and max coordinates)