Stamping die surface foreign matter detection method based on block template matching
Through the detection method based on block template matching, the real-time and reliability problems of foreign matter detection on the stamping die surface are solved, the detection efficiency and accuracy are improved, the false detection rate is reduced, the demand for high-speed automated production is met, and the stamping efficiency is improved. Automation level of product quality inspection.
Patent Information
- Application Number
- CN202410673875.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-28
AI Technical Summary
Existing technology cannot effectively monitor whether the stamping die surface is clean, resulting in low efficiency, poor reliability and batch scrapping. Moreover, conventional machine vision inspection has a low detection rate and a high false detection rate, making it unable to meet the needs of high-speed automated production.
A detection method based on block template matching is adopted. Through image collection, ROI area extraction, image block algorithm, rough matching and fine matching, the detection threshold is set to improve the algorithm detection rate and reduce the false detection rate, and introduce Exception counting mechanism to determine the accuracy of shutdown signals.
Significantly improves the efficiency and reliability of detection, reduces the false detection rate, reduces downtime costs caused by false detection, improves the automation level of stamping product quality inspection, can accurately characterize the high-frequency occurrence locations of foreign objects, and guides the mold process improve.
Smart Images

Figure CN118663718A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine vision detection, and in particular to a method for detecting foreign matter on the surface of a stamping die based on block template matching. Background Art
[0002] During the stamping process of the washing machine case, many small wastes of various shapes will be generated. If these wastes remaining on the mold surface are not cleaned up in time, defects such as indentations, scratches and abrasions will be formed on the surface of the case during the next stamping.
[0003] Currently, there is no effective way to monitor whether the waste on the mold has been cleaned up. The existing processing method is to manually visually inspect the stamped finished products at the end of the production line. When defects are found, the production line is stopped, and then the workers check the waste and clean it up. However, it still causes batch scrapping. The single line stop processing time is about 10 minutes, which is inefficient, unreliable, and costly, and cannot meet the needs of high-speed automated production. Although some conventional machine vision inspection systems have been used in industry, they have problems with low detection rate and high false detection rate. To this end, we designed a mold surface foreign body detection technology based on block template matching to solve the above problems. Summary of the invention
[0004] The technical problem to be solved by the present invention is to design a method for detecting foreign matter on the surface of a stamping die based on block template matching, so as to solve the problems of low real-time performance and poor reliability of traditional methods and low detection rate of conventional machine vision detection methods.
[0005] To achieve the above object, the present invention provides a technical solution: a method for detecting foreign matter on the surface of a stamping die based on block template matching, comprising the following steps:
[0006] Step 1: The image acquisition module acquires the original image of the mold surface to be tested and transmits it to the industrial computer for processing; Step 2: Extract the irregular ROI area in the original image to obtain an accurate image of the area to be tested;
[0007] Step 3: Divide the ROI image into small-sized sub-regions through an improved image segmentation algorithm;
[0008] Step 4: Set a suitable detection threshold, calculate the similarity between corresponding sub-regions by combining coarse matching with fine matching, and compare it with the threshold to achieve foreign body detection;
[0009] Step 5: Further judge based on the similarity results obtained in step 4 to improve the algorithm detection rate and reduce the false positive rate;
[0010] Step 6: Output the final test results, sound an alarm and shut down the machine if there is a foreign object.
[0011] Furthermore, in step 1, four sets of cameras and light sources are arranged at the four corners of the mold to collect images of the surface area to be tested, and the images are transmitted to the industrial computer for subsequent image processing. The light source uses near-infrared light and is placed on one side of the camera to provide lighting. The camera has a built-in infrared filter that responds to it, eliminating the impact of changes in ambient light on detection.
[0012] Furthermore, the ROI area to be extracted in step 2 is manually specified and framed by green lines in the image. When extracting the ROI, accurate ROI extraction is achieved through color features. The specific process is as follows:
[0013] (1) Convert the image to HSV space and extract the green pixels in the image;
[0014] (2) Fit an irregular quadrilateral based on the extracted green pixels and obtain its four vertices;
[0015] (3) According to the four vertices obtained, the ROI is specified by drawing a contour, and then the final ROI image is obtained by cropping.
[0016] Furthermore, the specific process of the image segmentation algorithm in step 3 is as follows:
[0017] (1) Regularize the width of the ROI to a composite number and determine the number of sub-columns k. This determines the number of primary sub-regions to be k, denoted by R. i ,i=1,2,…,k;
[0018] (2) Traverse the first and last rows of the ROI, find the non-zero pixels in them, and record the horizontal coordinate value and the corresponding subcolumn m and n;
[0019] (3) Traverse each sub-region R i The two column borders col i-1 and col i , respectively find the pixel points with the smallest and largest ordinate values whose grayscale values are not 0, and record their ordinate values and For the sub-region R corresponding to the sub-column m m , just record and Similarly, for sub-region R n , just record and
[0020] (4) Compare the values of the ordinates of the corresponding pixels. Take:
[0021]
[0022] Obtain the sub-region R i The coordinate origin of which is (col i-1 , min i ), and the height h i = max i - min i . For the sub-region R m , it is easy to obtain that its coordinate origin is (col m-1 , 0), and the height is max m . Similarly, the coordinate origin and height of the sub-region R n can be obtained.
[0023] (5) After obtaining the coordinate origin and width-height parameters of each sub-region, locate the position of the sub-region in the ROI image and participate in the subsequent matching process.
[0024] Furthermore, in the process of template matching, use the mold surface image without foreign objects as the template and the actually acquired image as the image to be detected, calculate their similarity, and judge whether the image contains foreign objects according to the size of the similarity value.
[0025] Furthermore, the specific process of the foreign object detection algorithm based on template matching in step four is as follows:
[0026] (1) First, perform rough matching on several first-level sub-regions R i divided from the ROI image to obtain the similarity S i ;
[0027] (2) Compare S i with the lower detection threshold t D1 and the upper detection threshold t' D1 of the first-level sub-region respectively. If S i < t D1 , then the similarity is low, and it is determined that there are foreign objects in the image. If S i > t' D1 , then the similarity is very high, and it is determined that there are no foreign objects in the image. If t D1 ≤ S i ≤ t' D1 , then there may be foreign objects, and it is necessary to further divide the second-level sub-regions for fine matching;
[0028] (3) On the basis of each first-level sub-region R i , divide it into four equal parts in a "field" shape as the second-level sub-regions, denoted as . Calculate the similarity between each corresponding and compare with the detection threshold t D2 of the second-level sub-region. If This indicates that the similarity is low and it is determined that there is a foreign object in the image. This indicates that the similarity is high, and it is determined that there is no foreign matter in the image;
[0029] (4) For the sub-area where foreign matter exists, its border is marked in red.
[0030] Furthermore, the detection threshold in step 4 is obtained through a large number of matching experiments and is specifically set to t D1 =0.91,t′ D1 =0.99,t D2 =0.9.
[0031] Furthermore, the specific operation of further judging based on similarity in step 5 is:
[0032] (1) If the detection is successful but the values of two adjacent sub-regions are significantly lower than the normal values, it is considered that there is a foreign object located on the boundary between the two adjacent sub-regions. The sub-region is regenerated and the detection is performed using the adaptive sub-region method. The specific steps of the adaptive sub-region method are as follows:
[0033] (1.1) Differentiate the image to be tested from the template image to eliminate the interference of background pixels;
[0034] (1.2) Adaptive threshold segmentation is performed using the OTSU method, and the location of foreign matter is highlighted through binarization processing;
[0035] (1.3) Remove interfering pixels through the opening operation in morphological operation, and then use the Canny operator to extract the edge;
[0036] (1.4) Based on the edge image, start from the boundary line of adjacent sub-regions and extend to both sides, traverse all the pixels in each column. When one side detects that a column does not contain non-zero pixels, stop traversal and record the position of the column in the image. The coordinates are the new boundaries of the sub-region. When the traversal on both sides stops, re-split according to the two recorded coordinates to generate a new temporary sub-region R temp Conduct retesting;
[0037] (2) If the detection is successful but the similarity value of a certain sub-region is lower than the normal value, or if the detection is not successful but it can be judged as a false detection, it is considered that the background grayscale of a certain area of the image to be tested has changed, and there is a large difference in the grayscale of the area corresponding to the existing template. The existing template needs to be updated. The template update method is as follows:
[0038]
[0039] Where T k+1 is the template image after the kth detection, which is used as the detection template for the k+1th detection. kis the template image for the kth detection, I k is the image to be tested during the kth detection; D k is the result of the kth test, 1 means the test passed, 0 means it failed; d μ is the difference between the grayscale mean of the template and the corresponding sub-region of the image, μ T is the grayscale mean of the template sub-region; is the similarity value calculated for the corresponding sub-region, t U is the update threshold, and α is the update weight.
[0040] Furthermore, in step six, an abnormality counting mechanism is introduced to determine whether it is a false detection before issuing a shutdown signal. The specific operation is: every time a test fails, the abnormality count is increased by one, and the system issues an alarm but does not stop. If no operator comes to handle it, the stamping operation continues, and then two consecutive tests are conducted. If the latter two tests fail, it means that there are foreign objects on the mold surface. At this time, the system shuts down. If one of the latter two tests passes, it is considered to be a false detection caused by interference factors. The system stops the alarm, the abnormality count is reset, and the production line operates normally.
[0041] Compared with the existing methods, the beneficial effects of the present invention are as follows: a method for detecting foreign matter on the surface of a stamping die based on block template matching is proposed. Compared with the conventional detection method based on template matching, the improved image block method is used to divide the sub-regions so that the sub-regions are more closely aligned with the ROI, the number of invalid regions is reduced, the efficiency of the detection method is improved, and the detection rate of the method is significantly improved by coarse matching followed by fine matching. In addition, the false detection rate of the method is reduced through the improved template update method and the abnormality counting mechanism, and the time cost of downtime caused by false detection is reduced. The results of the present invention have positive significance for improving the level of automation of stamping product quality inspection. The relevant detection results can characterize the locations where foreign matter appears frequently, which helps to guide the improvement of the mold process. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is the overall detection flow chart of the present invention;
[0043] Figure 2 It is a schematic diagram of the hardware layout of the image acquisition module of the present invention;
[0044] Figure 3 A schematic diagram of a region to be tested on the surface of a mold object to which the present invention is applied;
[0045] Fig. 4 (a) and (b) are respectively the collected original image and the ROI extraction result of the present invention;
[0046] Figure 5 The image segmentation result of the image segmentation method proposed by the present invention;
[0047] Figure 6 is a flow chart of the foreign body detection method of the present invention;
[0048] Figure 7(a)-Figure 7(c) They are the original image, the local image of the sub-region that needs to be adaptively generated, and the final result image;
[0049] Figure 8(a)-Figure 8(e) This is a diagram of some foreign matter detection results of the present invention.
[0050] In the figure: 1. mold upper mold, 2. mold lower mold, 3. mold surface to be measured, 4. light source, 5. camera, 6. mold workbench, 7. area to be measured, 8. mold surface. DETAILED DESCRIPTION
[0051] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention.
[0052] Example: See Figure 1 The method for detecting foreign matter on the surface of a stamping die based on adaptive block template matching of this embodiment includes the following steps:
[0053] Add a template
[0054] Before detection, an initial template needs to be added. The selection of the initial template is very important. It is necessary not only to ensure that there are no foreign objects in the template image, but also to ensure that the brightness and position of the template are moderate.
[0055] Collect the image to be tested. Figure 2 and Figure 3 , through four groups of cameras and light sources arranged at the corners of the mold, the image of the area to be tested on the mold surface is completely collected.
[0056] Preprocessing
[0057] Preprocessing includes ROI extraction and image filtering. Refer to Figure 4, accurate ROI extraction is achieved by segmenting the green pixels in the image. Then the image is smoothed by Gaussian filtering to reduce the impact of noise on the detection results.
[0058] Divide into sub-areas
[0059] The specific steps of dividing the sub-areas are as follows:
[0060] (1) The extracted ROI size is 1181×225. The width of the ROI is regularized to a sum of 1184, and the number of sub-columns is determined to be 16. Therefore, the number of first-level sub-regions is determined to be 16, which is recorded as R. i ,i=1,2,…,16;
[0061] (2) Traverse the first and last two rows of the ROI, find the non-zero pixel points therein, and record the horizontal coordinate value and the corresponding subcolumn m and n. In this embodiment, m=2 and n=14;
[0062] (3) Traverse each sub-region R i The two column borders col i-1 and col i , respectively find the pixel points with the smallest and largest ordinate values whose grayscale values are not 0, and record their ordinate values and For the sub-region R corresponding to the sub-column m m , just record and Similarly, for sub-region R n , just record and
[0063] (4) Compare the values of the ordinates of the corresponding pixels. Take:
[0064]
[0065] Get sub-region R i The origin of the coordinates is (col i-1 , min i ), high h i =max i -min i For sub-region R m , it is easy to get its coordinate origin as (col m-1 , 0), height is max m , and similarly we can get sub-region R n The coordinate origin and height of .
[0066] (5) After obtaining the coordinate origin and width and height parameters of each sub-region, locate the position of the sub-region in the ROI image and participate in the subsequent matching process.
[0067] See also Figure 5 ,The sub-regions divided by the improved image segmentation method fit well to ROI, reducing the interference of redundant regions.
[0068] Template Matching
[0069] In the process of template matching, the mold surface image without foreign matter is used as the template, and the actual collected image is used as the image to be tested. Their similarity is calculated, and the size of the similarity value is used to determine whether the image contains foreign matter. Figure 6 ,The specific steps of the foreign body detection method based on block template matching are:
[0070] (1) First, divide the ROI image into several first-level sub-regions R i for rough matching to obtain the similarity S i ;
[0071] (2) Compare S i with the lower detection threshold t D1 and the upper detection threshold t' D1 of the first-level sub-region respectively. If S i < t D1 then the similarity is low, and it is determined that there is a foreign object in the image. If S i > t' D1 then the similarity is very high, and it is determined that there is no foreign object in the image. If t D1 ≤ S i ≤ t' D1 then there may be a foreign object, and it is necessary to further divide the second-level sub-region for fine matching;
[0072] (3) Based on each first-level sub-region R i , divide it into four equal parts in a "field" shape as the second-level sub-region, denoted as Calculate the similarity between each corresponding and compare with the detection threshold t D2 of the second-level sub-region. If it indicates that the similarity is low, and it is determined that there is a foreign object in the image. If it indicates that the similarity is high, and it is determined that there is no foreign object in the image;
[0073] The detection thresholds in the template matching process are obtained through a large number of experiments, specifically t D1 = 0.91, t' D1 = 0.99, t D2 = 0.9.
[0074] Judgment and processing of detection results
[0075] The specific process of judgment and processing of detection results is as follows:
[0076] (1) If the detection passes but there are two adjacent sub-regions with values significantly lower than the normal value, it is considered that there is a foreign object on the boundary between the two adjacent sub-regions. The specific steps of the adaptive sub-region method for re-generating sub-regions and performing detection are as follows:
[0077] (1.1) Differentiate the image to be measured from the template image to eliminate the interference of background pixels;
[0078] (1.2) Perform adaptive threshold segmentation through the OTSU method and highlight the location of the foreign object through binarization;
[0079] (1.3) Remove interfering pixels through the opening operation in morphological operation, and then use the Canny operator to extract the edge;
[0080] (1.4) Refer to Figure 7. Based on the edge image, start from the boundary line of adjacent sub-regions and extend to both sides. Traverse all the pixels in each column. When one side detects that a column does not contain non-zero pixels, stop traversing and record the position of the column in the image. The coordinates are the new boundaries of the sub-region. When the traversal on both sides stops, re-split according to the two recorded coordinates to generate a new temporary sub-region R temp Conduct retesting;
[0081] (2) If the detection is successful but the similarity value of a certain sub-region is lower than the normal value, or if the detection is not successful but it can be judged as a false detection, it is considered that the background grayscale of a certain area of the image to be tested has changed, and there is a large difference in the grayscale of the area corresponding to the existing template. The existing template needs to be updated. The template update method is as follows:
[0082]
[0083] The parameters in the update method are determined through experiments, and the update threshold t U is set to 0.95 and the update weight α is set to 0.4.
[0084] The final result is shown in Figure 8. After the test is completed, the final test result image is output. If there is no foreign matter in the test image, "test passed" is output. If foreign matter is detected in the image, the border of the sub-area where the foreign matter is located is marked in red, and "test failed" is output. The system sends an alarm signal and controls the production line to stop.
[0085] Before issuing a shutdown signal, the abnormality counting mechanism is used to determine whether it is a false detection. Every time a test fails, the abnormality count is increased by one, and the system issues an alarm but does not shut down. After that, two consecutive tests are conducted. If the latter two tests fail, it means that there are foreign objects on the mold surface. At this time, the system shuts down. If one of the latter two tests passes, it is considered to be a false detection caused by interference factors. The system stops the alarm, the abnormality count is reset, and the production line operates normally.
[0086] The above description of the present invention and its embodiments is not restrictive. The accompanying drawings show only one embodiment of the present invention, and the practical application is not limited thereto. If a person skilled in the art is inspired by it and, without departing from the purpose of the invention, designs a structure and an embodiment similar to the technical solution without creativity, they shall all fall within the protection scope of the present invention.
Claims
1. A method for detecting foreign matter on the surface of a stamping die based on block template matching, characterized in that: The method comprises the following steps: Step 1: The image acquisition module acquires the original image of the mold surface to be tested and transmits it to the industrial computer for processing; Step 2: Extract the irregular ROI area in the original image to obtain an accurate image of the area to be tested; Step 3: Divide the ROI image into small-sized sub-regions through an improved image segmentation algorithm; Step 4: Set a suitable detection threshold, calculate the similarity between corresponding sub-regions by combining coarse matching with fine matching, and compare it with the threshold to achieve foreign body detection; Step 5: Further process and judge based on the similarity result obtained in step 4; Step 6: Output the final test results, sound an alarm and shut down the machine if there is a foreign object.
2. The method for detecting foreign matter on the surface of a stamping die based on block template matching according to claim 1, characterized in that: The specific process of the image segmentation algorithm in step 3 is: (1) Regularize the width of the ROI to a composite number and determine the number of sub-columns k. This determines the number of primary sub-regions to be k, denoted by R. i ,i=1,2,…,k; (2) Traverse the first and last rows of the ROI, find the non-zero pixels in them, and record their horizontal coordinate values and the subcolumns m and n to which they belong; (3) Traverse each sub-region R i The two column borders col i-1 and col i , respectively find the pixel points with the smallest and largest ordinate values whose grayscale values are not 0, and record their ordinate values and For the sub-region R corresponding to the sub-column m m , just record and Similarly, for sub-region R n , just record and (4) Compare the values of the ordinates of the corresponding pixels and take: Get sub-region R i The origin of the coordinates is (col i-1 , min i ), high h i =max i -min i , for sub-region R m , it is easy to get its coordinate origin as (col m-1 , 0), height is max m , and similarly we can get sub-region R n The coordinate origin and height of (5) After obtaining the coordinate origin and width and height parameters of each sub-region, locate the position of the sub-region in the ROI image and participate in the subsequent matching process.
3. The method for detecting foreign matter on the surface of a stamping die based on block template matching according to claim 1, characterized in that: The specific process of the foreign body detection algorithm based on template matching in step 4 is as follows: (1) First, divide the ROI image into several first-level sub-regions R i Perform a rough match and get the similarity S i ; (2) S i The lower detection threshold t of the first-level sub-region D1 and the upper detection threshold t′ D1 Compare respectively, if S i <t D1 The similarity is low, and it is determined that there is a foreign object in the image. If S i >t′ D1 The similarity is very high, and it is determined that there is no foreign object in the image. If t D1 ≤S i ≤t′ D1 There may be foreign matter, and it is necessary to further divide the secondary sub-areas for precise matching; (3) On the basis of each first-level sub-region R i , divide it into four equal parts in a "field" shape as second-level sub-regions, denoted as j = 1, 2, 3, 4, calculate the similarity between each corresponding and and compare with the detection threshold t of the second-level sub-region D2 . If , it indicates that the similarity is low, and it is determined that there is a foreign object in the image. If , it indicates that the similarity is high, and it is determined that there is no foreign object in the image; (4) For the sub-area where foreign matter exists, its border is marked in red.
4. The method for detecting foreign matter on the surface of a stamping die based on block template matching according to claim 1, characterized in that: The specific operations for further judging based on similarity in step 5 are: (1) If the detection is successful but the values of two adjacent sub-regions are significantly lower than the normal values, it is considered that there is a foreign object located on the boundary between the two adjacent sub-regions. The sub-region is regenerated and the detection is performed using the adaptive sub-region method. The specific steps of the adaptive sub-region method are as follows: (1.1) Differentiate the image to be tested from the template image to eliminate the interference of background pixels; (1.2) Adaptive threshold segmentation is performed using the OTSU method, and the location of foreign matter is highlighted through binarization processing; (1.3) Remove interfering pixels through the opening operation in morphological operation, and then use the Canny operator to extract the edge; (1.4) Based on the edge image, start from the boundary line of adjacent sub-regions and extend to both sides, traverse all the pixels in each column. When one side detects that a column does not contain non-zero pixels, stop traversing and record the position of the column in the image. The coordinates are the new boundaries of the sub-region. When the traversal on both sides stops, re-split according to the two recorded coordinates to generate a new temporary sub-region R temp Conduct retesting; (2) If the detection is successful but the similarity value of a certain sub-region is lower than the normal value, or if the detection is not successful but it can be judged as a false detection, it is considered that the background grayscale of a certain area of the image to be tested has changed, and there is a large difference in the grayscale of the area corresponding to the existing template. The existing template needs to be updated. The template update method is as follows: Where T k+1 is the template image after the kth detection, which is used as the detection template for the k+1th detection. k is the template image for the kth detection, I k is the image to be tested during the kth detection; D k is the result of the kth test, 1 means the test passed, 0 means it failed; d μ is the difference between the grayscale mean of the template and the corresponding sub-region of the image, μ T is the grayscale mean of the template sub-region; is the similarity value calculated for the corresponding sub-region, t U is the update threshold, and α is the update weight.
5. The method for detecting foreign matter on the surface of a stamping die based on block template matching according to claim 1, characterized in that: In step six, an abnormality counting mechanism is designed to determine whether it is a false detection before issuing a shutdown signal. The specific operation is: every time a test fails, the abnormality count is increased by one, and the system issues an alarm but does not stop. If no operator comes to handle it, the stamping operation continues, and then two consecutive tests are performed. If the latter two tests fail, it means that there are foreign objects on the mold surface. At this time, the system shuts down. If one of the latter two tests passes, it is considered to be a false detection caused by interference factors. The system stops the alarm, the abnormality count is reset, and the production line operates normally.
Citation Information
Patent Citations
GFV-SIFT characteristic-based vibrating environment injection mould abnormal defect detecting method
CN108195841A
PCB defect positioning method based on multi-template matching
CN109724988A
Precision stamping die surface state recognition method based on machine vision
CN116563574A
Detection method for mold of electric injection molding machine
WO2018107525A1
Method, device, and system for detecting depth information
WO2020199563A1
