## 5 Conclusions  
The study presented in this paper focuses on the application of machine vision and deep learning algorithms to enhance the conventional industrial production process by automating the detection of metal parts. A dedicated experimental platform for machine vision detection is developed to meet the requirements of detecting surface defects and measuring the size of the lock cylinder's bead hole. Extensive algorithm research, specifically in the areas of size detection and surface defect detection of lock cylinders and lock bodies, has led to several significant conclusions.  
1. This paper introduces the YOLOv6 algorithm as the proposed method for identifying surface defects on the lock body and lock cylinder. Through a rigorous training process consisting of 1000 iterations, YOLOv6 effectively detects seven distinct types of surface defects. The algorithm demonstrates a remarkable mean Average Precision (\(mAP\)) value of 0.911, highlighting its accuracy and efficiency in defect detection.
2. The Devernay algorithm is refined, and a new algorithm based on Canny-Devernay sub-pixel edge detection is proposed for measuring the lock cylinder's bead hole. The average measurement error for each region of interest (ROI) in the lock core bead hole area is less than 0.03 mm, and the average measurement time is 20.54 ms. These results meet the requirements for the automatic measurement of small size, high speed, and high precision, approximately 3 mm. The algorithm proposed in this paper outperforms manual detection in terms of speed and efficiency while maintaining comparable accuracy.  
However, this paper has two limitations. Firstly, the use of YOLOv6, although effective, may not be the optimal tool for the defect recognition of small targets such as bad items in the lock body and lock cylinder. The network structure will be improved in future research to enhance the performance of small target detection. Secondly, there is still a 4.063% probability that the accuracy of the size measurement method suggested in this paper may have a measurement error greater than 0.05 mm. Therefore, future optimizations will focus on improving the algorithm's robustness and enhancing measurement accuracy.  
Figure 14: Comparison of measurement errors among three methods.  
**Author Contributions:** X.X.: Conceptualization, Methodology, Formal analysis, Writing--Original draft. H.W.: Project administration, Funding acquisition, Writing--Review and editing. Y.L.: Resources, Supervision and writing. D.L.: Visualization and writing. B.L.: Software and writing. Y.T.: Methodology, Writing--Review and editing. All authors have read and agreed to the published version of the manuscript.  
This work was supported in part by the Laboratory of Lingnan Modern Agriculture Project under Grant NT2021009 and the Guangdong Basic and Applied Basic Research Foundation (2022A1515140162). We would like to express our gratitude for the support provided by the project \"Application of Multi-source Sensing Information Fusion Technology in Engineering Inspection\".  
Not applicable.  
**Data Availability Statement:** The data that support the findings of this study are available from the corresponding author, upon reasonable request.  
The authors would like to thank the anonymous reviewers for their critical comments and suggestions for improving the manuscript.  
The authors declare no conflict of interest.