Skip to content

perf(vision): accelerate Soft-NMS beyond OpenCV - #37

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

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

Conversation

@rsasaki0109

Copy link
Copy Markdown
Owner

What changed

  • replace Soft-NMS repeated sorting/removal with a one-pass active-candidate decay, compaction, and next-best scan
  • short-circuit disjoint IoU work and borrow contiguous Python score arrays without an unconditional copy
  • add exact sorting-reference regressions, non-contiguous Python coverage, and Criterion baselines
  • add a reproducible OpenCV comparison harness and publish results in the README, roadmap, algorithm catalog, vision page, and measurement note

Why

Soft-NMS is useful for crowded detections because it decays overlapping scores instead of removing every overlap. The existing implementation preserved the algorithm but repeatedly sorted and shifted the candidate vector, adding avoidable overhead.

Measured impact

On the documented Windows 11 / Intel 6-core test host, SpatialRust is 3.42x to 7.40x faster than OpenCV 4.10 across linear and Gaussian Soft-NMS workloads from 100 to 8,400 boxes. Selected indices match exactly; maximum updated-score error is 1.79e-7.

Validation

  • cargo test -p spatialrust-vision --features detection (8 passed)
  • cargo clippy -p spatialrust-vision --all-targets --features detection -- -D warnings
  • cargo clippy --manifest-path crates/spatialrust-py/Cargo.toml --all-targets -- -D warnings
  • Python binding tests (67 passed, 1 skipped)
  • OpenCV report contract tests (8 passed)
  • changed Rust files pass rustfmt --check
  • cargo doc -p spatialrust-vision --features detection --no-deps

Workspace-wide rustfmt still reports the repository's pre-existing formatting baseline in unrelated files such as stereo.rs; this slice does not modify those files.

@rsasaki0109
rsasaki0109 marked this pull request as ready for review July 15, 2026 14:15
@rsasaki0109
rsasaki0109 merged commit 6591132 into main Jul 15, 2026
86 of 92 checks passed
@rsasaki0109
rsasaki0109 deleted the agent/soft-nms-opencv-performance branch July 15, 2026 14:20
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