在使用cv2.FisheyeUndortRectiptyMap()生成map1和map2后,当使用cv2.UndortRectiptyMap()重新映射时,即使将平衡保持为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)
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:
目前没有回答
相关问题 更多 >
编程相关推荐