Optical Mark Recognition – On The Cheap

At my job about a year ago, my coordinator asked me to look into using some kind of optical mark recognition (OMR) program to read surveys that we were administering, to cut down on the burden of data entry. There are a lot of commercial programs for OMR, but we wanted to avoid spending any money, so I did a little research and stumbled across this gem, the Udai OMR tool. It was developed as a free alternative to commercial projects, for use by non-profits.

It definitely has some issues, no doubt, so if you’re looking for a packaged, out of the box solution, you would want to keep on clicking (and head for some of those paid solutions instead). But, if you want to use it, it can be done. We ended up not using it, so my half-finished version has languished for awhile, and I thought I’d share. Here’s some notes from my experiences for anyone who’s trying to get this system working.

1) You’ll need Java. No biggie, but make sure you get it. I ran everything from the command line using “java -cp”.

2) The examples provided by the Udai OMR creators are all for surveys where the entire survey is on a single page. In effect, the system can only read a page at a time. You can work around this, using command-line tools to manipulate files and PDFs. I highly recommend, if working in a Windows environment, that you grab both PDFTK (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) and UnixUtils (http://unxutils.sourceforge.net/).

3) I only got the system working at reading .PNG files, in a grayscale colorspace, at 300dpi. We scanned them initially using our department’s Xerox machine – they were scanned to PDF at 600dpi. I had batch files in place to split the bulk PDF into individual surveys, and to run an entire directory of .PNGs through the OMR program. I never wrote a batch to convert the PDFs to PNGs, or to extract all the 1st pages, 2nd pages, etc, but it doesn’t seem like it would be a difficult script to write.

4) The way the system works can seem circuitous. Bear with me as I explain (and also, the readme is fairly good).

You create a document with two black “doughnuts” in the corners, which allows the system to align your document. You put your questions and your answer bubbles onto the document. Then, you save that as the blank version, and create a “template” version, where every circle is filled in black. (The authors recommend just filling it in with a pen, but you can also use a black circle symbol in the document itself – more on that in a minute).

Convert the “template” version to a .PNG (300dpi, grayscale, etc), and feed it through the omrproj.ProcessTemplate code. This creates a template file, which is basically a text file that shows ——– where there is no circle, and places a 0 where it thinks there is one. You just edit that file to group together the 0s (by replacing them with a letter, like “a”), to make your template complete.

For instance, if a question asks the gender of a participant, and the choices are male or female, you would put an “a” on the template for the circles that represent both male and female. That way, the system knows that responses in either of those circles get mapped to the same output variable.

Finally, you create a fields file that lets you assign each letter to a field. There’s a number of field types spelled out in the readme. Don’t let the apparent complexity here discourage you too much – it’s actually fairly straightforward. Most of my issues dealt with image format problems, which you hopefully can avoid since you have this guidance.

5) I created the surveys in MS Word. I found that putting the “doughnuts” (which you can extract from a .PPT file they include) into two spots made the system work well. One should be 0.67 inches below the top of the page and 0.67 inches right of the left side of the page. The other should be 0.67 inches above the bottom of the page, and 0.67 inches left of the right side of the page. I used a 1.25 inch margin to keep all the scannable stuff inside a rectangle bounded by those “doughnuts”, but that might not be necessary. I created the answer circles using 14 point SimSum font and a specific character. The blank circles were Character Code 25CB, while the black circles were Character Code 25CF.

6) On troubleshooting: the instructions tell you not to touch the .config file that it makes. You can edit it, though, which can resolve some issues. Sometimes the template processing will identify a circle where none exist (especially with the letter o, for instance). You can delete them from the template (the .ASC file) and then remove them from the .CONFIG file as well, to ensure that your system doesn’t hiccup. Simply ID their location (column and row) in the .ASC file and then find the same entry in the .CONFIG file. The column and row measurements are given as the last numbers in each row in the section labeled “Marks”. Just delete the row. Sometimes a “ghost mark” or two will show up as well, with location 0 0 or something similar. You can edit that out as well.

7) One more point: the data that comes out will be a single file per PNG that is fed into the system. The file is formatted with variable=value, with one variable on each line. You can use a batch file to combine all the output files into a single file, and then it should be easy to write a SAS script to read them in.

In conclusion…

OMR is great stuff when it works, but it takes quite a bit of effort (regardless of whether you use something like Teleform or something like this free solution). Whenever possible, I think the best path is to put the survey on a computer, to eliminate the data entry step and the possibility of error. But, if you have to do paper, and you’re looking for a way around data entry, it’s worth looking at this. Up top, I said it was on the cheap. It isn’t, however, free – you’ll have to spend some time working at it. Make sure you budget that into any project you’re working on.

Hope this is helpful to people!

Comments are closed.