Skip to content

perf(vision): beat OpenCV on detection NMS - #35

Merged
rsasaki0109 merged 1 commit into
mainfrom
agent/nms-opencv-performance
Jul 15, 2026
Merged

rsasaki0109 merged 1 commit into
mainfrom
agent/nms-opencv-performance

Conversation

@rsasaki0109

Copy link
Copy Markdown
Owner

What changed

  • cache validated box areas across greedy NMS, batched NMS, and Soft-NMS overlap checks
  • borrow contiguous NumPy score arrays and retain the non-contiguous packing fallback
  • add native Criterion and schema-valid OpenCV Python NMS performance harnesses
  • publish Epic 114G results in README, ROADMAP, receipt, and GitHub Pages algorithm catalog

Why

NMS repeatedly recomputed both box areas for every candidate/selected comparison. Detection outputs commonly contain hundreds to 8,400 candidates, so invariant geometry dominated post-processing.

Correctness

  • ordered kept indices exactly match OpenCV dnn.NMSBoxes for deterministic 100, 1,000, and 8,400 candidate profiles
  • cached-area IoU is bit-identical to the public IoU implementation across overlap, disjoint, identical, and zero-area cases
  • contiguous and non-contiguous NumPy score arrays follow the same result path

Performance receipt

Windows 11, CPython 3.12.10, OpenCV 4.10, OpenCL off, randomized interleaved Python calls:

  • 100 candidates: SpatialRust 8.95x
  • 1,000 candidates: SpatialRust 3.82x
  • 8,400 candidates: SpatialRust 3.22x

Validation

  • spatialrust-vision detection tests: 5 passed
  • spatialrust-py binding tests: 68 passed, 1 skipped
  • OpenCV report contract tests: 8 passed
  • vision and Python crate Clippy with warnings denied
  • native Criterion detection benchmark
  • changed Rust file rustfmt check and git diff check

@rsasaki0109
rsasaki0109 marked this pull request as ready for review July 15, 2026 13:12
@rsasaki0109
rsasaki0109 merged commit 0c1f76d into main Jul 15, 2026
86 of 92 checks passed
@rsasaki0109
rsasaki0109 deleted the agent/nms-opencv-performance branch July 15, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant