def rectify(mtx1, dist1, mtx2, dist2, R, T):
# R????????????P?3*4????????Q?4*4??????
R1, R2, P1, P2, Q, roi1, roi2 = cv2.stereoRectify(
mtx1, dist1,
mtx2, dist2,
(BINIMG_W, BINIMG_H),
R,
T,
flags=cv2.CALIB_ZERO_DISPARITY,
alpha=-1,
newImageSize=(BINIMG_W, BINIMG_H)
)
if __name__ == '__main__':
printMat(R1, R2, P1, P2, Q, roi1, roi2)
# ??????????????mapx, mapy?
mapx1, mapy1 = cv2.initUndistortRectifyMap(
mtx1, dist1,
R1, P1,
(BINIMG_W, BINIMG_H),
cv2.CV_16SC2
)
mapx2, mapy2 = cv2.initUndistortRectifyMap(
mtx2, dist2,
R2, P2,
(BINIMG_W, BINIMG_H),
cv2.CV_16SC2
)
return mapx1, mapy1, mapx2, mapy2, Q, roi1, roi2
评论列表
文章目录