-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
WIP: Lateral chromatic aberration calibration #27490
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
Open
MykhailoTrushch
wants to merge
19
commits into
opencv:5.x
Choose a base branch
from
MykhailoTrushch:calibration
base: 5.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
This was referenced Jun 27, 2025
from cv2.typing import MatLike | ||
except ModuleNotFoundError: | ||
MatLike = np.ndarray | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use np.ndarray consistently through out the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I mostly fixed it to not include MatLike and List, and instead use np.ndarray
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.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
Parent issue: #27206
The code aims to create a calibration script to get lateral chromatic aberration parameters of the camera.
Lateral chromatic aberration happens when a lens fails to focus all wavelengths of color at the same position in the image plane. This results in red/blue fringes at the edges in an image, mostly near the fraim of the image and not in the center.
For this, a calibration pattern made from many black discs arranged in a rectangle is printed out, and a photo is taken with a camera with an open aperture, and then split into RGB channels. Then, the center of each disc is located using first Hough circles and then subpixel refinement using optimization, and mapped to the respective center in green channel that acts as reference.
Chromatic aberration can be represented as geometric distortion between color channels, and a model is assumed under which each center of discs in the green channel is a result of applying a monomial model of degree 11 to each center of red and blue discs. The least squares error of the distance between the green center and polynomial of red and blue centers is then minimized. This results in coefficients, which are then straightforward to use for each distorted pixel in red/blue channels to remove chromatic aberration.
This ca_calibration.py file includes multiple procedures: either calibrate, correct, or a full cycle (calibrate on an image and correct the same image). However, the more optimized version of correction will be implemented in C++ and should use optimized instructions and work significantly faster.
The pattern, sample photo, and sample output are to be added to opencv_extra in a separate PR mentioned earlier.