Table of Contents

Class OcrEngineInfo

Namespace
Egami.Ocr
Assembly
Egami.dll

What an IOcrEngine can do. Callers such as a PDF driver read it to size and schedule their requests.

public sealed record OcrEngineInfo : IEquatable<OcrEngineInfo>
Inheritance
OcrEngineInfo
Implements
Inherited Members

Examples

// An engine is one method: an image in, lines of words out. This one finds a single word; a real one wraps an OCR program,
// an OS service or a cloud API (see samples/Ocr).
public sealed class OneWordEngine : IOcrEngine
{
    public OcrEngineInfo Info { get; } = new("one-word") { Languages = ["eng"], IsThreadSafe = true };

    public Task<OcrResult> RecognizeAsync(OcrRequest request, CancellationToken cancellationToken = default)
    {
        OcrQuad box = OcrQuad.FromBounds(10, 10, request.Image.Width / 2, 20);
        OcrLine line = new([new OcrWord("Duck", box, Confidence: 0.9, Language: "eng")]);
        return Task.FromResult(new OcrResult([line]) { ImageSize = new Size(request.Image.Width, request.Image.Height) });
    }
}

Constructors

OcrEngineInfo(string)

What an IOcrEngine can do. Callers such as a PDF driver read it to size and schedule their requests.

public OcrEngineInfo(string Name)

Parameters

Name string

The engine's name, for reports and diagnostics, such as "tesseract".

Examples

// An engine is one method: an image in, lines of words out. This one finds a single word; a real one wraps an OCR program,
// an OS service or a cloud API (see samples/Ocr).
public sealed class OneWordEngine : IOcrEngine
{
    public OcrEngineInfo Info { get; } = new("one-word") { Languages = ["eng"], IsThreadSafe = true };

    public Task<OcrResult> RecognizeAsync(OcrRequest request, CancellationToken cancellationToken = default)
    {
        OcrQuad box = OcrQuad.FromBounds(10, 10, request.Image.Width / 2, 20);
        OcrLine line = new([new OcrWord("Duck", box, Confidence: 0.9, Language: "eng")]);
        return Task.FromResult(new OcrResult([line]) { ImageSize = new Size(request.Image.Width, request.Image.Height) });
    }
}

Properties

FindsOrientation

Gets a value indicating whether the engine finds the page orientation and reports it in Rotation.

public bool FindsOrientation { get; init; }

Property Value

bool

IsThreadSafe

Gets a value indicating whether several calls to the engine may run at once. Defaults to true.

public bool IsThreadSafe { get; init; }

Property Value

bool

Languages

Gets the languages the engine reads, as the engine names them (such as "eng" or "en-US"), or empty if not known.

public IReadOnlyList<string> Languages { get; init; }

Property Value

IReadOnlyList<string>

MaxImageDimension

Gets the largest width or height, in pixels, the engine accepts, or null for no limit. Callers scale larger images down and the boxes back up.

public int? MaxImageDimension { get; init; }

Property Value

int?

Name

The engine's name, for reports and diagnostics, such as "tesseract".

public string Name { get; init; }

Property Value

string