3D/2D Affine Transformation

Module: cutoop.transform.

functioncalculate_2d_projections​(coordinates_3d: ndarray, intrinsics_K: ndarray)

Parameters:

Returns: projected_coordinates: N, 2

functiondepth2xyz​(depth_img: ndarray, intrinsics: CameraIntrinsicsBase)

Transform depth_img pixel value to 3D coordinates under cv space, using camera intrinsics.

About different camera space:

  • cv space: x goes right, y goes down, and you look through the positive direction of z axis
  • blender camera space: x goes right, y goes up, and you look through the negative direction of z axis

Parameters: depth_img – 2D matrix with shape (H, W)

Returns: coordinates of each pixel with shape (H, W, 3)

functionpixel2xyz​(h: int, w: int, pixel: ndarray, intrinsics: CameraIntrinsicsBase)

Transform (pixel0, pixel1) to normalized 3D vector under cv space, using camera intrinsics.

Parameters:

  • h – height of the actual image
  • w – width of the actual image
functionsRTdestruct​(rts_Nx4x4: ndarray): tuple[ndarray, ndarray, ndarray]

Destruct multiple 4x4 affine transformation into scales, rotations and translations.

Returns: scales, rotations and translations each of shape N, N, 3, 3, N, 3

functiontoAffine​(scale_N: ndarray, rot_Nx3x3: ndarray, tr_Nx3: ndarray)

return affine transformation: N, 4, 4

functiontransform_coordinates_3d​(coordinates: ndarray, sRT: ndarray)

Apply 3D affine transformation to pointcloud.

Parameters:

  • coordinates – ndarray of shape 3, N
  • sRT – ndarray of shape 4, 4

Returns: new pointcloud of shape 3, N