def getUndistortRectifyMap(self, imgWidth, imgHeight):
if self.mapx is not None and self.mapx.shape == (imgHeight, imgWidth):
return self.mapx, self.mapy
cam = self.coeffs['cameraMatrix']
d = self.coeffs['distortionCoeffs']
(newCameraMatrix, self.roi) = cv2.getOptimalNewCameraMatrix(cam,
d, (imgWidth,
imgHeight), 1,
(imgWidth, imgHeight))
self.mapx, self.mapy = cv2.initUndistortRectifyMap(cam,
d, None, newCameraMatrix,
(imgWidth, imgHeight), cv2.CV_32FC1)
return self.mapx, self.mapy
评论列表
文章目录