class documentation

class KeypointAnnotation(Annotation):

View In Hierarchy

Keypoint annotation.

The coordinates are normalized to [0, 1] based on the image size.

Static Method combine_to_numpy Combine keypoint annotations into flattened keypoint rows.
Method to_numpy Convert the keypoint annotation to flattened row format.
Instance Variable keypoints Keypoints in (x, y, visibility) format. Visibility follows the COCO convention:
Class Method _validate_values Undocumented
@staticmethod
@override
def combine_to_numpy(annotations: list[KeypointAnnotation], classes: list[int] | None = None, n_classes: int | None = None) -> np.ndarray:

Combine keypoint annotations into flattened keypoint rows.

Parameters
annotations:list[KeypointAnnotation]Keypoint annotations to combine.
classes:list[int] | NoneUnused class IDs kept for API compatibility.
n_classes:int | NoneUnused class count kept for API compatibility.
Returns
np.ndarrayAn array of shape (N, 3K) where N is the number of keypoint annotations and K is the number of keypoints per annotation. Flattened keypoint rows. Each row contains keypoint coordinates and visibility in the format [x1, y1, v1, x2, y2, v2, …] where (xi, yi, vi) are the coordinates and visibility of the i-th keypoint.
def to_numpy(self) -> np.ndarray:

Convert the keypoint annotation to flattened row format.

Returns
np.ndarrayAn array of shape (3K, ) where K is the number of keypoints. The format of the array is [x1, y1, v1, x2, y2, v2, …] where (xi, yi, vi) are the coordinates and visibility of the i-th keypoint.
keypoints: list[tuple[NormalizedFloat, NormalizedFloat, KeypointVisibility]] =

Keypoints in (x, y, visibility) format. Visibility follows the COCO convention:

  • 0: Not visible or not labeled.
  • 1: Occluded.
  • 2: Visible.
@model_validator(mode='before')
@classmethod
def _validate_values(cls, values: dict[str, Any]) -> dict[str, Any]:

Undocumented