OpenCV & 3D reconstruction: Why does map1 from initUndistortRectifyMap() has dimentions (x, y, 2)?

Viewed 132

CONTEXT

I'm playing with stereo vision according to OpenCV docs. I've performed everything up to stereoRectify(). I found info that next step is getting maps from initUndistortRectifyMap()and then remapping them with images that I'll be working on.

ISSUE

I don't know why initUndistortRectifyMap()returns me map1 which has size like (y, x, 2), where x and y are img dimensions, (x=360, y=640) in my case. map2 is (y, x) and it looks fine.

CODE

retL, mtxL, distL, rvecsL, tvecsL = cv2.calibrateCamera(objpoints, imgpointsL, grayL.shape[::-1], None, None)
retR, mtxR, distR, rvecsR, tvecsR = cv2.calibrateCamera(objpoints, imgpointsR, grayR.shape[::-1], None, None)
retval, camMat1, dCoeffs1, camMat2, dCoeffs2, R, T, E, F = cv2.stereoCalibrate(objpoints, imgpointsL, imgpointsR,
                                                                               mtxL, distL, mtxR, distR,
                                                                               grayL.shape[::-1], flags=cv2.CALIB_FIX_INTRINSIC)

R1, R2, P1, P2, Q, roi1, roi2 = cv2.stereoRectify(camMat1, dCoeffs1, camMat2, dCoeffs2, grayL.shape[::-1], R, T)
map1, map2 = cv2.initUndistortRectifyMap(camMat1, dCoeffs1, R, P1, (360, 640), cv2.CV_16SC2)
0 Answers
Related