Class OcrRequest
One image to recognize, with how to read it.
public sealed record OcrRequest : IEquatable<OcrRequest>
- Inheritance
-
OcrRequest
- 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
OcrRequest(Raster<Rgba8>)
One image to recognize, with how to read it.
public OcrRequest(Raster<Rgba8> Image)
Parameters
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
Dpi
Gets the image resolution in pixels per inch, which engines use to judge text size. Defaults to 300. Must be positive.
public double Dpi { get; init; }
Property Value
Image
The image. The engine reads it and must not change or dispose it.
public Raster<Rgba8> Image { get; init; }
Property Value
Languages
Gets the languages to read, as the engine names them (such as "eng" and "nor"), most likely first; empty for the engine's default.
public IReadOnlyList<string> Languages { get; init; }
Property Value
PageIndex
Gets the page number, from 0, when the image is one page of a document; for engines that report or log it.
public int PageIndex { get; init; }