Optical Mark Recognition (OMR) is widely used for questionnaires, surveys, and other data‑collection forms. This article shows how to create and validate OMR question and bubble answer sheets in a .NET application using C#. We will cover three main steps:
OMR Template Creator and Checker API – Installation
Create OMR Question Sheet Template, Image, and PDF File using C#
Perform OMR on Multiple Choice Bubble Answer Sheet Images using C#
OMR Template Creator and Checker API – Installation
To work with OMR templates in C# or VB.NET, first install Aspose.OMR for .NET. Download it from New Releases or use the following NuGet command:
Install-Package Aspose.OMR -Version 20.6.0
You are now ready to create multiple‑choice question sheet resources with the API.
Create OMR Question Sheet Template, Image, and PDF File using C#
We will store sample questions in a TXT file that the OMR engine will use to generate the template, image, and PDF. Below is the text markup that serves as input for the engine:
?text=Name__________________________________ Date____________
?grid=ID
sections_count=8
#What is Aspose.OMR main function?
() OCR () Capture human-marked data
() There is no main function () Enhance images
#Can Aspose.OMR process not only scans, but also photos?
() Yes, indeed! () No
#Aspose.OMR is available on any platform, because it is:
() Cross-platform code () Cloud service
#Aspose.OMR works with any kind of OMR forms: tests, exams, questionnaires, surveys, etc.
() Yes, indeed! () No
#Excellent recognition results can be achieved only for filled bubbles at least for:
() 40% () 60% () 75% () 98%
#Do you have to mark up every question on the page?
(Yes) Yes, that will help a lot! (No) No
#Rate your preference from 0 to 9 with "0" being preference towards performance
and "9" being preference towards flexibility.
(0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
#I found aspose omr to be a useful tool. (5 - strongly agree, 1 - strongly disagree)
(5) (4) (3) (2) (1)
?text= Answer sheet section
?answer_sheet=MainQuestions
elements_count=10
columns_count=5
?text=Sign________________________________
Follow these steps with C# code:
- Initialize the OMR engine
- Call the GenerateTemplate method with the markup
- Save the generated question sheet
The code snippet below demonstrates these steps:
{{< gist aspose-com-gists f08b8b0277fe563d616a807aefce753d “CreateOMR.cs” >}}
The resulting OMR question paper appears as shown in the screenshot. Print the PDF or image to distribute the sheets.
{{< figure align=center src=“images/Grid-724x1024.png” alt=“OMR template”>}}
Perform OMR on Multiple Choice Bubble Answer Sheet Images using C#
After collecting responses on the printed sheets, scan or photograph them and run OMR with C#. The API will produce a comma‑separated (CSV) file with the results.
{{< figure align=center src=“images/Sheet1-768x1024.jpg” alt=“create omr”>}}
Steps to perform OMR:
- Specify the template file path
- Specify the scanned image file path
- Initialize TemplateProcessor
- Call RecognizeImage to process the image
- Write the CSV output to a TXT file
The following code snippet shows the complete process:
{{< gist aspose-com-gists f08b8b0277fe563d616a807aefce753d “PerformOMR.cs” >}}
The screenshot below illustrates the accurate CSV output generated by Aspose.OMR for .NET.
{{< figure align=center src=“images/OCR-answer-sheet-1.png” alt=“perform omr”>}}
Conclusion
We have demonstrated how to create OMR question sheets, generate PDFs, and then scan bubble answer sheets using C#. These techniques simplify data collection for research, exams, and surveys. For additional help, visit our Free Support Forums.