TPJ.OCR
10.0.0
dotnet add package TPJ.OCR --version 10.0.0
NuGet\Install-Package TPJ.OCR -Version 10.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TPJ.OCR" Version="10.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TPJ.OCR" Version="10.0.0" />
<PackageReference Include="TPJ.OCR" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TPJ.OCR --version 10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TPJ.OCR, 10.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TPJ.OCR@10.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TPJ.OCR&version=10.0.0
#tool nuget:?package=TPJ.OCR&version=10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TPJ.OCR
Simple OCR helper library for .NET 10 built on top of Tesseract.
What it does
TPJ.OCR makes it easy to:
- read text from a full image
- read text from a specific rectangle in an image
- read multiple named areas in one call
- read from a file path,
Stream, orbyte[]
Requirements
.NET 10- Tesseract language data in a
tessdatafolder
By default, the library looks for tessdata in the application output folder:
tessdata/eng.traineddata
If your files are stored somewhere else, set OCROptions.DataPath.
Install
NuGet
dotnet add package TPJ.OCR
Project reference
<ItemGroup>
<ProjectReference Include="..\TPJ.OCR\TPJ.OCR.csproj" />
</ItemGroup>
Namespaces
using TPJ.OCR;
using TPJ.OCR.Enums;
Simple examples
Read all text from an image
var text = OCRReader.ReadText("ExampleImage.png");
Console.WriteLine(text);
Read digits from a specific area
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);
Read multiple named areas
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}");
}
Read multiple areas into a dictionary
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"]);
Read from a stream
using var stream = File.OpenRead("ExampleImage.png");
var text = OCRReader.ReadText(stream);
Console.WriteLine(text);
Read from bytes
var imageBytes = File.ReadAllBytes("ExampleImage.png");
var text = OCRReader.ReadText(imageBytes);
Console.WriteLine(text);
Use custom OCR options
var options = new OCROptions
{
DataPath = Path.Combine(AppContext.BaseDirectory, "tessdata"),
Language = "eng",
NormalizeWhitespace = true
};
var text = OCRReader.ReadText("ExampleImage.png", options);
Console.WriteLine(text);
Notes
OCRRectangle(x, y, width, height)uses pixel coordinates.ContentType.DigitsandContentType.Alphabeticapply simple result cleanup for common OCR mistakes.- OCR areas must fit inside the image bounds.
Example app
See TPJ.TestOCR/Program.cs for a working sample that reads:
- the full image
- a single area
- multiple areas
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- IronSoftware.System.Drawing (>= 2026.4.1)
- Tesseract (>= 5.2.0)
- Tesseract.Drawing (>= 5.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
.NET 10 update see readme for more details