Method for Color-ring Resistor Detection and Localization in Printed Circuit Board Based on Convolutional Neural Network
-
摘要: 色环电阻是印刷电路板(PCB)中最常用的电子元器件之一,主要依靠色环的排列顺序和颜色等视觉信息进行区分,易发生装配错误。但是色环电阻装配质量的人工检测方法效率低、误检率高,而传统的基于图像处理技术的自动检测方法鲁棒性较差,难以解决不同拍摄角度、物距及光照条件下的PCB板色环电阻检测问题。针对这一问题,该文提出一种基于卷积神经网络(CNN)的PCB板色环电阻自动检测与定位方法,首先采用编码器-解码器结构的卷积神经网络模型及带有权重的交叉熵损失函数的网络训练方法,较好地解决了复杂光照及场景下PCB板色环电阻的图像分割问题;然后采用最小面积外接矩形方法定位单个色环电阻,并通过仿射变换对色环电阻位置进行垂直校正;最后通过高斯模板匹配方法实现了色环电阻的色环定位。采用1270幅PCB图像对该文方法进行了实验和验证,并与传统的基于形态学和基于模板匹配的色环电阻检测方法进行了对比,结果表明,该文方法在召回率、准确率及重叠度等性能指标上具有明显优势,处理速度快,能满足实际应用要求。Abstract: The color-ring resistor is one of the most commonly used electronic components in Printed Circuit Board (PCB). It is featured by sequential color rings, which often brings assembling errors, however. Manual detection of color-ring resistors has low efficiency and high false detection rate. Traditional image-based automatic detection methods have difficulties in dealing with PCB images under various illuminations, imaging distance and views. To solve this problem, an automatic detection and localization method for PCB color-ring resistor is proposed based on Convolution Neural Network (CNN). Firstly, the encoder-decoder CNN model is established and trained using weighted cross-entropy loss function. With CNN, color-ring resistors are segmented from PCB images with complex illumination and scenes. Secondly, each color-ring resistor is localized using minimum area bounding rectangle, and its position is adjusted to the vertical direction by affine transformation. Finally, the localization of color rings on the resistor is achieved by Gaussian template matching. The proposed method is tested and verified by 1270 PCB images, and the result is compared with that of the traditional method (method based on geometric contour, and method based on template matching). It is shown that the proposed method has obvious advantages in performance indices, including recall rate, precision, and intersection of unions, which can meet the requirements of practical applications.
-
图 8 本文方法与Ostu方法[9]的色环分割结果对比
表 1 不同检测方法对图像1-图像4中色环电阻的分割与检测结果
表 2 不同网络层数时色环电阻的分割性能指标对比
平均Acc 平均Recall 平均Precision 平均IoU 平均F1 W=3 0.985 0.970 0.887 0.870 0.925 W=4 0.991 0.959 0.953 0.924 0.995 W=5 0.985 0.883 0.965 0.865 0.921 W=6 0.979 0.837 0.936 0.805 0.881 表 3 CNN在测试集与验证集上的性能指标对比
平均Acc 平均Recall 平均Precision 平均IoU 平均F1 验证集 0.991 0.959 0.953 0.924 0.995 测试集 0.982 0.979 0.851 0.834 0.899 -
熊光洁, 马树元, 聂学俊, 等. 基于机器视觉的高密度电路板缺陷检测系统[J]. 计算机测量与控制, 2011, 19(8): 1824–1826.XIONG Guangjie, MA Shuyuan, NIE Xuejun, et al. Defects inspection system of HID PCB based on machine vision[J]. Computer Measurement &Control, 2011, 19(8): 1824–1826. 吴福培, 张宪民. 印刷电路板无铅焊点假焊的检测[J]. 光学 精密工程, 2011, 19(3): 697–702. doi: 10.3788/OPE.20111903.0697WU Fupei and ZHANG Xianmin. Inspection of pseudo solders for lead-free solder joints in PCBs[J]. Optics and Precision Engineering, 2011, 19(3): 697–702. doi: 10.3788/OPE.20111903.0697 CHEN Y S and WANG J Y. Reading resistor based on image processing[C]. 2015 IEEE International Conference on Machine Learning and Cybernetics, Guangzhou, China, 2015: 566–571. doi: 10.1109/ICMLC.2015.7340616. GAIDHANE V H, HOTE Y V, and SINGH V. An efficient similarity measure approach for PCB surface defect detection[J]. Pattern Analysis and Applications, 2018, 21(1): 277–289. doi: 10.1007/s10044-017-0640-9 倪尧, 鲍宇. 基于目标轮廓几何特征的电容元件定位方法[J]. 计算机工程与科学, 2017, 39(8): 1476–1482. doi: 10.3969/j.issn.1007-130X.2017.08.014NI Yao and BAO Yu. A capacitor element localization method based on geometrical features of target contour[J]. Computer Engineering and Science, 2017, 39(8): 1476–1482. doi: 10.3969/j.issn.1007-130X.2017.08.014 DONG Na, WU C H, IP W H, et al. Chaotic species based particle swarm optimization algorithms and its application in PCB components detection[J]. Expert Systems with Applications, 2012, 39(16): 12501–12511. doi: 10.1016/j.eswa.2012.04.063 王耀南, 刘良江, 周博文, 等. 一种基于混沌优化算法的PCB板元件检测方法[J]. 仪器仪表学报, 2010, 31(2): 410–415. doi: 10.19650/j.cnki.cjsi.2010.02.028WANG Yaonan, LIU Liangjiang, ZHOU Bowen, et al. Detection method of printed circuit board components based on chaotic optimization algorithm[J]. Chinese Journal of Scientific Instrument, 2010, 31(2): 410–415. doi: 10.19650/j.cnki.cjsi.2010.02.028 姜建国, 王国林, 孟宏伟, 等. 一种电子元器件组装结果检测方法[J]. 西安电子科技大学学报: 自然科学版, 2014, 41(3): 110–115, 173. doi: 10.3969/j.issn.1001-2400.2014.03.016JIANG Jianguo, WANG Guolin, MENG Hongwei, et al. Detection method for assembling results of electronic components[J]. Journal of Xidian University, 2014, 41(3): 110–115, 173. doi: 10.3969/j.issn.1001-2400.2014.03.016 毛林威. 轴向色环电阻质量自动检测系统的设计[D]. [硕士论文], 北京理工大学, 2015.MAO Linwei. The design of color-ring resistor quality automatic detection system[D]. [Master dissertation], Beijing Institute of Technology, 2015. CHEN Y S and WANG J Y. Computer vision on color-band resistor and its cost-effective diffuse light source design[J]. Journal of Electronic Imaging, 2016, 25(6): 061409. doi: 10.1117/1.JEI.25.6.061409 BADRINARAYANAN V, KENDALL A, and CIPOLLA R. SegNet: A deep convolutional encoder-decoder architecture for image segmentation[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39(12): 2481–2495. doi: 10.1109/TPAMI.2016.2644615 王海, 蔡英凤, 贾允毅, 等. 基于深度卷积神经网络的场景自适应道路分割算法[J]. 电子与信息学报, 2017, 39(2): 263–269. doi: 10.11999/JEIT160329WANG Hai, CAI Yingfeng, JIA Yunyi, et al. Scene adaptive road segmentation algorithm based on deep convolutional neural network[J]. Journal of Electronics &Information Technology, 2017, 39(2): 263–269. doi: 10.11999/JEIT160329 DUAN Jiaxu, LIU Xiaoyan, WU Xin, et al. Detection and segmentation of iron ore green pellets in images using lightweight U-net deep learning network[J]. Neural Computing and Applications, 2020, 32(10): 5775–5790. doi: 10.1007/s00521-019-04045-8 YE Ruifang, PAN C S, CHANG Ming, et al. Intelligent defect classification system based on deep learning[J]. Advances in Mechanical Engineering, 2018, 10(3): 1–7. doi: 10.1177/1687814018766682 ZHANG Shifeng, WEN Longyin, BIAN Xiao, et al. Single-shot refinement neural network for object detection[C]. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, USA, 2018: 18–23. doi: 10.1109/CVPR.2018.00442. REN Shaoqing, HE Kaiming, GIRSHICK R, et al. Faster RCNN: Towards real-time object detection with region proposal networks[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39(6): 1137–1149. doi: 10.1109/TPAMI.2016.2577031 张烨, 许艇, 冯定忠, 等. 基于难分样本挖掘的快速区域卷积神经网络目标检测研究[J]. 电子与信息学报, 2019, 41(6): 1496–1502. doi: 10.11999/JEIT180702ZHANG Ye, XU Ting, FENG Dingzhong, et al. Research on faster RCNN object detection based on hard example mining[J]. Journal of Electronics &Information Technology, 2019, 41(6): 1496–1502. doi: 10.11999/JEIT180702 IOFFE S and SZEGEDY C. Batch normalization: Accelerating deep network training by reducing internal covariate shift[C]. The 32nd International Conference on Machine Learning, Lille, France, 2015: 448–456. KINGMA D P and BA J. Adam: A method for stochastic optimization[C]. The 3rd International Conference on Learning Representations (ICLR), San Diego, USA, 2015: 1–13. 邸男, 李桂菊, 陈春宁, 等. 结合归一化差分高斯特征的图像匹配技术研究[J]. 电子测量与仪器学报, 2014, 28(6): 585–590. doi: 10.13382/j.jemi.2014.06.002DI Nan, LI Guiju, CHEN Chunning, et al. Image matching technology research based on normalized DOG features[J]. Journal of Electronic Measurement and Instrumentation, 2014, 28(6): 585–590. doi: 10.13382/j.jemi.2014.06.002 卢倩雯, 陶青川, 赵娅琳, 等. 基于生成对抗网络的漫画草稿图简化[J]. 自动化学报, 2018, 44(5): 75–89. doi: 10.16383/j.aas.2018.c170486LU Qianwen, TAO Qingchuan, ZHAO Yalin, et al. Sketch simplification using generative adversarial networks[J]. Acta Automatica Sinica, 2018, 44(5): 75–89. doi: 10.16383/j.aas.2018.c170486