Skip to main content

checkboxer / npboxdetect

Fastest checkbox detector. NumPy + Numba. No deep learning.

Benchmark

Approach p50 (ms) boxes vs npboxdetect
npboxdetect 34ms 69 baseline
boxdetect 60ms 67 1.8x slower
opencv_contours 33ms 179 ~same (but noisy)
morphology 34ms 25 ~same (misses many)

50-run p50, full pipeline including imread, on 2200×1700 document images.

Pure processing (imread excluded):

Image npboxdetect boxdetect Speedup
lc_application1.png 6.5ms 25.5ms 3.9x
lc_application2.png 7.1ms 18.6ms 2.6x

Usage

from npboxdetect.detector import get_boxes

boxes = get_boxes("form.png")
# [(x, y, w, h), ...]

How it works

Five steps, all near-hardware-limit:

downsample 2x        ~0ms   stride view, zero copy
otsu + threshold      1.4ms  fused numba: histogram → binarize in one shot
morph open            1.3ms  numba parallel run-length scan (rows+cols)
connected components  1.3ms  cv2.connectedComponentsWithStats
NMS                   0.2ms  vectorized pairwise IoU matrix
─────────────────────────────
processing total      ~6ms

Key ideas:

  • 2x downsample before processing — free stride view, halves pixel count
  • Fused numba otsu+threshold — one serial histogram pass + one parallel binarize pass, no cv2 call
  • Run-length morph open — each row/column independent → prange parallelism, no cumsum overhead
  • Filter before NMS — size/ratio filter drops 1000+ blobs to ~70 before NMS

Install

git clone https://github.com/santhoshkammari/checkboxer
cd checkboxer
pip install numba opencv-python numpy

Journey

See JOURNEY.md (v0→v6, 4248ms→37ms) and JOURNEY2.md (v7→v10, 37ms→6ms).

Author

santhoshkammari

Metadata

Release files for npboxdetect 0.1.2

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

Source distribution (sdist)

Source distribution for npboxdetect 0.1.2
File Size Uploaded
npboxdetect-0.1.2.tar.gz 17.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for npboxdetect 0.1.2
File Interpreter ABI Platform
npboxdetect-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 MB

Release files / npboxdetect-0.1.2.tar.gz

Download URL npboxdetect-0.1.2.tar.gz
Size 17.3 MB
Tags Source
SHA-256 checksum
How to use checksums
d72a50c6db53b6670e1e89e157c932dfb54b814d06f2a60f9f6fe4ea4a840689
BLAKE2b-256 checksum
How to use checksums
03268f4c6c07914e46e5effaa5410b91983f5466a59b8b92a95ef56f5349d3a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / npboxdetect-0.1.2-py3-none-any.whl

Download URL npboxdetect-0.1.2-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15c7dcd07ebdc9e15ffc1c2c7d2ef69505cdc659134e2cf95ae941466d0a5545
BLAKE2b-256 checksum
How to use checksums
472fb40d82c7ae31c271569448cfa229def726ef95acdada709df4769d8c265f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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