Table of Contents

Class TesseractOcrEngine

Namespace
LMKit.Integrations.Tesseract
Assembly
LM-Kit.NET.dll

Provides OCR functionality using the Tesseract engine, with optional language and orientation detection, and automatic model download support.

public sealed class TesseractOcrEngine : OcrEngine, IDisposable
Inheritance
TesseractOcrEngine
Implements
Inherited Members

Constructors

TesseractOcrEngine()

Initializes a new instance of the TesseractOcrEngine using the default model storage directory specified by Global.Configuration.ModelStorageDirectory.

TesseractOcrEngine(string)

Initializes a new instance of the TesseractOcrEngine class with the specified Tesseract resource path.

Properties

DefaultLanguage

Gets or sets the default ISO 639-2/T language code to use when a specific language model is not found. Must be one of the supported codes: ara, hye, bul, chi_sim, chi_tra, hrv, ces, dan, nld, eng, fin, fra, deu, heb, hin, hun, ind, ita, jpn, kor, ell, nor, pol, por, ron, rus, srp, slk, spa, swe, tha, tur, ukr, vie.

Default: "eng"

Setting an unsupported code will throw an ArgumentException.
EnableLanguageDetection

Gets or sets a value indicating whether automatic language detection should be performed before OCR.

Default: true

EnableModelDownload

When true, automatically downloads missing Tesseract traineddata files from the Hugging Face repository if they are not present locally.

Default: true

EnableOrientationDetection

Gets or sets a value indicating whether automatic orientation detection should be performed before OCR.

Default: true

Methods

Dispose()

Releases all resources used by this instance.

RunAsync(OcrParameters, CancellationToken)

Runs OCR on the provided image data asynchronously.

Events

LanguageDetected

Occurs when a language is detected during OCR processing, typically when EnableLanguageDetection is enabled. Subscribers can use this callback to inspect or log the detected Language before the OCR engine proceeds.

OrientationDetected

Occurs when an orientation is detected during OCR processing. Subscribers receive the rotation angle (in degrees).