Opencv: distort back

后端 未结 7 756
清歌不尽
清歌不尽 2021-02-02 02:53

I have the cameraMatrix and the distCoeff needed to undistort an image or a vector of points. Now I\'d like to distort them back.

Is it poss

7条回答
  •  春和景丽
    2021-02-02 03:14

    Another way is to use remap to project rectified image to distorted image:

    img_distored = cv2.remap(img_rect, mapx, mapy, cv2.INTER_LINEAR)
    

    mapx and mapy are mappings from rectified pixel locations to distorted pixel locations. It can be obtained in below steps:

    X, Y = np.meshgrid(range(w), range(h)
    pnts_distorted = np.merge(X, Y).reshape(w*h, 2)
    pnts_rectified = cv2.undistortPoints(pnts_distorted, cameraMatrix, distort, R=rotation, P=pose)
    mapx = pnts_rectified[:,:,0]
    mapy = pnts_rectified[:,:,1]
    

    cameraMatrix, distort, rotation, pose are the parameters returned in cv calibration and stereoRectify functions.

提交回复
热议问题