Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
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 a 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?
  • How do I initialize a repository?
    				
    RasterCodecs.Startup();
    RasterCodecs codecs = new RasterCodecs();
    DiskMasterFormsRepository repository = new DiskMasterFormsRepository(codecs,
    rootFolderPath);
    
  • How do I initialize a multithread AutoForms engine?

    Initialize a multithread AutoForms engine by creating multiple OCR engines and pass them to the AutoFormEngine constructor.

    				
    List<IOcrEngine> ocrEngine = new List<IOcrEngine>();
    IOcrEngine ocrEngine;
                
    //to use four threads
    int numberOfThreads = 4;
    for(int i = 0; i < numberOfThreads; i++)
    {
         ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, true);
         ocrEngine.Startup(null, null, null);
         ocrEngine.Add(ocrEngine);
     }
     BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d |
     BarcodeMajorTypeFlags.Barcodes2dRead | BarcodeMajorTypeFlags.BarcodesDataMatrixRead |
     BarcodeMajorTypeFlags.BarcodesPdfRead | BarcodeMajorTypeFlags.BarcodesQrRead);
     BarcodeEnigne barcodeEngine = new BarcodeEngine();
     AutoFormsEngine autoEngine = new AutoFormsEngine(repository, ocrEngine, barcodeEngine, 30, 80,
     true);
    
  • How do I find and set the best minimum confidence value to speed up the recognition process over my Master Forms repository?
    				
    autoEngine.MinimumConfindenceRecognized =
    autoEngine.GetMinimumRecognizedConfidencePage();
    
  • How do I initialize a non-thread AutoForms engine?
    				
    IOcrEngine ocrEngine;
    ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Professional, true);
    ocrEngine.Startup(null, null, null, null);
    BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d |
    BarcodeMajorTypeFlags.Barcodes2dRead | BarcodeMajorTypeFlags.BarcodesDatamatrixRead | 
    BarcodeMajorTypeFlags.BarcodesPdfRead | BarcodeMajorTypeFlags.BarcodesQrRead);
    BarcodeEngine barcodeEngine = new BarcodeEngine();
    AutoFormsEngine autoEngine = new AutoFormsEngine(repository,ocrEngine,barcodeEngine,30,80, 
    true);
    
  • How do I recognize and process a Form image at the same time?
    				
    AutoFormsRunResult result = autoEngine.RecognizeForm(image, null, null, null);
    
  • How do I recognize a Form image only?
    				
    AutoFormsRunResult result = autoEngine.RecognizeForm(image, null);
    
  • How can I speed up Forms Recognition and Processing?
    1. Use the multithread case of AutoFormsEngine.
    2. If you are doing both recognition and processing initialize the AutoFormsEngine with the OCR engines only, use the OCR Professional.
    3. If you are doing recognition only without processing and all your Master Forms have different barcodes, then use only the Barcode engine to generate the Masters attributes and use the barcode engine only to initialize the AutoForms Engine.
  • How do I initialize the Forms Recognition engine?
    				
    FormRecognitionEngin RecognitionEngine = new FormRecognitionEngine();
    
  • How do I set the ObjectsManagers for the recognition engine?

    Set the ObjectsManagers of the FormRecognitionEngineRecognition Engine according to the anticipated form set. For example, if all forms have a barcode label that identifies them, then BarcodeObjectsManager would be a good choice because it is very fast and yet very accurate. If not all forms have barcode labels you can use either OcrObjectsManager alone or OcrObjectsManager and BarcodeObjectsManager together.

    If the forms being detected are simple and can be distinguished based on the lines and inverted text objects inside them, then you may use DefaultObjectsManager alone.

    Select the object manager when forms processing is going to be performed after the recognition as follows:

    1. If all forms are generated under the same conditions as the master and template form images, then any type of Object Manager will find the appropriate alignment.
    2. If the form source is undetermined then use the OcrObjectsManager to find the appropriate alignment.
    				
    void SetObjectManagers(FormsRecognitionEngine RecognitionsEngine, bool
    enableDefault, bool enableOcr, bool enableBarcode)
    {
       if(enableDefault)
       {
          IOcrEngine FormsOcrEngine =
          OcrEngineManager.CreateEngine(OcrEngineType.Plus, false);
          FormsOcrEngine.Startip(null, null, null);
          OcrObjectsManager ocrObejectManager = new
          OcrObjectsManager(FormsOcrEngine);
          ocrObjectManager.Engine = FormsOcrEngine;
          RecognitionEngine.ObjectsManagers.Add(ocrObejectManager);
       }
       if(enableBarcode)
       {
          BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d |
          BarcodeMajorTypeFlags.Barcodes2dRead |
          BarcodeMajorTypeFlags.BarcodesDatamatrixRead |
          BarcodeMajorTypeFlags.BarcodesPdfRead |
          BarcodeMajorTypeFlags.BarcodesQrRead);
          BarcodeEngine FormsBarcodeEngine = new BarcodeEngine();
          BarcodeObjectsManager barcodeObjectManager = new
          BarcodeObjectsManager(FormsBarcodeEngine);
          barcodeObjectManager.Engine = FormsBarcodeEngine;
          RecognitionEngine.ObjectsManagers.Add(barcodeObjectManager);
       }
    }          
    
  • How do I create Master Form Attributes?

    You can create a Master Form and then modify (add/delete) the form pages at a later time. Notice that a form’s attribute set is like a file: you have to open it before modifying it and close it after you finish modifying it. Do that by either:

    1. Create Master Form Attributes

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

    2. Add Pages to an already existing Master Form Attribute

    				
    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);
    }
    

    3. Create a Master Form Attributes and add the pages at the same time

    				
    public FormRecognitionAttributes CreateMasterForm(string name,
    RasterImage image, FormRecognitionEngine RecognitionEngine)
    {
      FormRecognitionAttributes masterFormAttributes =
      RecognitionEngine.CreateMasterForm(name, Guid.Empty, null);
      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);
      return attributes;
    }
    
  • How do I create a Master Form Attributes without modification?
    				
    public FormRecognitionAttributes CreateMasterForm(string name,
    FormRecognitionEngine RecognitionEngine)
    {
        FormRecognitionAttributes attributes =
        RecognitionEngine.CreateMasterForm(name, Guid.Empty, null);
        RecognitionEngine.CloseMasterForm(attributes);
        return attributes;
    }
    
  • How do I add pages to an existing Master Form 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);
    }
    
  • How do I save a form’s Attributes?
    				
    public void SaveAttributes(FormRecognitionAttributes attributes,
    string attributesFileName)
    {
        byte[] data = attributes.GetData();
        File.WriteAllBytes(attributesFileName, data);
    }
    
  • How do I load a form's Attributes?
    				
    public void LoadMasterFormAttributes(FormRecognitionAttributes
    attributes, string attributesFileName)
    {
        byte[] data = File.ReadAllBytes(attributesFileName);
        attributes.SetData(data);
    }
    
  • How do I initialize a processing engine?

    Initialize an engine then add Ocr and Barcode engines

    				
    FormProcessingEngineProcessingEngine = new FormProcessingEngine ();
    IOcrEngine FormsOcrEngine =
    OcrEngineManager.CreateEngine(OcrEngineType.Plus, false);
    FormsOcrEngine.Startup(null, null, null); ProcessingEngine.OcrEngine =
    FormsOcrEngine; BarcodeEngine.Startup(BarcodeMajorTypeFlags.Barcodes1d
    | BarcodeMajorTypeFlags.Barcodes2dRead |
    BarcodeMajorTypeFlags.BarcodesDatamatrixRead |
    BarcodeMajorTypeFlags.BarcodesPdfRead  |
    BarcodeMajorTypeFlags.BarcodesQrRead); BarcodeEngine
    ProcessingEngine.BarcodeEngine = FormsBarcodeEngine;
    
  • How do I create a Text Field?
    				
    Public void CreateTextField(List<FormField> fields, string name,
    LogicalRectangle bounds)
    {
        TextFormField text = new TextFormField();
        text.Name = name; text.Bounds = bounds; fields.Add(text);
    }
    
  • How do I create an OMR Field?
    				
    Public void CreateOmrField(List<FormField> fields, string name,
    LogicalRectangle bounds)
    {
        OmrFormField omr = new OmrFormField();
        omr.Name = name; omr.Bounds = bounds; fields.Add(omr);
    }
    
  • How do I create a Barcode Field?
    				
    Public void CreateBarcodeField(List<FormField> fields, string name,
    LogicalRectangle bounds)
    {
        BarcodeFormField barcode = new
        BarcodeFormField(); barcode.Name = name; barcode.Bounds = bounds;
        fields.Add(barcode);
    }
    
  • How do I create an Image Field?
    				
    Public void CreateImageField(List<FormField> fields, string name, LogicalRectangle bounds)
    {
        ImageFormField image = new ImageFormField();
        image.Name = name; image.Bounds = bounds; fields.Add(image);
    }
    
  • How do I add fields to a page's fields?

    This will create a page for the fields. The page number and the resolution of the image that the fields are associated with should be known.

    				
    Public FormPage AddFieldsToFormPage(List<FormField> fields, int pageNumber, int dpiX, int dpiY)
    {
        FormPage formPage = new FormPage(pageNumber, dpiX, dpiY);
        formPage.AddRange(fields); return formPage;
    }
    
  • How do I add page fields to processing engine pages?
    				
    Public void AddPageToProcessingPages(FormPage formPage, FormProcessingEngineProcessingEngine)
    {
        ProcessingEngine.Pages.Add(formPage);
    }
    
  • How do I save Processing Fields?
    				
    ProcessingEngine.SaveFields(fileName);
    
  • How do I load Processing Fields?

    The fields will be load in the Processing Engine Pages.

    				
    ProcessingEngine.LoadFields(fileName);
    
  • What is Low Level Form Recognition and Processing?

    It is a group of classes and methods that allow users to build their own algorithms for recognition and processing and to implement their own multithreading processes. The speed of recognition and processing may be slow depending on the implementation and the performance of the algorithm.

  • How do I create and add pages to a Form's Attributes?

    You can create a Master Form and then modify (add or delete) the form pages at a later time. Notice that a form’s attributes are like a file: you have to open it before modifying it and close it after you finish. You can do that by either:

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

    Add 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);
    }
    
  • How do I create a Form's Attributes?
    				
    public FormRecognitionAttributes CreateForm(FormRecognitionEngine RecognitionEngine)
    {
        FormRecognitionAttributes attributes =
        RecognitionEngine.CreateForm(null);
        RecognitionEngine.CloseForm(attributes); return attributes;
    }
    
  • How do I add pages to an existing Form's 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;
    }
    
  • How do I compare a Form to a Master Form?
    				
    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.

  • How do I compare a Form Page to a Master Form Page?
    				
    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.

  • How do I Get Form Alignment?

    Get Form Alignment

    				
    IList<PageAlignment>GetFormAlignment(FormRecognitionAttributes master,
    FormRecognitionAttributes form, FormRecognitionEngine RecognitionEngine)
    {
        return RecognitionEngine.GetPageAlignment(master, masterPage, form, formPage);
    }
    

    Get Page Alignment

    				
    PageAlignment GetPageAlignment(FormRecognitionAttributes master,
    int masterPage, FormRecognitionAttributes form,int formPage,
    FormRecognitionEngine RecognitionEngine)
    {
        return RecognitionEngine.GetPageAlignment(master, masterPage, form, formPage);
    }
    

    Get Pages Alignment from FormRecognitionResult

    				
    List<PageAlignment>GetFormAlignment(FormRecognitionResult results)
    {
        List<PageAlignment> alignment = new List<PageAlignment>();
        for(int i = 0; i < form.Result.PageResults.Count; i++)
            alignment.Add(results.PageResults[i].Alignment);
            return alignment;    
    }
    
  • How do I process fields?
    				
    Public void AddPageToProcessingPages(FormProcessingEngine ProcessingEngine,
    RasterImage form, IList<PageAlignment> formAlignment)
    {   
        ProcessingEngine.Process(form, formAlignment);
    }
    

Top ^

See Also