Browse our Products

Aspose.OCR for Java 25.5.0 - Release Notes

What was changed

KeySummaryCategory
OCRJAVA‑430Exposed control over ONNX session options for advanced users.New feature
OCRJAVA‑429Optimization: create classes for one-time InferenceSession initialization and optimize performance.Enhancement

Public API changes and backwards compatibility

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

Added public APIs:

The following public APIs have been introduced in this release:

OnnxRuntimeSessionOptions class

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

OnnxRuntimeSessionOptions is a static class that exposes the following properties:

PropertyTypeDescription
graphOptimizationLevelGraphOptimizationLevelOnnxGraph 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.
executionModeExecutionModeOnnxExecution 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.

Deprecated APIs

The following public APIs have been marked as deprecated and will be removed in 25.10.0 (October 2025) release:

RecognitionResult.recognitionAreasText

RecognitionResult.recognitionAreasRectangles

Removed public APIs:

No changes.

Examples

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

Change the number of threads for ONNX runtime

import com.aspose.ocr.models.*;

OnnxRuntimeSessionOptions.intraOpNumThreads = 8;
// Initialize recognition API
AsposeOCR api = new AsposeOCR();
// Add an image to OcrInput object
OcrInput input = new OcrInput(InputType.SingleImage);
input.Add("source.png");
// Recognize image
ArrayList<RecognitionResult> results = api.Recognize(input);