Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, April 27, 2017 12:41:47 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 163

Was thanked: 9 time(s) in 9 post(s)

Some LEADTOOLS operations contain callbacks which reports information regarding the state of the operation. In addition, these operations offer a way to preemptively terminate the operation in question. For example, OcrDocument.AutoZone() and OcrDocument.Recognize() both implement the OcrProgressCallback event.
https://www.leadtools.com/help/leadtools/v20/dh/fo/ocrprogresscallback.html

This event is raised internally and provides data relevant to the progress of the operation.
https://www.leadtools.com/help/leadtools/v20/dh/fo/iocrprogressdata--members.html

Note all these properties are read-only save one: Status. This value is of the OcrProgressStatus enumeration type and has two values--Continue and Abort.
https://www.leadtools.com/help/leadtools/v20/dh/fo/ocrprogressstatus.html

The default value is Continue which instructs the operation to proceed normally. However, this can be changed to Abort to instruct the operation to cease as soon as possible.

Code:

IOcrEngine engine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);
IOcrDocument document = engine.DocumentManager.CreateDocument();
document.Pages.AddPages("input.tiff", 1, -1, null);
document.Pages.AutoZone(null);
document.Pages.Recognize(ocr_callback);


Code:

private void ocr_callback(IOcrProgressData data)
{
    data.Status = OcrProgressStatus.Abort;
}


Do note this does not halt the operation immediately, but rather when it is convenient for the operation to do so. As a general rule, the operation stops after the current page. Note that when an operation is completed this way, any existing result of the operation is discarded, so using this to only perform a specific number of pages in a document is infeasible. This can be used to either force a timeout for long operations, or to accommodate a "Cancel" button exposed to the end-user via the project's UI.

For more information on callbacks used by LEADTOOLS operations and ways to implement them, see this forum post.
https://www.leadtools.com/support/forum/posts/t12155-How-To--Inlining-Anonymous-Methods-As-a-Parameter

Edited by moderator Friday, October 18, 2019 4:41:48 PM(UTC)  | Reason: Updating links and code to v20

Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.087 seconds.