Fix motion tracker shapes not properly clipping out of frame - #1279
Open
doruphin wants to merge 9 commits into
Open
Fix motion tracker shapes not properly clipping out of frame#1279doruphin wants to merge 9 commits into
doruphin wants to merge 9 commits into
Conversation
doruphin
marked this pull request as ready for review
August 4, 2026 00:58
Contributor
There was a problem hiding this comment.
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->boundingBoxto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:

After:
