HOME - - - - - Lazarus Tutorials TOC - - - - - -

OMR- Optical Mark Recognition

We can do this!

Page URL: lt8n-chall-omr-corners.htm

This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a narrow window. With most browsers, pressing plus, minus or zero while the control key (ctrl) is held down will change the texts size. (Enlarge, reduce, restore to default, respectively.) (This is more fully explained, and there's another tip, at my http://www.arunet.co.uk/tkboyd/hh3d.htm Power Browsing page.)

I've been shirking a project for years. It seemed too big. It seemed the sort of thing that someone else would write, and save me the trouble.

Well... no one else has written what I want. And, the more I think about it, the more I think I can do this!

Also, I now have a wonderful scanner. (The software that comes with it adds enormously to it's utility.) I can turn 10 pages of a book into a .pdf... or a pretty well OCR'd word file... in about two minutes with it. (It is a Czur Shine Ultra.. £140 (2/24))

What I want to do...

I want to be able to administer multiple choice tests or surveys, without much hassle over converting responses to data files.

I dream of the people responding using an ordinary multiple choice answer sheet, and then I will just scan the sheets, and, presto, the computer will spit out feedback for test takers, and compiled results for me for tests or surveys.

How hard can it be? It will be fun!

The challenge...

I hope you'll have fun with this in any language you like working with. As I like using Lazarus, I would be particularly interesting in any Lazarus solutions.

I would also be interested in any documentation you generate in the course of attempting this challenge. I'd be happy to "showcase" good efforts here. I am most likely to reward you with publicity if you simply supply me with a link to material published by you on the web.

The sheet the users will enter their responses on will have four marks in its corners, as shown in the illustration.

((Image lt8n-chall-omr-simple.jpg should appear here))

It will also, of course, have... not shown in the illustration... a grid with boxes to fill in... a column for each possible answer, a row for each question.)

          a  b  c  d  e
1.       o  o  o  o  o
2.       o  o  o  o  o
3.       o  o  o  o  o
4.       o  o ... etc

All you need to do...

... to accomplish the challenge I'm presenting is to write a program to determine the coordinates of the four registration marks in the corners!

Details

So... that's the general idea. Here are some specifics for you...

The images from which you have to extract the mark coordinates will be supplied as .jpgs from a scanner.

The marks will be pretty well as you see them in the illustration. Note that due to the exigencies of scanning...

To be useful to a wide audience...

You are allowed to assume that there is (almost) no black outside the polygon defined by the four marks... except in an error state. You should probably set up "zones". You might allow a narrow "anything goes" zone around the edges of the image, to allow for slightly misaligned sheets having a little black on one or more edges. You certainly should define a "should be white" zone just outside the polygon defined by the four marks. (The width of it would be one of the things that should be user-set-able.

For simplicity, let's agree that the marks, on a perfect scan, will be equally spaced from each of the adjacent sheet edges.

Your program should have a "diagnostic" mode in which an graphic is generated to show what the program looked at while it was trying to find the registration marks.

"Extra credit" goes to anyone who provides for "straightening up" the image between loading the raw scan and trying to analyze where the corners are.

Note the shape chosen for the registration marks. You are encouraged to work with that shape, but if you have strong reasons to use a different shape, and explain them, fine.

The inward pointing element ends in a point below and inside where the corner would be if the shape were a simple square.

The challenge is to find the x, y coordinates of the tips of the four inward pointing elements. In pixels from the upper left corner of the internal representation of the sheet being processed by the software. (Those four x/y pairs are, of course, the starting point for the next stage of this project... "reading" the user's responses to the questions.)

If you think carefully, there are various things you can do to make your code elegant.

Broad outline of code...

Here's a sketch of what the code should look like...

Set up various arrays, etc.
Read config file.
Fill sundry global variables.

Repeat...
  Ask user to specify a file held on storage the program can access
  Load that into an image object on the screen
  Examine the image
  Display the coordinates, in pixel terms, of the four inward facing points
Until user has had enough

Returning to the config file...

(If config files are not something you're already using comfortably, I've done a tutorial on config/ ini files.)

The config file could hold values for such things as...

The net effect of the following tell the software where it needs to look for the registration marks: rtAspRat, rtIgnoreOuter, rtrtRegMkZoneOuter, rtRegMkZoneInner.

I would also put my wants in respect of the resolution used by the program into the config file. I.e. how big I want the image component the raw data will be loaded into. I'd specify it by a value to be loaded into rtImgWidth. That value in pixels. (rtImgHeight would be involved as well, calculated from rtImgWidth and rtAspRat.)

Good luck!

Why did I write this up? I hope it will be a fun challenge for schools, hobbyists, etc. Also it helped me focus my thoughts about how I am going to proceed, when I write my own version of this. No time spent planning before you write any code is ever wasted!!!

As I said, I'd be delighted to post links to web pages talking about how you proceeded with this challenge.





Search across all my sites with the Google search...

Custom Search

Use this to search THIS site.... (Go to my other sites, below, and use their search buttons if you want to search them.)

(Alas... my Lazarus material is split across two sites... SheepdogGuides.com and WYWTK.com. Sorry!)

index sitemap advanced
search engine by freefind

Site Map    What's New    Search

This search engine is "old skool"- it merely looks for the words you type, so....
*    Spell them properly.
*     Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....


Please also note that I have three other sites, and that this search will not include them. They have their own search buttons.

My WhatYouWantToKnow site- https:/wywtk.com.

My SheepdogSoftware.co.uk site.

http://www.arunet.co.uk/tkboyd/index2.htm: My site at Arunet. (Sorry.. not httpS accessible)


Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to Lazarus Tutorials main page

To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcomed! Please cite "lt8n-chall-omr-corners.htm".




Valid HTML Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes.

AND passes... Valid CSS!

Click either icon to run its test. You may need to enter URL of page to be checked by hand, kin the case of the CSS check, by editing the entry in address box.

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....