-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
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
ROI returned by cvGetOptimalNewCameraMatrix has wrong width & height #24831
Comments
note: previous icvGetRectangles fix, from 4.8.0: #23305 |
The error is actually a bit different. Adding |
Yes it should do floor(x-0.5) on the minimum bound and ceil(x+0.5) on the second |
Or something like that. To take into account the footprint of a pixel |
This fixes opencv#24831
Are there any updates on this one? |
System Information
OpenCV python version: 4.8.0.76
Operating System / Platform: macOS
Python version: 3.10.6
Detailed description
I noticed here that cvGetOptimalNewCameraMatrix returns (0,0,width-1,height-1) when the distortion parameters are zero.
Looking more closely at the code, I see that the internal function icvGetRectangles finds the rectangles by sampling points in the (0,width-1)x(0,hieght-1) range, and then computes the output ROI sizes as (maxX-minX,maxY-minY), which of course misses one pixel in each dimension!
I think the code in icvGetRectangles should add 1 pixel to both dimensions, because the max value should be included.
Steps to reproduce
Test code:
Output:
both rois should be (0, 0, 1920, 1080).
Issue submission checklist
The text was updated successfully, but these errors were encountered: