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
TThe numeric type for calculations.
TDataThe data type being augmented.
- Inheritance
-
AugmentationBase<T, TData>SpatialAugmentationBase<T, TData>
- Implements
-
ISpatialAugmentation<T, TData>IAugmentation<T, TData>
- Derived
- Inherited Members
Constructors
SpatialAugmentationBase(double)
Initializes a new spatial augmentation.
protected SpatialAugmentationBase(double probability = 1)
Parameters
probabilitydoubleThe probability of applying this augmentation.
Properties
SupportsBoundingBoxes
Gets whether this augmentation supports bounding box transformation.
public virtual bool SupportsBoundingBoxes { get; }
Property Value
SupportsKeypoints
Gets whether this augmentation supports keypoint transformation.
public virtual bool SupportsKeypoints { get; }
Property Value
SupportsMasks
Gets whether this augmentation supports mask transformation.
public virtual bool SupportsMasks { get; }
Property Value
Methods
ApplyAugmentation(TData, AugmentationContext<T>)
Default implementation that calls ApplyWithTransformParams.
protected override TData ApplyAugmentation(TData data, AugmentationContext<T> context)
Parameters
dataTDatacontextAugmentationContext<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
sampleAugmentedSample<T, TData>The augmented sample containing data and targets.
contextAugmentationContext<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
dataTDataThe input data.
contextAugmentationContext<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
boxBoundingBox<T>The bounding box to transform.
transformParamsIDictionary<string, object>The transformation parameters.
contextAugmentationContext<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
keypointKeypoint<T>The keypoint to transform.
transformParamsIDictionary<string, object>The transformation parameters.
contextAugmentationContext<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
maskSegmentationMask<T>The mask to transform.
transformParamsIDictionary<string, object>The transformation parameters.
contextAugmentationContext<T>The augmentation context.
Returns
- SegmentationMask<T>
The transformed mask.