Embodiments of the invention disclose a two-dimensional code
distortion correction method and apparatus. The method comprises the steps of obtaining a two-dimensional code image; according to the two-dimensional code image, calculating distorted image coordinates of four vertexes of the two-dimensional code image; according to a preset length-
width ratio of a two-dimensional code, calculating undistorted image coordinates corresponding to the four vertexes of the two-dimensional code image; according to the distorted image coordinates and the undistorted image coordinates, establishing a linear equation set; according to the linear equation set, calculating unknown parameters in a
homography matrix; according to a calculation result, correcting the two-dimensional code image; and outputting a rectangular image containing the corrected two-dimensional code image. The method and the apparatus can be used for
distortion correction of different types of two-dimensional codes; the use convenience and the diversity of application scenes are remarkably improved; the rotation-free corrected two-dimensional code image can be quickly obtained; the correction process is simple and quick; thefinally output corrected two-dimensional code image is a rectangular region image only containing two-dimensional code region information; subsequent decoding is facilitated; and the decoding efficiency can be improved.