Limitations of the pinhole method and astigmatic defocus detection have difficulties in determining the direction of defocus and a restricted linear correction range. Here, a distance-measuring approach based on the laser triangulation principle is proposed with a corresponding mathematical model to overcome these problems and to satisfy the requirements of an industrial thin-film transistor liquid-crystal display (TFT-LCD) inspection microscope system in active auto-focus applications. The approach combines infrared light at a wavelength of 808 nm with visible light. The light reflected from the surface of the object reaches a CCD camera and forms a spot via a set of optical devices. To control a PZT to achieve real-time auto-focusing, a Gaussian curve fitting method is used to process the spot information with the presented mathematical model giving the relationship between the detection value and the defocus value focus error signal (FES). The preliminary experiments with a 50× objective lens show that the measured values are consistent with the theoretical values, have good linearity and possess a focusing accuracy of 0.2 µm within ±30 µm of the focal plane. The analysis of the experimental results proves the feasibility of using this method in industrial applications. Compared with the traditional method of microscope focus correction, this method has the advantages of high accuracy, good linearity, and fast focus speed for the actual requirements of industrial inspection processes. This method has been applied to the circuit board component defect detection in our laboratory. INDEX TERMS Optical images, laser triangulation, auto-focus, Gaussian curve fitting.