如何解决使用 cv2.fisheye undistort 时无法重新映射保留所有黑色区域
使用 cv2.fisheyeUndistortRectifyMap() 生成 map1 和 map2 后,使用 cv2.UndistortRectifyMap() 重新映射时,即使将 Balance 保持为 1,我也无法获取完整的黑色区域。 预期图像的所有角都应可见,包括缺失的左下角和左上角和右上角,使生成的图像显示为星形。
#Camera Matrix
mtx = np.array([[965.,0.,960.],[ 0.,970.,540.],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,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:
Output of the code appears as so:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。