Forms Recognition and Processing FAQ

Frequently Asked Questions

Table of Contents

General

  1. How do I initialize a repository?
  2. How do I initialize a multithreaded AutoForms engine?
  3. How do I initialize a non-threaded AutoForms engine?
  4. How do I find and set the best minimum confidence value to speed up the recognition process over my Master Forms repository?
  5. How do I recognize and process a Form's image at the same time?
  6. How do I recognize only a Form's image?
  7. How can I speed up Forms Recognition and Processing?

Generating Master Forms

  1. How do I initialize the Forms Recognition engine?
  2. How do I set the ObjectsManagers for the recognition engine?
  3. How do I create Master Form Attributes?
  4. How do I create Master Form Attributes without modification?
  5. How do I add pages to an existing Master Form Attributes?
  6. How do I save a form's attributes?
  7. How do I load a form's attributes?
  8. How do I initialize a processing engine?
  9. How do I create a Text Field?
  10. How do I create an OMR Field?
  11. How do I create a Barcode Field?
  12. How do I create an Image Field?
  13. How do I add fields to a page fields?
  14. How do I add page fields to processing engine pages?
  15. How do I save Processing Fields?
  16. How do I load Processing Fields?

Low Level

  1. What is Low Level Form Recognition and Processing?
  2. How do I create and add pages to a Form Attributes?
  3. How do I create a Form Attributes?
  4. How do I add pages to an existing Form Attributes?
  5. How do I compare a Form to a Master Form?
  6. How do I compare a Form Page to Master Form Page?
  7. How do I Get Form Alignment?
  8. How do I process fields?

string rootFolderPath = @"C:\Users\Public\Documents\LEADTOOLS Images\Forms\MasterForm Sets\OCR\"; 
RasterCodecs codecs = new RasterCodecs(); 
DiskMasterFormsRepository repository = new DiskMasterFormsRepository(codecs, rootFolderPath); 

IOcrEngine ocrEngine; 
ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, true); 
ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); 
BarcodeEngine barcodeEngine = new BarcodeEngine(); 
AutoFormsEngine autoEngine = new AutoFormsEngine(repository,ocrEngine,barcodeEngine,30,80, true); 

autoEngine.MinimumConfindenceRecognized = autoEngine.GetMinimumRecognizedConfidencePage();

AutoFormsRunResult result = autoEngine.RecognizeForm(image, null, null, null);

AutoFormsRunResult result = autoEngine.RecognizeForm(image, null);

FormRecognitionEngin RecognitionEngine = new FormRecognitionEngine();

void SetObjectManagers(FormsRecognitionEngine RecognitionsEngine, bool enableDefault, bool enableOcr, bool enableBarcode) 
{ 
   if(enableDefault) 
   { 
      IOcrEngine FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false); 
      FormsOcrEngine.Startip(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); 
      OcrObjectsManager ocrObejectManager = new 
      OcrObjectsManager(FormsOcrEngine); 
      ocrObjectManager.Engine = FormsOcrEngine; 
      RecognitionEngine.ObjectsManagers.Add(ocrObejectManager); 
   } 
                    
   if(enableBarcode) 
   { 
      BarcodeEngine FormsBarcodeEngine = new BarcodeEngine(); 
      BarcodeObjectsManager barcodeObjectManager = new BarcodeObjectsManager(FormsBarcodeEngine); 
      barcodeObjectManager.Engine = FormsBarcodeEngine; 
      RecognitionEngine.ObjectsManagers.Add(barcodeObjectManager); 
   } 
} 

public FormRecognitionAttributes CreateMasterForm(string name, FormRecognitionEngine RecognitionEngine) 
{ 
   FormRecognitionAttributes attributes = RecognitionEngine.CreateMasterForm(name, Guid.Empty, null); 
   RecognitionEngine.CloseMasterForm(attributes); 
   return attributes; 
} 

public void AddPagesToMasterForm (RasterImage image, FormRecognitionAttributes masterFormAttributes, FormRecognitionEngine RecognitionEngine) 
{ 
   RecognitionEngine.OpenMasterForm(masterFormAttributes); 
   int saveCurrentPageIndex = image.Page; 
   for(int i = 0; i < image.PageCount; i++) 
   { 
      image.Page = i + 1; 
      RecognitionEngine.AddMasterFormPage(masterFormAttributes, image, null); 
   } 
                    
   image.Page = saveCurrentPageIndex; 
   RecognitionEngine.CloseMasterForm(masterFormAttributes); 
} 

public void SaveAttributes(FormRecognitionAttributes attributes, string attributesFileName) 
{ 
   byte[] data = attributes.GetData(); 
   File.WriteAllBytes(attributesFileName, data); 
} 

public void LoadMasterFormAttributes(FormRecognitionAttributes attributes, string attributesFileName) 
{ 
   byte[] data = File.ReadAllBytes(attributesFileName); 
   attributes.SetData(data); 
} 

FormProcessingEngineProcessingEngine = new FormProcessingEngine (); 
IOcrEngine FormsOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false); 
FormsOcrEngine.Startup(null, null, null, @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"); 
ProcessingEngine.OcrEngine = FormsOcrEngine; 
ProcessingEngine.BarcodeEngine = FormsBarcodeEngine; 

public void CreateTextField(List<FormField> fields, string name, LogicalRectangle bounds) 
{ 
   TextFormField text = new TextFormField(); 
   text.Name = name; 
   text.Bounds = bounds; 
   fields.Add(text); 
} 

public void CreateOmrField(List<FormField> fields, string name, LogicalRectangle bounds) 
{ 
   OmrFormField omr = new OmrFormField(); 
   omr.Name = name; 
   omr.Bounds = bounds; 
   fields.Add(omr); 
} 

public void CreateBarcodeField(List<FormField> fields, string name, LogicalRectangle bounds) 
{ 
   BarcodeFormField barcode = new BarcodeFormField(); 
   barcode.Name = name; 
   barcode.Bounds = bounds; 
   fields.Add(barcode); 
} 

public void CreateImageField(List<FormField> fields, string name, LogicalRectangle bounds) 
{ 
   ImageFormField image = new ImageFormField(); 
   image.Name = name; 
   image.Bounds = bounds; 
   fields.Add(image); 
} 

public FormPage AddFieldsToFormPage(List<FormField> fields, int pageNumber, int dpiX, int dpiY) 
{ 
   FormPage formPage = new FormPage(pageNumber, dpiX, dpiY); 
   formPage.AddRange(fields); 
   return formPage; 
} 

public void AddPageToProcessingPages(FormPage formPage, FormProcessingEngineProcessingEngine) 
{ 
   ProcessingEngine.Pages.Add(formPage); 
} 

ProcessingEngine.SaveFields(fileName);

ProcessingEngine.LoadFields(fileName);

public FormRecognitionAttributes CreateForm(FormRecognitionEngine RecognitionEngine) 
{ 
   FormRecognitionAttributes attributes = RecognitionEngine.CreateForm(null); 
   RecognitionEngine.CloseForm(attributes); 
   return attributes; 
} 

Adding Pages to an existing Form Attributes

public void AddPagesToForm (RasterImage image, FormRecognitionAttributes formAttributes, FormRecognitionEngine RecognitionEngine) 
{ 
   RecognitionEngine.OpenForm(masterFormAttributes); 
   int saveCurrentPageIndex = image.Page; 
   for(int i = 0; i < image.PageCount; i++) 
   { 
      image.Page = i + 1; 
      RecognitionEngine.AddFormPage(formAttributes, image, null); 
   } 
                    
   image.Page = saveCurrentPageIndex; 
   RecognitionEngine.CloseForm(masterFormAttributes); 
} 

public FormRecognitionAttributes CreateForm(FormRecognitionEngine RecognitionEngine) 
{ 
   FormRecognitionAttributes attributes = RecognitionEngine.CreateForm(null); 
   RecognitionEngine.CloseForm(attributes); 
   return attributes; 
} 

public void AddPagesToForm (RasterImage image, FormRecognitionAttributes formAttributes, FormRecognitionEngine RecognitionEngine) 
{ 
   RecognitionEngine.OpenForm(masterFormAttributes); 
   saveCurrentPageIndex = image.Page; 
   for(int i = 0; i < image.PageCount; i++) 
   { 
      image.Page = i + 1; 
      RecognitionEngine.AddFormPage(formAttributes, image, null); 
   } 
                    
   image.Page = saveCurrentPageIndex; 
   RecognitionEngine.CloseForm(masterFormAttributes; 
} 

FormRecognitionResult CompareForm(FormRecognitionAttributes master, FormRecognitionAttributes form, FormRecognitionEngine RecognitionEngine) 
{ 
   return RecognitionEngine.CompareForm(master, form, null); 
} 

Note: When there is a list of Master Forms, the Form Attributes should be compared to each Master Form Attributes. The Master Form with maximum confidence result is considered to be the type of the Form Attributes. If the maximum confidence is very small (for example, less than 20) then the Form is considered to be of unknown type.

PageRecognitionResult CompareForm(FormRecognitionAttributes master, int masterPage, FormRecognitionAttributes form, int formPage, FormRecognitionEngine RecognitionEngine) 
{ 
   return RecognitionEngine.ComparePage(master, 1, form, 1); 
} 
Note: This is very helpful in speeding up the recognition by comparing the first page only if Master Forms do not have the same first page. This comparison is also very useful for determining the form type for a single page.

Top ^

Help Version 20.0.2018.1.23
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document