0

在使用 cv2.fisheyeUndistortRectifyMap() 生成 map1 和 map2 后,在使用 cv2.UndistortRectifyMap() 重新映射时,即使将 Balance 保持为 1,我也无法获取完整的黑色区域。预期的图像应具有可见的所有角,包括缺少左下角和左上角和右上部分,使生成的图像显示为星形。

#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)

下面附上此处使用的示例以及生成的图像

Input to the code Sample.jpg: 输入代码 327_Sample.jpg

Output of the code appears as so: 代码的输出显示为

4

0 回答 0