←Select platform

OmrEngine Class

Summary

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

Syntax
C#
C++/CLI
Java
Python
public class OmrEngine 
public class OmrEngine 
public: 
   ref class OmrEngine 
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:\LEADTOOLS22\Support\Common\License\LEADTOOLS.LIC"; 
   string key = System.IO.File.ReadAllText(@"C:\LEADTOOLS22\Support\Common\License\LEADTOOLS.LIC.key"); 
 
   try 
   { 
      RasterSupport.SetLicense(licenseFile, key); 
   } 
   catch (Exception) 
   { 
      return false; 
   } 
 
   return !RasterSupport.IsLocked(RasterSupportType.Omr); 
}  
// OMR Engine Example Source 
/// <!--Insert:OmrEngine--> 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
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.Processing.Omr Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.