| As an important component in production and life,commutators are widely used in automobiles,home appliances and other fields.In order to ensure the quality of the commutator,machine vision is used to detect the surface defects of the commutator,which requires that the vision detection algorithm should have good real-time and generalization.In this thesis,generalization means that the algorithm does not fail to detect defects due to the difference of image distribution caused by tool wear.During the production and processing of the commutator production line,the surface quality of the workpiece is constantly changing with the wear of the processing tools,resulting in different image features and image distributions taken by the camera.In order to effectively detect various defects under the above conditions and meet the real-time and generalization requirements of the algorithm,this thesis proposes the following research content:Research on the detection of planar defects based on the enhancement of defect features.Planar defects have the characteristics of many types of defects,a small number of defect samples and great difference in background.In order to improve the generalization of the algorithm,a defect detection algorithm based on the reference region and recombination of HSV channel is proposed for defects with obvious color characteristics.The algorithm uses HSV channel fusion and recombination to enhance defect characteristics and suppress background interference.Using the reference region to determine the segmentation threshold to avoid the problem of inaccurate threshold determination due to the small amount of defect data.For defects without obvious color features,a defect detection algorithm based on gray gradient feature image and region growing is proposed.The algorithm combines gray features with gradient features to realize the unification and enhancement of various defect features,and uses the improved region growing algorithm to extract different types of defects.Experimental results show the effectiveness of the proposed method,which can improve the generalization of the algorithm.Research on the detection of small defects in the groove edge region based on the strip convolution and spatial attention mechanism.Small defects have the characteristics of small area,weak contrast,and large numbers.The neural network has better generalization when there are more training data.The strip convolution strengthens the model’s ability to adapt to different shape defects,and the spatial attention mechanism helps the algorithm to perceive the position of the defect.Supervised learning network segmentation results and defect location information by using self-defined loss function.Sort out the small defect data set and determine the algorithm evaluation standard.Experiments verify the segmentation effect of the model,which shows that the generalization of the detection algorithm is improved.Finally,the real-time and generalization of the algorithm are optimized and verified.Data parallelization,AOP and GPU acceleration are used to optimize the real-time performance of the algorithm.After optimization,the detection time of a single workpiece is shortened from4512.24 ms to 1758.96 ms,and the optimal speedup ratio is up to 2.56.The running time of the optimized algorithm can meet the real-time requirements.The verification of algorithm generalization uses different types and different batches of defect samples to test the algorithm respectively.The test results are: the comprehensive detection precision rate of planar defects is 99.6%,and the recall rate is 96.7%.The comprehensive detection accuracy rate of small defects is 99.5%,and the recall rate is 94.3%,which shows that the algorithm has good generalization. |