CN114004826B - A vision-based method for detecting appearance defects of medical injection molded parts - Google Patents

A vision-based method for detecting appearance defects of medical injection molded parts Download PDF

Info

Publication number
CN114004826B
CN114004826B CN202111343233.8A CN202111343233A CN114004826B CN 114004826 B CN114004826 B CN 114004826B CN 202111343233 A CN202111343233 A CN 202111343233A CN 114004826 B CN114004826 B CN 114004826B
Authority
CN
China
Prior art keywords
image
injection molded
medical injection
light
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111343233.8A
Other languages
Chinese (zh)
Other versions
CN114004826A (en
Inventor
张立兴
毛亮
孟春婵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bokeshi Suzhou Technology Co ltd
Original Assignee
Bokeshi Suzhou Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bokeshi Suzhou Technology Co ltd filed Critical Bokeshi Suzhou Technology Co ltd
Priority to CN202111343233.8A priority Critical patent/CN114004826B/en
Publication of CN114004826A publication Critical patent/CN114004826A/en
Application granted granted Critical
Publication of CN114004826B publication Critical patent/CN114004826B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/02Affine transformations
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Molecular Biology (AREA)
  • Artificial Intelligence (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Injection Moulding Of Plastics Or The Like (AREA)

Abstract

本发明公开了一种基于视觉模板匹配结合深度学习的医用注塑件外观缺陷检测方法,包括:在环光和集光两种光源下分别对待测医用注塑件拍照成像,获取待测医用注塑件的环光图像和集光图像;使用深度学习模型对待测医用注塑件的环光图像进行缺胶、麻点以及合模线的缺陷特征检测,保存该环光图像的环光判决结果;使用模板匹配方法对待测医用注塑件的集光图像进行披锋、毛边的缺陷特征检测,输出该集光图像的集光判决结果;将环光判决结果和集光判决结果整合,全部合格时,输出该待测医用注塑件的检测结果为合格品,否则为不良品。本发明可在保证生产节拍的前提下,快速将不合格品检出,通过将两类检测结果综合评判输出,减少了对单个样品的处理时间。

The present invention discloses a method for detecting appearance defects of medical injection molded parts based on visual template matching combined with deep learning, comprising: photographing and imaging the medical injection molded parts to be tested under two light sources, namely, ring light and collected light, respectively, to obtain the ring light image and the collected light image of the medical injection molded parts to be tested; using a deep learning model to detect the defect characteristics of lack of glue, pitting and mold line on the ring light image of the medical injection molded parts to be tested, and saving the ring light judgment result of the ring light image; using a template matching method to detect the defect characteristics of burrs and burrs on the collected light image of the medical injection molded parts to be tested, and outputting the collected light judgment result of the collected light image; integrating the ring light judgment result and the collected light judgment result, and outputting the detection result of the medical injection molded parts to be tested as qualified products when all are qualified, otherwise as defective products. The present invention can quickly detect unqualified products under the premise of ensuring the production rhythm, and reduces the processing time for a single sample by comprehensively judging and outputting the two types of detection results.

Description

一种基于视觉的医用注塑件的外观缺陷检测方法A vision-based method for detecting appearance defects of medical injection molded parts

技术领域Technical Field

本发明涉及计算机视觉识别技术领域,尤其涉及一种基于视觉的医用注塑件的外观缺陷检测方法。The invention relates to the technical field of computer vision recognition, and in particular to a method for detecting appearance defects of medical injection molded parts based on vision.

背景技术Background Art

此注塑件用于呼吸机的吸气混合部分,作用为将输入呼吸机的空气和氧气进行混合,并保证呼吸机的气密性,是呼吸机中非常重要的零部件。目前对于注塑件检测的痛点在于存在微小的缺陷,传统的人工检测方法稳定性及效率较差。This injection molded part is used in the inhalation mixing part of the ventilator. Its function is to mix the air and oxygen input into the ventilator and ensure the air tightness of the ventilator. It is a very important part of the ventilator. At present, the pain point of injection molded part inspection is the existence of tiny defects. The traditional manual inspection method has poor stability and efficiency.

现有技术中,Eggert等人在ACM的Improving small object proposals forcompany logo detection一文中提出了一种基于特征图上采样的候选框提取方法,他们使用高分辨率的特征图来提取小目标的候选框,一方面让候选框更接近于目标框,另一方面也通过放大特征图增强了小目标的信息。In the prior art, Eggert et al. proposed a candidate box extraction method based on feature map upsampling in the ACM paper Improving small object proposals for company logo detection. They used high-resolution feature maps to extract candidate boxes for small targets, which not only made the candidate boxes closer to the target boxes, but also enhanced the information of small targets by enlarging the feature maps.

Singh等人在IEEE的An analysis of scale invariance in object detectionsnip一文中提出通过将数据集中不同尺寸的目标划分成不同的子集,同时在网络中设计多个检测不同尺寸的检测器,然后让不同尺寸的目标分别通过网络中检测对应尺寸的检测器,从而避免了数据集中的类别不均衡问题,让小目标的检测效果更好。Singh et al. proposed in the IEEE paper An analysis of scale invariance in object detection snip that by dividing objects of different sizes in the data set into different subsets, designing multiple detectors for detecting different sizes in the network, and then allowing objects of different sizes to pass through the detectors of corresponding sizes in the network, they can avoid the problem of class imbalance in the data set and achieve better detection of small objects.

Yu等人在IEEE/CVF的Scale match for tiny person detection一文中提出将目标周围的信息融合进当前目标的特征中,从而获得更好的针对小目标的特征表示,有效提升了小目标检测的效果。Yu et al. proposed in the IEEE/CVF paper Scale match for tiny person detection to integrate the information around the target into the features of the current target, so as to obtain better feature representation for small targets, effectively improving the effect of small target detection.

现有的检测技术对于硅胶件的检测精度达不到产品的检测要求,且无法在生产节拍的时间范围内完成对硅胶件的检测。The existing detection technology cannot meet the detection requirements of silicone parts in terms of detection accuracy, and cannot complete the detection of silicone parts within the time frame of the production cycle.

发明内容Summary of the invention

为解决上述技术问题,本发明实施例提供一种基于视觉的医用注塑件的外观缺陷检测方法,In order to solve the above technical problems, an embodiment of the present invention provides a method for detecting appearance defects of medical injection molded parts based on vision.

一种基于视觉的医用注塑件的外观缺陷检测方法,包括如下步骤:A method for detecting appearance defects of medical injection molded parts based on vision comprises the following steps:

步骤S1:在环光和集光两种光源下分别对待测医用注塑件拍照成像,获取待测医用注塑件的环光图像和集光图像;Step S1: photographing and imaging the medical injection molded part to be tested under two light sources, an annular light and a concentrated light, respectively, to obtain an annular light image and a concentrated light image of the medical injection molded part to be tested;

步骤S2:使用深度学习模型对待测医用注塑件的环光图像进行缺胶、麻点以及合模线的缺陷特征检测,保存该环光图像的环光判决结果;Step S2: using a deep learning model to detect defect features of glue shortage, pitting and parting line on the ring light image of the medical injection molded part to be tested, and saving the ring light judgment result of the ring light image;

步骤S3:使用模板匹配方法对待测医用注塑件的集光图像进行披锋、毛边的缺陷特征检测,输出该集光图像的集光判决结果;Step S3: using a template matching method to detect the defect features of burrs and burrs on the light collection image of the medical injection molded part to be tested, and outputting the light collection judgment result of the light collection image;

步骤S4:将环光判决结果和集光判决结果整合,全部合格时,输出该待测医用注塑件的检测结果为合格品,否则为不良品。Step S4: Integrate the ring light judgment result and the collected light judgment result. If all are qualified, output the inspection result of the medical injection molded part to be tested as a qualified product, otherwise it is a defective product.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,所述深度学习模型的预训练过程包括步骤:Preferably, in the above-mentioned vision-based appearance defect detection method for medical injection molded parts, the pre-training process of the deep learning model includes the steps of:

步骤S21:采集医用注塑件在环光光源下的环光图像;Step S21: collecting a ring light image of the medical injection molded part under a ring light source;

步骤S22:对存在麻点、缺胶、合模线缺陷的环光图像进行标注,生成缺胶、麻点以及合模线的缺陷检测数据集;Step S22: annotating the ring light images with defects such as pitting, glue deficiency, and parting line defects to generate a defect detection data set of glue deficiency, pitting, and parting line defects;

步骤S23:将所述步骤S22中生成的缺陷检测数据集作为训练数据集输入至缺陷检测网络中;Step S23: inputting the defect detection data set generated in step S22 into the defect detection network as a training data set;

步骤S24:训练得到缺陷的种类、中心点、边界框信息;Step S24: training to obtain defect type, center point, and bounding box information;

步骤S25:输出深度学习模型。Step S25: Output the deep learning model.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,所述步骤S3包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, step S3 comprises:

步骤S31:选取合格医用注塑件样品在集光光源下拍照成像,获取一张合格医用注塑件的模板图像,标注模板图像中的特征点;Step S31: Select a qualified medical injection molded part sample and take a photo of it under a light source to obtain a template image of the qualified medical injection molded part, and mark the feature points in the template image;

步骤S32:按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点;Step S32: marking the characteristic points on the light-collecting image of the medical injection molded part to be tested that are consistent with the characteristic points in the template image in order;

步骤S33:对模板图像进行两次仿射变换,将得到的仿射变换图像与集光图像进行作差,得到两幅差分图像,然后对两幅差分图像取与;Step S33: performing two affine transformations on the template image, subtracting the obtained affine transformation image from the light-collecting image to obtain two differential images, and then performing AND operation on the two differential images;

步骤S34:对取与后的图像的各个区域进行连通域分析,过滤掉面积较小的区域;Step S34: Performing connected domain analysis on each region of the image after ANDing, filtering out regions with smaller areas;

步骤S35:通过面积过滤后的图像区域分别进行前景面积、轮廓相似度、梯度的计算;Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering;

步骤S36:综合判断计算后的值是否大于阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断。Step S36: Comprehensively judge whether the calculated value is greater than the threshold value. If so, output this part as a defect feature, otherwise proceed to judge the next area.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S31中,在标注模板图像中的特征点之前,还包括对所述模板图像的图像预处理,对所述模板图像的图像预处理包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S31, before marking the feature points in the template image, it also includes image preprocessing of the template image, and the image preprocessing of the template image includes:

对获取到的所述模板图像进行ROI区域提取,以减小图像大小,加快后续的处理速度。The ROI region is extracted from the acquired template image to reduce the image size and speed up subsequent processing.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S32中,在标注待测医用注塑件的集光图像上的特征点之前,还包括对所述集光图像的图像预处理,对所述集光图像的图像预处理包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S32, before marking the feature points on the light-collecting image of the medical injection molded part to be tested, the image preprocessing of the light-collecting image is also included, and the image preprocessing of the light-collecting image includes:

对获取到的所述待测医用注塑件的集光图像进行ROI区域提取,将所述集光图像的尺寸缩放到与所述模板图像的尺寸一致。The ROI region is extracted from the acquired light-collecting image of the medical injection molded part to be tested, and the size of the light-collecting image is scaled to be consistent with the size of the template image.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S31中,所述标注模板图像中的特征点,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S31, the feature points in the annotation template image include:

标注模板图像的8个特征点的质心点,按照质心坐标的x值进行编号排序,将8个质心点分为两组。The centroid points of the eight feature points of the labeled template image are numbered and sorted according to the x-values of the centroid coordinates, and the eight centroid points are divided into two groups.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S32中,所述按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S32, the step of sequentially marking the feature points on the light-collecting image of the medical injection molded part to be tested that are consistent with the feature points in the template image includes:

标注待测医用注塑件的集光图像的8个特征点的质心点,并按照与模板图像中的8个质心点相同的顺序,对集光图像的8个质心点进行编号,并分为两组。The centroid points of the eight feature points of the light-collecting image of the medical injection molded part to be tested are marked, and the eight centroid points of the light-collecting image are numbered in the same order as the eight centroid points in the template image, and divided into two groups.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S33中,所述对模板图像进行两次仿射变换,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S33, performing two affine transformations on the template image includes:

使用两组对应的质心点,将模板图像进行两次仿射变换,得到仿射变换图像。Using two sets of corresponding centroid points, the template image is affine transformed twice to obtain an affine transformed image.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S34中,所述对取与后的图像的各个区域进行连通域分析,过滤掉面积较小的区域,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S34, the connected domain analysis is performed on each region of the acquired image to filter out regions with smaller areas, including:

对取与后的图像的各个区域进行连通域分析,找出连通域面积大于5的区域,过滤掉面积小于5的区域。Perform connected domain analysis on each area of the image after ANDing, find out the areas with connected domain area greater than 5, and filter out the areas with area less than 5.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S35中,所述通过面积过滤后的图像区域进行前景面积计算,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S35, the foreground area calculation of the image area after area filtering includes:

进行前景面积搜索,找出前景面积最大的区域,将模板图像和待测医用Perform foreground area search to find the area with the largest foreground area and compare the template image with the medical image to be tested.

注塑件的集光图像的该区域进行截取;The region of the light-collecting image of the injection molded part is intercepted;

根据计算比较模板图像和待测医用注塑件的集光图像的Hu不变矩,其中,7个不变矩组表示如下:The Hu invariant moments of the template image and the collected light image of the medical injection molded part to be tested are calculated and compared, where the 7 invariant moment groups are expressed as follows:

I1=y20+y02 (1)I 1 =y 20 +y 02 (1)

I3=(y30+3y)2+(3y21-y03)2 (3)I 3 =(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3)

I4=(y30+y12)2+(y21+y03)2 (4)I 4 =(y 30 +y 12 ) 2 +(y 21 +y 03 ) 2 (4)

I6=(y20-y02)[(y30+y12)2-(y21+y03)2]+4y11(y30+y12)(y21+y03) (6)I 6 =(y 20 -y 02 )[(y 30 +y 12 ) 2 -(y 21 +y 03 ) 2 ]+4y 11 (y 30 +y 12 )(y 21 +y 03 ) (6)

其中,ypq为(p+q)阶矩,p、q为0-3之间的整数,I1-I7为7个不变矩。Among them, y pq is the (p+q)th order moment, p and q are integers between 0 and 3, and I 1 -I 7 are 7 invariant moments.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S35中,所述通过面积过滤后的图像区域进行轮廓相似度的计算,轮廓相似度的计算表达式为:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S35, the contour similarity of the image area after area filtering is calculated, and the calculation expression of the contour similarity is:

其中,分别是图像A,B的Hu矩。in, are the Hu moments of images A and B respectively.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S35中,所述通过面积过滤后的图像区域进行梯度计算,梯度计算的表达式为:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S35, the image area after area filtering is subjected to gradient calculation, and the expression for gradient calculation is:

其中,G(x,y)为坐标为(x,y)点的灰度值,Gx(x,y)为x方向梯度,Gy(x,y)为y方向梯度,为点(x,y)处的梯度值,θ(x,y)为梯度方向。Among them, G(x,y) is the grayscale value of the point with coordinates (x,y), Gx (x,y) is the gradient in the x direction, and Gy (x,y) is the gradient in the y direction. is the gradient value at the point (x, y), and θ(x, y) is the gradient direction.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S36中,所述综合判断计算后的值是否大于阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断,包括:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S36, the comprehensive judgment is whether the calculated value is greater than a threshold value, if so, this part is output as a defect feature, otherwise, the judgment of the next area is performed, including:

步骤S361:根据所述步骤S35中计算出的前景面积值进行判断,如果前景面积大于所设置的阈值,则该区域判为缺陷,否则判断轮廓相似度;Step S361: judging according to the foreground area value calculated in step S35, if the foreground area is greater than the set threshold, the area is judged as a defect, otherwise the contour similarity is judged;

步骤S362:若轮廓相似度小于设置的阈值,则将该区域进行剔除;Step S362: if the contour similarity is less than the set threshold, the area is eliminated;

步骤S363:根据轮廓相似度与梯度之和作为判决条件,如果大于阈值,则该位置判定为缺陷区域;Step S363: using the sum of the contour similarity and the gradient as a judgment condition, if it is greater than a threshold, the position is determined to be a defective area;

步骤S364:在得到所有可能为缺陷区域的位置后,计算候选框区域的质心到注塑件质心的距离,并以此判断候选区域的位置,对于候选区域在外边缘的区域,放宽判决条件,若最终存在缺陷区域,则输出该集光图像的集光判决结果为不合格,否则输出该集光图像的集光判决结果为合格。Step S364: After obtaining the positions of all possible defective areas, calculate the distance from the centroid of the candidate frame area to the centroid of the injection molded part, and use this to determine the position of the candidate area. For the area on the outer edge of the candidate area, relax the judgment conditions. If a defective area exists in the end, the light collection judgment result of the light collection image is output as unqualified. Otherwise, the light collection judgment result of the light collection image is output as qualified.

本发明的有益效果为:本发明提出的基于视觉的医用注塑件的外观缺陷检测方法在保证流水线进行快速生产的情况下,可以对医用注塑件的进行快速准确的检测。采用的深度学习搭配模板匹配的算法模型,解决了传统方法无法在短时间内对全部样品进行多种缺陷检测的问题,对于单个样品的处理时间只需600ms,完全满足流水线生产的节拍要求,提高产线的自动化程度。The beneficial effects of the present invention are as follows: the visual-based appearance defect detection method for medical injection molded parts proposed by the present invention can quickly and accurately detect medical injection molded parts while ensuring rapid production of the assembly line. The algorithm model of deep learning combined with template matching solves the problem that traditional methods cannot perform multiple defect detection on all samples in a short time. The processing time for a single sample is only 600ms, which fully meets the rhythm requirements of assembly line production and improves the automation level of the production line.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

图1为本发明的流程图;Fig. 1 is a flow chart of the present invention;

图2为本发明的医用注塑件的拍照结构主视图;FIG2 is a front view of the photographic structure of the medical injection molded part of the present invention;

图3为本发明的医用注塑件在玻璃载具上的俯视图;FIG3 is a top view of the medical injection molded part of the present invention on a glass carrier;

图4为本发明的合格品医用注塑件的集光图像;FIG4 is a light-collecting image of a qualified medical injection molded part of the present invention;

图5为本发明具有毛边的不良品医用注塑件的集光图像;FIG5 is a light-collecting image of a defective medical injection molded part with burrs according to the present invention;

图6为本发明具有披锋的不良品医用注塑件的集光图像;FIG6 is a light-collecting image of a defective medical injection molded part with flash according to the present invention;

图7为本发明的合格品医用注塑件的环光图像;FIG. 7 is a ring light image of a qualified medical injection molded part of the present invention;

图8为本发明具有合模不良的不良品医用注塑件的环光图像;FIG8 is a ring light image of a defective medical injection molded part with poor mold closing according to the present invention;

图9为本发明具有麻点的不良品医用注塑件的环光图像。FIG. 9 is a ring light image of a defective medical injection molded part having pitting according to the present invention.

具体实施方式DETAILED DESCRIPTION

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

医用注塑件的缺陷类型可以抽象分为形态类和纹理类。光学成像方案分别针对这两种缺陷种类进行环光和集光两种方式拍摄。The defect types of medical injection molded parts can be abstractly divided into morphological and texture types. The optical imaging solution uses two methods to shoot these two types of defects: ring light and concentrated light.

对于形态类的缺陷,主要表现为毛边和披锋,这些缺陷会在一定程度上改变注塑件的形态,使用集光进行成像拍摄,可以达到很好的表现注塑件的形态特征,而淡化其他特征的效果,有助于降低算法处理中的匹配误差,提高检测的精度,解决微小缺陷漏检的问题。For morphological defects, they are mainly manifested as burrs and flashes. These defects will change the shape of the injection molded parts to a certain extent. Using concentrated light for imaging can well show the morphological characteristics of the injection molded parts, while downplaying the effect of other features. This helps to reduce matching errors in algorithm processing, improve detection accuracy, and solve the problem of missed detection of minor defects.

对于纹理类的缺陷,主要表现为麻点和合模线,使用环光进行拍摄,能够在成像中进行良好的细节呈现,可以优化深度学习模型对于注塑件特征信息的提取能力,提高模型判断的准确性,并精确的标记出缺陷所在的位置,方便检测人员进行缺陷观察,更好的指导生产的改进。For texture defects, which mainly manifest as pitting and mold lines, using ring light for shooting can present good details in the image, optimize the deep learning model's ability to extract feature information of injection molded parts, improve the accuracy of model judgment, and accurately mark the location of defects, making it easier for inspectors to observe defects and better guide production improvements.

采用环光和集光两种打光方式的相互配合,在成像中最大程度的还原了医用注塑件的形态特征及纹理特征,对两种打光下的图片进行分线程处理,再综合判断,这样不仅提高了检测的速度,而且保证了对缺陷的准确检出,完全满足医用注塑件的生产检测需求,大大提高了生产的自动化程度。By using the coordination of ring light and focused light, the morphological and texture features of medical injection molded parts are restored to the greatest extent in the imaging. The images under the two lighting modes are processed in different threads and then comprehensively judged. This not only improves the speed of detection, but also ensures the accurate detection of defects, fully meets the production and inspection needs of medical injection molded parts, and greatly improves the degree of production automation.

请参见图1,本发明提出了一种基于视觉的医用注塑件的外观缺陷检测方法,包括如下步骤:Referring to FIG. 1 , the present invention proposes a method for detecting appearance defects of medical injection molded parts based on vision, comprising the following steps:

步骤S1:玻璃载具1沿着设定方向移动,当待测医用注塑件2移动至预设位置时,首先待测医用注塑件2上方的侧向低角度环形光源3(环光光源)打开,对待测医用注塑件2进行环光拍摄;然后关闭侧向低角度环形光源3,打开底部平行集光源4(集光光源),对待测医用注塑件2进行集光拍摄。由此得到待测医用注塑件2在两种光源下的成像效果图,分别为环光图像和集光图像;Step S1: The glass carrier 1 moves along a set direction. When the medical injection molded part 2 to be tested moves to a preset position, the lateral low-angle annular light source 3 (annular light source) above the medical injection molded part 2 to be tested is first turned on to perform annular light photography of the medical injection molded part 2 to be tested; then the lateral low-angle annular light source 3 is turned off, and the bottom parallel light source 4 (light collecting light source) is turned on to perform light collecting photography of the medical injection molded part 2 to be tested. Thus, imaging effect diagrams of the medical injection molded part 2 to be tested under two light sources are obtained, which are annular light images and light collecting images respectively;

步骤S2:在环光下可以将待测医用注塑件2的表面缺陷清晰的显示出来,存在缺陷的区域与正常区域存在较大的纹理性差别,使用深度学习模型对待测医用注塑件2的环光图像进行缺胶、麻点以及合模线的缺陷特征检测,存在缺陷的位置,会在图片中用矩形框进行框选显示,保存该环光图像的环光判决结果;Step S2: Under the ring light, the surface defects of the medical injection molded part 2 to be tested can be clearly displayed. There is a large texture difference between the defective area and the normal area. The ring light image of the medical injection molded part 2 to be tested is used to detect the defect features of glue shortage, pitting and mold line using a deep learning model. The location of the defect will be selected and displayed in a rectangular frame in the image, and the ring light judgment result of the ring light image is saved;

步骤S3:使用模板匹配方法对待测医用注塑件2的集光图像进行披锋、毛边的缺陷特征检测。找出待测医用注塑件2的8个孔的质心,按横坐标按从小到大进行排序。然后将修正后的检测图像与制作的标准模板图像进行差分,存在毛边及披锋的位置在差分后会出现一定面积的白色区域。对这些白色区域进行逐步分析,计算这些区域的面积,梯度,相似度等参数。如果所有区域参数都没有超过设定条件,则该待测医用注塑件2被判合格,否则判为不合格,对于存在缺陷的位置,在最终显示的图中会使用矩形框进行框选显示,输出该集光图像的判决结果;Step S3: Use the template matching method to detect the defect features of burrs and burrs on the light-collecting image of the medical injection-molded part 2 to be tested. Find the centroids of the 8 holes of the medical injection-molded part 2 to be tested, and sort them in ascending order according to the horizontal coordinate. Then perform a difference between the corrected test image and the produced standard template image. After the difference, white areas of a certain area will appear at the locations where burrs and burrs exist. Perform a step-by-step analysis on these white areas, and calculate the area, gradient, similarity and other parameters of these areas. If all area parameters do not exceed the set conditions, the medical injection-molded part 2 to be tested is judged to be qualified, otherwise it is judged to be unqualified. For the locations where defects exist, a rectangular frame will be used to select and display them in the final displayed image, and the judgment result of the light-collecting image will be output;

步骤S4:将环光判决结果和集光判决结果整合,全部合格时,输出该待测医用注塑件2的检测结果为合格品,否则为不良品。Step S4: Integrate the ring light judgment result and the collected light judgment result. If all are qualified, output the detection result of the medical injection molded part 2 to be tested as a qualified product, otherwise it is a defective product.

如图2和图3所示,图2为本发明的待测医用注塑件2的拍照结构主视图,其中,待测医用注塑件2(产品)分布在高透光玻璃1上,高透光玻璃1设在高透光玻璃载具5上,可沿着直线方向移动。高透光玻璃1的上方设置相机6,通过相机6对下方经过的待测医用注塑件2(产品)进行拍照。其中,高透光玻璃1正下方设置底部平行集光源4(集光光源),为待测医用注塑件2(产品)提供集光光源。在高透光玻璃1的上方,位于待测医用注塑件2(产品)的上方周侧,设有环向围绕的侧向低角度环形光源3(环光光源),通过该侧向低角度环形光源3可为待测医用注塑件2(产品)提供环光光源。As shown in Figures 2 and 3, Figure 2 is a front view of the photographing structure of the medical injection molded part 2 to be tested of the present invention, wherein the medical injection molded part 2 (product) to be tested is distributed on the high light transmittance glass 1, and the high light transmittance glass 1 is arranged on the high light transmittance glass carrier 5 and can move along a straight line. A camera 6 is arranged above the high light transmittance glass 1, and the medical injection molded part 2 (product) to be tested passing below is photographed by the camera 6. Among them, a bottom parallel light source 4 (light collecting light source) is arranged directly below the high light transmittance glass 1 to provide a light collecting light source for the medical injection molded part 2 (product) to be tested. Above the high light transmittance glass 1, located on the upper peripheral side of the medical injection molded part 2 (product) to be tested, a circumferentially surrounding lateral low-angle annular light source 3 (ring light source) is arranged, and the lateral low-angle annular light source 3 can provide a ring light source for the medical injection molded part 2 (product) to be tested.

具体地,玻璃载具5沿着设定方向移动,当待测医用注塑件2(产品)移动至预设位置时,首先待测医用注塑件2(产品)上方的侧向低角度环形光源3打开,对经过的待测医用注塑件2(产品)进行环光拍摄,用于麻点、合模线、缺胶的检测。然后,关闭侧向低角度环形光源3,打开玻璃载具5下方的底部平行集光源4,对经过的待测医用注塑件2(产品)进行集光拍摄,用于毛边和披锋的检测。Specifically, the glass carrier 5 moves along the set direction, and when the medical injection molded part 2 (product) to be tested moves to the preset position, the lateral low-angle annular light source 3 above the medical injection molded part 2 (product) to be tested is first turned on, and the passing medical injection molded part 2 (product) is photographed with an annular light for the detection of pitting, mold line, and glue deficiency. Then, the lateral low-angle annular light source 3 is turned off, and the bottom parallel light source 4 below the glass carrier 5 is turned on, and the passing medical injection molded part 2 (product) is photographed with an annular light for the detection of burrs and flashes.

其中,图4所示为集光光源下的合格品医用注塑件,图5为具有毛边的不良品医用注塑件的集光图像,图6为具有披锋的不良品医用注塑件的集光图像,图7所示为为环光图像下的合格品医用注塑件,图8为具有合模不良的不良品医用注塑件的环光图像,图9为具有麻点的不良品医用注塑件的环光图像。Among them, Figure 4 shows qualified medical injection molded parts under a concentrated light source, Figure 5 is a concentrated light image of a defective medical injection molded part with burrs, Figure 6 is a concentrated light image of a defective medical injection molded part with burrs, Figure 7 shows qualified medical injection molded parts under a ring light image, Figure 8 is a ring light image of a defective medical injection molded part with poor mold closing, and Figure 9 is a ring light image of a defective medical injection molded part with pockmarks.

进一步地,在本发明的优选实施中,所述深度学习模型的预训练过程包括步骤:Furthermore, in a preferred embodiment of the present invention, the pre-training process of the deep learning model comprises the steps of:

步骤S21:采集医用注塑件在环光光源下的环光图像,挑选出存在缺陷的图像;Step S21: collecting the ring light image of the medical injection molded part under the ring light source, and selecting the image with defects;

步骤S22:对存在麻点、缺胶、合模线缺陷的环光图像利用labelimg软件进行标注,将存在缺陷的位置利用矩形框进行框出,软件可以自动生成.xml文件保存标注信息,这样就可以生成缺胶、麻点以及合模线的缺陷检测数据集;Step S22: label the ring light image with pitting, glue deficiency and parting line defects using labelimg software, and frame the defective position with a rectangular frame. The software can automatically generate an .xml file to save the labeling information, so that a defect detection data set of glue deficiency, pitting and parting line can be generated;

步骤S23:将所述步骤S22中生成的缺陷检测数据集作为训练数据集输入至缺陷检测网络中,网络会根据标注的位置及标注的缺陷种类对网络参数进行优化;Step S23: input the defect detection data set generated in step S22 as a training data set into the defect detection network, and the network will optimize the network parameters according to the marked positions and marked defect types;

步骤S24:经过训练模型会得到数据集缺陷的种类、边界框及置信度信息;Step S24: After the training model, the type, bounding box and confidence information of the data set defects will be obtained;

步骤S25:将训练好的权重文件、缺陷名称、网络结构信息作为输出文件,输出深度学习模型。Step S25: Use the trained weight file, defect name, and network structure information as output files to output the deep learning model.

进一步地,在本发明的优选实施中,所述步骤S3包括:Furthermore, in a preferred embodiment of the present invention, step S3 includes:

步骤S31:选取合格医用注塑件样品在集光光源下拍照成像,获取一张合格医用注塑件的模板图像,标注模板图像中的特征点,用于检测时与待检样品图像进行比对;Step S31: Select a qualified medical injection molded part sample and take a photo of it under a light source to obtain a template image of the qualified medical injection molded part, and mark the feature points in the template image for comparison with the sample image to be tested during testing;

步骤S32:按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点,计算得到图像中8个孔的质心位置,按坐标次序对8个孔的质心进行编号,将质心点分为两组,分别与模板图中对应编号的质心进行对应匹配。Step S32: mark the feature points on the light-collecting image of the medical injection molded part to be tested that are consistent with the feature points in the template image in order, calculate the centroid positions of the 8 holes in the image, number the centroids of the 8 holes in order of coordinates, divide the centroid points into two groups, and match them with the centroids of corresponding numbers in the template image respectively.

步骤S33:利用两组质心匹配,对模板图像进行两次仿射变换,将得到的仿射变换图像与集光图像进行作差,得到两幅差分图像,然后对两幅差分图像取与,得到待检图像与标准模板图像存在不同的区域;Step S33: using two sets of centroid matching, perform two affine transformations on the template image, subtract the obtained affine transformation image from the light collection image to obtain two differential images, and then perform ANDing on the two differential images to obtain the area where the image to be tested and the standard template image are different;

步骤S34:对取与后的图像的各个区域进行连通域分析,计算每个连通域的面积,根据缺陷的尺寸要求,设置筛选的阈值,过滤掉面积较小的区域;Step S34: Performing connected domain analysis on each area of the acquired image, calculating the area of each connected domain, setting a screening threshold according to the defect size requirements, and filtering out areas with smaller areas;

步骤S35:通过面积过滤后的图像区域分别进行前景面积、轮廓相似度、梯度的计算;Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering;

步骤S36:综合设计判决器,判断计算后的值是否大于设定阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断,直至将所有连通域分析完毕,若不存在缺陷区域,将此待检品判为合格,否则判为不合格品。Step S36: A comprehensive judgment device is designed to judge whether the calculated value is greater than the set threshold. If so, this part is output as a defect feature, otherwise the next area is judged until all connected domains are analyzed. If there is no defective area, the product to be inspected is judged as qualified, otherwise it is judged as unqualified.

进一步地,在本发明的优选实施中,在所述步骤S31中,在标注模板图像中的特征点之前,还包括对所述模板图像的图像预处理,对所述模板图像的图像预处理包括:Furthermore, in a preferred embodiment of the present invention, in the step S31, before marking the feature points in the template image, the image preprocessing of the template image is also included, and the image preprocessing of the template image includes:

对获取到的所述模板图像寻找注塑件的位置,然后以注塑件最小外接矩形作为基础,四条边各向外扩展50各像素,作为图像的ROI区域,进行ROI区域提取,以减小图像大小,加快后续的处理速度。The position of the injection molded part is found for the template image obtained, and then the minimum circumscribed rectangle of the injection molded part is used as the basis, and the four sides are each expanded outward by 50 pixels as the ROI area of the image, and the ROI area is extracted to reduce the image size and speed up the subsequent processing.

进一步地,在本发明的优选实施中,在所述步骤S32中,在标注待测医用注塑件的集光图像上的特征点之前,还包括对所述集光图像的图像预处理,对所述集光图像的图像预处理包括:Furthermore, in a preferred embodiment of the present invention, in the step S32, before marking the feature points on the light-collecting image of the medical injection molded part to be tested, the image preprocessing of the light-collecting image is also included, and the image preprocessing of the light-collecting image includes:

对获取到的所述待测的集光图像寻找注塑件的位置,然后以注塑件最小外接矩形作为基础,四条边各向外扩展50各像素,作为图像的ROI区域,进行ROI区域提取,将所述集光图像的尺寸缩放到与所述模板图像的尺寸一致。The position of the injection molded part is found in the acquired light-collecting image to be tested, and then the minimum circumscribed rectangle of the injection molded part is used as the basis, and the four sides are each expanded outward by 50 pixels as the ROI area of the image, and the ROI area is extracted, and the size of the light-collecting image is scaled to be consistent with the size of the template image.

进一步地,在本发明的优选实施中,在所述步骤S31中,所述标准模板图像中的特征点,包括:Furthermore, in a preferred implementation of the present invention, in step S31, the feature points in the standard template image include:

提取标准模板图像的8个孔的的质心点,按照质心坐标的x值进行编号排序,将8个质心点分为两组。The centroid points of the eight holes of the standard template image are extracted, numbered and sorted according to the x-values of the centroid coordinates, and the eight centroid points are divided into two groups.

进一步地,在本发明的优选实施中,在所述步骤S32中,所述按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点,包括:Further, in a preferred embodiment of the present invention, in step S32, the step of sequentially marking the feature points on the light-collecting image of the medical injection molded part to be tested that are consistent with the feature points in the template image includes:

标注待测医用注塑件的集光图像的8个特征点的质心点,并按照与模板图像中的8个质心点相同的顺序,对集光图像的8个质心点进行编号,并分为两组。The centroid points of the eight feature points of the light-collecting image of the medical injection molded part to be tested are marked, and the eight centroid points of the light-collecting image are numbered in the same order as the eight centroid points in the template image, and divided into two groups.

进一步地,在本发明的优选实施中,在所述步骤S33中,所述对模板图像进行两次仿射变换,包括:Furthermore, in a preferred implementation of the present invention, in step S33, performing two affine transformations on the template image includes:

使用两组对应的质心点,将编号相同的模板图与待检图进行对应,对模板图像进行两次仿射变换,得到仿射变换图像,然后将模板图与待检图进行两次作差,再取与,就得到两张图像存在差异的区域。Using two sets of corresponding centroid points, the template image with the same number is matched with the image to be tested, and the template image is affine transformed twice to obtain an affine transformed image. Then, the template image and the image to be tested are subtracted twice, and then the sum is taken to obtain the area where the two images are different.

进一步地,在本发明的优选实施中,在所述步骤S34中,所述对取与后的图像的各个区域进行连通域分析,过滤掉面积较小的区域,包括:Furthermore, in a preferred embodiment of the present invention, in step S34, the connected domain analysis is performed on each region of the image after the AND operation to filter out regions with smaller areas, including:

对取与后的图像的各个区域进行连通域分析,计算每个连通域的面积大小,找出连通域面积大于5的区域,过滤掉面积小于5的区域。Perform connected domain analysis on each area of the image after ANDing, calculate the area of each connected domain, find out the areas with connected domain area greater than 5, and filter out the areas with area less than 5.

进一步地,在本发明的优选实施中,在所述步骤S35中,所述通过面积过滤后的图像区域进行前景面积计算,包括:Furthermore, in a preferred embodiment of the present invention, in step S35, the foreground area of the image area after area filtering is calculated, including:

进行前景面积搜索,找出前景面积最大的区域,然后将模板图像和待测医用注塑件的集光图像的该区域进行截取,提取此区域的轮廓信息,根据以下公式计算两幅图像轮廓的相似度及梯度等信息,作为判决基础。Perform a foreground area search to find the area with the largest foreground area, then capture the area of the template image and the light-collecting image of the medical injection molded part to be tested, extract the contour information of this area, and calculate the similarity and gradient of the contours of the two images according to the following formula as the basis for judgment.

根据计算比较模板图像和待测医用注塑件的集光图像的Hu不变矩,其中,7个不变矩组表示如下:The Hu invariant moments of the template image and the collected light image of the medical injection molded part to be tested are calculated and compared, where the 7 invariant moment groups are expressed as follows:

I1=y20+y02 (1)I 1 =y 20 +y 02 (1)

I3=(y30+3y)2+(3y21-y03)2 (3)I 3 =(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3)

I4=(y30+y12)2+(y21+y03)2 (4)I 4 =(y 30 +y 12 ) 2 +(y 21 +y 03 ) 2 (4)

I6=(y20-y02)[(y30+y12)2-(y21+y03)2]+4y11(y30+y12)(y21+y03) (6)I 6 =(y 20 -y 02 )[(y 30 +y 12 ) 2 -(y 21 +y 03 ) 2 ]+4y 11 (y 30 +y 12 )(y 21 +y 03 ) (6)

其中,ypq为(p+q)阶矩,p、q为0-3之间的整数,I1-I7为7个不变矩。Among them, y pq is the (p+q)th order moment, p and q are integers between 0 and 3, and I 1 -I 7 are 7 invariant moments.

优选地,在上述的基于视觉的医用注塑件的外观缺陷检测方法中,在所述步骤S35中,所述通过面积过滤后的图像区域进行轮廓相似度的计算,轮廓相似度的计算表达式为:Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, in the step S35, the contour similarity of the image area after area filtering is calculated, and the calculation expression of the contour similarity is:

其中,分别是图像A,B的Hu矩。in, are the Hu moments of images A and B respectively.

进一步地,在本发明的优选实施中,在所述步骤S35中,所述通过面积过滤后的图像区域进行梯度计算,梯度计算的表达式为:Further, in a preferred embodiment of the present invention, in step S35, the image area after area filtering is subjected to gradient calculation, and the expression for gradient calculation is:

其中,G(x,y)为坐标为(x,y)点的灰度值,Gx(x,y)为x方向梯度,Gy(x,y)为y方向梯度,为点(x,y)处的梯度值,θ(x,y)为梯度方向。Among them, G(x,y) is the grayscale value of the point with coordinates (x,y), Gx (x,y) is the gradient in the x direction, and Gy (x,y) is the gradient in the y direction. is the gradient value at the point (x, y), and θ(x, y) is the gradient direction.

进一步地,在本发明的优选实施中,在所述步骤S36中,所述综合判断计算后的值是否大于阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断,包括:Further, in a preferred embodiment of the present invention, in step S36, the comprehensive judgment is performed to determine whether the calculated value is greater than a threshold value. If so, this part is output as a defect feature. Otherwise, the judgment of the next area is performed, including:

步骤S361:根据所述步骤S35中计算出的前景面积值进行判断,如果前景面积大于所设置的阈值,则该区域判为缺陷,否则判断轮廓相似度;Step S361: judging according to the foreground area value calculated in step S35, if the foreground area is greater than the set threshold, the area is judged as a defect, otherwise the contour similarity is judged;

步骤S362:若轮廓相似度小于设置的阈值,则将该区域进行剔除;Step S362: if the contour similarity is less than the set threshold, the area is eliminated;

步骤S363:根据轮廓相似度与梯度之和作为判决条件,如果大于阈值,则该位置判定为缺陷区域;Step S363: using the sum of the contour similarity and the gradient as a judgment condition, if it is greater than a threshold, the position is determined to be a defective area;

步骤S364:在得到所有可能为缺陷区域的位置后,计算候选框区域的质心到注塑件质心的距离,并以此判断候选区域的位置,对于候选区域在外边缘的区域,放宽判决条件,若最终存在缺陷区域,则输出该集光图像的集光判决结果为不合格,否则输出该集光图像的集光判决结果为合格。Step S364: After obtaining the positions of all possible defective areas, calculate the distance from the centroid of the candidate frame area to the centroid of the injection molded part, and use this to determine the position of the candidate area. For the area on the outer edge of the candidate area, relax the judgment conditions. If a defective area exists in the end, the light collection judgment result of the light collection image is output as unqualified. Otherwise, the light collection judgment result of the light collection image is output as qualified.

本发明的有益效果为:本发明提出的基于视觉的医用注塑件的外观缺陷检测方法在保证流水线进行快速生产的情况下,可以对医用注塑件的进行快速准确的检测。采用的深度学习搭配模板匹配的算法模型,解决了传统方法无法在短时间内对全部样品进行多种缺陷检测的问题,对于单个样品的处理时间只需600ms,完全满足流水线生产的节拍要求,提高产线的自动化程度。The beneficial effects of the present invention are as follows: the visual-based appearance defect detection method for medical injection molded parts proposed by the present invention can quickly and accurately detect medical injection molded parts while ensuring rapid production of the assembly line. The algorithm model of deep learning combined with template matching solves the problem that traditional methods cannot perform multiple defect detection on all samples in a short time. The processing time for a single sample is only 600ms, which fully meets the rhythm requirements of assembly line production and improves the automation level of the production line.

以上所述实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围,均应包含在本发明的保护范围之内。The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims (12)

1.一种基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,包括如下步骤:1. A method for detecting appearance defects of medical injection molded parts based on vision, characterized in that it comprises the following steps: 步骤S1:在环光和集光两种光源下分别对待测医用注塑件拍照成像,获取待测医用注塑件的环光图像和集光图像;Step S1: photographing and imaging the medical injection molded part to be tested under two light sources, an annular light and a concentrated light, respectively, to obtain an annular light image and a concentrated light image of the medical injection molded part to be tested; 步骤S2:使用深度学习模型对待测医用注塑件的环光图像进行缺胶、麻点以及合模线的缺陷特征检测,保存该环光图像的环光判决结果;Step S2: using a deep learning model to detect defect features of glue shortage, pitting and parting line on the ring light image of the medical injection molded part to be tested, and saving the ring light judgment result of the ring light image; 步骤S3:使用模板匹配方法对待测医用注塑件的集光图像进行披锋、毛边的缺陷特征检测,输出该集光图像的集光判决结果;Step S3: using a template matching method to detect the defect features of burrs and burrs on the light collection image of the medical injection molded part to be tested, and outputting the light collection judgment result of the light collection image; 其中所述步骤S3包括:Wherein said step S3 comprises: 步骤S31:选取合格医用注塑件样品在集光光源下拍照成像,获取一张合格医用注塑件的模板图像,标注模板图像中的特征点;Step S31: Select a qualified medical injection molded part sample and take a photo of it under a light source to obtain a template image of the qualified medical injection molded part, and mark the feature points in the template image; 步骤S32:按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点;Step S32: marking the characteristic points on the light-collecting image of the medical injection molded part to be tested that are consistent with the characteristic points in the template image in order; 步骤S33:对模板图像进行两次仿射变换,将得到的仿射变换图像与集光图像进行作差,得到两幅差分图像,然后对两幅差分图像取与;Step S33: performing two affine transformations on the template image, subtracting the obtained affine transformation image from the light-collecting image to obtain two differential images, and then performing AND operation on the two differential images; 步骤S34:对取与后的图像的各个区域进行连通域分析,过滤掉面积较小的区域;Step S34: Performing connected domain analysis on each region of the image after ANDing, filtering out regions with smaller areas; 步骤S35:通过面积过滤后的图像区域分别进行前景面积、轮廓相似度、梯度的计算;Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering; 步骤S36:综合判断计算后的值是否大于阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断;Step S36: comprehensively judge whether the calculated value is greater than the threshold value. If so, output this part as a defect feature, otherwise proceed to judge the next area; 步骤S4:将环光判决结果和集光判决结果整合,全部合格时,输出该待测医用注塑件的检测结果为合格品,否则为不良品。Step S4: Integrate the ring light judgment result and the collected light judgment result. If all are qualified, output the inspection result of the medical injection molded part to be tested as a qualified product, otherwise it is a defective product. 2.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,所述深度学习模型的预训练过程包括步骤:2. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that the pre-training process of the deep learning model comprises the steps of: 步骤S21:采集医用注塑件在环光光源下的环光图像;Step S21: collecting a ring light image of the medical injection molded part under a ring light source; 步骤S22:对存在麻点、缺胶、合模线缺陷的环光图像进行标注,生成缺胶、麻点以及合模线的缺陷检测数据集;Step S22: annotating the ring light images with defects such as pitting, glue deficiency, and parting line defects to generate a defect detection data set of glue deficiency, pitting, and parting line defects; 步骤S23:将所述步骤S22中生成的缺陷检测数据集作为训练数据集输入至缺陷检测网络中;Step S23: inputting the defect detection data set generated in step S22 into the defect detection network as a training data set; 步骤S24:训练得到缺陷的种类、中心点、边界框信息;Step S24: training to obtain defect type, center point, and bounding box information; 步骤S25:输出深度学习模型。Step S25: Output the deep learning model. 3.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S31中,在标注模板图像中的特征点之前,还包括对所述模板图像的图像预处理,对所述模板图像的图像预处理包括:3. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S31, before marking the feature points in the template image, it also includes image preprocessing of the template image, and the image preprocessing of the template image includes: 对获取到的所述模板图像进行ROI区域提取,以减小图像大小,加快后续的处理速度。The ROI region is extracted from the acquired template image to reduce the image size and speed up subsequent processing. 4.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S32中,在标注待测医用注塑件的集光图像上的特征点之前,还包括对所述集光图像的图像预处理,对所述集光图像的图像预处理包括:4. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S32, before marking the feature points on the light-collecting image of the medical injection molded part to be tested, it also includes image preprocessing of the light-collecting image, and the image preprocessing of the light-collecting image includes: 对获取到的所述待测医用注塑件的集光图像进行ROI区域提取,将所述集光图像的尺寸缩放到与所述模板图像的尺寸一致。The ROI region is extracted from the acquired light-collecting image of the medical injection molded part to be tested, and the size of the light-collecting image is scaled to be consistent with the size of the template image. 5.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S31中,所述标注模板图像中的特征点,包括:5. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S31, the feature points in the annotated template image include: 标注模板图像的8个特征点的质心点,按照质心坐标的x值进行编号排序,将8个质心点分为两组。The centroid points of the eight feature points of the labeled template image are numbered and sorted according to the x-values of the centroid coordinates, and the eight centroid points are divided into two groups. 6.根据权利要求5所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S32中,所述按顺序标注出待测医用注塑件的集光图像上与模板图像中的特征点一致的特征点,包括:6. The visual-based appearance defect detection method for medical injection molded parts according to claim 5, characterized in that, in the step S32, the step of sequentially marking the feature points on the light-collecting image of the medical injection molded part to be tested that are consistent with the feature points in the template image comprises: 标注待测医用注塑件的集光图像的8个特征点的质心点,并按照与模板图像中的8个质心点相同的顺序,对集光图像的8个质心点进行编号,并分为两组。The centroid points of the eight feature points of the light-collecting image of the medical injection molded part to be tested are marked, and the eight centroid points of the light-collecting image are numbered in the same order as the eight centroid points in the template image, and divided into two groups. 7.根据权利要求6所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S33中,所述对模板图像进行两次仿射变换,包括:7. The visual-based appearance defect detection method for medical injection molded parts according to claim 6, characterized in that, in the step S33, performing two affine transformations on the template image comprises: 使用两组对应的质心点,将模板图像进行两次仿射变换,得到仿射变换图像。Using two sets of corresponding centroid points, the template image is affine transformed twice to obtain an affine transformed image. 8.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S34中,所述对取与后的图像的各个区域进行连通域分析,过滤掉面积较小的区域,包括:8. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S34, the connected domain analysis is performed on each region of the image after the AND operation to filter out regions with smaller areas, comprising: 对取与后的图像的各个区域进行连通域分析,找出连通域面积大于5的区域,过滤掉面积小于5的区域。Perform connected domain analysis on each area of the image after ANDing, find out the areas with connected domain area greater than 5, and filter out the areas with area less than 5. 9.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S35中,所述通过面积过滤后的图像区域进行前景面积计算,包括:9. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S35, the foreground area of the image area after area filtering is calculated, comprising: 进行前景面积搜索,找出前景面积最大的区域,将模板图像和待测医用注塑件的集光图像的该区域进行截取;Perform foreground area search to find the area with the largest foreground area, and intercept the area of the template image and the light-collecting image of the medical injection molded part to be tested; 根据计算比较模板图像和待测医用注塑件的集光图像的Hu不变矩,其中,7个不变矩组表示如下:The Hu invariant moments of the template image and the collected light image of the medical injection molded part to be tested are calculated and compared, where the 7 invariant moment groups are expressed as follows: I1=y20+y02 (1)I 1 =y 20 +y 02 (1) I3=(y30+3y)2+(3y21-y03)2 (3)I 3 =(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3) I4=(y30+y12)2+(y21+y03)2 (4)I 4 =(y 30 +y 12 ) 2 +(y 21 +y 03 ) 2 (4) I6=(y20-y02)[(y30+y12)2-(y21+y03)2]+4y11(y30+y12)(y21+y03) (6)I 6 =(y 20 -y 02 )[(y 30 +y 12 ) 2 -(y 21 +y 03 ) 2 ]+4y 11 (y 30 +y 12 )(y 21 +y 03 ) (6) 其中,ypq为(p+q)阶矩,p、q为0-3之间的整数,I1-I7为7个不变矩。Among them, y pq is the (p+q)th order moment, p and q are integers between 0 and 3, and I 1 -I 7 are 7 invariant moments. 10.根据权利要求9所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S35中,所述通过面积过滤后的图像区域进行轮廓相似度的计算,轮廓相似度的计算表达式为:10. The visual-based appearance defect detection method for medical injection molded parts according to claim 9, characterized in that, in the step S35, the contour similarity of the image area after area filtering is calculated, and the calculation expression of the contour similarity is: 其中,分别是图像A,B的Hu矩。in, are the Hu moments of images A and B respectively. 11.根据权利要求9所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S35中,所述通过面积过滤后的图像区域进行梯度计算,梯度计算的表达式为:11. The visual-based appearance defect detection method for medical injection molded parts according to claim 9, characterized in that, in the step S35, the image area after area filtering is subjected to gradient calculation, and the expression for gradient calculation is: 其中,G(x,y)为坐标为(x,y)点的灰度值,Gx(x,y)为x方向梯度,Gy(x,y)为y方向梯度,为点(x,y)处的梯度值,θ(x,y)为梯度方向。Among them, G(x,y) is the grayscale value of the point with coordinates (x,y), Gx (x,y) is the gradient in the x direction, and Gy (x,y) is the gradient in the y direction. is the gradient value at the point (x, y), and θ(x, y) is the gradient direction. 12.根据权利要求1所述的基于视觉的医用注塑件的外观缺陷检测方法,其特征在于,在所述步骤S36中,所述综合判断计算后的值是否大于阈值,如果是,则将此部分作为缺陷特征输出,否则进行下一区域的判断,包括:12. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that, in the step S36, the comprehensive judgment is whether the calculated value is greater than a threshold value, if so, this part is output as a defect feature, otherwise, the judgment of the next area is performed, including: 步骤S361:根据所述步骤S35中计算出的前景面积值进行判断,如果前景面积大于所设置的阈值,则该区域判为缺陷,否则判断轮廓相似度;Step S361: judging according to the foreground area value calculated in step S35, if the foreground area is greater than the set threshold, the area is judged as a defect, otherwise the contour similarity is judged; 步骤S362:若轮廓相似度小于设置的阈值,则将该区域进行剔除;Step S362: if the contour similarity is less than the set threshold, the area is eliminated; 步骤S363:根据轮廓相似度与梯度之和作为判决条件,如果大于阈值,则该位置判定为缺陷区域;Step S363: using the sum of the contour similarity and the gradient as a judgment condition, if it is greater than a threshold, the position is determined to be a defective area; 步骤S364:在得到所有可能为缺陷区域的位置后,计算候选框区域的质心到注塑件质心的距离,并以此判断候选区域的位置,对于候选区域在外边缘的区域,放宽判决条件,若最终存在缺陷区域,则输出该集光图像的集光判决结果为不合格,否则输出该集光图像的集光判决结果为合格。Step S364: After obtaining the positions of all possible defective areas, calculate the distance from the centroid of the candidate frame area to the centroid of the injection molded part, and use this to determine the position of the candidate area. For the area on the outer edge of the candidate area, relax the judgment conditions. If a defective area exists in the end, the light collection judgment result of the light collection image is output as unqualified. Otherwise, the light collection judgment result of the light collection image is output as qualified.
CN202111343233.8A 2021-11-13 2021-11-13 A vision-based method for detecting appearance defects of medical injection molded parts Active CN114004826B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111343233.8A CN114004826B (en) 2021-11-13 2021-11-13 A vision-based method for detecting appearance defects of medical injection molded parts

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111343233.8A CN114004826B (en) 2021-11-13 2021-11-13 A vision-based method for detecting appearance defects of medical injection molded parts

Publications (2)

Publication Number Publication Date
CN114004826A CN114004826A (en) 2022-02-01
CN114004826B true CN114004826B (en) 2024-11-05

Family

ID=79929008

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111343233.8A Active CN114004826B (en) 2021-11-13 2021-11-13 A vision-based method for detecting appearance defects of medical injection molded parts

Country Status (1)

Country Link
CN (1) CN114004826B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115471684A (en) * 2022-08-18 2022-12-13 武汉理工大学 Injection molding workpiece template matching method, electronic equipment and storage medium
CN115452844B (en) * 2022-11-11 2023-02-03 广东海洋大学 Injection molding part detection method and system based on machine vision
CN116597225B (en) * 2023-05-30 2023-11-03 常州市升越模塑股份有限公司 Method and system for detecting drawing defect of hollowed-out injection molding part
CN118721649B (en) * 2024-06-25 2025-05-13 荆州市悠进电装有限公司 Household electrical appliances injection molding performance detecting system based on artificial intelligence
CN121540727A (en) * 2026-01-19 2026-02-17 中国计量大学 A Defect Detection Method for Injection Molded Parts Based on Dual Robotic Arm Collaborative Operation

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109636772A (en) * 2018-10-25 2019-04-16 同济大学 The defect inspection method on the irregular shape intermetallic composite coating surface based on deep learning
CN111369545A (en) * 2020-03-10 2020-07-03 创新奇智(重庆)科技有限公司 Edge defect detection method, device, model, equipment and readable storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110220917B (en) * 2019-06-11 2021-09-07 江苏农林职业技术学院 An online detection method for crown cover surface defects based on image processing

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109636772A (en) * 2018-10-25 2019-04-16 同济大学 The defect inspection method on the irregular shape intermetallic composite coating surface based on deep learning
CN111369545A (en) * 2020-03-10 2020-07-03 创新奇智(重庆)科技有限公司 Edge defect detection method, device, model, equipment and readable storage medium

Also Published As

Publication number Publication date
CN114004826A (en) 2022-02-01

Similar Documents

Publication Publication Date Title
CN114004826B (en) A vision-based method for detecting appearance defects of medical injection molded parts
CN105913093B (en) A Template Matching Method for Character Recognition Processing
CN105067638B (en) Tire fetal membrane face character defect inspection method based on machine vision
CN110321815A (en) A road crack recognition method based on deep learning
CN105069790B (en) A kind of gear open defect fast image detection method
CN111650220A (en) Vision-based image-text defect detection method
CN106610969A (en) Multimodal information-based video content auditing system and method
CN110175982A (en) A kind of defect inspection method based on target detection
CN107389701A (en) A kind of PCB visual defects automatic checkout system and method based on image
CN115690012B (en) Detection method for electric energy meter fault line connection
CN115147363A (en) Image defect detection and classification method and system based on deep learning algorithm
CN105973148A (en) Pen point appearance size standardization detection system based on machine vision
CN104392240A (en) Parasite egg identification method based on multi-feature fusion
CN114549446A (en) A detection method for cylinder liner defect marks based on deep learning
CN108844961A (en) A kind of temperature controller case vision detection system and method
WO2017181724A1 (en) Inspection method and system for missing electronic component
CN111242899A (en) Image-based flaw detection method and computer-readable storage medium
CN113962929A (en) Photovoltaic cell assembly defect detection method and system and photovoltaic cell assembly production line
CN116091505B (en) Automatic defect detection and classification method and system for sapphire substrate
CN110443791B (en) Workpiece detection method and device based on deep learning network
CN108802052A (en) A kind of detecting system and its detection method about slide fastener defect
CN119919410B (en) Method for measuring size and appearance of O-rings
CN110930393A (en) Chip material pipe counting method, device and system based on machine vision
CN115599844A (en) A visual detection method for incorrect or missing installation of aircraft wing surface connectors
CN113505784A (en) Automatic nail annotation analysis method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant