How to Undistort fisheye image into max bounding rectangle?
I have calibrated camera with cv2.fisheye.calibrate
with images of size 720x1280. Python script
K =
array([[541.11407173, 0. , 659.87320043],
[ 0. , 541.28079025, 318.68920531],
[ 0. , 0. , 1. ]])
D =
array([[-3.91414244e-02],
[-4.60198728e-03],
[-3.02912651e-04],
[ 2.83586453e-05]])
And performed un-distortion with
new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (1280, 720), np.eye(3), balance=1)
map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), new_K, (1280, 720), cv2.CV_16SC2)
undistorted_img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_CUBIC, borderMode=cv2.BORDER_CONSTANT)
How can I achieve max obtainable rectangular image?
If I directly crop this image, quality deteriotes :(
I guess I have to play with balance
, new_size
, fov_scale
properties of estimateNewCameraMatrixForUndistortRectify()
.
And also some properties of initUndistortRectifyMap()
.