Table of Contents

Class Keypoint<T>

Namespace
AiDotNet.Augmentation.Image
Assembly
AiDotNet.dll

Represents a keypoint annotation for pose estimation and landmark detection.

public class Keypoint<T>

Type Parameters

T

The numeric type for coordinates.

Inheritance
Keypoint<T>
Inherited Members

Remarks

Keypoints are specific points of interest on objects, typically used for: - Human pose estimation (joints, facial landmarks) - Animal pose estimation - Object landmark detection (car wheels, furniture corners)

For Beginners: Think of keypoints as dots marking important locations on an object. For a human, these might be the shoulders, elbows, wrists, etc. When you flip or rotate an image, these points need to move accordingly.

Constructors

Keypoint()

Creates an empty keypoint.

public Keypoint()

Keypoint(T, T, int, string?, int)

Creates a keypoint with the specified coordinates.

public Keypoint(T x, T y, int visibility = 2, string? name = null, int index = 0)

Parameters

x T

The X coordinate.

y T

The Y coordinate.

visibility int

The visibility state (default: 2 = visible).

name string

The keypoint name.

index int

The keypoint index.

Properties

Confidence

Gets or sets the confidence score (if from a detector).

public T? Confidence { get; set; }

Property Value

T

ImageHeight

Gets or sets the image height (for normalized coordinates).

public int ImageHeight { get; set; }

Property Value

int

ImageWidth

Gets or sets the image width (for normalized coordinates).

public int ImageWidth { get; set; }

Property Value

int

Index

Gets or sets the keypoint index within the skeleton.

public int Index { get; set; }

Property Value

int

IsNormalized

Gets or sets whether coordinates are normalized to [0, 1].

public bool IsNormalized { get; set; }

Property Value

bool

Metadata

Gets or sets additional metadata.

public IDictionary<string, object>? Metadata { get; set; }

Property Value

IDictionary<string, object>

Name

Gets or sets the keypoint name/label.

public string? Name { get; set; }

Property Value

string

ParentIndex

Gets or sets the parent keypoint index (for skeleton hierarchy).

public int ParentIndex { get; set; }

Property Value

int

Remarks

-1 indicates no parent (root keypoint).

Visibility

Gets or sets the visibility state.

public int Visibility { get; set; }

Property Value

int

Remarks

Standard values:

  • 0: Not labeled (missing from annotation)
  • 1: Labeled but not visible (occluded)
  • 2: Labeled and visible

X

Gets or sets the X coordinate.

public T X { get; set; }

Property Value

T

Y

Gets or sets the Y coordinate.

public T Y { get; set; }

Property Value

T

Methods

Clone()

Creates a deep copy of this keypoint.

public Keypoint<T> Clone()

Returns

Keypoint<T>

A new keypoint with the same values.

DistanceTo(Keypoint<T>)

Calculates the Euclidean distance to another keypoint.

public double DistanceTo(Keypoint<T> other)

Parameters

other Keypoint<T>

The other keypoint.

Returns

double

The distance in pixels.

IsLabeled()

Checks if this keypoint is labeled (visible or occluded).

public bool IsLabeled()

Returns

bool

True if visibility is 1 or 2.

IsVisible()

Checks if this keypoint is visible.

public bool IsVisible()

Returns

bool

True if visibility is 2 (labeled and visible).

IsWithinBounds(int, int)

Checks if this keypoint is within image boundaries.

public bool IsWithinBounds(int width, int height)

Parameters

width int

The image width.

height int

The image height.

Returns

bool

True if the keypoint is within bounds.

OKS(Keypoint<T>, double, double)

Calculates the Object Keypoint Similarity (OKS) score.

public double OKS(Keypoint<T> groundTruth, double scale, double kappa = 0.05)

Parameters

groundTruth Keypoint<T>

The ground truth keypoint.

scale double

The object scale (usually sqrt of bbox area).

kappa double

The per-keypoint constant (standard COCO values range 0.025-0.107).

Returns

double

The OKS score between 0 and 1.

ToAbsolute()

Converts to absolute pixel coordinates.

public (double x, double y) ToAbsolute()

Returns

(double min, double max)

The (x, y) coordinates in pixels.

ToNormalized()

Converts to normalized coordinates [0, 1].

public (double x, double y) ToNormalized()

Returns

(double min, double max)

The (x, y) coordinates normalized to [0, 1].