Table of Contents

Class SpatialAugmentationBase<T, TData>

Namespace
AiDotNet.Augmentation
Assembly
AiDotNet.dll

Base class for augmentations that transform spatial targets (bounding boxes, keypoints, masks).

public abstract class SpatialAugmentationBase<T, TData> : AugmentationBase<T, TData>, ISpatialAugmentation<T, TData>, IAugmentation<T, TData>

Type Parameters

T

The numeric type for calculations.

TData

The data type being augmented.

Inheritance
SpatialAugmentationBase<T, TData>
Implements
IAugmentation<T, TData>
Derived
Inherited Members

Constructors

SpatialAugmentationBase(double)

Initializes a new spatial augmentation.

protected SpatialAugmentationBase(double probability = 1)

Parameters

probability double

The probability of applying this augmentation.

Properties

SupportsBoundingBoxes

Gets whether this augmentation supports bounding box transformation.

public virtual bool SupportsBoundingBoxes { get; }

Property Value

bool

SupportsKeypoints

Gets whether this augmentation supports keypoint transformation.

public virtual bool SupportsKeypoints { get; }

Property Value

bool

SupportsMasks

Gets whether this augmentation supports mask transformation.

public virtual bool SupportsMasks { get; }

Property Value

bool

Methods

ApplyAugmentation(TData, AugmentationContext<T>)

Default implementation that calls ApplyWithTransformParams.

protected override TData ApplyAugmentation(TData data, AugmentationContext<T> context)

Parameters

data TData
context AugmentationContext<T>

Returns

TData

ApplyWithTargets(AugmentedSample<T, TData>, AugmentationContext<T>?)

Applies the augmentation to data and all spatial targets.

public AugmentedSample<T, TData> ApplyWithTargets(AugmentedSample<T, TData> sample, AugmentationContext<T>? context = null)

Parameters

sample AugmentedSample<T, TData>

The augmented sample containing data and targets.

context AugmentationContext<T>

The augmentation context.

Returns

AugmentedSample<T, TData>

The augmented sample with transformed targets.

ApplyWithTransformParams(TData, AugmentationContext<T>)

Applies the augmentation and returns both the result and transform parameters.

protected abstract (TData data, IDictionary<string, object> parameters) ApplyWithTransformParams(TData data, AugmentationContext<T> context)

Parameters

data TData

The input data.

context AugmentationContext<T>

The augmentation context.

Returns

(TData data, IDictionary<string, object> parameters)

The transformed data and transform parameters.

TransformBoundingBox(BoundingBox<T>, IDictionary<string, object>, AugmentationContext<T>)

Transforms a bounding box according to the spatial transformation.

protected abstract BoundingBox<T> TransformBoundingBox(BoundingBox<T> box, IDictionary<string, object> transformParams, AugmentationContext<T> context)

Parameters

box BoundingBox<T>

The bounding box to transform.

transformParams IDictionary<string, object>

The transformation parameters.

context AugmentationContext<T>

The augmentation context.

Returns

BoundingBox<T>

The transformed bounding box.

TransformKeypoint(Keypoint<T>, IDictionary<string, object>, AugmentationContext<T>)

Transforms a keypoint according to the spatial transformation.

protected abstract Keypoint<T> TransformKeypoint(Keypoint<T> keypoint, IDictionary<string, object> transformParams, AugmentationContext<T> context)

Parameters

keypoint Keypoint<T>

The keypoint to transform.

transformParams IDictionary<string, object>

The transformation parameters.

context AugmentationContext<T>

The augmentation context.

Returns

Keypoint<T>

The transformed keypoint.

TransformMask(SegmentationMask<T>, IDictionary<string, object>, AugmentationContext<T>)

Transforms a segmentation mask according to the spatial transformation.

protected abstract SegmentationMask<T> TransformMask(SegmentationMask<T> mask, IDictionary<string, object> transformParams, AugmentationContext<T> context)

Parameters

mask SegmentationMask<T>

The mask to transform.

transformParams IDictionary<string, object>

The transformation parameters.

context AugmentationContext<T>

The augmentation context.

Returns

SegmentationMask<T>

The transformed mask.