Skip to content

Fix motion tracker shapes not properly clipping out of frame - #1279

Open
doruphin wants to merge 9 commits into
mltframework:masterfrom
doruphin:tracker_clip_shapes_out_of_frame
Open

Fix motion tracker shapes not properly clipping out of frame#1279
doruphin wants to merge 9 commits into
mltframework:masterfrom
doruphin:tracker_clip_shapes_out_of_frame

Conversation

@doruphin

@doruphin doruphin commented Aug 4, 2026

Copy link
Copy Markdown

This PR includes the changes in #1275

Previously, we would bound the bounding box center from 0 to height/width since opencv was crashing. This meant that shapes would draw weirdly at boundaries. The crash only came from the blur, as drawing shapes out of bounds works fine as expected, so this moves the bounding logic to the blur only.

Before:
Screenshot 2026-07-29 182806

After:
Screenshot 2026-08-03 171554

@doruphin doruphin closed this Aug 4, 2026
@doruphin doruphin reopened this Aug 4, 2026
@doruphin
doruphin marked this pull request as ready for review August 4, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the OpenCV motion tracker filter so tracked shapes can extend outside the frame without forcing the tracked bounding box back into frame bounds, while still safely clipping the blur ROI to avoid OpenCV crashes. This aligns shape drawing behavior with expected rendering at frame edges and keeps blur processing constrained to valid image coordinates.

Changes:

  • Remove in-place clamping of data->boundingBox to frame bounds and instead compute a clipped ROI (clippedBox) specifically for blur operations.
  • Rework blur application to operate on an ROI and copy results back (optionally masked for ellipse shape).
  • Use an explicit OpenCV line type constant (cv::LINE_4) when drawing the ellipse overlay.

Comment thread src/modules/opencv/filter_opencv_tracker.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@doruphin
doruphin requested a review from ddennedy August 5, 2026 00:34
@ddennedy
ddennedy requested a review from j-b-m August 5, 2026 05:06
@ddennedy ddennedy added this to the v7.42.0 milestone Aug 5, 2026
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.

3 participants