Class OcrResult
The text an engine found in one image: lines of words, in reading order.
public sealed record OcrResult : IEquatable<OcrResult>
- Inheritance
-
OcrResult
- 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
OcrResult(IReadOnlyList<OcrLine>)
The text an engine found in one image: lines of words, in reading order.
public OcrResult(IReadOnlyList<OcrLine> Lines)
Parameters
LinesIReadOnlyList<OcrLine>The lines, in reading order.
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
Empty
Gets an empty result, for an image with no text.
public static OcrResult Empty { get; }
Property Value
ImageSize
Gets the size of the image the boxes refer to, or Size zero if not known. hOCR and ALTO files give it per page.
public Size ImageSize { get; init; }
Property Value
Lines
The lines, in reading order.
public IReadOnlyList<OcrLine> Lines { get; init; }
Property Value
Rotation
Gets the clockwise turn, in degrees (0, 90, 180 or 270), that would put the image upright, as the engine found it; 0 when it is upright or the engine does not look. Boxes are always in the image as given, not turned.
public int Rotation { get; init; }
Property Value
Text
Gets the text: words joined by spaces, lines by line feeds.
public string Text { get; }
Property Value
Words
Gets every word, line by line.
public IEnumerable<OcrWord> Words { get; }