Skip to content

fix: normalize rectangle rotations#476

Merged
tybulewicz merged 2 commits intomasterfrom
ttybulew/normalize-rotations
Jan 28, 2026
Merged

fix: normalize rectangle rotations#476
tybulewicz merged 2 commits intomasterfrom
ttybulew/normalize-rotations

Conversation

@tybulewicz
Copy link
Copy Markdown
Contributor

@tybulewicz tybulewicz commented Jan 27, 2026

Pull request overview

This PR normalizes rotated rectangle angles returned by OpenCV's minAreaRect function to ensure consistent angle representation within the (0, 90] degree range. OpenCV's minAreaRect can return angles in different ranges depending on rectangle orientation, which can lead to inconsistent results.

There was an issue introduced with OpenCV 4.13.0.90 where some rectangles were rotated in a different way then in previous versions, which broke comparisons in tests.

Changes:

  • Implemented angle normalization logic that adjusts angles to (0, 90] range by swapping width/height and adding/subtracting 90 degrees as needed
  • Updated test reference data to reflect the normalized angle values for rotated rectangles

Fixes #475

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@github-actions github-actions bot added tests Related to tests python python related changes labels Jan 27, 2026
@tybulewicz tybulewicz requested a review from Copilot January 27, 2026 12:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 normalizes rotated rectangle angles returned by OpenCV's minAreaRect function to ensure consistent angle representation within the (0, 90] degree range. OpenCV's minAreaRect can return angles in different ranges depending on rectangle orientation, which can lead to inconsistent results.

Changes:

  • Implemented angle normalization logic that adjusts angles to (0, 90] range by swapping width/height and adding/subtracting 90 degrees as needed
  • Updated test reference data to reflect the normalized angle values for rotated rectangles

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/model_api/models/utils.py Added normalization logic to ensure rotated rectangle angles are in (0, 90] range by adjusting width/height swap and angle offset
tests/accuracy/public_scope.json Updated expected test values to match normalized rotated rectangle representations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tybulewicz tybulewicz marked this pull request as ready for review January 27, 2026 12:12
@tybulewicz tybulewicz requested a review from a team as a code owner January 27, 2026 12:12
@tybulewicz tybulewicz enabled auto-merge January 27, 2026 13:35
@tybulewicz tybulewicz added this pull request to the merge queue Jan 27, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 27, 2026
@tybulewicz tybulewicz added this pull request to the merge queue Jan 28, 2026
Merged via the queue into master with commit 805a58a Jan 28, 2026
36 of 38 checks passed
@tybulewicz tybulewicz deleted the ttybulew/normalize-rotations branch January 28, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python python related changes tests Related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accuracy tests failing after opencv upgrade

3 participants