Class YoloDetector
- Namespace
- VisioForge.Core.AI
- Assembly
- VisioForge.Core.AI.dll
Object detector built on top of VisioForge.Core.AI.OnnxInferenceEngine that supports multiple model families (YOLOv8/v11, YOLOX, RT-DETR / D-FINE) selected via VisioForge.Core.Types.X.AI.YoloDetectorSettings.Model.
public class YoloDetector : IDisposableInheritance
Implements
Inherited Members
Remarks
On construction it asks the family-specific decoder for the right preprocessing options (cached for the detector's lifetime). Then on every frame it letterboxes/resizes the frame accordingly via the engine, runs the model, hands the raw outputs to the decoder, and optionally draws the resulting boxes onto the RGBA frame. The underlying engine is lazily initialized on the first VisioForge.Core.AI.YoloDetector.Process(VisioForge.Core.Types.X.VideoFrameX) call (before the first frame is preprocessed, so the model's real input size is authoritative). The class name is retained for API compatibility although it now drives non-YOLO models too.
Constructors
YoloDetector(YoloDetectorSettings)
Initializes a new instance of the VisioForge.Core.AI.YoloDetector class.
public YoloDetector(YoloDetectorSettings settings)Parameters
settingsYoloDetectorSettings-
The detector settings.
Exceptions
- ArgumentNullException
-
Thrown when
settingsis null.
Properties
ActiveProvider
Gets the execution provider the underlying inference session actually engaged (valid after VisioForge.Core.AI.YoloDetector.Init).
public OnnxExecutionProvider ActiveProvider { get; }Property Value
- OnnxExecutionProvider
Methods
Dispose()
Releases the inference engine.
public void Dispose()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
Init()
Loads the model and prepares the detector for inference.
public bool Init()Returns
- bool
-
trueif initialization succeeded; otherwise,false.
Process(VideoFrameX)
Runs detection on a single RGBA frame. The engine is lazily initialized on first use. If that
initialization fails (missing/corrupt model, provider error) the failure is latched and detection is
disabled for this detector: subsequent frames return empty without retrying, until a later explicit
VisioForge.Core.AI.YoloDetector.Init call succeeds (or the detector is recreated). See _initFailed.
public OnnxDetection[] Process(VideoFrameX frame)Parameters
frameVideoFrameX-
The source RGBA frame.
Returns
- OnnxDetection[]
-
The detected objects, in source-frame coordinates; empty when nothing was found or when initialization has failed.
SetContext(BaseContext)
Sets the processing context used for logging and propagates it to the inference engine.
public void SetContext(BaseContext context)Parameters
contextBaseContext-
The context.