Optical Mark Recognition in C++ with OpenCV

The description of the problem

Optical Mark Recognition (OMR) software is used to receive and analyze the answers from multiple-choice tests. Assume that each question has \(5\) possible answers: \(A\), \(B\), \(C\), \(D\), or \(E\). The students will answer the questions on paper forms. The pictures of the forms are later taken by a standard camera that produces jpg or png files. The program has to analyze these pictures and find out the answers provided by students.

The program also has to be able to calculate the score for the students based on the answer key.

An OMR software of good quality should address the following possible requests:

  • 1. Be robust enough and tolerate different cameras and lighting conditions. It should be able to recognize a proper orientation of the picture as sometimes the cameras or photographers end up taking upside-down images. Also different photographers may position the camera at slightly different distances from the forms.

  • 2. Find out if a student has selected more than one answer, or if a student has not selected any answers. This would allow instructors to design tests with fewer questions and still use the same form that can accept a large number of answers.

  • 3. After grading is completed, provide grading sheets with individual answers and scores for students. This can be achieved by having students supply their ID numbers on answer sheets. Also, identify tests that were not possible to grade (the picture was of extremely poor quality, a cat or a bird was taking the test instead of the student, etc.).

  • 4. Provide a way for test to have several versions with different answers.

You should create the program and the test form. It is up to you to design the test form so you can grade it easily. You may want to put some little marks on the form that can help you discover the proper orientation of the paper and the lighting conditions under which the picture was taken. You should also have the section on the form that collects the student ID number and possibly the test ID number. It would be good to have the form capable of collecting 50 answers to questions.

OpenCV library

The C++ code needs to read, understand, and perform operations on jpg and png images. This is done using the library OpenCV.

Install the library openCV using the command

sudo apt-get install libopencv-dev python-opencv

Example of an OMR program

The file omr.tar.gz contains the source codes from which you can learn basic operations on images that can get you started with the project.

The program grades an extremely pointless and simple test that contains only one True/False question and is capable of grading the following three images:

\(\quad\) \(\quad\)

The sample program is not very robust. It must accept the picture of correct orientation. The program also does not allow for a picture to be taken from a slightly bigger distance or in a different lighting setting. Exposure parameters are hard-coded in the program and the algorithm is not flexible if a lighter or darker image is provided. The algorithm would also behave in an undesirable way if a student filled both T and F, or if student did not fill either of the choices.