Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix optical distortion #2009

Merged
merged 2 commits into from
Oct 23, 2024
Merged

Fix optical distortion #2009

merged 2 commits into from
Oct 23, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Oct 23, 2024

Fixes: #2007

Summary by Sourcery

Fix optical distortion in bounding boxes by updating the distortion_bboxes function and add comprehensive test cases to ensure correct behavior.

Bug Fixes:

  • Fix optical distortion in bounding boxes by updating the distortion_bboxes function to correctly transform corner points and reshape them back to bounding box format.

Tests:

  • Add new test cases for distortion_bboxes function to verify correct handling of identity mapping, simple translation, multiple bounding boxes, boundary conditions, and complex distortion patterns.

Copy link
Contributor

sourcery-ai bot commented Oct 23, 2024

Reviewer's Guide by Sourcery

This pull request fixes an issue with optical distortion in bounding boxes. The main changes involve modifying the distortion_bboxes function to use a more accurate method for transforming bounding boxes under distortion, and adding comprehensive test cases to verify the new implementation.

Updated class diagram for distortion_bboxes function

classDiagram
    class distortion_bboxes {
        +np.ndarray distortion_bboxes(np.ndarray bboxes, np.ndarray map_x, np.ndarray map_y, tuple<int, int> image_shape)
    }

    class distortion_keypoints {
        +np.ndarray distortion_keypoints(np.ndarray corners, np.ndarray map_x, np.ndarray map_y, tuple<int, int> image_shape)
    }

    distortion_bboxes --> distortion_keypoints : uses

    note for distortion_bboxes "Updated to transform corners using distortion_keypoints and reshape back to bboxes format"
Loading

File-Level Changes

Change Details Files
Refactored the distortion_bboxes function for improved accuracy
  • Removed the border_mode parameter as it's no longer needed
  • Changed the approach from using masks to directly transforming corner points
  • Utilized the distortion_keypoints function for corner transformation
  • Implemented min/max operations to form new bounding boxes from transformed corners
  • Added support for bounding boxes with additional attributes (e.g., class labels)
albumentations/augmentations/geometric/functional.py
Updated the OpticalDistortion transform to use the new distortion_bboxes function
  • Removed the border_mode parameter from the apply_to_bboxes method call
albumentations/augmentations/geometric/transforms.py
Added comprehensive test cases for the distortion_bboxes function
  • Created a new test function test_distortion_bboxes with multiple test cases
  • Included test cases for identity mapping, simple translation, multiple bboxes, boundary conditions, and empty arrays
  • Added a complex distortion test case using radial distortion pattern
tests/test_bbox.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ternaus - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ternaus ternaus merged commit a4884f6 into main Oct 23, 2024
14 checks passed
@ternaus ternaus deleted the fix_optical_distortion branch October 23, 2024 01:23
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.

[OpticalDistortion] Inaccurate Bbox output when distort_limit is high
1 participant