fisheye calib视野调整

1.  畸变模型采用

K = np.array([[6.2597563231075685e+02, 0., 1.1601088601848592e+03],
       [0., 6.2525998102575511e+02, 1.1634786618991664e+03],
       [0., 0., 1.]])

2. 直接使用

initUndistortRectifyMap和remap时注意调节视野的大小,为了方便得到想要的大小需要借助
estimateNewCameraMatrixForUndistortRectify

参数

fov_scale=1.0时,调整后的新的内参如下:

[[1.02625557e+02 0.00000000e+00 1.16010886e+03], [0.00000000e+00 1.02508230e+02 1.16347352e+03], [0.00000000e+00 0.00000000e+00 1.00000000e+00]]

f/f_new=6.2597563231075685e+02/1.02625557e+02=6.0996076475449175881208615510852

 

fov_scale=0.5时,调整后的新的内参如下:

[[2.05251114e+02 0.00000000e+00 1.16121771e+03], [0.00000000e+00 2.05016460e+02 1.16794704e+03], [0.00000000e+00 0.00000000e+00 1.00000000e+00]]

fov_scale=0.2时,调整后的新的内参如下:

[[5.13127786e+02 0.00000000e+00 1.16454428e+03], [0.00000000e+00 5.12541149e+02 1.18136761e+03], [0.00000000e+00 0.00000000e+00 1.00000000e+00]]

3. 完整代码如下:

    K = np.array([[6.2597563231075685e+02, 0., 1.1601088601848592e+03],
           [0., 6.2525998102575511e+02, 1.1634786618991664e+03],
           [0., 0., 1.]])
    D = np.array([[0.069],
           [-2.24e-03],
           [-0.01487],
           [3.78e-03]])

    img = cv2.imread("D:/ISP/FourFisheyeLensStitching/images/ENCMFUR/square.png")
    imgHeight, imgWidth, imgDeep = img.shape
    # new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (1280, 720), np.eye(3), balance=1)
    # map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), new_K, (1280, 720), cv2.CV_16SC2)
    # undistorted_img = cv2.remap(img, map1, map2, interpolation=cv2.INTER_CUBIC, borderMode=cv2.BORDER_CONSTANT)

    # new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (1280, 720), np.eye(3), balance=1,
    #                                                                new_size=(3400, 1912), fov_scale=1)
    # map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), new_K, (3400, 1912), cv2.CV_16SC2)
    # undistorted_img = cv2.remap(img, map1[575:1295, 23:3119, :], map2[575:1295, 23:3119],
    #                             interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)


    new_K = cv2.fisheye.estimateNewCameraMatrixForUndistortRectify(K, D, (imgWidth, imgHeight), np.eye(3), balance=1.0,
                                                                   new_size=(imgWidth, imgHeight), fov_scale=1.0)
    map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), new_K, (imgWidth, imgHeight), cv2.CV_16SC2)
    undistorted_img = cv2.remap(img, map1, map2,
                                interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)

    cv2.imwrite('D:/ISP/FourFisheyeLensStitching/images/ENCMFUR/undistorted_square_balance_1.0_fov_scale_1.0.png', undistorted_img)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值