HOME - - - - - Lazarus Tutorials TOC - - - - - - Programming Challenges TOC - - - - - - OMR Challenge Main Page - - - - - -

Find the corners- sub-task of...

OMR- Optical Mark Recognition programming challenge

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

This page is some ideas I hope will help you if you've decided to accept the challenge to write code for a system to do optical mark recognition. I.e. to turn ink-on-paper response forms for a multiple choice test or survey into machine readable data.

If you haven't already read the overview page for the "create OMR software" challenge, then read it before you study this. (There's a link to this from there.)

One sub-task of that would be creating the code to determine the coordinates of the four registration marks in the corners of each response form.

Details

The marks could be like what you see 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.

You might think that "straightening up" the image between loading the raw scan and trying to analyze where the corners are would be useful. That makes the next phase of capturing the data easier... but I'm not sure it's the way to go.

I think I'd use a system that calculated where each response cell is from the coordinates of the four reference marks, and the "ideal" of where the response cells should be.

To every simple question there is a simple answer. But it is often wrong!

Note the shape chosen for the registration marks. You could use a different shape.

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

Originally, I said that 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.)

On reflection, I realized that was a Bad Idea. (Can you see why?) It would be better (I think at the moment!) to find the coordinates of the "outside" corner of the mark, i.e. the upper left corner of the upper left mark.

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 for finding the corners of the registration marks on a set of response forms 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
  [A huge chunk of code will go here in the final "do it all" code]
Until user has had enough

The config file...

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

I spoke briefly about the config file in the overview of this challenge. 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!

Please remember that this page is merely a sub-page of a big challenge. There's a different webpage with an overview of the "create an OMR system" challenge.

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 my sites with a Google search...

This searches wywtk, skywoof, sheepdogguides, sheepdogsoftware and arunet... but doesn't always give all of the pages that have content which matches the criterion.

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 .....