kornia.geometry.keypoints#

Module with useful functionalities for 2D and 3D keypoints manipulation.

class kornia.geometry.keypoints.Keypoints(keypoints, raise_if_not_floating_point=True)#

2D Keypoints containing Nx2 or BxNx2 points.

Parameters:
  • keypoints (Union[Tensor, List[Tensor]]) – Raw tensor or a list of Tensors with the Nx2 coordinates

  • raise_if_not_floating_point (bool, optional) – will raise if the Tensor isn’t float Default: True

clone()#
Return type:

Keypoints

property data: Tensor#
property device: device#

Returns keypoints device.

property dtype: dtype#

Returns keypoints dtype.

classmethod from_tensor(keypoints)#
Return type:

Keypoints

index_put(indices, values, inplace=False)#
Return type:

Keypoints

pad(padding_size)#

Pad a bounding keypoints.

Parameters:

padding_size (Tensor) – (B, 4)

Return type:

Keypoints

property shape: Tuple[int, ...] | Size#
to_tensor(as_padded_sequence=False)#

Cast Keypoints to a tensor. mode controls which 2D keypoints format should be use to represent keypoints in the tensor.

Parameters:

as_padded_sequence (bool, optional) – whether to keep the pads for a list of keypoints. This parameter is only valid if the keypoints are from a keypoint list. Default: False

Return type:

Union[Tensor, List[Tensor]]

Returns:

Keypoints tensor \((B, N, 2)\)

transform_keypoints(M, inplace=False)#

Apply a transformation matrix to the 2D keypoints.

Parameters:
  • M (Tensor) – The transformation matrix to be applied, shape of \((3, 3)\) or \((B, 3, 3)\).

  • inplace (bool, optional) – do transform in-place and return self. Default: False

Return type:

Keypoints

Returns:

The transformed keypoints.

transform_keypoints_(M)#

Inplace version of Keypoints.transform_keypoints()

Return type:

Keypoints

type(dtype)#
Return type:

Keypoints

unpad(padding_size)#

Pad a bounding keypoints.

Parameters:

padding_size (Tensor) – (B, 4)

Return type:

Keypoints

class kornia.geometry.keypoints.Keypoints3D(keypoints, raise_if_not_floating_point=True)#

3D Keypoints containing Nx3 or BxNx3 points.

Parameters:
  • keypoints (Union[Tensor, List[Tensor]]) – Raw tensor or a list of Tensors with the Nx3 coordinates

  • raise_if_not_floating_point (bool, optional) – will raise if the Tensor isn’t float Default: True

clone()#
Return type:

Keypoints3D

property data: Tensor#
classmethod from_tensor(keypoints)#
Return type:

Keypoints3D

pad(padding_size)#

Pad a bounding keypoints.

Parameters:

padding_size (Tensor) – (B, 6)

Return type:

Keypoints3D

property shape: Size#
to_tensor(as_padded_sequence=False)#

Cast Keypoints to a tensor. mode controls which 2D keypoints format should be use to represent keypoints in the tensor.

Parameters:

as_padded_sequence (bool, optional) – whether to keep the pads for a list of keypoints. This parameter is only valid if the keypoints are from a keypoint list. Default: False

Return type:

Union[Tensor, List[Tensor]]

Returns:

Keypoints tensor \((B, N, 3)\)

transform_keypoints(M, inplace=False)#

Apply a transformation matrix to the 2D keypoints.

Parameters:
  • M (Tensor) – The transformation matrix to be applied, shape of \((3, 3)\) or \((B, 3, 3)\).

  • inplace (bool, optional) – do transform in-place and return self. Default: False

Return type:

Keypoints3D

Returns:

The transformed keypoints.

transform_keypoints_(M)#

Inplace version of Keypoints.transform_keypoints()

Return type:

Keypoints3D

unpad(padding_size)#

Pad a bounding keypoints.

Parameters:

padding_size (Tensor) – (B, 6)

Return type:

Keypoints3D