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)[source]¶
2D Keypoints containing Nx2 or BxNx2 points.
- Parameters:
- property data: Tensor¶
Return the raw 2D keypoint coordinate tensor.
- Returns:
Tensor storing keypoint coordinates in
(..., 2)format, where the last dimension containsxandy.
- index_put(indices, values, inplace=False)[source]¶
Write keypoint coordinates at selected tensor indices.
- Parameters:
indices (
Union[Tuple[Tensor,...],List[Tensor]]) – Index tuple or list accepted byTensor.index_put_for the stored coordinate tensor.values (
Union[Tensor,Keypoints]) – Replacement coordinates, either as a raw tensor or anotherKeypointsobject.inplace (
bool, optional) – IfTrue, update this object in place. Otherwise, clone the coordinates first and return a new wrapper. Default:False
- Return type:
- Returns:
Keypointsobject containing the updated coordinates.
- property shape: Tuple[int, ...] | Size¶
Return the tensor shape used to store 2D keypoints.
- Returns:
Shape of
data. The common layouts are \((N, 2)\) for unbatched keypoints and \((B, N, 2)\) for batched keypoints, where \(B\) is the batch size, \(N\) is the number of keypoints, and the final dimension stores(x, y)coordinates.
- to_tensor(as_padded_sequence=False)[source]¶
Cast
Keypointsto a tensor.modecontrols which 2D keypoints format should be use to represent keypoints in the tensor.
- transform_keypoints_(M)[source]¶
Inplace version of
Keypoints.transform_keypoints().- Return type:
- class kornia.geometry.keypoints.Keypoints3D(keypoints, raise_if_not_floating_point=True)[source]¶
3D Keypoints containing Nx3 or BxNx3 points.
- Parameters:
- property data: Tensor¶
Return the raw 3D keypoint coordinate tensor.
- Returns:
Tensor storing coordinates in
(..., 3)format, with the final dimension ordered as(x, y, z).
- classmethod from_tensor(keypoints)[source]¶
Validate and wrap a tensor of 3D keypoint coordinates.
- Parameters:
keypoints (
Tensor) – Tensor in \((N, 3)\) or \((B, N, 3)\) format, where the last dimension stores(x, y, z).- Return type:
- Returns:
New
Keypoints3Dinstance containing the input coordinates.
- pad(padding_size)[source]¶
Pad a bounding keypoints.
- Parameters:
padding_size (
Tensor) – (B, 6)- Return type:
- property shape: Size¶
Return the tensor shape used to store 3D keypoints.
- Returns:
Shape of
data. The common layouts are \((N, 3)\) and \((B, N, 3)\), where the final dimension stores(x, y, z)coordinates.
- to_tensor(as_padded_sequence=False)[source]¶
Cast
Keypointsto a tensor.modecontrols which 2D keypoints format should be use to represent keypoints in the tensor.
- transform_keypoints(M, inplace=False)[source]¶
Apply a transformation matrix to the 2D keypoints.
- Parameters:
- Return type:
- Returns:
The transformed keypoints.
- transform_keypoints_(M)[source]¶
Inplace version of
Keypoints.transform_keypoints().- Return type: