Skip to content

perf(polygon-annotator): crop mask to bbox before findContours to reduce scan area#2275

Draft
jeku46 wants to merge 1 commit intomainfrom
improve-visualization-block-speed
Draft

perf(polygon-annotator): crop mask to bbox before findContours to reduce scan area#2275
jeku46 wants to merge 1 commit intomainfrom
improve-visualization-block-speed

Conversation

@jeku46
Copy link
Copy Markdown
Contributor

@jeku46 jeku46 commented Apr 25, 2026

perf(polygon-annotator): crop mask to bbox before findContours to reduce scan area

What does this PR do?

Instead of running mask_to_polygons on the full frame mask, crop to the detection bounding box first and offset the resulting polygon points back to full-frame coordinates. Adds a coordinate-correctness test that would catch a broken offset (existing tests used origin-aligned detections where the +[0,0] offset is a no-op).

Related Issue(s):

Type of Change

  • Refactoring (no functional changes)
  • Other:

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:
I ran this code change on the pella edge devices and the masks drew as before. I also verified there was a significant speedup in the block.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

…uce scan area

Instead of running mask_to_polygons on the full frame mask, crop to the
detection bounding box first and offset the resulting polygon points back
to full-frame coordinates. Adds a coordinate-correctness test that would
catch a broken offset (existing tests used origin-aligned detections where
the +[0,0] offset is a no-op).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jeku46 jeku46 force-pushed the improve-visualization-block-speed branch from 2bbf36f to 7b84b73 Compare April 25, 2026 21:23
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