Browse our Products

Latest release

What was changed

KeySummaryCategory
#OCRNET‑1212Add region-level recognition results to RecognitionResult. Add the ability to access recognized text per detected region via RecognitionRegionsResult.New feature
#OCRNET‑1220Fix JSON serialization for RecognitionResult, including byte-array image fields, to produce stable and complete serialized output.Bug fix

Public API changes and backwards compatibility

This section lists all public API changes introduced in Aspose.OCR for .NET 26.5 that may affect the code of existing applications.

Added public APIs:

The following public APIs have been introduced in this release:

Aspose.OCR.RecognitionResult.RecognitionRegionsResult - a new property

Contains recognition output split by detected regions.

Aspose.OCR.RecognitionResult.RegionResult - a new type

Represents the recognition result for a single region (for example, region text and region type).

Updated public APIs:

No signature changes.

Serialization behavior of RecognitionResult has been fixed to correctly handle JSON output, including byte-array image data.

Removed public APIs:

No changes.

Examples

The code samples below illustrate the changes introduced in this release.

Recognize only detected table regions and read region texts

Use DetectTables to get candidate rectangles, pass them into RecognitionSettings.RecognitionAreas, and then read RecognitionRegionsResult.

using Aspose.OCR;
using System;
using System.IO;
using System.Linq;

AsposeOcr api = new AsposeOcr();
string imgPath = Path.Combine(testDataDir, "Tables", img);

OcrInput input = new OcrInput(InputType.SingleImage);
input.Add(imgPath);

var tableDetection = api.DetectTables(input)[0];

var result = api.Recognize(input, new RecognitionSettings
{
    RecognitionAreas = tableDetection.Rectangles
})[0];

Console.WriteLine($"Detected table regions: {tableDetection.Rectangles.Count}");
Console.WriteLine($"Recognized regions: {result.RecognitionRegionsResult.Count}");

string mergedRegionText = string.Concat(
    result.RecognitionRegionsResult.Select(r => r.TextInRegion));

Console.WriteLine("Merged region text equals full text: " +
    (mergedRegionText == result.RecognitionText));
Console.WriteLine("First region type: " + result.RecognitionRegionsResult[0].RegionType);

Read text and region types from a multi-column PDF

When DetectAreasMode.MULTICOLUMN is enabled, RecognitionRegionsResult provides per-region text so you can process columns/blocks separately.

using Aspose.OCR;
using System;
using System.IO;

AsposeOcr api = new AsposeOcr();
string imgPath = Path.Combine(testDataDir, "pdfs", img);

OcrInput input = new OcrInput(InputType.PDF);
input.Add(imgPath);

var result = api.Recognize(input, new RecognitionSettings
{
    DetectAreasMode = DetectAreasMode.MULTICOLUMN
})[0];

Console.WriteLine("--- full text ---");
Console.WriteLine(result.RecognitionText);

for (int i = 0; i < result.RecognitionRegionsResult.Count; i++)
{
    var region = result.RecognitionRegionsResult[i];
    Console.WriteLine($"--- region {i} ({region.RegionType}) ---");
    Console.WriteLine(region.TextInRegion);
}