How to Create OMR Answer Sheet Checker in C#

In this how-to topic, we’ll show you how to create OMR answer sheet checker in C#. After this step by step guide, you’ll be able to scan multiple choice answer sheet in C# code. This topic helps to apply optical mark recognition in C# applications to an image.

Steps to Create OMR Answer Sheet Checker in C#

  1. Install Aspose.OMR for .NET package from NuGet.org
  2. Use Aspose.OMR and Aspose.OMR.Api namespaces to scan answer sheet in C#
  3. Set Aspose.OMR for .NET API license using SetLicense method
  4. Read OMR template into TemplateProcessor object using OmrEngine class
  5. Scan and Recognize PNG image to extract result as CSV data
  6. Save extracted CSV data as an output CSV file

The steps above help you read multiple choice answer sheet in C# quickly and easily. You do not need any external software to read answer sheet in C# application. The Aspose.OMR for .NET can solve this problem.

Code to Create OMR Answer Sheet Checker in C#

using System;
using System.IO;
//Add reference to Aspose.OMR for .NET API
//Use following namespaces to create OMR answer sheet checker
using Aspose.OMR;
using Aspose.OMR.Api;
namespace CreateOMRAnswerSheetChecker
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before creating OMR answer sheet checker
//using Aspose.OMR for .NET
Aspose.OMR.License AsposeOMRLicense = new Aspose.OMR.License();
AsposeOMRLicense.SetLicense(@"c:\asposelicense\license.lic");
//Load template file into template processor
OmrEngine OMREngine = new OmrEngine();
TemplateProcessor OMRTemplateProcessor = OMREngine.GetTemplateProcessor("OMRTemplate.omr");
//Get CSV values from the actual image
String ExtractedCSVFromImage = OMRTemplateProcessor.RecognizeImage("AnswerSheetImageToOMR.png").GetCsv();
//Save output as CSV
File.WriteAllText("OutputExtractedCSVValues.csv", ExtractedCSVFromImage);
}
}
}

In the above code, we have applied optical mark recognition on a PNG image and read answer sheet in C#. Note that we’re using an OMR template to recognize the multiple choice answer sheet. Finally, we have saved the extracted data in a CSV file.

 English