←Select platform

DiskMasterFormsRepository Class

Summary
Implements the IMasterFormsRepository interface for Master Forms stored on local disk.

Syntax
C#
C++/CLI
Java
Python
public class DiskMasterFormsRepository : IMasterFormsRepository 
public class DiskMasterFormsRepository 
    implements IMasterFormsRepository 
public ref class DiskMasterFormsRepository : public IMasterFormsRepository   
class DiskMasterFormsRepository(IMasterFormsRepository): 
Remarks

This class is the LEADTOOLS implementation for the IMasterFormsRepository interface for Master Forms stored on the local disk. You can create your own custom implementation in case your storage requirements are different.

The source code for this interface implementation class is available at <INSTALLDIR>\Examples\Forms\DotNet\AutoMasterFormsRepository.

This implementation assumes that Master Forms are stored inside directories, each directory represent a category, the repository is the top directory that contains all Master Forms and their directories. Each Master Form has three files (one mandatory and two optional). The mandatory file is the attributes file stored using the Master Form with extension ".bin". The first optional file is Processing fields file, it is needed if the Master Form has fields to be processed and it is stored using the Master Form name with extension ".xml". The second optional file is the image file, it is stored using the Master Form file name with extension ".tif" usually images are stored as 1-bit black and white.

DiskMasterFormsRepository will have the Master Forms and Categories organized in the same way that they are stored on the local disk. If any modification is done to the local disk such as adding/deleting file and categories without using Leadtools.Forms.Auto, Refresh should be called to reflect these change to the IMasterFormsRepository object.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Forms.Auto; 
using Leadtools.Document; 
using Leadtools.Ocr; 
using Leadtools.Forms.Recognition; 
using Leadtools.Forms.Processing; 
using Leadtools.Barcode; 
 
using Leadtools.Forms; 
 
public RasterCodecs Codecs; 
public string FormFileName; 
 
public void MyPageRequestCallback(PageRequestCallbackData data) 
{ 
   data.Page = Codecs.Load(FormFileName, 1, CodecsLoadByteOrder.Bgr, data.FormPageNumber, data.FormPageNumber); 
} 
public void AutoFormRunAutomatic() 
{ 
   string root = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\FormsDemo\OCR_Test"); 
   RasterCodecs codecs = new RasterCodecs(); 
   //create repository 
   DiskMasterFormsRepository repository = new DiskMasterFormsRepository(codecs, root); 
 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
      BarcodeEngine barcodeEngine = new BarcodeEngine(); 
 
      //create AutoForm Engine 
      AutoFormsEngine autoEngine = new AutoFormsEngine(repository, ocrEngine, barcodeEngine); 
      //set the flag to process the first page only 
      autoEngine.RecognizeFirstPageOnly = true; 
      autoEngine.MinimumConfidenceKnownForm = 40; 
      //calculate the minimum confidence recognized form according to the correlation between the master forms in the repository 
      autoEngine.MinimumConfidenceRecognized = autoEngine.GetMinimumRecognizedConfidenceForm(); 
 
      Codecs = codecs; 
      FormFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Forms to be Recognized\OCR\FCC-107_OCR_Filled.tif"); 
      //load the first page of the image 
      RasterImage form = codecs.Load(FormFileName, 1, CodecsLoadByteOrder.Bgr, 1, 1); 
      //recognize and process the form 
      AutoFormsRunResult result = autoEngine.Run(form, MyPageRequestCallback, null, null); 
      if (result == null) 
         return; 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Forms.Auto Assembly

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