Open source Optical Mark Recognition: a handy tool for cross-sectional research

September 30, 2008

For a medical student, questionnaire-based short term cross-sectional studies are shortcuts to research papers. A little more effort in study design and we can turn them into some kind of case-control study or at least publish it in a fairly reputed journal, a feat for someone at our level.

While designing one such cross sectional study, a friend wondered if we can use a scantron-like system on our questionnaire to automate data entry. This would save us time and increase accuracy, at least relatively. On each questionnaire, there could be bubbles to shade for multiple-choice questions, just like SAT or TOEFL. Once we get the questionnaire back from our respondents, we would shade out corresponding bubbles for the choices they made. Then, we would simply run it through a document feeding scanner (not a flatbed, that would be way more laborius) and finally, run it through a computer program that would look at the scanned file, see what bubbles are shaded, translate that into what choices the respondent made and make it available in a format friendly to SPSS or some other statistical package. Looking at shaded areas and recognizing them is called Optical Mark Recognition or OMR.

A little research and I found that there were no open-source or freeware/shareware OMR solutions available except one developed by Aaditeshwar Seth at Udai Waterloo Chapter. It was called the Udai OMR tool and developed for an Indian NGO initially, later made available for all NGO and non-profit use. The tool is written in Java and although it is not the most user-friendly piece of software around, it is the only free OMR software and it actually works. Once you make a questionnaire with the right spots to shade using the templates they provide on their website, you first scan an all-bubbles-shaded questionnaire for the program to recognize where to look for. Then, you assign variables and values to all sites recognized and finally, you start reading your forms. It reads one form at a time and writes the data to a text file. So for each page/form, you have to run the program again and it makes a new text file.

About 3-4 days of continuous fidgeting with this and then about a day to automate so that multiple pages can be read in a sequence and the data is handled and stored into a quick database and there, the next study I am part of is using OMR :)

Tags: , , , ,

38 Responses to “Open source Optical Mark Recognition: a handy tool for cross-sectional research”

  1. SIKI Says:

    I used this tool and it actually worked. But i want to read multiple scanned papers. do i have to write a java class that loops for several papers??

  2. Murtaza Says:

    Hi.. I wrote a VB.NET program that does that for me. I wasn’t too comfortable with java and didn’t want to spend the time to learn the relevant areas. If you want I can send you the code for what I have done in VB. It basically reads 2 pages of a questionnaire and deciphers them. then stores the data in an XML data file and exports on demand to csv. Interested?

    • Anup Pawaskar Says:

      Dear Murtaza,
      My name is Anup A.Pawaskar. I am currently pursuing B.E.( Computer Engineering) from the Don Bosco Institute of Technolgy, Kurla (W.), Mumbai.
      I am currently studying in the final year . As a part of my final year project, my group plans to develop a “PC based mark reader.” for scanning and evaluating OMR sheets.
      We plan to develop this as a GUI based open source software using a programming language such as VB.net.

      We will be very thankful if you can send us some more information regarding this topic and the working of the OMR code developed by you.Thank you.
      kindly reply at pawaskaranup@gmail.com

    • hami Says:

      HI Murtaza
      could you send me the code in VB?
      thank you

    • Ram Says:

      Hi Murtaza,
      Thanks for the great work. I am looking for the similar software. can u please send me the code.

      Regards,
      Ram

  3. Rajeev Says:

    Hi Murtaza,
    Could you send me the code in vb?

    Rajeev

  4. Rajeev Says:

    Thank you and I am still trying to download it! Have you done any surveys using the same?

  5. Murtaza Says:

    Yes, one is ongoing. A doctors study actually.. but it lets me get away without entering lots of data by hand. Let me know if you can’t download it and i will find another way to send it to you. Good luck.

  6. Rajeev Says:

    I got it. But now i need to put up with vb .net! I will try someone who knows at my end!

  7. Mihir Says:

    Murtaza,

    I am also very much interested in similar code.
    Could you send me your code?

    Also can somebody help me giving instructions on how to execute Udai OMR tool?
    It is failing on my system with following error:

    I am trying to execute it with Java 5 Update 12 and creation of template step is failing with error:
    C:\Documents and Settings\Administrator\My Documents\tambe CET\software\OMRProj>
    java -cp “dist/OMRProj.jar;dist/lib/jiu.jar” omrproj.ProcessTemplate 2circletif.
    TIF
    Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version n
    umber in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    C:\Documents and Settings\Administrator\My Documents\tambe CET\software\OMRProj>

    I tried with Java 6 Update 12. It is failing as well.

    C:\Documents and Settings\Administrator\My Documents\software\OMRProj>
    java -cp “dist/OMRProj.jar;dist/lib/jiu.jar” omrproj.ProcessTemplate
    Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0
    at omrproj.ProcessTemplate.main(ProcessTemplate.java:25)

    C:\Documents and Settings\Administrator\My Documents\software\OMRProj>
    java -cp “dist/OMRProj.jar;dist/lib/jiu.jar” omrproj.ProcessTemplate 2circle.gif

    java.lang.NullPointerException
    at omrproj.ImageUtil.readImage(ImageUtil.java:28)
    at omrproj.ProcessTemplate.main(ProcessTemplate.java:27)

    C:\Documents and Settings\Administrator\My Documents\software\OMRProj>

    Thanks!
    mihirnimbalkar [at] gmail [dot] com

  8. David Blewett Says:

    Hi Murtaza:

    I would like to take a look at your code if you don’t mind as well. Is it hosted somewhere? Thanks.

  9. MH Says:

    Mihir and David, just sent it to both of you. Let me know if I can be of help.

    Murtaza

  10. J.D. Says:

    Murtaza,

    Could you send me your vb code as well?

    Thanks!

  11. Fabian Says:

    Murtaza, could you please send me your vb code.

    fperich@terra.cl

    very much thanks


  12. Hi Murtaza, I was randomly browsing around and noticed that you’d actually extended the OMR software. I’d wanted to do this myself, but I’ve been awfully busy lately. It will be wonderful if you can publish your changes somewhere, or send them to me so that I can try to integrate them. Thanks again!

    Adi

  13. Giovanni Says:

    Reply to Mihir:

    I can’t help you with your problems with java 5.

    With Java 6 I experienced some problems too and found that:

    - Input images must have a colordepth of 24 bits
    - Input images must not exceed about 24M
    - Program fails with jpeg, bmp and compressed tif, but works ok with uncompressed tif and png
    - A4 images with a resolution of 72 dpi cause a crash of the program


  14. Hi Murtaza,

    Thanks for your hard work…could you send me your VB code! I would really appreciate it.

    Thanks!

  15. Aditya Says:

    Hi Aditeshwar/Murtaza

    I downloaded the source code of OMR Tool and tried to run it on the image provided with the download ie “2circle-org-colored-whole.gif”

    I am getting the same error Mihir got.
    java.lang.NullPointerException
    at com.psl.omr.ImageUtil.readImage(ImageUtil.java:19)
    at com.psl.omr.ProcessTemplate.main(ProcessTemplate.java:21)

    Can you tell me, what’s wrong with the code or image ?

    Thanks

  16. Aditya Says:

    Giovanni,

    how to check colordepth of an image ?

    Thanks

  17. Greg Says:

    Murtaza, could you send me the VB code, too?

    Thanks!

  18. jim stevens Says:

    Hi – could you send me the vb code as well. Thanks a lot!

  19. Kevin Rusch Says:

    Murtaza,
    Looks like you have some popular code. Can you send it to me as well?

    Thanks!

  20. Lookman Says:

    Hi could you send me the VB code as well
    thanks!

  21. Indressh Says:

    I want to make project in java n my project is optical mark recognisation…
    m beginners in java,
    somebody help me..

  22. Deivid Says:

    Hi Murtaza, your code is exactly what i need, also i need it in .net =) .. Can you send it to me as well?
    Thnks!

  23. mark william Says:

    Hi Murtaza, can you also provide me with the VB code. I am developing a grassroots survey project and I’m sure this will be a great help. I will also share my experiences with this project of mine. Thanks

  24. Murtaza Says:

    Just sent some of you a note with the code. Let me know if I can be of any further help. Good luck.

  25. Anthony Richards Says:

    Dear Murtaza,

    Will appreciate your VB code. I am associated with educational institutions and am sure your efforts in OMR will be highly helpful and appreciated. Regards

  26. Ezio Says:

    Hi Murtaza,
    I would like to take a look at your code,could you send me your vb code as well?
    thank you.

  27. Murtaza Says:

    It seems there has been quite some interest on this post and a lot of us would like to use this software. Can we put together a collaboration of sorts to extend this software (keeping it open source) and include perhaps a decent GUI and versions that can be run as a desktop application as well as automated?

    Any one who is interested, please comment here and if we have a decent group of people put together, we can have a go at this. Udai (the original developer), your input on this will be welcome.

    Thanks,
    Murtaza

  28. Luca Says:

    Hi Murtaza, I would be interested in your vb code? Could you send it to me as well?
    Thanks.

  29. Tusar Says:

    If any one have successfully run the omr .
    Plz send me the sample images & code .
    trytusar@gmail.com

  30. Claude Says:

    Hi Murtaza,
    I would appreciate to get a copy your vb code about OMR.
    Thanks.

  31. Tusarkant Sahoo Says:

    I ahve the follwing error
    ————————
    00000…..
    199:268:1464:1974
    curr angle = 36.55695648693926
    curr diag = 2123.831678829563
    scaledtop: 39:53
    scaledbot: 292:394
    nummarks = 25739
    Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 50
    at omrproj.ImageManipulation.filter(ImageManipulation.java:313)
    i->50178:Found j->50179:Found j->51177:Found j->51178:Found j->51179:Found j->52177:Found j->52178:Found j->52179:Found j->53177:Found j->53178:Found j->53179:Found j->54177:Found j->54178:Found j->54179:Found j->55177:Found j->55178:Found j->55179:Found j->56177:Found j->56178:Found j->56179:Found j->57177:Found j->57178:Found j->57179:Found j->58177:Found j->58178:Found j->58179:Found j->59177:Found j->59178:Found j->59179:Found j->60177:Found j->60178:Found j->60179:Found j->61177:Found j->61178:Found j->61179:Found j->62177:Found j->62178:Found j->62179:Found j->63177:Found j->63178:Found j->63179:Found j->64177:Found j->64178:Found j->64179:Found j->65176:Found j->64175:Found j->63174:Found j->63173:Found j->63172:Found j->63171:
    at omrproj.ImageManipulation.locateMarks(ImageManipulation.java:121)
    at omrproj.ProcessTemplate.main(ProcessTemplate.java:34)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 11 seconds)

    =======================
    Image: scan1.png
    SIZE: 3.84MB
    Width: 1700 pixels
    Height:2338 pixels
    Horizontal Resolution:199 dpi
    Vertical Resolution:199 dpi
    Bit Depth:24
    Frame Count:1

    trytusar@gmail.com
    plz help me

  32. MH Says:

    I think you need a higher resolution scan.


Leave a Reply