Aiming at the problems of low detection efficiency and high labor cost for manual aerospace electronic components surface, this paper proposes a surface defect detection method based on machine vision. Firstly, based on the design of the components surface defect detection device, the characteristics of the surface image are analyzed. Then, the image is preprocessed by bilateral filtering algorithm and morphological operation, and the edge is removed while the noise is removed. Finally, the fast adaptive threshold is adopted. Segmentation to achieve defect detection on the components surface. The experimental results show that the detection method has a good detection effect on the surface of the components. The detection rate and false detection rate are 3.2% and3.8%, respectively, which provides a feasible solution for the detection of defects on the surface of aerospace electronic products. Has a certain practical value.