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
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.