Performs field processing on all recognized document pages within LEADDocument.
public void ProcessForm(
LEADDocument leadDoc,
FormRecognitionAttributes masterAttributes,
FormPages formFields
)
leadDoc
The LEADDocument containing the recognized document pages.
masterAttributes
The Master Form attributes of the form type.
formFields
The fields to be processed for the Master Form of the form type.
This method allows form processing at a later state or on another machine without the need to recreate the recognition result object.
The document alignment is calculated from the recognition results.
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 void AutoFormRecognitionAndProcessingLEADDocWithAttributes()
{
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();
AutoFormsEngine autoEngine = new AutoFormsEngine(repository, ocrEngine, barcodeEngine);
autoEngine.MinimumConfidenceKnownForm = 80;
// Load the LEADDocument from file with default options
LoadDocumentOptions loadOptions = new LoadDocumentOptions();
LEADDocument leadDoc = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Filled Forms\FCC-107_OCR_Filled.tif"), loadOptions);
// Recognize the LEADDocument
AutoFormsRecognizeFormResult result = autoEngine.RecognizeForm(leadDoc, null);
if (result == null)
return;
// Get form fields
FormPages formFields = result.MasterForm.ReadFields();
FormRecognitionAttributes attributes = result.MasterForm.ReadAttributes();
// Process Form
autoEngine.ProcessForm(leadDoc, attributes, formFields);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime";
}