Table of Contents

Class Detection<T>

Namespace
AiDotNet.ComputerVision.Detection.ObjectDetection
Assembly
AiDotNet.dll

Represents a single detected object.

public class Detection<T>

Type Parameters

T

The numeric type used for coordinates and scores.

Inheritance
Detection<T>
Inherited Members

Remarks

For Beginners: This represents one object found in the image. It tells you: - Where the object is (bounding box) - What type of object it is (class ID and name) - How confident the model is (0.0 to 1.0) - Optionally, a pixel mask for instance segmentation

Constructors

Detection()

Creates a new detection with default numeric operations.

public Detection()

Detection(BoundingBox<T>, int, T, string?)

Creates a new detection with specified values.

public Detection(BoundingBox<T> box, int classId, T confidence, string? className = null)

Parameters

box BoundingBox<T>

The bounding box.

classId int

The class ID.

confidence T

The confidence score.

className string

Optional class name.

Properties

Area

Gets the area of the bounding box.

public double Area { get; }

Property Value

double

Box

The bounding box defining the object's location.

public BoundingBox<T> Box { get; set; }

Property Value

BoundingBox<T>

CenterX

Gets the center X coordinate of the bounding box.

public double CenterX { get; }

Property Value

double

CenterY

Gets the center Y coordinate of the bounding box.

public double CenterY { get; }

Property Value

double

ClassId

The class ID (index) of the detected object.

public int ClassId { get; set; }

Property Value

int

ClassName

The human-readable name of the class (e.g., "person", "car").

public string? ClassName { get; set; }

Property Value

string

Confidence

Confidence score from 0 to 1 indicating detection certainty.

public T Confidence { get; set; }

Property Value

T

Keypoints

Optional keypoints for pose estimation.

public List<Keypoint<T>>? Keypoints { get; set; }

Property Value

List<Keypoint<T>>

Mask

Optional instance segmentation mask for this object.

public SegmentationMask<T>? Mask { get; set; }

Property Value

SegmentationMask<T>

Remarks

Only populated when using instance segmentation models like Mask R-CNN or YOLOv8-Seg.

TrackId

Optional track ID for object tracking across frames.

public int? TrackId { get; set; }

Property Value

int?

Methods

ToString()

Gets a string representation of this detection.

public override string ToString()

Returns

string