Skip to content

Refactor CV utility modules and add pytest coverage#3

Merged
mandaiy merged 2 commits intomainfrom
refactor
Feb 22, 2026
Merged

Refactor CV utility modules and add pytest coverage#3
mandaiy merged 2 commits intomainfrom
refactor

Conversation

@mandaiy
Copy link
Owner

@mandaiy mandaiy commented Feb 22, 2026

Summary

This PR reorganizes CV-related modules and adds initial pytest coverage for core utilities and geometry rotation behavior.

Changes

  • Refactored modules into clearer package boundaries (cv, albumentations, ultralytics) and updated exports.
  • Added and updated utility implementations across geometry, color, masking, matching, metrics, and PIL helpers.
  • Added unit tests for src/excvish/__init__.py, src/excvish/types.py, and rotation-focused paths in src/excvish/cv/geometry.py.
  • Added make test target and updated repository documentation, including structure and PR template docs.

Testing

  • make format
  • make lint
  • make test

Checklist

  • I updated relevant documentation under docs/.
  • I verified that the changes are backward compatible, or documented breaking changes.
  • I confirmed this PR is ready for review.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8eae71a08f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

from ..cv.geometry import compute_horizontal_rotation_angle, compute_min_area_rect, rotate_image


class AlignLongEdgeHorizontal(DualTransform):

Choose a reason for hiding this comment

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

P1 Badge Handle bbox/keypoint targets in AlignLongEdgeHorizontal

AlignLongEdgeHorizontal is declared as a DualTransform, so has_dual_transform marks it as spatial and the Ultralytics adapter passes bboxes/keypoints through this transform path, but this class only rotates image and mask and does not implement bbox/keypoint rotation. In detection/keypoint pipelines this will either leave annotations unrotated (misaligned labels) or raise at runtime depending on Albumentations internals, which can corrupt training results as soon as this transform is used with instances.

Useful? React with 👍 / 👎.

image,
rotation_matrix,
(new_w, new_h),
flags=cv2.INTER_LINEAR,

Choose a reason for hiding this comment

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

P2 Badge Use nearest interpolation when rotating masks

rotate_image hard-codes cv2.INTER_LINEAR, but this helper is also used for mask rotation (AlignLongEdgeHorizontal.apply_to_mask and rotate_rgba_by_mask_long_edge). Linear interpolation introduces intermediate label values on mask edges, so binary/class masks become corrupted after rotation, which can change foreground area and degrade segmentation/detection preprocessing.

Useful? React with 👍 / 👎.

@mandaiy mandaiy merged commit e30d758 into main Feb 22, 2026
1 check passed
@mandaiy mandaiy deleted the refactor branch February 22, 2026 12:45
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