Visual counting method for sealing rings under complex shielding condition
By calculating the characteristics of the connecting domain in the seal ring visual counting method and comprehensively judging, the problem of low seal ring counting accuracy under complex occlusion conditions is solved, efficient counting in dense and multi-pose scenarios is achieved, and the reliability of the production line is improved. and efficiency.
Patent Information
- Application Number
- CN202411025772.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
Under complex occlusion conditions, traditional visual counting methods are difficult to accurately count seals, especially in dense and multi-pose scenarios, where counting accuracy is reduced, and deep learning methods still need to be improved when dealing with occlusion and multi-pose problems.
Using a seal ring visual counting method under complex occlusion conditions, the connection domain is separated by image preprocessing, and the four characteristics of the connection domain are calculated: area, contour corner point, contour convexity and number of holes are calculated, and these characteristics are combined to determine the seal ring Quantity to improve counting accuracy.
It improves the accuracy of seal ring counting under complex conditions, improves the reliability and efficiency of the production line, and can quickly and accurately identify the number of seal rings.
Smart Images

Figure CN118967736A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of industrial machine vision and relates to visual counting of sealing ring workpieces, in particular to a sealing ring visual counting method under complex occlusion conditions. Background Art
[0002] In the industrial production process, accurate counting of small parts such as seals is crucial to the automation and efficiency of the production line. In traditional visual counting algorithms, such as the counting method based on the area of connected domains, the counting effect is stable and accurate in scenes where the shape of the counted objects does not change much. However, it is often difficult to ensure sufficient accuracy when dealing with dense, multi-pose, and occluded seals. [1] Another commonly used traditional method is template matching, which has higher counting accuracy in scenes where the posture of the counted objects is stable. [2] However, for images with diverse poses or with a lot of occlusions, the accuracy of the counting method based on template matching decreases significantly.
[0003] In another scenario, the watershed segmentation algorithm combined with distance transform performs well in counting adjacent or connected components, but the counting effect is poor when dealing with materials with a lot of occlusion. [3] In recent years, deep learning methods have shown significant advantages in object detection and counting. [4][5] However, the training process of these methods requires a large amount of labeled data, and the training and reasoning of the model require high-performance computing resources. In addition, deep learning models still need to be further improved in dealing with occlusion and multi-pose problems. Summary of the invention
[0004] The purpose of the present invention is to provide a fast and accurate method for counting dense sealing rings when they fall, i.e., a visual counting method for sealing rings under complex occlusion conditions. This method can improve the counting accuracy under complex conditions and improve the reliability and efficiency of the production line.
[0005] The technical solution for achieving the purpose of the present invention is:
[0006] A method for visually counting sealing rings under complex occlusion conditions comprises the following steps:
[0007] 1) Image preprocessing to separate connected domains;
[0008] 2) Calculate the four features of the connected domain: the area of the connected domain, the corner points of the connected domain contour, the convexity of the connected domain contour, and the number of holes in the connected domain;
[0009] 3) Determine the number of sealing rings in the connected domain based on comprehensive features;
[0010] 4) Accumulate the number of sealing rings in all connected domains: After comprehensively determining the number of sealing rings in each connected domain, sum the number of sealing rings in all connected domains in an image. The calculated value is the number of sealing rings in an image, thereby completing the counting of sealing rings in an image.
[0011] The specific process of step 1) is: setting a global threshold, comparing all pixel values in the collected sealing ring image with the global threshold, so as to segment the sealing ring image, that is, automatically selecting the global threshold by maximizing the inter-class variance calculated by the Otsu method, and dividing the image into foreground and background according to the set global threshold parameter ThresholdPara to obtain separated connected domains.
[0012] The four features of the connected domain calculated in step 2) are specifically:
[0013] (2.1) Calculation of connected domain area:
[0014] Use the connected domain with 8 connectivity, traverse the connected domain marking results, and count the number of pixels in each connected domain. The number of pixels is the area of the connected domain, namely ConnectedArea, where 8 connectivity means that a pixel is connected in four directions: up, down, left, right, and diagonal.
[0015] (2.2) Calculation of corner points of connected domain contour:
[0016] Harris corner detection algorithm is used to detect corner points in the seal ring image and save the coordinates of all corner points. Based on the characteristics of the corner points, a local window is selected and moved in all directions. The difference between the pixels in the window before and after the movement is calculated to determine whether the area corresponding to the window is a corner point. The mathematical description of corner point judgment is as follows:
[0017] E(u,v)=∑ x,y w(xy)[I(x+u,y+v)-I(x,y)] 2
[0018] Where E is the energy function, u and v reflect the movement of the window, x and y are the coordinates in the seal ring image, and w(x, y) is the window function;
[0019] Traverse all points on the contour of the current connected domain one by one, and compare them with each saved corner point. If the straight-line distance between the two points is less than DisPara pixels, the point on the current contour is judged to be a contour corner point. DisPara is the distance parameter. Finally, the number of all contour corner points on the connected domain, i.e. CornerNum, is saved.
[0020] (2.3) Calculation of the convexity of the connected domain contour:
[0021] Use the convexity of the connected domain contour to determine whether there is an occluded sealing ring in the current connected domain, so that the sealing ring count under occlusion conditions is more accurate. Use the edge detection algorithm to detect the area contour of the current connected domain, first calculate the contour perimeter, and then calculate the convex hull perimeter; the contour perimeter is calculated by summing the number of regional contour pixel points. The convex hull refers to a minimum convex polygon that surrounds a group of points. A convex polygon is a polygon with all internal angles less than 180 degrees. Andrew's Algorith is used to calculate the convex hull perimeter;
[0022] The convexity of the connected domain contour is calculated as follows:
[0023]
[0024] Among them, Perimeter of Contour represents the perimeter of the contour itself, Perimeter of Convex Hull represents the perimeter of the contour convex hull, and the range of contour convexity is [0,1];
[0025] (2.4) Calculation of the number of holes in the connected domain:
[0026] The number of holes in a connected domain reflects the number of sealing rings that are blocked in a certain form. A hole refers to an area inside a connected domain. The number of holes in a connected domain is calculated by analyzing each connected domain and its internal hierarchical structure. The number of holes inside the connected domain, i.e., HoleNum, is calculated by traversing the hierarchical structure of each connected domain.
[0027] In step 3), the number of sealing rings in the connected domain is determined by comprehensive characteristics as follows:
[0028] (3.1) The number range of sealing rings is calculated through the connected area ConnectedArea feature. First, multiple image segmentation processes are performed to calculate the maximum area of a single sealing ring SingleMaxArea;
[0029] Num connectedArea : The number of sealing rings determined by the area of the connected domain;
[0030] The conditions for using the connected domain area to judge the number of sealing rings are as follows: when the current connected domain area ConnectedArea is greater than 0 and less than the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 1; when the connected domain area ConnectedArea is greater than the maximum area of a single sealing ring and less than 1+1*AreaPara times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 2; when the connected domain area ConnectedArea is greater than 1+1*AreaPara times the maximum area of a single sealing ring and less than 1+AreaPara*2 times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 3; where AreaPara is the area parameter;
[0031] 0 <ConnectedArea<SingleMaxArea,Num connectedArea =1
[0032] SingleMaxArea≤ConnectedArea<(1+AreaPara*1)*SingleMaxArea,
[0033] Num connectedArea =2
[0034] (1+AreaPara*1)*SingleMaxArea≤ConnectedArea
[0035] <(1+AreaPara*2)*SingleMaxArea,
[0036] Num connectedArea =3
[0037] And so on, so we have:
[0038]
[0039] (3.2) The number of sealing rings in the connected domain is determined by the contour corner points. Assuming there are two contour corner points, it is determined that there is one blocked sealing ring, that is, the number of sealing rings is at least two; if there are four contour corner points, it is determined that there are two blocked sealing rings, that is, the number of sealing rings is at least three. By analogy, the number of sealing rings determined by the contour corner point feature is obtained.
[0040] Num corner : The number of sealing rings determined by contour corner feature;
[0041]
[0042] (3.3) The number of sealing rings in the connected domain is determined by the convexity. If the convexity of the connected domain is less than the convexity parameter ConvexityPara, it is determined that there is an occluding sealing ring in the connected domain, and the number of sealing rings in the corresponding connected domain is greater than or equal to 2;
[0043] Num convexity : The number of sealing rings under convexity feature judgment;
[0044] if Convexity <ConvexityPara,Num convexity ≥2;
[0045] (3.4) The number of sealing rings in the connected domain is determined by the number of holes. When there is no abnormal material in the sealing ring, one sealing ring has at most one hole, and two sealing rings have at most three holes. That is, when there are more than three holes in the current connected domain, the number of sealing rings is greater than or equal to 2;
[0046] First, how many holes can n sealing rings finally form? According to the recursive method, we can solve the geometric problem: how many parts can n circles divide the plane into at most? We get:
[0047] R(n)=n 2 -n+2
[0048] It can be concluded that the maximum number of holes that can be formed by n circles in a plane is:
[0049] Num hole (n) = n 2 -n+1
[0050] The minimum number of sealing rings in the connected domain is determined by the known number of holes in the connected domain;
[0051] Num hole : The number of sealing rings under the feature judgment of the number of holes;
[0052]
[0053] From the root-finding formula of a quadratic equation It is concluded that the negative numbers in the solution are discarded;
[0054] Finally, the minimum value of each feature judgment is taken by combining the four features of connected domain area, connected domain contour corner points, connected domain contour convexity, and connected domain hole number. The maximum value among the minimum values under each feature judgment is compared and the maximum value is taken as the number of sealing rings in the current connected domain ConnectedNum.
[0055] ConnectedNum
[0056] =Max(min(Num connectedArea),min(Num corner ),min(Num convexity ),min(Num hol )).
[0058] This technical solution uses newly added contour corner point features, contour convexity, and contour hole count to identify the sealing rings that are blocked by each other when the sealing rings fall densely, thereby improving the accuracy of sealing ring part counting.
[0059] This method can improve the counting accuracy under complex conditions, improve the reliability and efficiency of the production line, and has important practical significance. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 is a flow chart of an embodiment;
[0061] Figure 2 It is a structural diagram of the counting and packaging equipment in the embodiment;
[0062] Figure 3 This is a schematic diagram of the result after the connected domain is separated in the embodiment;
[0063] Figure 4 This is a graph showing the calculation results of the corner points of the connected domain contour in the embodiment;
[0064] Figure 5 This is a diagram showing the calculation results of the number of holes in the connected domain in the embodiment;
[0065] Figure 6 It is a diagram showing the calculation results of the connected domain area and convexity in the embodiment. DETAILED DESCRIPTION
[0066] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, but the present invention is not limited thereto.
[0067] Example:
[0068] This example takes a sealing ring counting packaging machine as an example.
[0069] Reference Figure 1 , a sealing ring visual counting method under complex occlusion conditions, comprising the following steps:
[0070] In this example, a black and white line scan camera is used to collect gray images of objects dropped on the conveyor belt in real time. The light source adopts a strip backlight solution to reduce environmental contamination. Counting and packaging equipment such as Figure 2 shown.
[0071] According to the falling speed of the sealing ring, set the appropriate line frequency of the line scan camera to ensure that the collected sealing ring image will not be elongated. At the same time, set the line height of the line scan camera to save the image. The image height should not be too long to ensure real-time counting. In terms of counting structure, the sealing ring workpiece falling packaging process is used to perform visual recognition counting when the sealing ring falls, which improves the counting speed of the sealing ring and meets the requirements of real-time counting.
[0072] 1) Image preprocessing to separate connected domains;
[0073] 2) Calculate the four features of the connected domain: the area of the connected domain, the corner points of the connected domain contour, the convexity of the connected domain contour, and the number of holes in the connected domain, such as Figure 4-Figure 6 As shown;
[0074] 3) Determine the number of sealing rings in the connected domain based on comprehensive features;
[0075] 4) Accumulate the number of sealing rings in all connected domains: After comprehensively determining the number of sealing rings in each connected domain, sum the number of sealing rings in all connected domains in an image. The calculated value is the number of sealing rings in an image, thereby completing the counting of sealing rings in an image.
[0076] The specific process of step 1) is as follows: a global threshold is set, and all pixel values in the collected sealing ring image are compared with the global threshold, so as to segment the sealing ring image, that is, the global threshold is automatically selected by calculating the inter-class variance maximization through the Otsu method (a kind of threshold segmentation algorithm implemented in the open source visual processing library opencv), and the image is divided into foreground and background according to the set global threshold parameter ThresholdPara, and different connected areas in the image are marked to obtain separated connected domains. In this example, ThresholdPara is set to 100, and the connected domain separation result is as follows: Figure 3 shown.
[0077] The four features of the connected domain calculated in step 2) are specifically:
[0078] (2.1) Calculation of connected domain area, such as Figure 6 As shown:
[0079] Use the connected domain with 8 connectivity, traverse the connected domain marking results, and count the number of pixels in each connected domain. The number of pixels is the area of the connected domain, namely ConnectedArea, where 8 connectivity means that a pixel is connected in four directions: up, down, left, right, and diagonal.
[0080] (2.2) Calculation of corner points of connected domain contour, such as Figure 4 As shown:
[0081] Harris corner detection algorithm is used to detect the corners of the seal ring in the image, and the coordinates of all corners are saved. Based on the characteristics of the corners, a local window is selected, and the local window is moved in various directions. The difference between the pixels in the window before and after the movement is calculated to determine whether the area corresponding to the window is a corner point. The mathematical description of corner point judgment is as follows:
[0082] E(u,v)=∑ x,y w(xy)[I(x+u,y+v)-I(x,y)] 2
[0083] Where E is the energy function, u and v reflect the movement of the window, x and y are the coordinates in the seal ring image, and w(x, y) is the window function;
[0084] Traverse all points on the contour of the current connected domain one by one, and compare them with each saved corner point. If the straight-line distance between the two points is less than DisPara pixels, the point on the current contour is judged to be a contour corner point. DisPara is a distance parameter, which is set to 5 in this example. Finally, the number of all contour corner points on the connected domain, i.e. CornerNum, is saved.
[0085] (2.3) Calculation of the convexity of the connected domain contour, such as Figure 6 As shown:
[0086] The area contour of the current connected domain is detected by the edge detection algorithm. The contour perimeter is calculated first, and then the convex hull perimeter is calculated. The contour perimeter is calculated by summing the number of pixel points of the area contour. The convex hull refers to a minimum convex polygon that surrounds a group of points. A convex polygon is a polygon with all internal angles less than 180 degrees. The convex hull perimeter is calculated using the Andrew convex hull algorithm.
[0087] The convexity of the connected domain contour is calculated as follows:
[0088]
[0089] Among them, Perimeter of Contour represents the perimeter of the contour itself, Perimeter of Convex Hull represents the perimeter of the contour convex hull, and the range of contour convexity is [0,1];
[0090] (2.4) Calculation of the number of holes in the connected domain, such as Figure 5 As shown:
[0091] A hole refers to an area inside a connected domain. The number of holes in a connected domain is calculated by analyzing each connected domain and its internal hierarchical structure. The number of holes inside the connected domain, i.e., HoleNum, is calculated by traversing the hierarchical structure of each connected domain.
[0092] In step 3), the number of sealing rings in the connected domain is determined by comprehensive characteristics as follows:
[0093] (3.1) The number range of sealing rings is calculated through the connected area ConnectedArea feature. First, multiple image segmentation processes are performed to calculate the maximum area of a single sealing ring SingleMaxArea;
[0094] Num connectedArea : The number of sealing rings determined by the area of the connected domain;
[0095] The conditions for using the connected domain area to determine the number of sealing rings are as follows: when the current connected domain area ConnectedArea is greater than 0 and less than the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 1; when the connected domain area ConnectedArea is greater than the maximum area of a single sealing ring and less than 1+1*AreaPara times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 2; when the connected domain area ConnectedArea is greater than 1+1*AreaPara times the maximum area of a single sealing ring and less than 1+AreaPara*2 times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 3; Among them, AreaPara is the area parameter, and the default value is 0.8;
[0096] 0 <ConnectedArea<SingleMaxArea,Num connectedArea =1
[0097] SingleMaxArea≤ConnectedArea<(1+AreaPara*1)*SingleMaxArea,
[0098] Num connectedArea =2
[0099] (1+AreaPara*1)*SingleMaxArea≤ConnectedArea
[0100] <(1+AreaPara*2)*SingleMaxArea,
[0101] Num connectedArea =3
[0102] And so on, so we have:
[0103]
[0104] (3.2) The number of sealing rings in the connected domain is determined by the contour corner points. Assuming there are two contour corner points, it is determined that there is one blocked sealing ring, that is, the number of sealing rings is at least two; if there are four contour corner points, it is determined that there are two blocked sealing rings, that is, the number of sealing rings is at least three. By analogy, the number of sealing rings determined by the contour corner point feature is obtained.
[0105] Num corner : The number of sealing rings determined by contour corner feature;
[0106]
[0107] (3.3) The number of sealing rings in the connected domain is determined by the convexity. If the convexity of the connected domain is less than the convexity parameter ConvexityPara, it is determined that there is an occluding sealing ring in the connected domain. The number of sealing rings in the corresponding connected domain is greater than or equal to 2. The default value of ConvexityPara is 0.95.
[0108] Num convexity : The number of sealing rings under convexity feature judgment;
[0109] if Convexity <ConvexityPara,Num convexity ≥2;
[0110] (3.4) The number of sealing rings in the connected domain is determined by the number of holes. When there is no abnormal material in the sealing ring, one sealing ring has at most one hole, and two sealing rings have at most three holes. That is, when there are more than three holes in the current connected domain, the number of sealing rings is greater than or equal to 2;
[0111] First, how many holes can n sealing rings finally form? According to the recursive method, we can solve the geometric problem: how many parts can n circles divide the plane into at most? We get:
[0112] R(n)=n 2 -n+2
[0113] It can be concluded that the maximum number of holes that can be formed by n circles in a plane is:
[0114] Num hole (n) = n 2 -n+1
[0115] The minimum number of sealing rings in the connected domain is determined by the known number of holes in the connected domain;
[0116] Num hole : The number of sealing rings under the feature judgment of the number of holes;
[0117]
[0118] From the root-finding formula of a quadratic equation It is concluded that the negative numbers in the solution are discarded;
[0119] Finally, the minimum value of each feature judgment is taken by combining the four features of connected domain area, connected domain contour corner points, connected domain contour convexity, and connected domain hole number. The maximum value among the minimum values under each feature judgment is compared and the maximum value is taken as the number of sealing rings in the current connected domain ConnectedNum.
[0120] ConnectedNum
[0121] =Max(min(Num connectedArea ),min(Num corner ),min(Num convexity ),min(Num hole )).
[0123] In this example, before proceeding to step 2), an integer variable is first defined to store the current total value Num, and a temporary integer variable is defined to store the number of sealing rings in the current connected domain Num_connected.
[0124] After completing step 4), the current number of sealing rings is added to the current total value, and the next connected domain is traversed.
[0125] Determine whether the total value reaches the target number:
[0126] Assuming that the target count value of the packaging machine is 1000, the counting system will set a target value for early deceleration, such as 990. When the deceleration value is reached, the system will notify the conveyor structure to decelerate, and then slow down the delivery of the sealing ring and slow down the counting, and count the number of identified sealing rings one by one to ensure the accuracy of bagging. In this process, the current total count value will be judged in real time. If the current count value is greater than or equal to the set deceleration value of 990, the conveyor deceleration signal is triggered, and if it is greater than or equal to 1000, the conveyor stop signal is triggered.
[0127] Once the stop signal is triggered, the system automatically completes a counting and packaging task.
[0128] References:
[0129] [1]Toh YH,Ng TM,Liew B K.Automated fish counting using imageprocessing[C] / / 2009international conference on computational intelligence and software engineering.Ieee,2009:1-5.
[0130] [2]Khantuwan W,Khiripet N.Live shrimp larvae counting method using co-occurrence color histogram[C] / / 2012 9th International Conference onElectrical Engineering / Electronics,Computer,Telecommunications andInformation Technology.IEEE,2012:1-4.
[0131] [3] Zhang Tianhao, Liang Yansen, He Zhiyi. Application of image recognition counting in reserve pig statistics[J]. Computer Applications and Software, 2016, 33(12): 173-178.
[0132] [4]JIANG K, XIE T, YAN R, et al. An attention mechanism-improved YOLOv7object detection algorithm for hemp duck count estimation[J]. Agriculture, 2022, 12(10):1659.
[0133] [5] Huang Decheng, Ren Dejun. Design of workpiece counting system based on machine vision[J]. Modern Information Science and Technology, 2023, 7(16): 171-175. DOI: 10.19850 / j.cnki.2096-4706.2023.16.037.
Claims
1. A visual counting method for sealing rings under complex occlusion conditions, characterized in that: The steps include: 1) Image preprocessing to separate connected domains; 2) Calculate the four features of the connected domain: the area of the connected domain, the corner points of the connected domain contour, the convexity of the connected domain contour, and the number of holes in the connected domain; 3) Determine the number of sealing rings in the connected domain based on comprehensive features; 4) Accumulate the number of sealing rings in all connected domains: After comprehensively determining the number of sealing rings in each connected domain, sum the number of sealing rings in all connected domains in an image. The calculated value is the number of sealing rings in an image, thereby completing the counting of sealing rings in an image.
2. The sealing ring visual counting method under complex occlusion conditions according to claim 1 is characterized in that: The specific process of step 1) is: setting a global threshold, comparing all pixel values in the collected sealing ring image with the global threshold, so as to segment the sealing ring image, that is, automatically selecting the global threshold by maximizing the inter-class variance calculated by the Otsu method, and dividing the image into foreground and background according to the set global threshold parameter ThresholdPara to obtain separated connected domains.
3. The visual counting method for sealing rings under complex occlusion conditions according to claim 1 is characterized in that: The four features of the connected domain calculated in step 2) are specifically: (2.1) Calculation of connected domain area: Use the connected domain with 8 connectivity, traverse the connected domain marking results, and count the number of pixels in each connected domain. The number of pixels is the area of the connected domain, namely ConnectedArea, where 8 connectivity means that a pixel is connected in four directions: up, down, left, right, and diagonal. (2.2) Calculation of corner points of connected domain contour: Harris corner detection algorithm is used to detect corner points in the seal ring image and save the coordinates of all corner points. Based on the characteristics of the corner points, a local window is selected and moved in all directions. The difference between the pixels in the window before and after the movement is calculated to determine whether the area corresponding to the window is a corner point. The mathematical description of corner point judgment is as follows: E(u,v)=∑ x,y w(xy)[I(x+u,y+v)-I(x,y)] 2 Where E is the energy function, u and v reflect the movement of the window, x and y are the coordinates in the seal ring image, and w(x, y) is the window function; Traverse all points on the contour of the current connected domain one by one, and compare them with each saved corner point. If the straight-line distance between the two points is less than DisPara pixels, the point on the current contour is judged to be a contour corner point. DisPara is the distance parameter. Finally, the number of all contour corner points on the connected domain, i.e. CornerNum, is saved. (2.3) Calculation of the convexity of the connected domain contour: The area contour of the current connected domain is detected by the edge detection algorithm. The contour perimeter is calculated first, and then the convex hull perimeter is calculated. The contour perimeter is calculated by summing the number of pixel points of the area contour. The convex hull refers to a minimum convex polygon that surrounds a group of points. A convex polygon is a polygon with all internal angles less than 180 degrees. The convex hull perimeter is calculated using the Andrew convex hull algorithm. The convexity of the connected domain contour is calculated as follows: Among them, Perimeter of Contour represents the perimeter of the contour itself, Perimeter of Convex Hull represents the perimeter of the contour convex hull, and the range of contour convexity is [0,1]; (2.4) Calculation of the number of holes in the connected domain: A hole refers to an area inside a connected domain. The number of holes in a connected domain is calculated by analyzing each connected domain and its internal hierarchical structure. The number of holes inside the connected domain, i.e., HoleNum, is calculated by traversing the hierarchical structure of each connected domain.
4. The method for visually counting sealing rings under complex occlusion conditions according to claim 1, characterized in that: In step 3), the number of sealing rings in the connected domain is determined by comprehensive characteristics as follows: (3.1) The number range of sealing rings is calculated through the connected area ConnectedArea feature. First, the sealing ring image is segmented multiple times to calculate the maximum area of a single sealing ring SingleMaxArea; Num connectedArea : The number of sealing rings determined by the area of the connected domain; The conditions for using the connected domain area to judge the number of sealing rings are as follows: when the current connected domain area ConnectedArea is greater than 0 and less than the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 1; when the connected domain area ConnectedArea is greater than the maximum area of a single sealing ring and less than 1+1*AreaPara times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 2; when the connected domain area ConnectedArea is greater than 1+1*AreaPara times the maximum area of a single sealing ring and less than 1+AreaPara*2 times the maximum area of a single sealing ring, the number of connected domain sealing rings is judged to be 3; where AreaPara is the area parameter; 0<ConnectedArea<SingleMaxArea,Num connectedArea =1 SingleMaxArea≤ConnectedArea<(1+AreaPara*1)*SingleMaxArea, In a connectedArea =2 (1+AreaPara*1)*SingleMaxArea≤ConnectedArea <(1+AreaPara*2)*SingleMaxArea, In a connectedArea =3 And so on, so we have: (3.2) The number of sealing rings in the connected domain is determined by the contour corner points. Assuming there are two contour corner points, it is determined that there is one blocked sealing ring, that is, the number of sealing rings is two or more; if there are four contour corner points, it is determined that there are two blocked sealing rings, that is, the number of sealing rings is three or more. By analogy, the number of sealing rings determined by the contour corner point feature is obtained. Num corner : The number of sealing rings determined by contour corner feature; (3.3) The number of sealing rings in the connected domain is determined by the convexity. If the convexity of the connected domain is less than the convexity parameter ConvexityPara, it is determined that there is an occluding sealing ring in the connected domain, and the number of sealing rings in the corresponding connected domain is greater than or equal to 2; Num convexity : The number of sealing rings under convexity feature judgment; if Convexity<ConvexityPara,Num convexity ≥2; (3.4) The number of sealing rings in the connected domain is determined by the number of holes. When there is no abnormal material in the sealing ring, one sealing ring has one hole, and two sealing rings can form three holes. That is, when there are more than three holes in the current connected domain, the number of sealing rings is greater than or equal to 2; First, how many holes can n sealing rings finally form? According to the recursive method, we can solve the geometric problem: how many parts can n circles divide the plane into at most? We get: R(n)=n 2 -n+2 It can be concluded that the maximum number of holes that can be formed by n circles in a plane is: Num hole (n)=n 2 -n+1 The minimum number of sealing rings in the connected domain is determined by the known number of holes in the connected domain; Num hole : The number of sealing rings under the feature judgment of the number of holes; From the root-finding formula of a quadratic equation It is concluded that negative numbers in the solution are discarded; Finally, the minimum value of each feature judgment is taken by combining the four features of connected domain area, connected domain contour corner points, connected domain contour convexity, and connected domain hole number. The maximum value among the minimum values under each feature judgment is compared and the maximum value is taken as the number of sealing rings in the current connected domain ConnectedNum. ConnectedNum =Max(min(Num connectedArea ),min(Num corner ),min(Num convexity ),min(Num hole ))。
