ImageGear .NET
Monitor Progress

Typically the most time-consuming processes invoked by the Recognition engine are the recognition processes (RECOGNITION1, RECOGNITION2, and RECOGNITION3), and the final output document generation (WRITEFOUTDOC). In some particular cases, other processes like image loading (IMGINPUT) or image preprocessing (IMGPREPROCESS) might also take considerable time.

Sometimes it is advisable to provide the application user with feedback about these processes. The application can register an event handler for progress monitoring using the Progress Event of ImGearRecognition Class. The Recognition engine will fire the Progress Event during processing with a ImGearRecProgressEventArgs Class object containing information about the current process. The application can provide progress indication by handling this event. If the event handler sets the Abort Property of ImGearRecProgressEventArgs Class to true, it signals an interruption of the current process. This can be used to provide the application user with a cancel button.

The Process Property of the ImGearRecProgressEventArgs Class object identifies the current process (e.g., DECOMPOSITION, WRITEFOUTDOC, etc.). The Percent Property provides the progress information for the process.

If the current session includes one of the two recognition processes, the ImGearRecStatistics.CharCount Property and RejectedCharCount Property provide the number of recognized and rejected characters up to that point on the page being processed. This feature can be used to alert the user, or even some automatic monitoring code, that recognition accuracy has fallen below some predefined level.

Sample Event Registration and Event Handler for Progress Monitoring

C#
Copy Code
public delegate void UpdateProgressBarDelegate(ImGearRecProgressEventArgs e);
UpdateProgressBarDelegate progressDelegate = null;
void UpdateProgressBar(ImGearRecProgressEventArgs e)
{
     if (e.Percent < 100)
         toolStripStatusProgress.Text = e.Process + " - " + e.Percent + "%";
     else
         toolStripStatusProgress.Text = "Ready";
     this.Update();
}
private void recProgress(object sender, ImGearRecProgressEventArgs e)
{
     if(this.InvokeRequired)
     {
         object[] arg = new object[1];
         arg[0] = e;
         this.Invoke(progressDelegate, arg);
     }
     else
     {
         UpdateProgressBar(e);
     }
}
VB.NET
Copy Code
Public Delegate Sub UpdateProgressBarDelegate(ByVal e As ImGearRecProgressEventArgs)
Public progressDelegate As UpdateProgressBarDelegate
Sub UpdateProgressBar(ByVal e As ImGearRecProgressEventArgs)
     If e.Percent < 100 Then
         toolStripStatusProgress.Text = e.Process.ToString() + " - " + e.Percent.ToString() + "%"
     Else
         toolStripStatusProgress.Text = "Ready"
     End If
     Me.Update()
End Sub
Private Sub recProgress(ByVal sender As Object, ByVal e As ImGearRecProgressEventArgs)
     If Me.InvokeRequired Then
         Dim arg As Object() = New Object(0) {}
         arg(0) = e
         Me.Invoke(progressDelegate, arg)
     Else
         UpdateProgressBar(e)
     End If
End Sub

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback