Apr 2024Automation1 min read

OMR Sheet Automation

Exam answer sheets were checked by hand, and simple scanners broke on skewed or smudged scans. I built a staged Python and OpenCV pipeline that reads them and resumes from failures instead of rerunning. It has processed more than 90,000 sheets and is still in use.

Staged Python optical-mark pipeline that processed 90,000+ exam sheets

Python / OpenCV / Optical Mark Recognition / Image Processing

90,000+

Paper exam sheets read

each page, a thousand sheets90,000+

A staged Python and OpenCV pipeline, still in production use.
Forms processed
90,000+
Pipeline shape
4 stages with resume-from-failure
Status
Still in production use at the org today

What it does

High-volume paper exams produce thousands of optical-mark sheets. Manual grading does not scale; naive single-pass scanners fail on skew, dust, low contrast, smudges, and partial erasures.

This pipeline stages the work: normalize → align → extract bubble density → score with rules, and keeps intermediate artifacts so a bad file does not force a full 90k re-run. It is built on open-source tooling (Python, OpenCV), and it is not a one-time batch job: the org still runs it, past the initial 90,000+ sheets.

Constraints

  • Distinguish real marks from faint erasures and print artifacts
  • Accept variable scan angle, DPI, and lighting
  • Process large batches without leaking memory
  • Leave an audit trail for ambiguous cells

Decisions & tradeoffs

  1. Four isolated stages with persisted intermediates
  2. Perspective / affine correction before density analysis
  3. Relative histogram density vs control margins (less sensitive to global lighting)
  4. Deterministic CV over ML: reproducible scores, no GPU dependency, smaller footprint
How a scanned sheet becomes a score
  1. 1Normalize

    Each scan is cleaned up for dust, low contrast and uneven lighting.

  2. 2Align

    Perspective and affine correction straighten skewed scans before anything is measured.

  3. 3Measure bubbles

    Bubble fill is read as density relative to control margins, so global lighting matters less.

  4. 4Score with rules

    Deterministic rules turn densities into answers. Ambiguous cells go to a review queue instead of a guess.

  5. 5Resume, not rerun

    Every stage saves its output, so one bad file never forces the 90,000-sheet batch to start over.

Tradeoffs: intermediate artifacts use disk and make edge-case tuning far cheaper. Deterministic math means no learned bubble detector: ambiguous cases go to a review queue instead.

What it demonstrates

  • Batch automation under real physical-document failure modes
  • Pipeline design that favors resume and auditability over a single monolithic script
  • Choosing boring, reproducible CV when stakes are institutional grading