Class TemporalCrop<T>
- Namespace
- AiDotNet.Augmentation.Video
- Assembly
- AiDotNet.dll
Randomly crops a temporal segment from video.
public class TemporalCrop<T> : TemporalAugmenterBase<T>, IAugmentation<T, ImageTensor<T>[]>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, ImageTensor<T>[]>TemporalCrop<T>
- Implements
-
IAugmentation<T, ImageTensor<T>[]>
- Inherited Members
Remarks
For Beginners: Temporal cropping takes a random consecutive portion of the video. For example, from a 10-second video, it might extract 8 seconds starting at a random point. This helps models learn to recognize actions regardless of when they occur in the video.
When to use:
- Action recognition where action can occur anywhere in the video
- Training with variable-length videos
- Reducing overfitting to specific temporal positions
Constructors
TemporalCrop(double, double, double, double)
Creates a new temporal crop augmentation.
public TemporalCrop(double minCropRatio = 0.7, double maxCropRatio = 0.9, double probability = 0.5, double frameRate = 30)
Parameters
minCropRatiodoubleMinimum fraction of frames to keep (default: 0.7).
maxCropRatiodoubleMaximum fraction of frames to keep (default: 0.9).
probabilitydoubleProbability of applying this augmentation (default: 0.5).
frameRatedoubleFrame rate of the video (default: 30).
Properties
MaxCropRatio
Gets the maximum crop ratio (fraction of original length to keep).
public double MaxCropRatio { get; }
Property Value
Remarks
Default: 0.9 (keep at most 90% of frames)
MinCropRatio
Gets the minimum crop ratio (fraction of original length to keep).
public double MinCropRatio { get; }
Property Value
Remarks
Default: 0.7 (keep at least 70% of frames)
Methods
ApplyAugmentation(ImageTensor<T>[], AugmentationContext<T>)
Implement this method to perform the actual augmentation.
protected override ImageTensor<T>[] ApplyAugmentation(ImageTensor<T>[] data, AugmentationContext<T> context)
Parameters
dataImageTensor<T>[]The input data.
contextAugmentationContext<T>The augmentation context.
Returns
- ImageTensor<T>[]
The augmented data.
GetParameters()
Gets the parameters of this augmentation.
public override IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.