Real-Time Defect Detection for Metal Components: A Fusion of Enhanced Canny–Devernay and YOLOv6 Algorithms
Abstract
:1. Introduction
- (1)
- A conceptual model of an automated detection production line was established for the detection of metal workpieces such as lock bodies.
- (2)
- To achieve a fast and accurate detection of sub-pixel edge points, the Canny algorithm and the Devernay algorithm are seamlessly combined in the calculation process.
- (3)
- In order to enhance the accuracy and stability of Devernay’s method in determining sub-pixel edge points, various specialized instances have been employed, thereby boosting its overall performance.
- (4)
- This paper explores the identification method and size measurement method of common defects in metal parts, presenting a practical approach for the application of machine vision in the field of the automatic detection of metal parts.
2. Experimental Environment and Dataset
2.1. Experiment Environment
2.2. Datasets
3. Materials and Methods
3.1. Detection Method of Lock Body Defect
3.2. Size Measurement Method
3.2.1. Region of Interest Acquisition
3.2.2. Image Denoising
3.2.3. Sub-Pixel Edge Detection
- (1)
- The steps of the Canny operator to find the edge points are as follows.
- Smooth the image with a Gaussian filter. The obtained ROI region has been Gaussian filtered in Section 3.2, so this step is omitted.
- Calculate the gradient magnitude and direction. In this paper, the first-order partial derivative finite difference is used to calculate the gradient magnitude and direction, as shown in Equations (2)–(6).
- c.
- Non-maximum suppression of the gradient magnitude. As shown in Figure 7: g1, g2, g3, and g4 all represent pixel points. Obviously, they are four of the eight neighborhoods of point c. Point c in Figure 7 is the point we need to judge. The blue line is its gradient direction; that is to say, if c is a local maximum, its gradient magnitude M needs to be greater than or equal to the intersection of the line with g1g2 and g3g4, that is, the gradient magnitudes at the two points p and q. However, p and q are not integer pixels but sub-pixels; that is, the coordinates are floating points. We used linear interpolation to find their gradient magnitudes. For example, p is between g1 and g2, and the magnitudes of g1 and g2 are known. As long as we know the ratio of p between g1 and g2, we can obtain its gradient amplitude, and the ratio can be calculated by the included angle θ, which is the direction of the gradient. As shown in Formulas (7) and (8): set the amplitude of g1 M(g1), the amplitude of g2 M(g2), then p can be easily obtained.
- (2)
- Building upon the Devernay sub-pixel edge detection algorithm, accurate sub-pixel edge finding is achieved. Devernay further refined the Canny algorithm by proposing that the new edge point can be determined as the maximum value of the difference between multiple adjacent gradient modulus values. This value can be interpolated using a quadratic function based on the gradient modulus values at three adjacent points along the gradient direction. Figure 8 provides a visual representation of this process.
3.2.4. Radius Acquisition
4. Results
4.1. Defect Detection Experiment
4.1.1. Defect Detection Evaluation Index
4.1.2. Experimental Data and Analysis
4.2. Size Measurement Experiments
- (1)
- Size conversion. In this paper, a total of 64 pictures of the lock cylinder were captured, with five bead holes present in each picture. This amounts to a total of 320 lock core bead hole pictures after the extraction of the Region of Interest (ROI). Section 3 of the paper describes the process of obtaining the fitting circle radius for the lock cylinder’s bead hole. However, it should be noted that the calculated radius is in terms of pixels, and thus requires a size conversion to verify the accuracy of the algorithm. Equation (20) is provided in the article to facilitate this size conversion.
- (2)
- Size calculation. The measurement size can be calculated from equation after computing the average pixel equivalent (21). The 320 measurement data groups were separated into 6 groups, and Table 6 contains the average values of the calculated results for each group.
5. 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 () 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.
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Yang, J.; Li, S.; Wang, Z.; Dong, H.; Wang, J.; Tang, S. Using Deep Learning to Detect Defects in Manufacturing: A Comprehensive Survey and Current Challenges. Materials 2020, 13, 5755. [Google Scholar] [CrossRef]
- Chetverikov, D.; Hanbury, A. Finding defects in texture using regularity and local orientation. Pattern Recogn. 2002, 35, 2165–2180. [Google Scholar] [CrossRef]
- Hou, Z.; Parker, J.M. Texture Defect Detection Using Support Vector Machines with Adaptive Gabor Wavelet Features. In Proceedings of the 2005 Seventh IEEE Workshops on Applications of Computer Vision (WACV/MOTION’05)—Volume 1, Breckenridge, CO, USA, 5–7 January 2005; pp. 275–280. [Google Scholar]
- Zheng, S.; Zhong, Q.; Chen, X.; Peng, L.; Cui, G. The Rail Surface Defects Recognition via Operating Service Rail Vehicle Vibrations. Machines 2022, 10, 796. [Google Scholar] [CrossRef]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef] [PubMed] [Green Version]
- Cha, Y.; Choi, W.; Suh, G.; Mahmoudkhani, S.; Büyüköztürk, O. Autonomous Structural Visual Inspection Using Region-Based Deep Learning for Detecting Multiple Damage Types. Comput-Aided Civ. Inf. 2018, 33, 731–747. [Google Scholar] [CrossRef]
- Tao, X.; Zhang, D.; Wang, Z.; Liu, X.; Zhang, H.; Xu, D. Detection of Power Line Insulator Defects Using Aerial Images Analyzed with Convolutional Neural Networks. IEEE Trans. Syst. Man Cybern. Syst. 2020, 50, 1486–1498. [Google Scholar] [CrossRef]
- Li, J.; Su, Z.; Geng, J.; Yin, Y. Real-time Detection of Steel Strip Surface Defects Based on Improved YOLO Detection Network. IFAC-PapersOnLine 2018, 51, 76–81. [Google Scholar] [CrossRef]
- Wu, Y.; Guo, D.; Liu, H.; Huang, Y. An end-to-end learning method for industrial defect detection. Assem. Autom. 2020, 40, 31–39. [Google Scholar] [CrossRef]
- Xie, W.; Chen, H.; Wang, Z.; Liu, B.; Shuai, L. Display Line Defect Detection Method Based on Color Feature Fusion. Machines 2022, 10, 723. [Google Scholar] [CrossRef]
- Gao, Y.; Gao, L.; Li, X. A hierarchical training-convolutional neural network with feature alignment for steel surface defect recognition. Robot. Comput. Integr. Manuf. 2023, 81, 102507. [Google Scholar] [CrossRef]
- Li, W.; Zhang, H.; Wang, G.; Xiong, G.; Zhao, M.; Li, G.; Li, R. Deep learning based online metallic surface defect detection method for wire and arc additive manufacturing. Robot. Comput. Integr. Manuf. 2023, 80, 102470. [Google Scholar] [CrossRef]
- Yoon, S.; Song-Kyoo Kim, A.; Cantwell, W.J.; Yeun, C.Y.; Cho, C.; Byon, Y.; Kim, T. Defect detection in composites by deep learning using solitary waves. Int. J. Mech. Sci. 2023, 239, 107882. [Google Scholar] [CrossRef]
- Liguori, C.; Paolillo, A.; Pietrosanto, A. An on-line stereo-vision system for dimensional measurements of rubber extrusions. Measurement 2004, 35, 221–231. [Google Scholar] [CrossRef]
- Valkenburg, R.J.; McIvor, A.M. Accurate 3D measurement using a structured light system. Image Vision Comput. 1998, 16, 99–110. [Google Scholar] [CrossRef]
- Aguilar, J.J.; Torres, F.; Lope, M.A. Stereo vision for 3D measurement: Accuracy analysis, calibration and industrial applications. Meas. J. Int. Meas. Confed. 1996, 18, 193–200. [Google Scholar] [CrossRef]
- Xiang, R.; He, W.; Zhang, X.; Wang, D.; Shan, Y. Size measurement based on a two-camera machine vision system for the bayonets of automobile brake pads. Measurement 2018, 122, 106–116. [Google Scholar] [CrossRef]
- Li, X.; Yang, Y.; Ye, Y.; Ma, S.; Hu, T. An online visual measurement method for workpiece dimension based on deep learning. Measurement 2021, 185, 110032. [Google Scholar] [CrossRef]
- Xiao, G.; Li, Y.; Xia, Q.; Cheng, X.; Chen, W. Research on the on-line dimensional accuracy measurement method of conical spun workpieces based on machine vision technology. Measurement 2019, 148, 106881. [Google Scholar] [CrossRef]
- Lu, R.S.; Li, Y.F.; Yu, Q. On-line measurement of the straightness of seamless steel pipes using machine vision technique. Sens. Actuators A Phys. 2001, 94, 95–101. [Google Scholar] [CrossRef]
- Jia, Z.; Wang, B.; Liu, W.; Sun, Y. An improved image acquiring method for machine vision measurement of hot formed parts. J. Mater. Process. Technol. 2010, 210, 267–271. [Google Scholar] [CrossRef]
- Gao, P.; Liu, F.; Sun, X.; Wang, F.; Li, J. Rapid non-contact visual measurement method for key dimensions of revolving workpieces. Int. J. Metrol. Qual. Eng. 2021, 12, 10. [Google Scholar] [CrossRef]
- Yan, S.; Wang, X.; Yang, Q.; Xu, D.; He, H.; Liu, Y. Online deviation measurement system of the strip in the finishing process based on machine vision. Measurement 2022, 202, 111735. [Google Scholar] [CrossRef]
- Kurita, T.; Kasashima, N.; Matsumoto, M. Development of a vision-based high precision position and orientation measurement system to facilitate automation of workpiece installation in machine tools. CIRP J. Manuf. Sci. Technol. 2022, 38, 509–517. [Google Scholar] [CrossRef]
- Zhihao, X.; Zhijiang, Z.; Han, L.; Libo, P. Research on dynamic measurement of hot ring rolling dimension based on machine vision. IFAC-PapersOnLine 2022, 55, 125–130. [Google Scholar] [CrossRef]
- Lang, J.; Mao, J.; Liang, R. Non-horizontal target measurement method based on monocular vision. Syst. Sci. Control. Eng. 2022, 10, 443–458. [Google Scholar] [CrossRef]
- Zhang, W.; Han, Z.; Li, Y.; Zheng, H.; Cheng, X. A Method for Measurement of Workpiece form Deviations Based on Machine Vision. Machines 2022, 10, 718. [Google Scholar] [CrossRef]
- Luo, L.; Liu, W.; Lu, Q.; Wang, J.; Wen, W.; Yan, D.; Tang, Y. Grape Berry Detection and Size Measurement Based on Edge Image Processing and Geometric Morphology. Machines 2021, 9, 233. [Google Scholar] [CrossRef]
- Tang, Y.; Huang, Z.; Chen, Z.; Chen, M.; Zhou, H.; Zhang, H.; Sun, J. Novel visual crack width measurement based on backbone double-scale features for improved detection automation. Eng. Struct. 2023, 274, 115158. [Google Scholar] [CrossRef]
- Grompone Von Gioi, R.; Randall, G. A Sub-Pixel Edge Detector: An Implementation of the Canny/Devernay Algorithm. Image Process. Line 2017, 7, 347–372. [Google Scholar] [CrossRef] [Green Version]
- Luo, D.L.; Cai, Y.X.; Yang, Z.H.; Zhang, Y.Z.; Zhou, Y.; Bai, Y. Survey on industrial defect detection with deep learning. Sci. Sin. Inform. 2022, 52, 1002–1039. (In Chinese) [Google Scholar] [CrossRef]
- Xu, D.; Lu, W.; Li, F. A Review of Typical Object Detection Algorithms in Deep Learning. Comput. Eng. Appl. 2021, 57, 10–25. [Google Scholar]
- Wu, F.; Yang, Z.; Mo, X.; Wu, Z.; Tang, W.; Duan, J.; Zou, X. Detection and counting of banana bunches by integrating deep learning and classic image-processing algorithms. Comput. Electron. Agric. 2023, 209, 107827. [Google Scholar] [CrossRef]
- Wu, F.; Duan, J.; Ai, P.; Chen, Z.; Yang, Z.; Zou, X. Rachis detection and three-dimensional localization of cut off point for vision-based banana robot. Comput. Electron. Agric. 2022, 198, 107079. [Google Scholar] [CrossRef]
- Tang, Y.; Cheng, Z.; Huang, Z.; Nong, Y.; Li, L. Visual measurement of dam concrete cracks based on U-net and improved thinning algorithm. J. Exp. Mech. 2022, 37, 209–220. [Google Scholar] [CrossRef]
- Zhang, J.; Sun, Y.; Li, G.; Wang, Y.; Sun, J.; Li, J. Machine-learning-assisted shear strength prediction of reinforced concrete beams with and without stirrups. Eng. Comput. Ger. 2022, 38, 1293–1307. [Google Scholar] [CrossRef]
- Sun, J.; Ma, Y.; Li, J.; Zhang, J.; Ren, Z.; Wang, X. Machine learning-aided design and prediction of cementitious composites containing graphite and slag powder. J. Build. Eng. 2021, 43, 102544. [Google Scholar] [CrossRef]
- Sun, J.; Wang, J.; Zhu, Z.; He, R.; Peng, C.; Zhang, C.; Huang, J.; Wang, Y.; Wang, X. Mechanical Performance Prediction for Sustainable High-Strength Concrete Using Bio-Inspired Neural Network. Buildings 2022, 12, 65. [Google Scholar] [CrossRef]
- Sun, J.; Wang, X.; Zhang, J.; Xiao, F.; Sun, Y.; Ren, Z.; Zhang, G.; Liu, S.; Wang, Y. Multi-objective optimisation of a graphite-slag conductive composite applying a BAS-SVR based model. J. Build. Eng. 2021, 44, 103223. [Google Scholar] [CrossRef]
- Rifai, A.; FUKUDA, R.; Aoyama, H. Surface Roughness Estimation and Chatter Vibration Identification Using Vision-Based Deep Learning. J. Jpn. Soc. Precis. Eng. 2019, 85, 658–666. [Google Scholar] [CrossRef] [Green Version]
- Zhou, Y.; Tang, Y.; Zou, X.; Wu, M.; Tang, W.; Meng, F.; Zhang, Y.; Kang, H. Adaptive Active Positioning of Camellia oleifera Fruit Picking Points: Classical Image Processing and YOLOv7 Fusion Algorithm. Appl. Sci. 2022, 12, 12959. [Google Scholar] [CrossRef]
- Zhang, Y.; Liu, X.; Guo, J.; Zhou, P. Surface Defect Detection of Strip-Steel Based on an Improved PP-YOLOE-m Detection Network. Electronics 2022, 11, 2603. [Google Scholar] [CrossRef]
- Ge, H.; Dai, Y.; Zhu, Z.; Liu, R. A Deep Learning Model Applied to Optical Image Target Detection and Recognition for the Identification of Underwater Biostructures. Machines 2022, 10, 809. [Google Scholar] [CrossRef]
- Wang, J.; Dai, H.; Chen, T.; Liu, H.; Zhang, X.; Zhong, Q.; Lu, R. Toward surface defect detection in electronics manufacturing by an accurate and lightweight YOLO-style object detector. Sci. Rep. 2023, 13, 7062. [Google Scholar] [CrossRef]
- Ge, Y.; Lin, S.; Zhang, Y.; Li, Z.; Cheng, H.; Dong, J.; Shao, S.; Zhang, J.; Qi, X.; Wu, Z. Tracking and Counting of Tomato at Different Growth Period Using an Improving YOLO-Deepsort Network for Inspection Robot. Machines 2022, 10, 489. [Google Scholar] [CrossRef]
- Tang, Y.; Zhu, M.; Chen, Z.; Wu, C.; Chen, B.; Li, C.; Li, L. Seismic performance evaluation of recycled aggregate concrete-filled steel tubular columns with field strain detected via a novel mark-free vision method. Structures 2022, 37, 426–441. [Google Scholar] [CrossRef]
- Xiong, Z.; Guo, X.; Luo, Y.; Zhu, S.; Liu, Y. Experimental and numerical studies on single-layer reticulated shells with aluminium alloy gusset joints. Thin Walled Struct. 2017, 118, 124–136. [Google Scholar] [CrossRef]
- Que, Y.; Dai, Y.; Jia, X.; Leung, A.; Chen, Z.; Jiang, Z.; Tang, Y. Automatic classification of asphalt pavement cracks using a novel integrated generative adversarial networks and improved VGG model. Eng. Struct. 2023, 277, 115406. [Google Scholar] [CrossRef]
- Huang, B.; Wang, J.; Piukovics, G.; Zabihi, N.; Ye, J.; Saafi, M.; Ye, J. Hybrid cement composite-based sensor for in-situ chloride monitoring in concrete structures. Sens. Actuators B Chem. 2023, 385, 133638. [Google Scholar] [CrossRef]
- Xiong, Z.; Guo, X.; Luo, Y.; Xu, H. Numerical analysis of aluminium alloy gusset joints subjected to bending moment and axial force. Eng. Struct. 2017, 152, 1–13. [Google Scholar] [CrossRef]
- Getreuer, P. A Survey of Gaussian Convolution Algorithms. Image Process. Line 2013, 3, 286–310. [Google Scholar] [CrossRef] [Green Version]
- Canny, J. A Computational Approach to Edge Detection. IEEE Trans. Pattern Anal. Mach. Intell. 1986, PAMI-8, 679–698. [Google Scholar] [CrossRef]
- Devernay, F. A Non-Maxima Suppression Method for Edge Detection with Sub-Pixel Accuracy. Ph.D. Thesis, INRIA, Grenoble, France, 1995. [Google Scholar]
- Wang, Z.; Wang, Z.; Huang, N.; Zhao, J. An Improved Canny-Zernike Subpixel Detection Algorithm. Wirel. Commun. Mob. Comput. 2022, 2022, 1488406. [Google Scholar] [CrossRef]
- Tang, R.; Chen, W.; Wu, Y.; Xiong, H.; Yan, B. A Comparative Study of Structural Deformation Test Based on Edge Detection and Digital Image Correlation. Sensors 2023, 23, 3834. [Google Scholar] [CrossRef] [PubMed]
- Lin, E.; Tu, C.; Lien, J.J. Nut Geometry Inspection Using Improved Hough Line and Circle Methods. Sensors 2023, 23, 3961. [Google Scholar] [CrossRef] [PubMed]
Configuration | Parameter |
---|---|
Operating system | Windows10 |
Deep learning framework | pytorch1.8.1 |
Programming language | python3.7 |
GPU accelerated environment | CUDA10.2 |
GPU | NVIDIA GeForce RTX 2060 |
CPU | Intel(R)Core (TM)i7-10700 CPU@2.90GHz |
Equipment | Parameter | Data |
---|---|---|
LED ring light | Product number | JHZM-A40-W |
Luminous color | white | |
Number of LEDs | 48 shell LED | |
Industrial camera | Effective pixels | 5 million |
Color | multicolor | |
Cell size | 2.2 μm × 2.2 μm | |
Frame Rate/Resolution | 31 @2592 × 1944 | |
Camera lens | Focal length | 12 mm |
Maximum size of image surface | 1/1.8’’ (φ9 mm) | |
Aperture range | F2.8–F16 | |
Closest shooting distance | 0.06 m |
Classes | Quantity |
---|---|
Surface defects | 1740 |
Lock cylinder | 64 |
Parameter | Learning Rate | Batch-Size | Epoch | Img-Size | Workers |
---|---|---|---|---|---|
Value | 0.001 | 8 | 1000 | 640 | 8 |
Version | mAP | Weight Size | Training Time | Average Inference Time |
---|---|---|---|---|
YOLOv5 | 0.900 | 13.8 MB | 10 h | 15.31 ms |
YOLOv6 | 0.911 | 36.2 MB | 16 h | 10.29 ms |
YOLOv7 | 0.915 | 71.4 MB | 8 h | 11.23 ms |
Group | Number of Samples | Fitting Circle Diameter/(Pixel) | Real Value/(mm) | Predictive Value/(mm) | Mean Absolute Error/(mm) |
---|---|---|---|---|---|
1 | 45 | 225.891 | 3.00 | 3.001 | 0.027 |
2 | 50 | 227.495 | 3.00 | 3.022 | 0.023 |
3 | 60 | 227.611 | 3.04 | 3.024 | 0.019 |
4 | 50 | 227.246 | 3.04 | 3.019 | 0.023 |
5 | 50 | 225.031 | 2.98 | 2.989 | 0.028 |
6 | 65 | 222.217 | 2.98 | 2.952 | 0.028 |
Value | Triangle Width | Triangle Length | Square Length | Nut Width | Nut Length |
---|---|---|---|---|---|
Real Value/(mm) | 5.06 | 5.60 | 5.30 | 6.88 | 7.76 |
Mean Predictive Value/(mm) | 5.050 | 5.595 | 5.315 | 6.91 | 7.742 |
Mean Absolute Error/(mm) | 0.010 | 0.005 | 0.015 | 0.026 | 0.018 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Wang, H.; Xu, X.; Liu, Y.; Lu, D.; Liang, B.; Tang, Y. Real-Time Defect Detection for Metal Components: A Fusion of Enhanced Canny–Devernay and YOLOv6 Algorithms. Appl. Sci. 2023, 13, 6898. https://doi.org/10.3390/app13126898
Wang H, Xu X, Liu Y, Lu D, Liang B, Tang Y. Real-Time Defect Detection for Metal Components: A Fusion of Enhanced Canny–Devernay and YOLOv6 Algorithms. Applied Sciences. 2023; 13(12):6898. https://doi.org/10.3390/app13126898
Chicago/Turabian StyleWang, Hongjun, Xiujin Xu, Yuping Liu, Deda Lu, Bingqiang Liang, and Yunchao Tang. 2023. "Real-Time Defect Detection for Metal Components: A Fusion of Enhanced Canny–Devernay and YOLOv6 Algorithms" Applied Sciences 13, no. 12: 6898. https://doi.org/10.3390/app13126898
APA StyleWang, H., Xu, X., Liu, Y., Lu, D., Liang, B., & Tang, Y. (2023). Real-Time Defect Detection for Metal Components: A Fusion of Enhanced Canny–Devernay and YOLOv6 Algorithms. Applied Sciences, 13(12), 6898. https://doi.org/10.3390/app13126898