kornia.geometry.depth

kornia.geometry.depth.depth_to_3d(depth, camera_matrix, normalize_points=False)[source]

Compute a 3d point per pixel given its depth value and the camera intrinsics.

Parameters
  • depth (Tensor) – image tensor containing a depth value per pixel.

  • camera_matrix (Tensor) – tensor containing the camera intrinsics.

  • normalize_points (bool, optional) – whether to normalise the pointcloud. This must be set to True when the depth is represented as the Euclidean ray length from the camera position. Default: False

Shape:
  • Input: \((B, 1, H, W)\) and \((B, 3, 3)\)

  • Output: \((B, 3, H, W)\)

Return type

Tensor

Returns

tensor with a 3d point per pixel of the same resolution as the input.

kornia.geometry.depth.depth_to_normals(depth, camera_matrix, normalize_points=False)[source]

Compute the normal surface per pixel.

Parameters
  • depth (Tensor) – image tensor containing a depth value per pixel.

  • camera_matrix (Tensor) – tensor containing the camera intrinsics.

  • normalize_points (bool, optional) – whether to normalise the pointcloud. This must be set to True when the depth is Default: False

  • position. (represented as the Euclidean ray length from the camera) –

Shape:
  • Input: \((B, 1, H, W)\) and \((B, 3, 3)\)

  • Output: \((B, 3, H, W)\)

Return type

Tensor

Returns

tensor with a normal surface vector per pixel of the same resolution as the input.

kornia.geometry.depth.warp_frame_depth(image_src, depth_dst, src_trans_dst, camera_matrix, normalize_points=False)[source]

Warp a tensor from a source to destination frame by the depth in the destination.

Compute 3d points from the depth, transform them using given transformation, then project the point cloud to an image plane.

Parameters
  • image_src (Tensor) – image tensor in the source frame with shape \((B,D,H,W)\).

  • depth_dst (Tensor) – depth tensor in the destination frame with shape \((B,1,H,W)\).

  • src_trans_dst (Tensor) – transformation matrix from destination to source with shape \((B,4,4)\).

  • camera_matrix (Tensor) – tensor containing the camera intrinsics with shape \((B,3,3)\).

  • normalize_points (bool, optional) – whether to normalise the pointcloud. This must be set to True when the depth is represented as the Euclidean ray length from the camera position. Default: False

Return type

Tensor

Returns

the warped tensor in the source frame with shape \((B,3,H,W)\).