| Magnetic parts are widely used in communication,computer,household appliances and consumer electronics.In the process of manufacturing and transportation,cracks,missing corners and concave convex defects are inevitable.These defects will not only shorten the service life of the parts,but also bring potential safety hazards to the products using the parts.Therefore,before the delivery of magnetic parts,it is necessary to carry out defect quality inspection.In this paper,a surface defect detection scheme of magnetic parts based on machine vision is proposed,which provides a reference for automatic defect detection of magnetic parts.The main contents of this paper are as follows:1)The surface defect detection system of magnetic parts is designed,including the loading and unloading mechanism and the image acquisition and de tection module.The feeding mechanism adopts two sections of belt conveying feeding mode,and the feeding mechanism is designed with electromagnetic valve blowing mode.The image acquisition module includes Basler industrial array camera,OPT fixed focus industrial lens and OPT industrial light source.The image detection module includes on-line detection,recognition and classification module of crack,corner and bump,and off-line training module of deep learning.2)The image preprocessing is studied.The RGB color space is used to gray the collected image,the mean filter is used to denoise the image,the windowed median filter linear difference method with two different templates is used to enhance the image,and Sobel edge operator combined wit h morphological operation is used to complete the image segmentation.Finally,the detection standards of different defects are defined and quantified to complete the detection and identification of surface defects of magnetic parts.3)Aiming at the situation that some crack defects are slight and easy to break in segmentation,the crack stitching algorithm is studied.It is found that most of the cracks are along the radial direction of the parts,so the direction statistics of the segmented connected areas is carried out.Within a certain angle allowed to deviate from the radial direction,the connected areas whose adjacent distance is less than the given threshold are connected,so as to complete the splicing of the cracks.4)The neural network is used to classify the defects identified by the detection,and the situation that the dirt of parts is misjudged as defects in the detection and recognition algorithm is excluded.For the defects and a small number of dirty areas extracted from the detection and recognition algorithm,the trained yolov model is used for prediction and classification,which can not only avoid the prediction of the whole image,but also eliminate some misjudgment problems caused by the detection and recognition algorithm,so as to improve the accuracy of the final detection and reduce the time-consuming of the algorithm.The final classification accuracy can reach 96.33%. |