A new efftcient straight line detection algorithm, GPI ( Gray Projecting Integral) method is proposed. The gray values of a sub-window are projected onto a line, and sum the gray values which are projected onto one same point to shape a special vector, then rotate the projecting direction, obtain many such vectors corresponding to different projecting directions. The vectors can form a matrix, a GPI matrix of the sub-image. The problem of lines detection is converted into maxima or minima searching problem in the GPI matrix. Bused on the GPI matrix, the lines can be calculated. Different from traditional methods, the algorithm can detect the positions of lines accurately, quickly without previous edge detection, which costs less time, and avoids the error resulted from the poor threshold with traditional methods. This algorithm is useful and efftcient for numerous image understanding applications and robot visual navigation, especially for welded joint position detection in heavy noise.