import cv2
import numpy as np
parameter_mapping = {
# 内参
'internal_reference': [[25714.104851, 0.000000, 1847.417942], [0.000000, 2586.842593, 1152.893893],
[0.000000, 0.000000, 1.000000]],
# 畸变
'distortion': [-0.440493, 0.280272, 0.000074, 0.000357, 0.000000]
}
if __name__ == '__main__':
image_file = r"F:pythonProject测试图片去畸变7.jpg"
img = cv2.imdecode(np.fromfile(image_file, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
dst = cv2.undistort(img, np.array(parameter_mapping["internal_reference"]),
np.array(parameter_mapping["distortion"]), None, None)
cv2.imencode('.jpg', dst)[1].tofile('7.jpg')