Browse our Products

Aspose.OCR for .NET 25.2.0 - Release Notes

What was changed

KeySummaryCategory
OCRNET‑976Exposed control over ONNX session options for advanced users.New feature
OCRNET‑987Added automatic detection of image language, supporting: English (Latin), Cyrillic, Arabic, Chinese, Japanese, Korean, Hindi, Tamil, Telugu, and KannadaNew feature

Public API changes and backwards compatibility

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

Added public APIs:

The following public APIs have been introduced in this release:

Aspose.OCR.LanguageDetectionOutput class

This class stores the results of language detection.

PropertyTypeDescription
SourcestringThe full path or URL of the source file. If the file is provided as a MemoryStream object, an array of pixels, or a Base64 string, this value will be empty.
PageintPage number. When working with single-page images, this value is always 0.
LanguagesList<KeyValuePair<Aspose.OCR.Language, float>>Lists the languages (Aspose.OCR.Language) detected in the image along with their probabilities.

Aspose.OCR.DetectLanguages method

Identify languages on the images provided in Aspose.OCR.OcrInput object and return them as a list of Aspose.OCR.LanguageDetectionOutput objects.

Aspose.OCR.OnnxRuntimeSessionOptions class

Allows overriding the default ONNX runtime settings. Aspose.OCR for .NET is already optimized, so modifications are recommended only for fine-tuning the library’s behavior on specific hardware.

Aspose.OCR.OnnxRuntimeSessionOptions is a static class that exposes the following properties:

PropertyTypeDescription
GraphOptimizationLevelAspose.OCR.GraphOptimizationLevelOnnxGraph optimization level for the session:
  • ORT_DISABLE_ALL - disable all optimizations.
  • ORT_ENABLE_BASIC - enable basic optimizations, such as node fusion and constant folding.
  • ORT_ENABLE_EXTENDED - enable extended optimizations, including memory layout improvements.
  • ORT_ENABLE_ALL - enable all available optimizations for maximum performance.
By default, all available optimizations are enabled.
ExecutionModeAspose.OCR.ExecutionModeOnnxExecution mode for the session:
  • ORT_SEQUENTIAL - execute operators sequentially, ensuring that each operation is completed before the next one starts.
  • ORT_PARALLEL - execute operators in parallel (whenever possible), to improve performance.
By default, operators are executed concurrently, whenever possible.
IntraOpNumThreadsintNumber of threads for a single operations.
InterOpNumThreadsintNumber of threads for running multiple operations in parallel. If sequential execution (ExecutionModeOnnx.ORT_SEQUENTIAL) is enabled in ExecutionMode property, this value is ignored.

Updated public APIs:

No changes.

Removed public APIs:

No changes.

Examples

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

Detect languages on the image

Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Add an image to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source.png");
// Detect languages
List<Aspose.OCR.LanguageDetectionOutput> result = recognitionEngine.DetectLanguages(input);
foreach (Aspose.OCR.LanguageDetectionOutput item in result)
{
	Console.WriteLine($"Image: {item.Source}");
	foreach (KeyValuePair<Aspose.OCR.Language, float> lang in item.Languages)
	{
		Console.WriteLine($"Language: {lang.Key}: {lang.Value}");
	}
}

Change the number of threads for ONNX runtime

Aspose.OCR.OnnxRuntimeSessionOptions.IntraOpNumThreads = 8;
// Initialize recognition API
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();
// Add images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source1.png");
input.Add("source2.jpg");
// Recognize image
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input);