Method for Measuring O-Ring Dimensions and Detecting Appearance

The method addresses the limitations of existing O-type seal detection by integrating image preprocessing, edge detection, and deep learning for precise sizing and defect recognition, enhancing detection precision and adaptability, and reducing error rates in O-type seal measurements and inspections.

CN119919410BActive Publication Date: 2025-07-15SUZHOU LIGOU ROBOT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510405607.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-07-15
Estimated Expiration
2045-04-02

AI Technical Summary

Technical Problem

The existing O-ring defect detection methods are not very accurate, inefficient, poor versatility, and insufficient adaptability in complex environments when detecting small target defects and similar defects.

Method used

Image preprocessing is performed using a high-resolution industrial camera, combining Gaussian filtering and fixed threshold method segmentation, and separation edges are separated by Canny edge detection and morphological refinement, and the center point is positioned based on the weighted center of mass method, and dimension calculation is performed; edge-type and internal defect detection are performed by combining morphological processing and deep learning algorithms, and the results are fused and screened, and model training and optimization are used using the improved YOLOv8 network.

Benefits of technology

It improves the accuracy and efficiency of dimensional measurement, can quickly and accurately detect various defects of O-rings, adapt to O-rings of different sizes, materials and shapes, and ensures the reliability and ease of operation of the test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919410B_ABST
    Figure CN119919410B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for O-ring size measurement and appearance detection. The size of the O-ring is measured by means of image preprocessing, segmentation of the region of interest, edge extraction and center point determination. Then, appearance detection is carried out, including edge defect detection and internal defect detection respectively, and then result fusion and screening are carried out. Thus, high-precision measurement can be achieved, which can adapt to different types of O-rings, timely detect existing defects, and meet the detection of edge defects such as burrs and flash. Moreover, deep learning algorithms are used for internal defect detection. Through steps such as data preparation, model training and model optimization, internal defects such as lack of glue, impurities, breakage and fracture can be accurately identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the measurement and detection of an O-ring during processing, and particularly to a method for measuring the size and detecting the appearance of an O-ring. Background Art

[0002] As a widely used sealing element, the O-ring plays an important role in the industrial field. Its main function is to provide an extrusion-type sealing effect by forming a contact pressure on the sealing contact surface to prevent fluid or gas leakage.

[0003] During the production process of the O-ring, due to various reasons, defects such as scratches, depressions, burrs, material shortages, and fractures may appear on its surface. These defects will affect the sealing performance of the O-ring, thereby affecting the safety and reliability of the entire system. Therefore, it is necessary to detect defects in the O-ring.

[0004] Currently, the detection methods for O-ring defects mainly include manual detection and traditional image processing techniques. Manual detection mainly relies on the experience and subjective judgment of the inspectors, and has the following disadvantages: low detection efficiency, slow manual detection speed, and difficulty in meeting the requirements of large-scale production. High false detection rate, manual detection is easily affected by factors such as fatigue and emotion, resulting in a relatively high false detection rate. High cost, a large amount of human input is required, increasing the production cost.

[0005] At the same time, image processing techniques are also involved in the detection. However, such methods mainly perform defect detection through steps such as preprocessing, feature extraction, and classification, and still have the following deficiencies: feature extraction depends on prior knowledge, traditional methods require manual design of feature extraction algorithms, and subjectivity is strong. Poor generality, traditional methods are difficult to adapt to various types of defect detections, and different detection algorithms need to be designed for different types of defects.

[0006] With the development of deep learning technology, image recognition methods based on deep learning have gradually been applied to the field of industrial defect detection. However, for the detection of O-ring defects, the existing deep learning methods still have room for improvement in terms of detection accuracy and efficiency.

[0007] For example, CN117830253A proposes a method for detecting rubber seal ring defects based on YOLOv7-tiny. Although the feature extraction ability and feature fusion ability of the model are enhanced by introducing the PConv and GAM global attention mechanisms, in practical applications, this method still has certain limitations in detecting small target defects. In addition, CN118657762B proposes a method for detecting surface defects of O-rings for hydrogenated natural gas transmission. Although the detection accuracy and efficiency are improved by improving the YOLOv10n model, there are certain disadvantages in complex environments.

[0008] In summary, the existing defect detection methods for O-ring seals have the following main drawbacks:

[0009] Low detection accuracy: When the existing methods detect small target defects and similar defects, missed detections and false detections are likely to occur, resulting in low detection accuracy.

[0010] Low detection efficiency: It is difficult for the existing methods to meet the requirements of real-time detection in terms of detection speed, especially their applications on embedded devices are limited.

[0011] Poor versatility: It is difficult for the existing methods to adapt to O-ring seals of multiple models and various types of defect detections, and different detection algorithms need to be designed for different situations.

[0012] Insufficient adaptability to complex environments: Under complex lighting conditions and uneven imaging, the detection performance of the existing methods will decrease significantly.

[0013] In view of the above defects, it is expected to create a method for O-ring size measurement and appearance detection, making it more valuable for industrial use. Summary of the Invention

[0014] To solve the above technical problems, the object of the present invention is to provide a method for O-ring size measurement and appearance detection.

[0015] The method for O-ring size measurement and appearance detection of the present invention includes the following steps:

[0016] First, perform the size measurement of the O-ring, including

[0017] Step 1, image preprocessing. Use a high-resolution industrial camera to vertically photograph the O-ring; use Gaussian filtering to eliminate noise and retain edge details.

[0018] Step 2, perform the segmentation of the region of interest.

[0019] Segment the O-ring from the background by the fixed threshold method to generate a binary image.

[0020] Through closing operation, use a 3×3 rectangular kernel to fill the internal holes and eliminate small interference regions.

[0021] Step 3, perform edge extraction and center point determination.

[0022] Separate the outer edge and inner edge of the O-ring through Canny edge detection and morphological thinning.

[0023] Locate the center point of the O-ring based on the weighted centroid method.

[0024] Step 4, perform size calculation.

[0025] Obtain the outer diameter and inner diameter of the O-ring, calculate the Euclidean distance from each point on the outer edge and inner edge to the center point respectively, and use the least squares method to fit the outer / inner edge circle to obtain the outer diameter and inner diameter values.

[0026] The adopted formula for the outer diameter is

[0027] ,

[0028] where is the outer diameter value, is the center point coordinate, is the total number of outer edge points, (x i , y i ) is the coordinate of the i-th point on the outer edge,

[0029] The adopted formula for the inner diameter is

[0030] ,

[0031] where is the inner diameter value, is the center point coordinate, is the total number of inner edge points, (x i , y i ) is the coordinate of the i-th point on the inner edge;

[0032] Calculate the wire diameter. Sample every 10 points on the outer edge of the O-ring, calculate the shortest distance from this point to the inner edge, and take the average value as the wire diameter d.

[0033] The calculation formula for the wire diameter d is

[0034] , where M is the total number of sampling points, is the coordinate of the j-th point on the outer edge, is the coordinate of the k-th point on the inner edge;

[0035] After that, conduct appearance inspection, respectively conduct edge type defect detection and internal defect detection, and then conduct result fusion and screening;

[0036] The process of the edge type defect detection is to perform region segmentation after morphological processing. The internal defect detection includes data preparation, model training, and model optimization. The result fusion is to set geometric constraints, calculate the edge distance, and comprehensively output the result. The comprehensive output is to merge the results of the edge type defect detection and internal defect detection, and display and save the corresponding data of the defect position, type, and confidence level;

[0037] The confidence level is obtained by merging the previous detection results and obtaining the final result through a fusion strategy.

[0038] The rule merging of the detection results is to define the types of detection results, including

[0039] 1) T-D double confirmation defect: both edge defect detection and internal defect detection are detected.

[0040] 2) T single detection defect: edge defect detection is detected.

[0041] 3) D single detection defect: internal defect detection is detected.

[0042] The fusion strategy includes formulas.

[0043] , where T is the set of defects detected by the traditional algorithm, D is the set of defects detected by the deep learning algorithm. : represents the set of defects jointly detected by the traditional algorithm and the deep learning algorithm.

[0044] For T-D double confirmation defects, it includes formulas.

[0045] , where is the defect confidence level output by the deep learning model, and the traditional feature score is the normalized score of the connected domain area and aspect ratio features extracted based on morphological processing and region segmentation algorithms.

[0046] For single detection defects, it includes formulas.

[0047] ,

[0048] Non-maximum suppression is added to merge overlapping defects, and the improved weighted formula is

[0049] , where is the defect bounding box detected by the traditional algorithm. is the defect bounding box detected by the deep learning model, and IoU is the intersection over union.

[0050] Finally, fusion is performed through the merging rule, and the merging rule is

[0051] If the types are the same and IoU≥0.7, it is determined as the same type of defect and merged into one defect bounding box; if the types are different or IoU<0.3, it is determined as different defect bounding boxes and not merged; if IoU is greater than or equal to 0.3 and less than 0.7, it is not merged and the defect bounding box is retained.

[0052] Furthermore, for the above method for O-ring size measurement and appearance inspection, in step 1, the formula for Gaussian filtering is

[0053] , with a standard deviation σ = 1.5 and a kernel size of 5×5;

[0054] In step 2, the formula for threshold segmentation is

[0055] ,

[0056] In step 3, to locate the center point of the O-ring, the formula used is

[0057] , , where is the weight formed by the reciprocal of the edge point curvature.

[0058] Furthermore, for the above method for O-ring size measurement and appearance inspection, the morphological processing is to enhance edge defects such as burrs and frayed edges through top-hat transformation, expressed as , where is the original grayscale image, is the image subtraction operator, I is the input image, is the structuring element, composed of a 5×5 circular kernel, is the opening operation operator, is the output image after top-hat transformation.

[0059] Furthermore, for the above method for O-ring size measurement and appearance inspection, the region segmentation is to extract the defect region based on connected component analysis, calculate the area of the connected component and filter the noise, and finally perform screening. By using 8-neighborhood connectivity to mark the candidate defect regions, it is expressed as

[0060] ,

[0061] where is the k-th connected component, is the binarization threshold, is the starting point of the connected region, means there exists at least one;

[0062] The formula for calculating the area of the connected component and filtering the noise is ,

[0063] 1 represents the contribution value of each pixel point, representing a unit area, represents calculating the area of the connected component;

[0064] The screening criteria are that when pixels, the corresponding k-th connected component is retained .

[0065] The screening criteria are that when pixels, the corresponding k-th connected component is retained .

[0066] Furthermore, in the above method for O-ring size measurement and appearance detection, the data preparation is to collect O-ring images, label the defect categories, and divide the training set, validation set, and test set according to the defect categories. The defect categories include lack of glue, impurities, breakage, and fracture.

[0067] The model training is to train using the improved YOLOv8 network with corresponding parameters. The parameters include an initial learning rate of 0.001, a momentum of 0.8 to 1.0, and an iteration number of 200 to 400.

[0068] The model optimization is to use TensorRT to quantize and fuse the layers of the model, and the set inference speed is 6 to 12 ms / frame.

[0069] Furthermore, in the above method for O-ring size measurement and appearance detection, the geometric constraint is to perform secondary screening on the deep learning detection results to eliminate suspected defects that are more than 2 mm away from the edge. A physical space mapping formula is established to define the conversion coefficient from pixels to actual dimensions, denoted as . Among them, the actual outer diameter is the outer diameter of the O-ring obtained by the size measurement module, and the image outer diameter is the pixel diameter of the outer edge of the O-ring in the image. Specifically, this formula is used to define the conversion coefficient from image pixels to actual physical dimensions. pixels is the pixel unit, representing the number of pixels, and is the image size. mm is the millimeter unit, representing the actual physical dimensions.

[0070] Furthermore, in the above method for O-ring size measurement and appearance detection, the edge distance calculation is to calculate the pixel distance from the center of each defect region D to the nearest edge. The formula used is

[0071] ,

[0072] The formula for converting to physical distance is , and the screening rules are set

[0073] .

[0074] By means of the above solution, the present invention has at least the following advantages:

[0075] 1. High measurement accuracy. In terms of dimensional measurement: Through a series of steps such as image preprocessing, region of interest segmentation, edge extraction, and center point determination, the dimensional information such as the outer diameter, inner diameter, and wire diameter of the O-ring can be accurately obtained. For example, Gaussian filtering is used to eliminate noise and retain edge details to ensure image quality; the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge to improve the accuracy of edge extraction; the center point is located based on the weighted centroid method, considering the weights formed by the reciprocals of the curvatures of the edge points, making the center point positioning more accurate. The organic combination of these steps effectively improves the accuracy of dimensional measurement and can meet the requirements of high-precision measurement.

[0076] In terms of appearance inspection: Through the combination of edge defect detection and internal defect detection, various defects of the O-ring can be comprehensively and accurately detected. Edge defect detection uses traditional algorithms such as morphological processing and region segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms. Through steps such as data preparation, model training, and model optimization, internal defects such as lack of glue, impurities, breakage, and fracture can be accurately identified. The result fusion and screening process further improves the accuracy of detection. By setting geometric constraints and calculating edge distances, false detections and missed detections are effectively avoided, ensuring the reliability of the appearance inspection results.

[0077] 2. Strong adaptability. Adaptability to different O-rings: The method of the present invention is applicable to O-rings of various sizes, materials, and shapes. By adjusting the parameters in steps such as image preprocessing, dimensional measurement, and appearance inspection, the measurement and inspection requirements of different O-rings can be met. For example, in image preprocessing, the standard deviation and kernel size of Gaussian filtering can be adjusted according to the actual situation of the O-ring to obtain the best image quality; in dimensional measurement, by calculating parameters such as the outer diameter, inner diameter, and wire diameter, O-rings of different sizes can be adapted; in appearance inspection, by adjusting the parameters of the deep learning model and training data, defects of O-rings of different materials and shapes can be identified.

[0078] Adaptability to different defect types: The appearance inspection method of the present invention can adapt to a variety of defect types. Through the combination of edge defect detection and internal defect detection, edge defects and internal defects of the O-ring can be detected. Edge defect detection uses methods such as morphological processing and region segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, which can accurately identify internal defects such as lack of glue, impurities, breakage, and fracture. In addition, through the result fusion and screening process, the detection accuracy for different defect types can be further improved, ensuring the reliability of the detection results.

[0079] 3. High detection efficiency. For dimensional inspection: The dimensional measurement method of the present invention can quickly and accurately obtain the dimensional information of the O-ring through steps such as image processing and calculation. In the image preprocessing step, Gaussian filtering is used to eliminate noise and retain edge details, improving the image quality; in the region of interest segmentation step, the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; in the edge extraction and center point determination step, the Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge, and the center point is located based on the weighted centroid method, improving the accuracy and efficiency of dimensional measurement. The entire dimensional measurement process has a high degree of automation and can complete the dimensional measurement of a large number of O-rings in a short time, improving the production efficiency.

[0080] For appearance inspection: The appearance inspection method of the present invention can quickly and accurately detect various defects of the O-ring by combining edge-type defect detection and internal defect detection. Edge-type defect detection uses traditional algorithms such as morphological processing and region segmentation to quickly detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, and through steps such as data preparation, model training, and model optimization, can quickly identify internal defects such as lack of glue, impurities, breakage, and fracture. The result fusion and screening process further improves the detection efficiency. By setting geometric constraints and calculating edge distances, etc., effective defects are quickly screened out, avoiding false detection and missed detection, and ensuring the reliability of the appearance inspection results.

[0081] 4. Strong reliability. The dimensional measurement method of the present invention can obtain reliable dimensional measurement results through a series of precise calculation and processing steps. In the image preprocessing step, Gaussian filtering is used to eliminate noise and retain edge details to ensure the image quality; in the region of interest segmentation step, the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; in the edge extraction and center point determination step, the Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge, and the center point is located based on the weighted centroid method, improving the accuracy of dimensional measurement. In addition, by calculating parameters such as the outer diameter, inner diameter, and wire diameter, the dimensional information of the O-ring can be comprehensively and accurately reflected, ensuring the reliability of the dimensional measurement results.

[0082] The appearance detection method of the present invention can obtain reliable appearance detection results by combining edge - type defect detection and internal defect detection. Edge - type defect detection uses traditional algorithms such as morphological processing and region segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep - learning algorithms. Through steps such as data preparation, model training, and model optimization, it can accurately identify internal defects such as lack of glue, impurities, breakage, and fracture. The result fusion and screening process further improves the reliability of the detection results. By setting geometric constraints and calculating edge distances, etc., it effectively avoids false detection and missed detection, ensuring the reliability of the appearance detection results.

[0083] 5. Easy to operate. The dimension measurement method of the present invention realizes automatic measurement through steps such as image processing and calculation. The operator only needs to place the O - ring under a high - resolution industrial camera for image acquisition, and subsequent steps such as image pre - processing, region of interest segmentation, edge extraction and center point determination, and dimension calculation can all be automatically completed by a computer program. The entire dimension measurement process is easy to operate, without complex operation skills and a large amount of manual measurement, reducing the operation difficulty and improving the measurement efficiency. The appearance detection method of the present invention realizes automatic detection by combining edge - type defect detection and internal defect detection. The operator only needs to input the O - ring image into the detection system, and subsequent steps such as edge - type defect detection, internal defect detection, result fusion and screening can all be automatically completed by a computer program. The entire appearance detection process is easy to operate, without complex operation skills and a large amount of manual detection, reducing the operation difficulty and improving the detection efficiency.

[0084] The above description is only an overview of the technical solution of the present invention. In order to be able to more clearly understand the technical means of the present invention and implement it according to the content of the description, the following takes the preferred embodiments of the present invention and combines with the attached drawings to elaborate in detail as follows. Brief Description of the Drawings

[0085] Figure 1 It is a schematic diagram of an O - ring after image pre - processing.

[0086] Figure 2 It is a schematic diagram of taking inner - diameter samples using the present invention.

[0087] Figure 3 It is a schematic diagram of taking outer - diameter samples using the present invention.

[0088] Figure 4 It is a schematic diagram of taking wire - diameter samples using the present invention.

[0089] Figure 5 It is a schematic flow diagram of dimension calculation using the present invention.

[0090] Figure 6It is a schematic diagram of O-ring defect marking displayed on the software interface after fusion and screening. Specific implementation manner

[0091] The following combines the accompanying drawings and embodiments to further describe in detail the specific implementation manner of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0092] Such as Figures 1 to 6 A method applicable to O-ring size measurement and appearance detection, which is different in that it includes the following steps:

[0093] Perform O-ring size measurement, including the following:

[0094] First, perform image preprocessing. Use a high-resolution industrial camera to vertically shoot the O-ring. In this way, uniform illumination can be ensured and shadow interference can be avoided. A high-resolution industrial camera with a pixel value of not less than 20 million can be preferably selected. Then, use Gaussian filtering to eliminate noise and retain edge details. The formula for the Gaussian filtering used is,

[0095] , the standard deviation σ = 1.5, (x, y): pixel coordinates with the center of the kernel as the origin (range of values: x, y ∈ {—k, —k + 1,..., k}, k is the kernel size. At the same time, the kernel size of 5×5 can be preferably used. For different implementation requirements, the value range of the standard deviation σ can be from 1.0 to 2.0, which can better control the strength of the filtering. The value range of the kernel size of the rectangular kernel is from 3×3 to 7×7.

[0096] After that, perform segmentation of the region of interest (ROI). During implementation, the O-ring and the background are segmented by the fixed threshold method to generate a binary image. The formula for the threshold segmentation used is,

[0097] ,

[0098] where f(x, y) is the image gray value, T is the threshold for distinguishing the O-ring from the background, and the value range can be from 0 to 255. At the same time, g(x, y) represents the output binary image (0 = background, 255 = O-ring).

[0099] The internal holes can be filled and the tiny interference regions can be eliminated through closing operation for a 3×3 rectangular kernel. The tiny regions involved in the present invention refer to the area range ≤ 7 pixels (equivalent diameter ≤ 3 pixels approximately).

[0100] Next, perform edge extraction and center point determination. Separate the outer edge and inner edge of the O-ring through Canny edge detection and morphological thinning. And, locate the center point of the O-ring through the weighted centroid method. Considering the convenience of implementation, the formula used to locate the center point of the O-ring is,

[0101] , where is the weight formed by the reciprocal of the edge point curvature, and its value range is from 0 to 1.

[0102] Then, perform size calculation to obtain the outer diameter and inner diameter of the O-ring. Specifically, calculate the Euclidean distance from each point on the outer edge and inner edge to the center point, and take the average value to obtain the outer diameter and inner diameter.

[0103] The adopted outer diameter formula is

[0104] , where is the outer diameter value, is the center point coordinate, is the total number of outer edge points, (x i , y i ) is the coordinate of the i-th point on the outer edge.

[0105] The adopted inner diameter formula is

[0106] , where is the inner diameter value, is the center point coordinate, is the total number of inner edge points, (x i , y i ) is the coordinate of the i-th point on the inner edge.

[0107] Next, calculate the wire diameter. Samples can be taken every 10 points on the outer edge of the O-ring, calculate the shortest distance from this point to the inner edge, and take the average value as the wire diameter d. During implementation, the calculation formula for the wire diameter d adopted is

[0108] , where M is the total number of sampling points, is the inner edge point coordinate, (x i , y i ) is the outer edge point coordinate, and d is the wire diameter value. In this way, through the average distance calculation method based on the center point, the measurement error caused by the deformation of the soft O-ring can be effectively solved.

[0109] After that, appearance inspection is carried out, including edge defect detection and internal defect detection respectively, and then result fusion and screening are carried out. Specifically, the process of edge defect detection (traditional algorithm) adopted is to perform region segmentation after morphological processing to detect defects on the edge of the O-ring, such as burrs and rough edges. At the same time, the internal defect detection (deep learning algorithm) adopted includes data preparation, model training, and model optimization to detect internal defects of the O-ring, such as lack of glue, impurities, breakage, and fracture. In order to obtain more accurate values, the result fusion adopted is to set geometric constraints, calculate the edge distance, and comprehensively output the results. Specifically, the comprehensive output adopted is to merge the results of edge defect detection and internal defect detection, and display and save the corresponding data of the defect position, type, and confidence level for subsequent quality evaluation and processing.

[0110] Combined with a preferred embodiment of the present invention, the morphological processing adopted is to enhance edge defects such as burrs and rough edges through top-hat transformation, expressed as Itophat = Ioriginal—(IoS). Where Ioriginal is the original grayscale image, S is the structural element, which is composed of a 5×5 circular kernel, o is the opening operation operator, and Itophat is the output image after top-hat transformation. At the same time, the region segmentation adopted is to extract the defect region based on connected component analysis, calculate the area of the connected component, filter the noise, and finally perform screening. During the implementation, the candidate defect region can be marked by using 8-neighborhood connectivity, expressed as,

[0111] ,

[0112] where, is the kth connected component, is the binarization threshold. Considering the convenience of implementation, usually takes 1.2 times the median gray value of the top-hat image.

[0113] At the same time, the formula for calculating the area of the connected component and filtering the noise adopted in the present invention is, . The screening criterion adopted is that when Area( ) > 5 pixels, the corresponding kth connected component is retained .

[0114] Furthermore, in order to better perform deep learning and have a better pre-training process. The data preparation process is as follows: collect O-ring images and label the defect categories. According to common defect situations, the defect categories can include lack of glue, impurities, breakage, and fracture. Of course, adjustments can also be made in subsequent training. After that, divide the training set, validation set, and test set according to the defect categories.

[0115] During the implementation, the relationships of the training set, validation set, and test set used are shown in Table 1 below:

[0116]

[0117] The model training involved is to train by improving the YOLOv8 network with corresponding parameters. The parameters include an initial learning rate of 0.001, a momentum of 0.8 to 1.0, and an iteration number of 200 to 400. It can preferably be a momentum of 0.9 and an iteration number of 300. And, to facilitate the construction and implementation of the model, during the model optimization, this invention uses TensorRT to quantize the model, sets the inference speed to 6 to 12 ms / frame, and performs layer fusion after meeting the FP32 accuracy. Of course, the preferably inference speed can be 8 ms / frame.

[0118] From the actual implementation perspective, considering the optimization of result fusion and combining the data involved in the O-ring size measurement, the geometric constraint adopted is to perform a secondary screening on the deep learning detection results to eliminate suspected defects that are more than 2 millimeters away from the edge. In this way, false detections can be effectively avoided. At the same time, for the outer shape of the O-ring, a physical space mapping formula is established to define the conversion coefficient from pixels to actual dimensions. During the implementation, the following formula can be recommended,

[0119] ,

[0120] where the actual outer diameter is the outer diameter of the O-ring obtained through the size measurement module (unit: millimeter), and the image outer diameter is the pixel diameter of the outer edge of the O-ring in the image. Specifically, this formula is used to define the conversion coefficient from image pixels to actual physical dimensions. pixels is the pixel unit, representing the number of pixels, is the image size, and mm is the millimeter unit, representing the actual physical dimensions.

[0121] Furthermore, since abnormal features such as burrs are likely to occur at the edge positions, these abnormalities can be defined as defect regions D. For this, the edge distance calculation is as follows: for each defect region D, calculate the pixel distance from its center to the nearest edge, and the formula adopted is,

[0122] . Specifically, ( , ) are the coordinates of the defect region, ( , ) are the coordinates of the outer edge, is the pixel distance from the defect to the edge.

[0123] At the same time, to facilitate the conversion of the pixel distance to the actual physical distance, the following formula can be used for conversion. Specifically, the formula for converting to the physical distance is, , is the pixel distance from the center of the defect area to the nearest edge, and k is the conversion coefficient from pixels to the actual size. The converted physical distance.

[0124] Set the screening rules.

[0125]

[0126] Among them, The converted physical distance is the physical distance retained after passing the judgment condition.

[0127] During the implementation of the present invention, the confidence is obtained by merging the rules of previous detection results, and the final result can be obtained through the fusion strategy. Specifically, the rules of the detection results are merged, and the definition of the detection result types involved includes the following three cases:

[0128] 1) T-D double confirmation defect: Both edge defect detection and internal defect detection are detected. At the same time, for the T-D double confirmation defect, there is a formula

[0129] . During the implementation is the defect confidence (from 0 to 1) output by the deep learning model. The traditional feature score is a normalized score (from 0 to 100) calculated based on morphological features (such as connected domain area, aspect ratio). That is to say, the traditional feature score is a normalized score of the connected domain area and aspect ratio features extracted based on morphological processing and region segmentation algorithms.

[0130] 2) For single-detection defects, (T single-detection defect: Edge defect detection is detected. D single-detection defect: Internal defect detection is detected).

[0131] The formula is as follows

[0132] ,

[0133] Add non-maximum suppression (NMS) to merge overlapping defects. The improved weighted formula can be

[0134] .

[0135] Specifically, is the defect bounding box (BoundingBox) detected by traditional algorithms (such as morphological processing). is the defect bounding box detected by the deep learning model (such as the improved YOLOv8). IoU is the intersection over union, and the value range is 0 ≤ IoU ≤ 1.

[0136] Furthermore, in order to achieve better integration, the integration strategy involved in the present invention includes formulas,

[0137] .

[0138] Among them, T is the set of defects detected by traditional algorithms, and D is the set of defects detected by deep learning algorithms, : represents the set of defects jointly detected by traditional algorithms and deep learning algorithms.

[0139] Finally, fusion is carried out through a merging rule. During implementation, the merging rule adopted is,

[0140] If the types are the same and IoU ≥ 0.7, it is determined as the same type of defect and merged into one defect bounding box; if the types are different or IoU < 0.3, it is determined as different defect bounding boxes and not merged; if IoU is greater than or equal to 0.3 and less than 0.7, it is not merged and the defect bounding box is retained.

[0141] The working principle of the present invention is as follows:

[0142] As Figure 1 shown, through image preprocessing, the outer edge and inner edge of the O-ring image are extracted first. Then, the software applying the method of the present application is used to sequentially collect the sampling points of the inner diameter, outer diameter, and wire diameter, and the collection process is as shown by the arrows in reference Figures 2 to 4 . Then, referring to the flowchart shown in Figure 5 , the corresponding data is calculated to obtain the size data of the O-ring.

[0143] After that, the positions of the existing defects are calibrated through the software interface, similar to Figure 6 shown. Reference frames can be added to highlight the positions of the existing defects, with better visualization results. At the same time, different colors and texts can be used in combination to better facilitate the user to view the corresponding defects.

[0144] The following takes a nitrile rubber O-ring (standard outer diameter 24 mm, wire diameter 2.4 mm) on a certain industrial production line as an example to detail the specific process and parameter settings of using the method of the present invention.

[0145] Image acquisition and preprocessing.

[0146] Industrial camera: Resolution 2448×2048 pixels, frame rate 30 fps, vertically installed directly above the detection table. Image preprocessing is Gaussian filtering: Kernel size: 5×5 (specified in the document), standard deviation σ = 1.5 (specified in the document) formula:

[0147] , used to smooth noise and retain edge details.

[0148] Segment the region of interest (ROI). Threshold segmentation, where the fixed threshold T = 120 (set according to the actual grayscale histogram, background grayscale ≤ 120, O-ring grayscale > 120).

[0149] Through the binarization formula, perform morphological optimization. Use closing operation, through a 3×3 rectangular structuring element (specified in the document), fill internal holes, and eliminate small disturbances.

[0150] Edge extraction and center point calculation.

[0151] Use Canny edge detection. During this period, the high threshold = 100, the low threshold = 50 (adjusted according to experiments to ensure complete extraction of internal and external edges). Through the weighted centroid method, the weight wi : the reciprocal of the curvature of the edge point (the curvature calculation uses the adjacent three-point method). Combine with the center point coordinate formula,

[0152] , where, is the curvature of the th edge point, is the total number of edge points (in the example image

[0153] ≈ 2000).

[0154] .

[0155] For the inner diameter and wire diameter, calculate in the same way by substituting into the formula. The result is Din ≈ 18.997 mm, and the wire diameter d ≈ 2.402. Appearance defect detection. Edge type defect detection (traditional algorithm), use top-hat transformation:

[0156] . The structuring element S is a 5×5 circular kernel to enhance burrs and frayed edges.

[0157] Through connected component analysis: the binarization threshold Tbinary = 1.2 × median grayscale = 60 T binary = 1.2 × median grayscale = 60. The area filtering threshold > 5 pixels to eliminate noise. 2 burr defects are detected (with areas of 8 pixels and 12 pixels respectively).

[0158] Internal defect detection (deep learning).

[0159] Model configuration: Improve YOLOv8: Add the CBAM attention module and optimize the loss function to CIoU.

[0160] Training parameters: learning rate 0.001, momentum 0.9, iterate 300 times.

[0161] TensorRT Optimization: FP32 precision, inference speed 8 ms / frame (data in Table 2).

[0162] Detection Results: 1 glue deficiency defect detected (confidence 0.85), 1 impurity defect detected (confidence 0.78).

[0163] Result Fusion and Screening. Through physical space mapping, calculation of the distance from the defect to the edge: d mm = 40 × d pixel. For example, if the center of a certain defect is 50 pixels away from the edge, the actual distance is 1.25 mm (<2 mm, retained).

[0164] Confidence Fusion. T-D Double-Confirmation Defects:

[0165] Glue Deficiency Defect (traditional feature score 80, DL_Conf = 0.85): Confidence = 0.7×0.85 + 0.3×10080 = 0.595 + 0.24 = 0.835.

[0166] Single-Inspection Defect: Impurity Defect (DL_Conf = 0.78): Confidence = 0.9×0.78 = 0.702

[0167] Final Threshold θ = 0.6, both types of defects are retained.

[0168] NMS Merging: For the same type of defect (glue deficiency), IoU = 0.75 > 0.7, merged into one detection box. For different types of defects (glue deficiency and impurity), IoU = 0.2 < 0.3, not merged.

[0169] Output Results. Dimension Measurement, Outer Diameter: 23.997 mm (error ±0.003 mm), Inner Diameter: 18.997 mm, Wire Diameter: 2.402 mm.

[0170] Defect Detection:

[0171] Glue Deficiency (confidence 0.835, position (x = 320, y = 450)). Impurity (confidence 0.702, position (x = 700, y = 200)). Burrs (detected by traditional algorithm, positions (x = 150, y = 600), (x = 900, y = 300)).

[0172] Summary Table of Key Parameters, as shown in Table 2:

[0173]

[0174] From the above text description and in combination with the attached drawings, it can be seen that after adopting the present invention, the following advantages are achieved:

[0175] 1. High measurement accuracy. For dimensional measurement: Through a series of steps such as image preprocessing, region of interest segmentation, edge extraction, and center point determination, it is possible to accurately obtain dimensional information such as the outer diameter, inner diameter, and wire diameter of the O-ring. For example, Gaussian filtering is used to eliminate noise and retain edge details to ensure image quality; the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge to improve the accuracy of edge extraction; the center point is located based on the weighted centroid method, considering the weights formed by the reciprocals of the curvatures of the edge points to make the center point positioning more accurate. The organic combination of these steps effectively improves the accuracy of dimensional measurement and can meet the requirements of high-precision measurement.

[0176] For appearance inspection: By combining edge defect detection and internal defect detection, it is possible to comprehensively and accurately detect various defects of the O-ring. Edge defect detection uses traditional algorithms such as morphological processing and region segmentation to effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms. Through steps such as data preparation, model training, and model optimization, it can accurately identify internal defects such as lack of glue, impurities, breakage, and fracture. The result fusion and screening process further improves the accuracy of detection. By setting geometric constraints and calculating edge distances, etc., false detections and missed detections are effectively avoided, ensuring the reliability of the appearance inspection results.

[0177] 2. Strong adaptability. Adaptability to different O-rings: The method of the present invention is applicable to O-rings of various sizes, materials, and shapes. By adjusting the parameters in steps such as image preprocessing, dimensional measurement, and appearance inspection, it can meet the measurement and inspection requirements of different O-rings. For example, in image preprocessing, the standard deviation and kernel size of Gaussian filtering can be adjusted according to the actual situation of the O-ring to obtain the best image quality; in dimensional measurement, by calculating parameters such as the outer diameter, inner diameter, and wire diameter, it can adapt to O-rings of different sizes; in appearance inspection, by adjusting the parameters of the deep learning model and the training data, it can identify the defects of O-rings of different materials and shapes.

[0178] Adaptability to different defect types: The appearance inspection method of the present invention can adapt to various defect types. By combining edge defect detection and internal defect detection, it can detect the edge defects and internal defects of the O-ring. Edge defect detection uses methods such as morphological processing and region segmentation to effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms to accurately identify internal defects such as lack of glue, impurities, breakage, and fracture. In addition, through the result fusion and screening process, the detection accuracy for different defect types can be further improved, ensuring the reliability of the detection results.

[0179] 3. High detection efficiency. For dimensional inspection: The dimensional measurement method of the present invention can quickly and accurately obtain the dimensional information of the O-ring through steps such as image processing and calculation. In the image preprocessing step, Gaussian filtering is used to eliminate noise and retain edge details, improving the image quality; in the region of interest segmentation step, the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; in the edge extraction and center point determination step, the Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge, and the center point is located based on the weighted centroid method, improving the accuracy and efficiency of dimensional measurement. The entire dimensional measurement process has a high degree of automation and can complete the dimensional measurement of a large number of O-rings in a short time, improving the production efficiency.

[0180] For appearance inspection: The appearance inspection method of the present invention can quickly and accurately detect various defects of the O-ring by combining edge-type defect detection and internal defect detection. Edge-type defect detection uses traditional algorithms such as morphological processing and region segmentation to quickly detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, and through steps such as data preparation, model training, and model optimization, can quickly identify internal defects such as lack of glue, impurities, breakage, and fracture. The result fusion and screening process further improves the detection efficiency. By setting geometric constraints and calculating edge distances, etc., effective defects are quickly screened out, avoiding false detection and missed detection, and ensuring the reliability of the appearance inspection results.

[0181] 4. Strong reliability. The dimensional measurement method of the present invention can obtain reliable dimensional measurement results through a series of precise calculation and processing steps. In the image preprocessing step, Gaussian filtering is used to eliminate noise and retain edge details to ensure the image quality; in the region of interest segmentation step, the O-ring and the background are segmented by the fixed threshold method to generate a binary image for subsequent processing; in the edge extraction and center point determination step, the Canny edge detection and morphological thinning are used to separate the outer edge and the inner edge, and the center point is located based on the weighted centroid method, improving the accuracy of dimensional measurement. In addition, by calculating parameters such as the outer diameter, inner diameter, and wire diameter, the dimensional information of the O-ring can be comprehensively and accurately reflected, ensuring the reliability of the dimensional measurement results.

[0182] The appearance detection method of the present invention can obtain reliable appearance detection results by combining edge defect detection and internal defect detection. Edge defect detection uses traditional algorithms such as morphological processing and region segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, and through steps such as data preparation, model training, and model optimization, can accurately identify internal defects such as glue shortage, impurities, breakage, and fracture. The result fusion and screening process further improves the reliability of the detection results. By setting geometric constraints and calculating edge distances, etc., false detections and missed detections are effectively avoided, ensuring the reliability of the appearance detection results.

[0183] 5. Easy to operate. The dimension measurement method of the present invention realizes automatic measurement through steps such as image processing and calculation. The operator only needs to place the O-ring under a high-resolution industrial camera for image acquisition, and subsequent steps such as image preprocessing, region of interest segmentation, edge extraction and center point determination, and dimension calculation can all be automatically completed by a computer program. The entire dimension measurement process is easy to operate, without complex operation skills and a large amount of manual measurement, reducing the operation difficulty and improving the measurement efficiency. The appearance detection method of the present invention realizes automatic detection by combining edge defect detection and internal defect detection. The operator only needs to input the O-ring image into the detection system, and subsequent steps such as edge defect detection, internal defect detection, result fusion and screening can all be automatically completed by a computer program. The entire appearance detection process is easy to operate, without complex operation skills and a large amount of manual detection, reducing the operation difficulty and improving the detection efficiency.

[0184] In addition, the orientation or positional relationship described in the present invention is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or structure referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention.

[0185] The above is only the preferred embodiment of the present invention and is not used to limit the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the technical principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be regarded as the protection scope of the present invention.

Claims

1. A method for O-ring size measurement and appearance inspection, characterized in that It includes the following steps: First, measure the size of the O-ring, including Step 1, image preprocessing Vertically photograph the O-ring using a high-resolution industrial camera; use Gaussian filtering to eliminate noise and retain edge details; Step 2, segment the region of interest Segment the O-ring and the background by the fixed threshold method to generate a binary image Through closing operation, use a 3×3 rectangular kernel to fill internal holes and eliminate small interference regions; Step 3, perform edge extraction and center point determination Separate the outer edge and inner edge of the O-ring through Canny edge detection and morphological thinning Based on the weighted centroid method, locate the center point of the O-ring Step 4, perform size calculation Obtain the outer diameter and inner diameter of the O-ring, calculate the Euclidean distance from each point on the outer edge and inner edge to the center point respectively, and use the least squares method to fit the outer / inner edge circle to obtain the outer diameter and inner diameter values The adopted outer diameter formula is , Among them, is the outer diameter value, is the center point coordinate, is the total number of outer edge points, (x i , y i ) is the coordinate of the i-th point on the outer edge, The adopted inner diameter formula is , Among them, is the inner diameter value, is the center point coordinate, is the total number of inner edge points, (x i , y i ) is the coordinate of the i-th point on the inner edge; Calculate the wire diameter. Sample every 10 points on the outer edge of the O-ring, calculate the shortest distance from this point to the inner edge, and take the average value as the wire diameter d; The calculation formula for the wire diameter d is , where M is the total number of sampling points, is the coordinate of the j-th point on the outer edge, is the coordinate of the k-th point on the inner edge; After that, perform appearance inspection, including edge defect detection and internal defect detection respectively, and then perform result fusion and screening; The process of the edge defect detection is to perform region segmentation after morphological processing The internal defect detection includes data preparation, model training, and model optimization The result fusion is to set geometric constraints, calculate edge distances, and comprehensively output results The comprehensive output is to combine the results of edge defect detection and internal defect detection, and display and save the corresponding data of the defect position, type, and confidence level The confidence level is obtained by combining the previous detection results and getting the final result through a fusion strategy The combination of the detection results by rules is to define the types of detection results, including 1) T-D double confirmation defect: detected by both edge defect detection and internal defect detection 2) T single detection defect: detected by edge defect detection 3) D single detection defect: detected by internal defect detection The fusion strategy includes formulas , For T-D double confirmation defects, it includes formulas , where is the defect confidence level output by the deep learning model, and the traditional feature score is the normalized score of the connected domain area and aspect ratio features extracted based on the morphological processing and region segmentation algorithm; For single detection defects, it includes formulas , Add non-maximum suppression to merge overlapping defects, and the improved weighted formula is , where is the defect bounding box detected by the traditional algorithm, is the defect bounding box detected by the deep learning model, and IoU is the intersection over union; Finally, fuse through the merging rules, and the merging rules are If the types are the same and IoU≥0.7, it is determined as the same type of defect and merged into one defect bounding box; if the types are different or IoU<0.3, it is determined as different defect bounding boxes and not merged; if IoU is greater than or equal to 0.3 and less than 0.7, do not merge and retain the defect bounding box 2. The method for O-ring size measurement and appearance inspection according to claim 1, characterized in that: In Step 1, the formula for the Gaussian filtering is , the standard deviation σ = 1.5, and the kernel size used is 5×5; In Step 2, the threshold segmentation formula is , In Step 3, to locate the center point of the O-ring, the adopted formula is , , where is the weight formed by the reciprocal of the edge point curvature.

3. The method for O-ring size measurement and appearance detection according to claim 1, characterized in that: The morphological processing is to enhance burrs and frayed edge defects through top-hat transformation, expressed as , where is the original grayscale image, is the image subtraction operator, is the input image, is the structuring element, which is composed of a 5×5 circular kernel, is the opening operator, is the output image after top-hat transformation.

4. The method for O-ring size measurement and appearance detection according to claim 1, characterized in that: The region segmentation is to extract the defect region based on connected component analysis, calculate the area of the connected component and filter noise, and finally perform screening Mark the candidate defect regions by adopting 8-neighborhood connectivity, expressed as , wherein is the k-th connected component, is the binarization threshold, is the starting point of the connected region, means that there exists at least one; The formula for calculating the area of the connected component and filtering noise is , 1 represents the contribution value of each pixel point and represents a unit area. It represents calculating the area of the connected domain. The screening criterion is that when pixels, the corresponding k-th connected component is retained .

5. The method for O-ring size measurement and appearance detection according to claim 1, wherein: The data preparation is to collect O-ring images, label the defect categories, and divide the training set, validation set, and test set according to the defect categories. The defect categories include lack of glue, impurities, breakage, and fracture. The model training is to train using the improved YOLOv8 network with corresponding parameters. The parameters include an initial learning rate of 0.001, a momentum of 0.8 to 1.0, and an iteration number of 200 to 400. The model optimization is to use TensorRT to quantize and fuse layers of the model, and the set inference speed is 6 to 12 ms / frame.

6. The method for O-ring size measurement and appearance inspection according to claim 1, characterized in that: The geometric constraint is to perform secondary screening on the deep learning detection results and eliminate suspected defects that are more than 2 mm away from the edge. Establish a physical space mapping formula for defining the conversion coefficient from pixels to actual dimensions, denoted as , where the actual outer diameter is the outer diameter of the O-ring obtained by the dimension measurement module, and the image outer diameter is the pixel diameter of the outer edge of the O-ring in the image.

7. The method for O-ring size measurement and appearance inspection according to claim 1, characterized in that: The edge distance calculation is to calculate the pixel distance from the center of each defect region D to the nearest edge. The formula used is , The formula for converting to a physical distance is, , Set the screening rules. 。

Citation Information

Patent Citations

  • Metal workpiece machining surface defect detection method based on computer vision

    CN112102278A

  • Process, device and line of inspection for determination of a wire-edge at the site of an internal edge of a ring surface

    US20190204238A1