Geometry deformation occurred to images taken by CCD camera needs geometric correction. Geometric correction algorithm of bar code image based on line detection is proposed combined with edge detection algorithm and line extraction algorithm since common image geometric correction methods do not apply to the correction of barcode images. Image correction based on line detection is to detect the corresponding straight line at the edge of targeted barcode in the image without background, aiming to determine the deviation angle, and then proceed with the torsion correction. The experimental results show that the bar code images with deflection angle have been effectively corrected by the proposed method.