cv2.fisheye去畸变重映射时无法保留全边角黑区的问题咨询
鱼眼图像去畸变校正边角内容缺失问题概述
开展鱼眼图像去畸变校正工作时,通过cv2.fisheye.initUndistortRectifyMap()生成map1与map2映射表后,使用cv2.remap()执行重映射操作时,即便将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]])
- 完整实现逻辑代码:
# 读取需要去畸变的测试图像 img = cv2.imread("Sample.jpg") img_shape = img.shape[:2][::-1] # 基于鱼眼模型,设置balance=1计算新相机内参 new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(mtx, dist, img_shape, np.eye(3), balance=1) # 以1.5倍原图分辨率生成重映射表,尝试覆盖扩展区域 map1, map2 = cv2.fisheye.initUndistortRectifyMap( mtx, dist, np.eye(3), new_K, (int(1920*1.5), int(1080*1.5)), cv2.CV_32F ) # 执行重映射生成校正结果 res_img = cv2.remap( img, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT )
测试素材对照
- 输入测试样图(Sample.jpg):

- 当前代码实际输出结果:

内容的提问来源于stack exchange,提问作者amar adak
相关产品推荐
相关产品推荐

