LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Create a simple OMR processing forms demo
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
The attached VS 2017 C# .NET Project uses the
LEADTOOLS Forms SDK to processed filled out Bubble sheet or OMR (optical mark recognition) forms against a master form.
The class doing all of the hard work is the
AutoFormsEngine.
Here is the relevant code:
Code:
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Options.Load.AllPages = true;
codecs.Options.RasterizeDocument.Load.XResolution = 300;
codecs.Options.RasterizeDocument.Load.YResolution = 300;
string masterFormRepository = @"C:\Users\Public\Documents\LEADTOOLS Images\Forms\MasterForm Sets\OMR";
string filledFormDirectory = @"C:\Users\Public\Documents\LEADTOOLS Images\Forms\Forms to be Recognized\OMR";
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
ocrEngine.Startup(codecs, null, null, null);
IMasterFormsRepository repository = new DiskMasterFormsRepository(codecs, masterFormRepository);
using (AutoFormsEngine engine = new AutoFormsEngine(repository, ocrEngine, null, AutoFormsRecognitionManager.Default | AutoFormsRecognitionManager.Ocr, 30, 80, false))
{
foreach (var file in Directory.EnumerateFiles(filledFormDirectory))
{
Console.WriteLine("Processing file " + Path.GetFileName(file));
using (RasterImage image = codecs.Load(file))
{
AutoFormsRunResult runResult = engine.Run(image, null, null, null);
Console.WriteLine("Form Processed using " + runResult.RecognitionResult.MasterForm.Name);
if (runResult != null)
foreach (FormPage formPage in runResult.FormFields)
foreach (FormField field in formPage)
if ((field as OmrFormField) != null)
Console.WriteLine(field.Name + ": " + ((field.Result as OmrFormFieldResult)?.Text == "1").ToString());
}
Console.WriteLine("*****************************");
}
}
}
Console.WriteLine("Done processing");
Console.ReadLine();
}
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Create a simple OMR processing forms demo
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.