1 | initial version |
Here is a python implementation of the relevant functions that uses Newton-Raphson followed by a binary line searches for better calculations of the inverse distortion function. This will result in a more correct OptimalCameraMatrix.
The repository also contains a function that enables using calibration images where not all of the corners are visible or detected, hence allowing better constraints on the areas near the boundary of the image. This is required so the distortion parameters will be calculated more precisely and the undistorted image will be more accurate. Moreover, it reduces the chance that the OptimalCameraMatrix bug will be encountered.
Please note that this implementation uses only the first 5 distortion parameters.