A vision-based method for detecting appearance defects of medical injection molded parts
By combining deep learning models and template matching methods in the detection of medical injection molded parts, defect detection of images of medical injection molded parts under the annular and light collecting light sources is solved, and the problems of insufficient detection accuracy and slow speed in the prior art are solved. It realizes fast and accurate inspection to meet the production needs of assembly lines.
Patent Information
- Application Number
- CN202111343233.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-13
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2041-11-13
AI Technical Summary
The existing medical injection molded parts detection technology cannot complete the fast and accurate inspection of silicone parts within the time frame of the production beat, and the detection accuracy is not enough to meet product requirements.
Using vision-based detection methods, combined with deep learning models and template matching methods, defect detection of the images of medical injection molded parts under two light sources: ring light and light collection, and detection of pits, glue loss and mold clamping lines through ring light images. The light-gathering image detects the edges and burrs, and integrates the results to make judgments.
It realizes rapid and accurate testing of medical injection molded parts under the condition of rapid production of the assembly line. The processing time of a single sample is only 600ms, which meets the rhythm requirements of assembly line production and improves the degree of automation of the production line.
Smart Images

Figure CN114004826B_ABST
Abstract
Description
Technical Field
[0001] 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
[0002] 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.
[0003] 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.
[0004] 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.
[0005] 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.
[0006] 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
[0007] 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.
[0008] A method for detecting appearance defects of medical injection molded parts based on vision comprises the following steps:
[0009] 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;
[0010] 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;
[0011] 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;
[0012] 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.
[0013] 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:
[0014] Step S21: collecting a ring light image of the medical injection molded part under a ring light source;
[0015] 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;
[0016] Step S23: inputting the defect detection data set generated in step S22 into the defect detection network as a training data set;
[0017] Step S24: training to obtain defect type, center point, and bounding box information;
[0018] Step S25: Output the deep learning model.
[0019] Preferably, in the above-mentioned visual-based appearance defect detection method for medical injection molded parts, step S3 comprises:
[0020] 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;
[0021] 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;
[0022] 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;
[0023] Step S34: Performing connected domain analysis on each region of the image after ANDing, filtering out regions with smaller areas;
[0024] Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering;
[0025] 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.
[0026] 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:
[0027] The ROI region is extracted from the acquired template image to reduce the image size and speed up subsequent processing.
[0028] 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:
[0029] 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.
[0030] 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:
[0031] 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.
[0032] 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:
[0033] 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.
[0034] 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:
[0035] Using two sets of corresponding centroid points, the template image is affine transformed twice to obtain an affine transformed image.
[0036] 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:
[0037] 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.
[0038] 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:
[0039] 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.
[0040] The region of the light-collecting image of the injection molded part is intercepted;
[0041] 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:
[0042] I1=y 20 +y 02 (1)
[0043]
[0044] I3=(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3)
[0045] I4=(y 30 +y 12 ) 2 +(y 21 +y 03 ) 2 (4)
[0046]
[0047] I6=(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)
[0048]
[0049] Among them, y pq It is a (p+q)-order moment, p and q are integers between 0 and 3, and I1-I7 are 7 invariant moments.
[0050] 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:
[0051]
[0052] in, are the Hu moments of images A and B respectively.
[0053] 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:
[0054]
[0055]
[0056]
[0057] Among them, G(x,y) is the gray value of the point with coordinates (x,y), G x (x,y) is the gradient in the x direction, G y (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.
[0058] 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:
[0059] 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;
[0060] Step S362: if the contour similarity is less than the set threshold, the area is eliminated;
[0061] 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;
[0062] 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.
[0063] 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
[0064] 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.
[0065] Figure 1 is a flow chart of the present invention;
[0066] Figure 2 This is a photographic structural front view of the medical injection molded part of the present invention;
[0067] Figure 3 A top view of the medical injection molded part of the present invention on a glass carrier;
[0068] Figure 4 This is a light-collecting image of a qualified medical injection molded part of the present invention;
[0069] Figure 5 This is a light-collecting image of a defective medical injection molded part with burrs according to the present invention;
[0070] Figure 6 This is a light-collecting image of a defective medical injection molded part with flashing according to the present invention;
[0071] Figure 7The ring light image of the qualified medical injection molded part of the present invention;
[0072] Figure 8 The ring light image of the defective medical injection molded part with poor mold clamping according to the present invention;
[0073] Fig. 9 This is a ring light image of a defective medical injection molded part with pitting according to the present invention. DETAILED DESCRIPTION
[0074] 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.
[0075] 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.
[0076] 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.
[0077] 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.
[0078] 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.
[0079] See also Figure 1 The present invention proposes a method for detecting appearance defects of medical injection molded parts based on vision, comprising the following steps:
[0080] 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;
[0081] 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;
[0082] 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;
[0083] 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.
[0084] like Figure 2 and Figure 3 As shown, Figure 2It is a front view of the photographic 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-transmittance glass 1, and the high-transmittance glass 1 is arranged on the high-transmittance glass carrier 5 and can move in a straight line direction. A camera 6 is arranged above the high-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-transmittance glass 1 to provide a light collecting light source for the medical injection molded part 2 (product) to be tested. Above the high-transmittance glass 1, located on the upper circumferential 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.
[0085] 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.
[0086] in, Figure 4 The following is a qualified medical injection molded part under a concentrated light source. Figure 5 This is a light-collected image of a defective medical injection molded part with burrs. Figure 6 This is a light-collected image of a defective medical injection molded part with flash. Figure 7 The image shown is a qualified medical injection molded part under the ring light. Figure 8 This is a ring light image of a defective medical injection molded part with poor mold closing. Fig. 9 A halo image of a defective medical injection molded part with pitting.
[0087] Furthermore, in a preferred embodiment of the present invention, the pre-training process of the deep learning model comprises the steps of:
[0088] Step S21: collecting the ring light image of the medical injection molded part under the ring light source, and selecting the image with defects;
[0089] 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;
[0090] 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;
[0091] Step S24: After the training model, the type, bounding box and confidence information of the data set defects will be obtained;
[0092] Step S25: Use the trained weight file, defect name, and network structure information as output files to output the deep learning model.
[0093] Furthermore, in a preferred embodiment of the present invention, step S3 includes:
[0094] 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;
[0095] 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.
[0096] 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;
[0097] 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;
[0098] Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering;
[0099] 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.
[0100] 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:
[0101] 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.
[0102] 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:
[0103] 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.
[0104] Furthermore, in a preferred implementation of the present invention, in step S31, the feature points in the standard template image include:
[0105] 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.
[0106] 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:
[0107] 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.
[0108] Furthermore, in a preferred implementation of the present invention, in step S33, performing two affine transformations on the template image includes:
[0109] 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.
[0110] 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:
[0111] 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.
[0112] 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:
[0113] 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.
[0114] 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:
[0115] I1=y 20 +y 02 (1)
[0116]
[0117] I3=(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3)
[0118] I4=(y 30 +y 12 ) 2 +(y 21 +y 03 ) 2 (4)
[0119]
[0120] I6=(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)
[0121]
[0122] Among them, ypq It is a (p+q)-order moment, p and q are integers between 0 and 3, and I1-I7 are 7 invariant moments.
[0123] 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:
[0124]
[0125] in, are the Hu moments of images A and B respectively.
[0126] 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:
[0127]
[0128]
[0129]
[0130] Among them, G(x,y) is the gray value of the point with coordinates (x,y), G x (x,y) is the gradient in the x direction, G y (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.
[0131] 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:
[0132] 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;
[0133] Step S362: if the contour similarity is less than the set threshold, the area is eliminated;
[0134] 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;
[0135] 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.
[0136] 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.
[0137] 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
1. A visual-based method for detecting appearance defects of medical injection molded parts, characterized in that: The steps include: 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; 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; 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; Wherein said step S3 comprises: 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; 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; 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; Step S34: Performing connected domain analysis on each region of the image after ANDing, filtering out regions with smaller areas; Step S35: Calculate the foreground area, contour similarity and gradient of the image area after area filtering; 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; 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. 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 includes the following steps: Step S21: collecting a ring light image of the medical injection molded part under a ring light source; 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; Step S23: inputting the defect detection data set generated in step S22 into the defect detection network as a training data set; Step S24: training to obtain defect type, center point, and bounding box information; Step S25: Output the deep learning model.
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, the image preprocessing of the template image is also included, and the image preprocessing of the template image includes: The ROI region is extracted from the acquired template image to reduce the image size and speed up subsequent processing.
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, the image preprocessing of the light-collecting image is also included. The image preprocessing of the light-collecting image includes: 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. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that: In the step S31, the marking of feature points in the template image includes: 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. 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 includes: 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. The visual-based appearance defect detection method for medical injection molded parts according to claim 6, characterized in that: In 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.
8. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that: In step S34, the connected domain analysis is performed on each region of the acquired image to filter out regions with smaller areas, including: 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. 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, including: 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; 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=y 20 +y 02 (1) I3=(y 30 +3y) 2 +(3y 21 -y 03 ) 2 (3) I4=(and 30 +y 12 ) 2 +(and 21 +y 03 ) 2 (4) I6=(and 20 -and 02 )[(and 30 +y 12 ) 2 -(and 21 +y 03 ) 2 ]+4y 11 (and 30 +y 12 )(and 21 +y 03 ) (6) Among them, y pq It is a (p+q)-order moment, p and q are integers between 0 and 3, and I1-I7 are 7 invariant moments.
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: in, are the Hu moments of images A and B respectively.
11. The visual-based appearance defect detection method for medical injection molded parts according to claim 9, characterized in that: In step S35, the image area after area filtering is subjected to gradient calculation, and the expression for gradient calculation is: Among them, G(x,y) is the gray value of the point with coordinates (x,y), G x (x,y) is the gradient in the x direction, G y (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. The visual-based appearance defect detection method for medical injection molded parts according to claim 1, characterized in that: In step S36, the comprehensive judgment is whether the calculated value is greater than the threshold value. If so, this part is output as a defect feature. Otherwise, the judgment of the next area is performed, including: 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; Step S362: if the contour similarity is less than the set threshold, the area is eliminated; 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; 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.
