Table of Contents

Class OcrSettings

Namespace
VisioForge.Core.Types.X.AI
Assembly
VisioForge.Core.dll

Settings for the OCR block, which runs a multi-stage PaddleOCR (PP-OCR) pipeline on video frames: text detection (DBNet) → optional angle classification → text-line recognition (CRNN/SVTR + CTC).

public class OcrSettings

Inheritance

Inherited Members

Remarks

Unlike a single-model detector, OCR needs three ONNX models plus a recognizer character dictionary. Provide them via VisioForge.Core.Types.X.AI.OcrSettings.DetectionModelPath, VisioForge.Core.Types.X.AI.OcrSettings.RecognitionModelPath, VisioForge.Core.Types.X.AI.OcrSettings.CharacterDictionaryPath, and optionally VisioForge.Core.Types.X.AI.OcrSettings.ClassificationModelPath. The Apache-2.0 licensed PP-OCRv5 mobile models are a good default; the dictionary must match the recognition model's language.

Constructors

OcrSettings()

Initializes a new instance of the VisioForge.Core.Types.X.AI.OcrSettings class.

public OcrSettings()

OcrSettings(string, string, string, string)

Initializes a new instance of the VisioForge.Core.Types.X.AI.OcrSettings class with the specified model paths.

public OcrSettings(string detectionModelPath, string recognitionModelPath, string characterDictionaryPath, string classificationModelPath = null)

Parameters

detectionModelPath string

The detection model path.

recognitionModelPath string

The recognition model path.

characterDictionaryPath string

The recognizer character dictionary path.

classificationModelPath string

The optional angle-classification model path.

Properties

BoxColor

Gets or sets the color used for the region boxes and text when VisioForge.Core.Types.X.AI.OcrSettings.DrawResults is enabled. Defaults to lime.

public SKColor BoxColor { get; set; }

Property Value

SKColor

BoxScoreThreshold

Gets or sets the minimum mean probability a detected region must reach to be kept. Defaults to 0.5.

public float BoxScoreThreshold { get; set; }

Property Value

float

BoxThickness

Gets or sets the stroke thickness, in pixels, of the region boxes. Defaults to 2.

public float BoxThickness { get; set; }

Property Value

float

BoxThreshold

Gets or sets the binarization threshold applied to the detector probability map. Defaults to 0.3.

public float BoxThreshold { get; set; }

Property Value

float

CharacterDictionaryPath

Gets or sets the absolute path to the recognizer character dictionary (one symbol per line). Must match the language of VisioForge.Core.Types.X.AI.OcrSettings.RecognitionModelPath.

public string CharacterDictionaryPath { get; set; }

Property Value

string

ClassificationModelPath

Gets or sets the absolute path to the angle-classification ONNX model. Optional; leave null or empty (and set VisioForge.Core.Types.X.AI.OcrSettings.UseAngleClassifier to false) to skip 180° orientation handling.

public string ClassificationModelPath { get; set; }

Property Value

string

DetectionModelPath

Gets or sets the absolute path to the text-detection (DBNet) ONNX model.

public string DetectionModelPath { get; set; }

Property Value

string

DeviceId

Gets or sets the device identifier for hardware execution providers (the GPU index for CUDA/DirectML). Defaults to 0.

public int DeviceId { get; set; }

Property Value

int

DrawResults

Gets or sets a value indicating whether the recognized text regions are drawn directly into the video frame (boxes plus the recognized text). Defaults to true.

public bool DrawResults { get; set; }

Property Value

bool

FramesToSkip

Gets or sets the number of frames to skip between OCR runs. A value of 0 runs OCR on every frame. OCR is heavier than single-model detection, so a non-zero value is recommended for live video. Defaults to 0.

public int FramesToSkip { get; set; }

Property Value

int

LabelFontSize

Gets or sets the label font size, in pixels. A value of 0 auto-scales the font to the frame height. Defaults to 0.

public float LabelFontSize { get; set; }

Property Value

float

MaxSideLength

Gets or sets the side length, in pixels, the detector input's longer side is resized to (the longer side is scaled to this value, up or down). Defaults to 1024. Set to 0 (or a negative value) to use the adaptive PP-OCRv5 resize path instead (short side scaled to the model's tuned length, longer side bounded).

public int MaxSideLength { get; set; }

Property Value

int

Provider

Gets or sets the execution provider used by the OCR sessions. Defaults to VisioForge.Core.Types.X.AI.OnnxExecutionProvider.Auto.

public OnnxExecutionProvider Provider { get; set; }

Property Value

OnnxExecutionProvider

RecognitionModelPath

Gets or sets the absolute path to the text-recognition (CRNN/SVTR) ONNX model.

public string RecognitionModelPath { get; set; }

Property Value

string

TextScoreThreshold

Gets or sets the minimum average per-character recognition score a text line must reach to be reported. Defaults to 0.5.

public float TextScoreThreshold { get; set; }

Property Value

float

UnclipRatio

Gets or sets the unclip ratio used to expand detected text polygons. Defaults to 1.6.

public float UnclipRatio { get; set; }

Property Value

float

UseAngleClassifier

Gets or sets a value indicating whether the angle classifier is used to correct 180°-rotated text. Requires VisioForge.Core.Types.X.AI.OcrSettings.ClassificationModelPath. Defaults to true for the parameterless constructor; the VisioForge.Core.Types.X.AI.OcrSettings.#ctor(System.String,System.String,System.String,System.String) constructor instead derives it from whether a classification model path was supplied.

public bool UseAngleClassifier { get; set; }

Property Value

bool