Skip to main content

OMR detection

Grid model

The extractor models 40 questions as four columns of ten rows. Candidate bubble contours are filtered to area 80..2000, aspect ratio 0.5..2.0, and vertical center 300..1000.

Column centers are assigned by x-coordinate ranges:

Columnx range
1greater than 50 and less than 230
2greater than 230 and less than 410
3greater than 410 and less than 590
4greater than 590 and less than 800

For each candidate, the blurred grayscale mean must be below 165 to count as filled. Rows are derived from (cy - 380) / 51.5 and options from the column-specific starts [93, 275, 461, 645] using option spacing 32. Candidates are accepted only when the rounded row or option is within the implementation's tolerance (0.45 for rows and 0.48 for options).

Question number is column * 10 + row internally, then returned as one-based 1..40. Empty entries are returned as an empty string.

Multiple marks

When more than one option is detected for a question, the extractor concatenates the option letters and sorts them. A double-marked bubble therefore becomes a value such as AC, not a single selected option. Grading compares that string to the answer-key value, so it does not match a single-letter key.

These constants are implementation behavior, not a general-purpose form-recognition configuration.