After generating the map1 and map2 using the cv2.fisheyeUndistortRectifyMap(), while remapping using cv2.UndistortRectifyMap(), I am unable to fetch the full black region even by keeping the Balance as 1. The expected image shall have all corners visible including the missing bottom-left and upper-left and right portion, making the resulting image appear as a star.
#Camera Matrix
mtx = np.array([[965., 0., 960.],
[ 0., 970., 540.],
[ 0., 0., 1.]])
#Distortion Matrix
dist = np.array([[-0.07234645], [-0.00707313], [0.00762894], [-0.00343638]])
# Sample Image requiring the undistortion with black unwarp
img = cv2.imread("Sample.jpg")
img_shape = img.shape[:2][::-1]
# New camera matrix using fisheye
new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(mtx, dist, img_shape, np.eye(3), balance=1)
# Overlaying the maps on a higher resolution to fetch the extensions
map1, map2 = cv2.fisheye.initUndistortRectifyMap(mtx, dist, np.eye(3), new_K, (int(1920*1.5), int(1080*1.5)), cv2.CV_32F)
# Using the remap function to overlay the resultant image
res_img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
The sample used here is attached below along with the resultant image
Input to the code Sample.jpg:
Output of the code appears as so: