Table of Contents

Class OcrWord

Namespace
Egami.Ocr
Assembly
Egami.dll

One recognized word.

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

Examples

// Any IOcrEngine reads a Raster<Rgba8>; say the resolution and languages when you know them.
OneWordEngine engine = new();
using Raster<Rgba8> page = Raster.Load<Rgba8>("duck.png");
OcrResult result = await engine.RecognizeAsync(new OcrRequest(page) { Dpi = 300, Languages = ["eng"] }, Ct);

Console.WriteLine(result.Text);
foreach (OcrWord word in result.Words)
{
    Console.WriteLine($"{word.Text} at {word.Box.Bounds}, {word.Confidence:P0} sure");
}

Constructors

OcrWord(string, OcrQuad, double?, string?)

One recognized word.

public OcrWord(string Text, OcrQuad Box, double? Confidence = null, string? Language = null)

Parameters

Text string

The word's text.

Box OcrQuad

Where the word is, in pixels of the image, its corners in the word's own reading order.

Confidence double?

How sure the engine is, from 0 to 1, or null if it does not say.

Language string

The word's language as the engine names it, or null if not known.

Examples

// Any IOcrEngine reads a Raster<Rgba8>; say the resolution and languages when you know them.
OneWordEngine engine = new();
using Raster<Rgba8> page = Raster.Load<Rgba8>("duck.png");
OcrResult result = await engine.RecognizeAsync(new OcrRequest(page) { Dpi = 300, Languages = ["eng"] }, Ct);

Console.WriteLine(result.Text);
foreach (OcrWord word in result.Words)
{
    Console.WriteLine($"{word.Text} at {word.Box.Bounds}, {word.Confidence:P0} sure");
}

Properties

Box

Where the word is, in pixels of the image, its corners in the word's own reading order.

public OcrQuad Box { get; init; }

Property Value

OcrQuad

Confidence

How sure the engine is, from 0 to 1, or null if it does not say.

public double? Confidence { get; init; }

Property Value

double?

Language

The word's language as the engine names it, or null if not known.

public string? Language { get; init; }

Property Value

string

Text

The word's text.

public string Text { get; init; }

Property Value

string