def __init__(self, calibration=None, calib_data_path=None, rows=6, cols=9, cal_image_shape=None):
"""Helper class to remove lens distortion from images (camera calibration)
Args:
calibration: precalculated calibration matrices
calib_data_path: path to data for camera calibration
rows: number of rows on chessboard
cols: number of columns on chessboard
cal_image_shape: calibration image shape
"""
if calibration is not None:
self.ret, self.mtx, self.dist, self.rvecs, self.tvecs = cv2.calibrateCamera(
calibration['objpoints'], calibration['imgpoints'], cal_image_shape, None, None)
else:
calibration = calculate_camera_calibration(
calib_data_path, rows, cols, cal_image_shape)
self.mtx = calibration['mtx']
self.dist = calibration['dist']
评论列表
文章目录