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
TThe 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
xTThe X coordinate.
yTThe Y coordinate.
visibilityintThe visibility state (default: 2 = visible).
namestringThe keypoint name.
indexintThe 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
ImageWidth
Gets or sets the image width (for normalized coordinates).
public int ImageWidth { get; set; }
Property Value
Index
Gets or sets the keypoint index within the skeleton.
public int Index { get; set; }
Property Value
IsNormalized
Gets or sets whether coordinates are normalized to [0, 1].
public bool IsNormalized { get; set; }
Property Value
Metadata
Gets or sets additional metadata.
public IDictionary<string, object>? Metadata { get; set; }
Property Value
Name
Gets or sets the keypoint name/label.
public string? Name { get; set; }
Property Value
ParentIndex
Gets or sets the parent keypoint index (for skeleton hierarchy).
public int ParentIndex { get; set; }
Property Value
Remarks
-1 indicates no parent (root keypoint).
Visibility
Gets or sets the visibility state.
public int Visibility { get; set; }
Property Value
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
otherKeypoint<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
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
groundTruthKeypoint<T>The ground truth keypoint.
scaledoubleThe object scale (usually sqrt of bbox area).
kappadoubleThe 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
ToNormalized()
Converts to normalized coordinates [0, 1].
public (double x, double y) ToNormalized()