Class OcrLine
One line of text: its words, in reading order.
public sealed record OcrLine : IEquatable<OcrLine>
- Inheritance
-
OcrLine
- 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
OcrLine(IReadOnlyList<OcrWord>)
One line of text: its words, in reading order.
public OcrLine(IReadOnlyList<OcrWord> Words)
Parameters
WordsIReadOnlyList<OcrWord>The words, 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
Bounds
Gets the smallest pixel rectangle that holds every word, or an empty rectangle for a line with no words.
public Rect Bounds { get; }
Property Value
Text
Gets the text: the words joined by spaces.
public string Text { get; }
Property Value
Words
The words, in reading order.
public IReadOnlyList<OcrWord> Words { get; init; }