←Select platform

Process Event

Summary
Represents a process event.
Syntax
C#
C++/CLI
Python
public event EventHandler<ProgressEventArgs> Process 
public: 
event EventHandler<ProgressEventArgs^>^ Process 
def Process(sender,e): # sender: BankCheckReader e: ProgressEventArgs 
Event Data

The event handler receives an argument of type ProgressEventArgs containing data related to this event. The following ProgressEventArgs properties provide information specific to this event.

Property Description
Cancel Gets or sets the Cancel flag. When set to true cancels the process.
CurrentField The current field that is being processed.
FieldType The current BankCheckField type that will be or has been processed.
Percentage The current percent completion for processing the bank check image.
State The current state for the bank check image processing .
Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Ocr; 
using Leadtools.Forms.Commands; 
 
 
public void TestBankCheckReader() 
{ 
   // Initialize the RasterCodecs class 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Initialize the BankCheckReader class 
   BankCheckReader checkReader = new BankCheckReader(); 
 
   // The bank cheque image 
   string chequePath = Path.Combine(LEAD_VARS.ImagesDir, "BankCheck.jpg"); 
   RasterImage image = codecs.Load(chequePath); 
 
   IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD); 
   ocrEngine.Startup(codecs, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
   // Assign Engine to Reader 
   checkReader.OcrEngine = ocrEngine; 
 
   //Set MICR code type 
   checkReader.MicrFontType = BankCheckMicrFontType.E13b; 
 
   // handle Process Event 
   checkReader.Process += new EventHandler<ProgressEventArgs>(reader_Processed); 
 
   // Process Image 
   checkReader.ProcessImage(image); 
 
   ocrEngine.Shutdown(); 
} 
 
void reader_Processed(object sender, ProgressEventArgs e) 
{ 
   Console.WriteLine(string.Format("State      : {0}%", e.State)); 
   Console.WriteLine(string.Format("Percentage : {0}%", e.Percentage)); 
   Console.WriteLine(string.Format("FieldType  : {0}%", e.FieldType.ToString())); 
 
   if (e.State == ProcessState.Finish) 
   { 
      BankCheckReader reader = sender as BankCheckReader; 
      foreach (var value in reader.Results) 
      { 
         LeadRect bounds = value.Value.Bounds; 
         Console.WriteLine(string.Format("Field Name      : {0}", value.Key)); 
         Console.WriteLine(string.Format("Field Value     : {0}", value.Value.Text)); 
         Console.WriteLine(string.Format("Field Bounds    : {0},{0},{0},{0}", bounds.X.ToString(), bounds.Y.ToString(), bounds.Width.ToString(), bounds.Height.ToString())); 
         Console.WriteLine("************************************"); 
      } 
   } 
} 
 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.forms.commands.BankCheckMicrFontType; 
import leadtools.forms.commands.BankCheckReader; 
import leadtools.forms.commands.MRTDErrors; 
import leadtools.forms.commands.MRTDReader; 
import leadtools.forms.commands.ProcessListener; 
import leadtools.forms.commands.ProcessState; 
import leadtools.forms.commands.ProgressEvent; 
import leadtools.ocr.OcrEngine; 
import leadtools.ocr.OcrEngineManager; 
import leadtools.ocr.OcrEngineType; 
 
 
public void TestBankCheckReader() { 
   RasterCodecs codecs = new RasterCodecs(); 
   BankCheckReader checkReader = new BankCheckReader(); 
 
   // The bank cheque image 
   String LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String chequePath = combine(LEAD_VARS_ImagesDir, "BankCheck.jpg"); 
   RasterImage image = codecs.load(chequePath); 
   String LEAD_VARS_OcrLEADRuntimeDir = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
   ocrEngine.startup(codecs, null, null, LEAD_VARS_OcrLEADRuntimeDir); 
 
   // Assign Engine to Reader 
   checkReader.setOcrEngine(ocrEngine); 
 
   // Set MICR code type 
   checkReader.setMicrFontType(BankCheckMicrFontType.E13B); 
 
   // Handle Process Event 
   checkReader.addProcessListener(reader_Processed); 
 
   // Process Image 
   try { 
      checkReader.processImage(image); 
   } 
   catch (Exception ex) { 
      System.out.println(ex.getMessage()); 
   } 
 
   // Cleanup 
   ocrEngine.shutdown(); 
   ocrEngine.dispose(); 
   codecs.dispose(); 
   image.dispose(); 
} 
 
ProcessListener reader_Processed = new ProcessListener() { 
 
   @Override 
   public void onProcess(Object sender, ProgressEvent e) { 
      System.out.println(String.format("State      : %s%", e.getState())); 
      System.out.println(String.format("Percentage : %s%", e.getPercentage())); 
      System.out.println(String.format("FieldType  : %s%", e.getFieldType().toString())); 
 
      if (e.getState() == ProcessState.FINISH) { 
         BankCheckReader reader = (BankCheckReader) sender; 
         for (var value : reader.getResults().values()) { 
            LeadRect bounds = value.getBounds(); 
            System.out.println(String.format("Field Name      : %s", value)); 
            System.out.println(String.format("Field Value     : %s", value.getText())); 
            System.out.println(String.format("Field Bounds    : %1s,%2s,%3s,%4s", bounds.getX(), bounds.getY(), 
                  bounds.getWidth(), bounds.getHeight())); 
            System.out.println("************************************"); 
         } 
      } 
   } 
 
}; 
Requirements

Target Platforms

Help Version 23.0.2024.5.23
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.Commands Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.