Skip to content

Fix/ImgDetectionFilter segmentation mask reindexing#306

Merged
tadeas0 merged 1 commit into
mainfrom
fix/img_detection_filter_seg_mask_reindexing
Jul 15, 2026
Merged

Fix/ImgDetectionFilter segmentation mask reindexing#306
tadeas0 merged 1 commit into
mainfrom
fix/img_detection_filter_seg_mask_reindexing

Conversation

@tadeas0

@tadeas0 tadeas0 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

Reindex segmentation masks in ImgDetectionsFilter to match the new filtered detection list indices.

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

Added unit tests for this modified behavior. Validated all oak-examples with ImgDetectionsFilter still work as before.

AI Usage

Assisted-by: Pi Coding Agent:GPT-5.5

Submitted code was reviewed by a human: YES

The author is taking the responsibility for the contribution: YES

Summary by CodeRabbit

  • Bug Fixes

    • Improved segmentation-mask updates after filtering, sorting, non-maximum suppression, and limiting detections.
    • Preserved correct instance and class labels for retained detections.
    • Handled invalid mask labels and cases with no remaining detections by treating affected areas as background.
  • Tests

    • Added coverage for mask behavior across detection filtering and truncation scenarios.

@github-actions github-actions Bot added the fix Fixing a bug label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b8b9c951-e449-4940-9677-23773eb0d98d

📥 Commits

Reviewing files that changed from the base of the PR and between 60c8202 and 4581d25.

📒 Files selected for processing (2)
  • depthai_nodes/node/img_detections_filter.py
  • tests/unittests/test_nodes/test_host_nodes/test_img_detections_filter_node.py

📝 Walkthrough

Walkthrough

ImgDetectionsFilter now preserves original detection indices through filtering, NMS, sorting, and truncation, then uses those indices to remap segmentation masks. Unit tests cover reordered, suppressed, truncated, invalid, and empty detection results.

Changes

Detection filtering and mask handling

Layer / File(s) Summary
Indexed detection processing
depthai_nodes/node/img_detections_filter.py
Filtering, NMS, sorting, and first_k selection now operate on indexed detection tuples before rebuilding the output detection list.
Segmentation-mask remapping and validation
depthai_nodes/node/img_detections_filter.py, tests/unittests/test_nodes/test_host_nodes/test_img_detections_filter_node.py
Segmentation masks are remapped using kept original indices, with tests covering sorting, NMS, truncation, invalid labels, and empty outputs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: klemen1999, tersekmatija

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: reindexing segmentation masks in ImgDetectionsFilter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/img_detection_filter_seg_mask_reindexing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.21%. Comparing base (60c8202) to head (4581d25).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #306      +/-   ##
==========================================
+ Coverage   48.18%   48.21%   +0.03%     
==========================================
  Files          99       99              
  Lines        6438     6442       +4     
==========================================
+ Hits         3102     3106       +4     
  Misses       3336     3336              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@klemen1999 klemen1999 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tadeas0
tadeas0 merged commit c136883 into main Jul 15, 2026
13 checks passed
@tadeas0
tadeas0 deleted the fix/img_detection_filter_seg_mask_reindexing branch July 15, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants