Tracking recognition progress

Contents
[ ]

Aspose.OCR for .NET allows you to batch process multiple images, process all images from archives and folders, and extract texts from multi-page documents. These operations can take a significant amount of time and may cause the end user to think that recognition is stuck due to some error.

The library exposes the Aspose.OCR.AsposeOcr.OcrProgress event, which is raised when a page or file from a batch is processed. You can implement an event listener and report progress even in case of multi-threaded recognition.

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("page1.png");
input.Add("page2.png");
// Event handler
recognitionEngine.OcrProgress += (Aspose.OCR.Models.Events.OcrPageRecognizeEventsArgs e) => {
	Console.WriteLine($"Read page: {e.CurrentPage} | image: {e.CurrentImage} | time taken: {e.Duration.TotalSeconds} sec");
};
// Recognize images
List<Aspose.OCR.RecognitionResult> results = recognitionEngine.Recognize(input);
Aspose.OCR.AsposeOcr.SaveMultipageDocument("result.json", Aspose.OCR.SaveFormat.Json, results);

For each page or file, the following information is reported:

Property Type Description
CurrentImage int The ordinal number of the image.
CurrentPage int The ordinal number of the page in a batch or a multi-page image/document.
Duration TimeSpan The time interval from the start of image or page recognition until it is fully recognized.