Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix getUndistortRectangles() to ignore corners #27374

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
wants to merge 1 commit into
base: 4.x
Choose a base branch
Loading
from

Conversation

daishironishida
Copy link

@daishironishida daishironishida commented May 28, 2025

getUndistortRectangles() generates points along the image border, and uses the mapping of these points to determine the inscribed/circumscribed rectangles. However undistortPoints() is likely to fail in the image corners, and when it fails, it returns the input point. As a result, the inscribed rectangle cannot be greater than the input image size. This means that the result of getOptimalNewCameraMatrix() for alpha=0 has a smaller FOV than ideal.

Below image plots the points along the image border (Source Points) for a 1280x720 image, and the results of undistortPoints() for an AXIS M2035-LE camera.

Plot

I have edited getUndistortRectangles() to skip the image corners.
It is preferable to only ignore points where undistortPoints() failed, but that requires quite a bit of refactoring.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Contributor

Related PR: #24927

@daishironishida
Copy link
Author

Looks like test_videoio in Linux x64 Debug timed out. Can I run again?

command timed out: 600 seconds without output running buildenv python ../4.x/opencv/modules/ts/misc/run.py --configuration=Debug --test_tag_skip=size_hd --gtest_output=xml:results_test_videoio.xml -t videoio -a --test_threads=2, attempting to kill
process killed by signal 15
program finished with exit code -1
elapsedTime=668.744162


commands lock was released

@asmorkalov
Copy link
Contributor

Please ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.