←Select platform

OmrEngine Class

Summary

Provides a high level OMR forms functionality to create forms objects and process forms fields.

Syntax
C#
VB
C++
Java
public class OmrEngine 
public class OmrEngine 
Public Class OmrEngine 
public: 
   ref class OmrEngine 
Remarks

LEADTOOLS OMR toolkit provides high-level classes to process OMR bubbles in exams and surveys. OmrEngine allows creating forms, automatic detection of OMR bubbles, automatic alignment, and processing of different types of fields.

LEADTOOLS supports OmrFields, OcrField, ImageField and BarcodeField.

OmrField can be easily detected and extracted by providing the area of the group of OMR bubbles using ITemplateForm.ExtractInfo.

The OmrEngine can be used to create and load ITemplateForm and IRecognitionForm internal objects.

Example

OMR Example Workflow

The following example is a snippet of a larger example that demonstrates a basic workflow using LEADTOOLS OMR:
1. Create and initialize a new OmrEngine
2. Load the RasterImage
3. Create an ITemplateForm object from the rasterimage
4. Create a few zones and add them to the template
5. Save the template to a file on disk
6. Apply OMR to the answer key
7. Apply OMR to the individual forms
8. Analyze the documents and print the results
9. Shut down the OcrEngine associated with this OmrEngine

You can also download the complete example in Visual Studio 2017.

C#
using Leadtools; 
using Leadtools.Barcode; 
using Leadtools.Codecs; 
using Leadtools.Forms.Processing.Omr; 
using Leadtools.Forms.Processing.Omr.Fields; 
using Leadtools.Ocr; 
 
//  Main Workflow Example Source 
static void Main(string[] args) 
{ 
   if (SetLicense() == false) 
   { 
      Console.WriteLine("Either the  license is not set, or OMR functionality is not supported."); 
      Console.WriteLine("Application will exit."); 
 
      return; 
   } 
 
   // create and initialize a new OmrEngine 
   OmrEngine engine = OmrEngineExamples.CreateOmrEngine(); 
 
   // load a rasterimage that the template will use as a source 
   string inputImagePath = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\OMR Processing\Exam\exam.tif"); 
   RasterImage templateImage = engine.EnginesObject.RasterCodecs.Load(inputImagePath); 
 
   // create an ITemplateForm object from the rasterimage 
   ITemplateForm template = OmrEngineExamples.CreateNewTemplate(templateImage, engine); 
 
   // create a few zones and add them to the template 
   OmrFieldExamples.AddZonesToTemplate(template); 
 
   // save our constructed template to a file on disk 
   ITemplateFormExamples.SaveTemplateToDisk(template); 
 
   // apply OMR to the answer key 
   IRecognitionForm answers = IRecognitionFormExamples.RecognizeForm(template, engine); 
 
   // apply OMR to the individual forms 
   List<IRecognitionForm> recognizedForms = IRecognitionFormExamples.RecognizeMultipleForms(template, engine); 
 
   // analyze the documents and print the results 
   OmrEngineExamples.PerformAnalysis(recognizedForms, answers); 
 
   // shut down the OcrEngine associated with this OmrEngine 
   engine.EnginesObject.OcrEngine.Shutdown(); 
} 
 
 
private static bool SetLicense() 
{ 
   string licenseFile = @"C:\LEADTOOLS 21\Support\Common\License\LEADTOOLS.LIC"; 
   string key = System.IO.File.ReadAllText(@"C:\LEADTOOLS 21\Support\Common\License\LEADTOOLS.LIC.key"); 
 
   try 
   { 
      RasterSupport.SetLicense(licenseFile, key); 
   } 
   catch (Exception) 
   { 
      return false; 
   } 
 
   return !RasterSupport.IsLocked(RasterSupportType.Omr); 
}  
// OMR Engine Example Source 
public static OmrEngine CreateOmrEngine() 
{ 
   OmrEngine omrEngine = new OmrEngine(); 
 
   // the OmrEngine requires an OcrEngine to be associated with it and for that engine to be started 
   IOcrEngine engine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD); 
   engine.Startup(null, null, null, null); 
   omrEngine.EnginesObject.OcrEngine = engine; 
 
   omrEngine.EnginesObject.BarcodeEngine = new BarcodeEngine(); 
 
   // the OmrEngine also has a property for a RasterCodecs object we can use for convenience 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.Options.Load.Resolution = 300; 
   codecs.Options.Load.XResolution = 300; 
   codecs.Options.Load.YResolution = 300; 
   codecs.Options.RasterizeDocument.Load.Resolution = 300; 
   codecs.Options.RasterizeDocument.Load.XResolution = 300; 
   codecs.Options.RasterizeDocument.Load.YResolution = 300; 
   omrEngine.EnginesObject.RasterCodecs = codecs; 
 
   return omrEngine; 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Requirements
Target Platforms
Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.Processing.Omr Assembly

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