Skip to main content

checkbox-extractor

Finds ticked checkboxes and radio buttons in scanned or photographed forms and returns JSON. No template is needed: boxes are found from their outline, grouped into questions, and each group gets its header text from Tesseract OCR plus the positions of the ticked boxes.

Install

pip install .                      # or: pip install -e . while developing
sudo apt install tesseract-ocr poppler-utils   # OCR, and PDF support

Command line

checkbox-extract form.jpg
checkbox-extract form.pdf -o result.json --debug-dir debug/
checkbox-extract scans_folder/ --threshold 0.12 --lang eng+hin

python -m checkbox_extractor works the same way.

Output (one page):

{
  "source": "form.jpg",
  "page": 1,
  "checkbox_count": 5,
  "ticked_count": 2,
  "groups": [
    {"header": "Gender", "total": 2, "ticked": [1], "ticked_labels": ["Male"]},
    {"header": "Smoker?", "total": 3, "ticked": [2], "ticked_labels": ["No"]}
  ]
}

ticked holds 1-based positions. Add --full to also get every box's label, shape, fill ratio and bounding box (useful when tuning --threshold).

Python

from checkbox_extractor import extract

result = extract("form.jpg")
for group in result["groups"]:
    print(group["header"], group["ticked"])

result = extract("form.jpg", full=True)   # detailed output

# an image already in memory (BGR numpy array, e.g. from cv2.imread)
result = extract(image, threshold=0.12)

A PDF or a folder returns a list with one result per page.

Tests

bash test_forms/run_tests.sh       # fixed sample forms
python3 test_forms/fuzz_forms.py   # random generated forms

Metadata

Release files for checkbox-extractor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for checkbox-extractor 0.1.0
File Size Uploaded Provenance Actions
checkbox_extractor-0.1.0.tar.gz 17.1 kB Without provenance Details for checkbox_extractor-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for checkbox-extractor 0.1.0
File Interpreter ABI Platform Actions
checkbox_extractor-0.1.0-py3-none-any.whl Python 3 none any Details for checkbox_extractor-0.1.0-py3-none-any.whl

Total release size: 34.2 kB

Release files / checkbox_extractor-0.1.0.tar.gz

Download URL checkbox_extractor-0.1.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
621b6c7551546fea76dd9f817040ab677ab84ae359e1813f1e9df6f3d25c345a
BLAKE2b-256 checksum
How to use checksums
186776ba93f2d33b598e8a826ffade7cd4f4c8e0422e983469defdfa048c044c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / checkbox_extractor-0.1.0-py3-none-any.whl

Download URL checkbox_extractor-0.1.0-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9abc122b9ff03dac17df103d45d9091d8cce8e270d56aa1b11e8ab5a4e8fd822
BLAKE2b-256 checksum
How to use checksums
b067e08422a025f729233e2241e81af979b2afa6d60d3d81eba7bc0bba975936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for checkbox-extractor 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page