![]() |
VOOZH | about |
dotnet add package TPJ.OCR --version 10.0.0
NuGet\Install-Package TPJ.OCR -Version 10.0.0
<PackageReference Include="TPJ.OCR" Version="10.0.0" />
<PackageVersion Include="TPJ.OCR" Version="10.0.0" />Directory.Packages.props
<PackageReference Include="TPJ.OCR" />Project file
paket add TPJ.OCR --version 10.0.0
#r "nuget: TPJ.OCR, 10.0.0"
#:package TPJ.OCR@10.0.0
#addin nuget:?package=TPJ.OCR&version=10.0.0Install as a Cake Addin
#tool nuget:?package=TPJ.OCR&version=10.0.0Install as a Cake Tool
Simple OCR helper library for .NET 10 built on top of Tesseract.
TPJ.OCR makes it easy to:
Stream, or byte[].NET 10tessdata folderBy default, the library looks for tessdata in the application output folder:
tessdata/eng.traineddataIf your files are stored somewhere else, set OCROptions.DataPath.
dotnet add package TPJ.OCR
<ItemGroup>
<ProjectReference Include="..\TPJ.OCR\TPJ.OCR.csproj" />
</ItemGroup>
using TPJ.OCR;
using TPJ.OCR.Enums;
var text = OCRReader.ReadText("ExampleImage.png");
Console.WriteLine(text);
Use ContentType.Digits when the area should only contain numbers.
var employeeNumber = OCRReader.ReadText(
"ExampleImage.png",
ContentType.Digits,
new OCRRectangle(460, 220, 240, 100));
Console.WriteLine(employeeNumber);
var results = OCRReader.ReadAreas(
"ExampleImage.png",
new List<OCRArea>
{
OCRArea.FromBounds("Name", 300, 40, 400, 100, ContentType.Alphabetic),
OCRArea.FromBounds("Payroll Name", 1350, 40, 350, 100, ContentType.Alphabetic),
OCRArea.FromBounds("HRMS No", 460, 220, 240, 100, ContentType.Digits),
OCRArea.FromBounds("Pay Date", 1170, 220, 540, 100)
});
foreach (var item in results)
{
Console.WriteLine($"{item.AreaName} = {item.Value}");
}
var values = OCRReader.ReadAreaMap(
"ExampleImage.png",
new[]
{
OCRArea.FromBounds("Name", 300, 40, 400, 100, ContentType.Alphabetic),
OCRArea.FromBounds("HRMS No", 460, 220, 240, 100, ContentType.Digits)
});
Console.WriteLine(values["Name"]);
Console.WriteLine(values["HRMS No"]);
using var stream = File.OpenRead("ExampleImage.png");
var text = OCRReader.ReadText(stream);
Console.WriteLine(text);
var imageBytes = File.ReadAllBytes("ExampleImage.png");
var text = OCRReader.ReadText(imageBytes);
Console.WriteLine(text);
var options = new OCROptions
{
DataPath = Path.Combine(AppContext.BaseDirectory, "tessdata"),
Language = "eng",
NormalizeWhitespace = true
};
var text = OCRReader.ReadText("ExampleImage.png", options);
Console.WriteLine(text);
OCRRectangle(x, y, width, height) uses pixel coordinates.ContentType.Digits and ContentType.Alphabetic apply simple result cleanup for common OCR mistakes.See TPJ.TestOCR/Program.cs for a working sample that reads:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
.NET 10 update see readme for more details