TES76
TES76

Reputation: 43

How to detect checked box using python

I have the below PNG image and I am trying to identify which box is checked using Python.

I installed the OMR (optical mark recognition) package https://pypi.python.org/pypi/omr/0.0.7 but it wasn't any help and there wasn't any documentation about OMR. So I need to know if there is any API or useful package I can use with Python.

Here is my image:

image

Upvotes: 4

Views: 3709

Answers (1)

jcoppens
jcoppens

Reputation: 5440

If you're not afraid of a little experimenting, the Python Imaging Library (PIL, download from http://www.pythonware.com/products/pil/ or your favorite repo. Manual: http://effbot.org/imagingbook/pil-index.htm) permits loading the PNG, and accessing it.

You can extract a section of the image (eg. the interior of a checkbox. See crop in the library), and sum the pixels in that sub-image (see point). Compare that with a threshold (say > 10 pixels = checked).

If the PNG comes from scanning forms, you may have to add some positional checking.

Upvotes: 5

Related Questions