AnchorMatcher<T>

Models & Types · AiDotNet.ComputerVision.Detection.Anchors

Matches anchor boxes to ground truth boxes for training object detectors.

For Beginners

During training, we need to assign each anchor box to either:

  • A ground truth box (positive sample): The anchor should predict this object
  • Background (negative sample): The anchor should predict “no object”
  • Ignore: The anchor is borderline and excluded from loss calculation

This matching process determines which anchors learn to detect which objects.

Constructors

Constructor Summary
AnchorMatcher() Creates a new anchor matcher with default thresholds.
AnchorMatcher(double positiveThreshold, double negativeThreshold, bool allowLowQualityMatches) Creates a new anchor matcher with custom thresholds.

Properties

Property Summary
bool AllowLowQualityMatches { get; } Whether to allow low-quality matches (best anchor for each GT even if below threshold).
double NegativeThreshold { get; } IoU threshold below which an anchor is considered negative.
double PositiveThreshold { get; } IoU threshold above which an anchor is considered positive.

Methods

Method Summary
AnchorMatchResult<T> Match(List<BoundingBox<T>> anchors, List<BoundingBox<T>> groundTruth) Matches anchors to ground truth boxes.
AnchorMatchResult<T> MatchCenterBased(List<ValueTuple<double, double>> anchorCenters, List<BoundingBox<T>> groundTruth, List<int> anchorStrides) Matches anchors using center-based assignment (used in FCOS, YOLOX).
AnchorMatchResult<T> MatchSimOTA(List<BoundingBox<T>> anchors, List<BoundingBox<T>> groundTruth, List<BoundingBox<T>> predictions, List<double> predScores) Matches anchors using SimOTA (used in YOLOX).