python图片去畸变

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')
不论你在什么时候开始,重要的是开始之后就不要停止。 不论你在什么时候结束,重要的是结束之后就不要悔恨。
原文地址:https://www.cnblogs.com/yunhgu/p/15176489.html