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

Add fisheye #2157

Merged
merged 3 commits into from
Nov 19, 2024
Merged

Add fisheye #2157

merged 3 commits into from
Nov 19, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Nov 19, 2024

Summary by Sourcery

Add fisheye distortion model to the OpticalDistortion class, enabling users to choose between camera matrix and fisheye models for image transformations.

New Features:

  • Introduce fisheye distortion model to the OpticalDistortion class, allowing for direct radial distortion effects.

Enhancements:

  • Add support for selecting between camera matrix and fisheye distortion models in the OpticalDistortion class.

Copy link
Contributor

sourcery-ai bot commented Nov 19, 2024

Reviewer's Guide by Sourcery

This PR adds a new fisheye distortion model to the OpticalDistortion transform class. The implementation splits the distortion logic into two separate models: the original camera matrix model and the new fisheye model. The changes include new utility functions for generating distortion maps and updates to the OpticalDistortion class to support both models.

Class diagram for OpticalDistortion with fisheye model

classDiagram
    class OpticalDistortion {
        -tuple[float, float] distort_limit
        -tuple[float, float] shift_limit
        -Literal["camera", "fisheye"] mode
        -int interpolation
        -int border_mode
        -ColorType|None value
        -ColorType|None mask_value
        -int mask_interpolation
        -float p
        -bool|None always_apply
        +get_params_dependent_on_data(params: dict[str, Any], data: dict[str, Any]) dict[str, Any]
        +get_transform_init_args_names() tuple[str, ...]
    }
    note for OpticalDistortion "Supports two distortion models: camera and fisheye"
Loading

Class diagram for new utility functions

classDiagram
    class UtilityFunctions {
        +get_camera_matrix_distortion_maps(image_shape: tuple[int, int], cx: float, cy: float, k: float) tuple[np.ndarray, np.ndarray]
        +get_fisheye_distortion_maps(image_shape: tuple[int, int], cx: float, cy: float, k: float) tuple[np.ndarray, np.ndarray]
    }
    note for UtilityFunctions "Functions to generate distortion maps for camera and fisheye models"
Loading

File-Level Changes

Change Details Files
Added new utility functions for generating distortion maps
  • Implemented get_camera_matrix_distortion_maps function to handle the original camera model
  • Implemented get_fisheye_distortion_maps function using direct radial distortion formula
  • Both functions return x and y displacement maps
albumentations/augmentations/geometric/functional.py
Enhanced OpticalDistortion class to support multiple distortion models
  • Added 'mode' parameter to switch between 'camera' and 'fisheye' models
  • Updated documentation to describe both distortion models
  • Modified shift limit calculation to be relative to image dimensions
  • Refactored distortion map generation to use the new utility functions
albumentations/augmentations/geometric/transforms.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: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 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.

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

Attention: Patch coverage is 57.69231% with 11 lines in your changes missing coverage. Please review.

Project coverage is 90.01%. Comparing base (b1a79c2) to head (e9d0d25).
Report is 289 commits behind head on main.

Files with missing lines Patch % Lines
...bumentations/augmentations/geometric/functional.py 37.50% 10 Missing ⚠️
...bumentations/augmentations/geometric/transforms.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2157       +/-   ##
=========================================
+ Coverage      0   90.01%   +90.01%     
=========================================
  Files         0       48       +48     
  Lines         0     8547     +8547     
=========================================
+ Hits          0     7694     +7694     
- Misses        0      853      +853     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@ternaus ternaus merged commit 5aec657 into main Nov 19, 2024
16 checks passed
@ternaus ternaus deleted the add_fisheye branch November 19, 2024 02:36
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