Method for size measurement and appearance detection of O-shaped ring

By combining deep learning and traditional image processing technology, high-precision dimensional measurement and appearance detection of O-type sealing rings are achieved, solving the problem of insufficient detection accuracy, efficiency and adaptability in the prior art, and improving the accuracy and efficiency of detection.

CN119919410AActive Publication Date: 2025-05-02SUZHOU LIGOU ROBOT CO LTD

Patent Information

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

AI Technical Summary

Technical Problem

The existing O-ring defect detection methods have shortcomings in detection accuracy, efficiency, versatility and adaptability to complex environments, and it is difficult to meet the needs of high precision and high efficiency.

Method used

A comprehensive method is adopted, including image preprocessing, region of interest segmentation, edge extraction and center point determination, size calculation, edge-type defect detection and internal defect detection, and defect detection are carried out through a combination of deep learning algorithms and traditional image processing technology.

Benefits of technology

It improves the dimensional measurement accuracy and appearance detection accuracy of O-rings, enhances adaptability to different models and defect types, improves detection efficiency, and maintains detection performance in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919410A_ABST
    Figure CN119919410A_ABST
Patent Text Reader

Abstract

The invention relates to a method for size measurement and appearance detection of an O-shaped ring. The size measurement of the O-shaped ring is carried out through the modes of image preprocessing, region-of-interest segmentation, edge extraction, central point determination and the like. And then, appearance detection is carried out, edge type defect detection and internal defect detection are respectively carried out, and then result fusion and screening are carried out. Therefore, high-precision measurement can be achieved, the device is suitable for O-shaped rings of different types, existing defects can be found in time, and detection of edge defects such as burrs and deckle edges is met. Moreover, a deep learning algorithm is adopted for internal defect detection, and internal defects such as glue shortage, impurities, damage and fracture can be accurately recognized through the steps of data preparation, model training, model optimization and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

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

[0003] During the production process of O-rings, scratches, dents, burrs, missing materials, breakages and other defects may appear on the surface due to various reasons. These defects will affect the sealing performance of the O-rings, thus affecting the safety and reliability of the entire system. Therefore, it is necessary to perform defect detection on O-rings.

[0004] At present, the detection methods for O-ring defects mainly include manual detection and traditional image processing technology. 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 needs of large-scale production. High false detection rate, manual detection is easily affected by factors such as fatigue and emotions, resulting in a high false detection rate. High cost, requiring a large amount of manpower investment, and increasing production costs.

[0005] At the same time, image processing technology is also involved in detection. However, this type of method mainly performs defect detection through preprocessing, feature extraction and classification, and still has the following shortcomings: feature extraction relies on prior knowledge, and traditional methods require manual design of feature extraction algorithms, which are highly subjective. Poor versatility, traditional methods are difficult to adapt to various types of defect detection, 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 are gradually applied to the field of industrial defect detection. However, for O-ring defect detection, the existing deep learning methods still have room for improvement in detection accuracy and efficiency.

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

[0008] In summary, the existing O-ring defect detection methods have the following main disadvantages: Low detection accuracy: Existing methods are prone to missed detection and false detection when detecting small target defects and similar defects, resulting in low detection accuracy.

[0009] Low detection efficiency: Existing methods are difficult to meet the needs of real-time detection in terms of detection speed, especially their application on embedded devices is limited.

[0010] Poor versatility: Existing methods are difficult to adapt to the detection of various types of seals and various types of defects, and different detection algorithms need to be designed for different situations.

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

[0012] In view of the above-mentioned defects, a method for measuring the size and appearance of an O-ring is desired to be developed to make it more valuable for industrial use. Summary of the invention

[0013] In order to solve the above technical problems, the purpose of the present invention is to provide a method for measuring the size and appearance of an O-ring.

[0014] The method for measuring the size and appearance of an O-ring of the present invention comprises the following steps: First, measure the size of the O-ring, including: 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.

[0015] Step 2: Segment the region of interest. Use the fixed threshold method to segment the O-ring and the background to generate a binary image. Use the closing operation to fill the internal holes of the 3×3 rectangular kernel and eliminate the small interference area.

[0016] Step three, edge extraction and center point determination, through Canny edge detection and morphological refinement, separate the outer edge and inner edge of the O-ring, and locate the center point of the O-ring through the weighted centroid method.

[0017] Step 4: Perform size calculation to 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 take the average value as the outer diameter and inner diameter.

[0018] Calculate the wire diameter, sample every 10 points on the outer edge of the O-ring, calculate the shortest distance from the point to the inner edge, and take the average value as the wire diameter d; The calculation formula of the wire diameter d is, , where M is the total number of sampling points. After that, appearance inspection is performed, and edge defect detection and internal defect detection are performed respectively, followed by result fusion and screening.

[0019] The process of 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 output the results comprehensively. The comprehensive output is to merge the results of edge defect detection and internal defect detection, and display and save the corresponding data of defect location, type, and confidence.

[0020] Furthermore, in the above method for measuring the size and appearance of an O-ring, in step 1, the formula for Gaussian filtering is: , standard deviation σ=1.5, and the kernel size used is 5×5; In step 2, the threshold segmentation formula is: , In step 3, the center point of the O-ring is located using the formula: ,in, The weight is composed of the inverse of the curvature of the edge point; In step 4, the outer diameter formula used is: , in, is the center point coordinate, N is the total number of edge points, (x i ,y i ) is the coordinate of the i-th point on the outer edge, The inner diameter formula used is, , in, is the center point coordinate, N is the total number of edge points, (x i ,y i ) is the coordinate of the i-th point on the outer edge.

[0021] Furthermore, in the above-mentioned method for O-ring size measurement and appearance inspection, the morphological processing is to enhance edge defects such as burrs and burrs through top hat transformation, which is expressed as Itophat=Ioriginal-(IoS), wherein Ioriginal is the original grayscale image, S is the structural element, which is composed of a 5×5 circular kernel, o is the opening operator, and Itophat is the output image after the top hat transformation.

[0022] Furthermore, in the above method for O-ring size measurement and appearance inspection, the region segmentation is to extract defect regions based on connected domain analysis, calculate the connected domain area and filter the noise for final screening, and mark the candidate defect regions by using 8-neighborhood connectivity, which is expressed as: , in is the kth connected domain, is the binarization threshold, The formula for calculating the area of ​​the connected domain and filtering the noise is: , in, It represents the kth connected domain of the image, that is, the candidate defect area extracted by connectivity analysis. , represents the coordinates of all pixels belonging to the connected domain. 1 represents the contribution value of each pixel, representing a unit area. In other words, the physical meaning of this formula is to calculate the area of ​​the connected domain, which is used to count the number of all pixels in the connected domain. Each pixel is regarded as a unit area, so each point contributes 1, and the sum is the area of ​​this area.

[0023] The screening criteria are: When the pixel is , the corresponding k-th connected domain is retained .

[0024] Furthermore, in the above method for measuring the size and appearance of an O-ring, the data preparation includes collecting images of the O-ring, marking defect categories, and dividing the training set, the validation set, and the test set according to the defect categories, wherein the defect categories include lack of glue, impurities, damage, and fracture. The model training is performed by using an improved YOLOv8 network with corresponding parameters, wherein 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 is optimized by using TensorRT to quantize and fuse the layers of the model, and the inference speed is set to 6 to 12 ms / frame.

[0025] Furthermore, in the above method for measuring the size and appearance of an O-ring, the geometric constraint is to perform a secondary screening on the deep learning detection results to remove 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 size, which is set as . 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 size. pixels is the pixel unit, indicating the number of pixels, is the image size. mm is the millimeter unit, indicating the actual physical size.

[0026] Furthermore, in the above method for measuring the size and appearance of an O-ring, the edge distance is calculated as follows: for each defect area D, the pixel distance from its center to the nearest edge is calculated, and the formula used is: , The formula used to convert to physical distance is, , set filtering rules,

[0027] Furthermore, in the above-mentioned method for O-ring size measurement and appearance inspection, the confidence is obtained by combining previous inspection results according to rules and obtaining the final result through a fusion strategy.

[0028] The detection results are combined into rules to define the detection result type, including: 1) TD double confirmation defect: both edge defect detection and internal defect detection are detected.

[0029] 2) T single inspection defect: edge type defect detection.

[0030] 3) D single inspection defect: detected by internal defect inspection.

[0031] The fusion strategy includes the formula, , At the same time, for TD double confirmation defects, including formulas, , For single inspection defects, including formula , Add non-maximum suppression, merge overlapping defects, and use the improved weighted formula: , Finally, the fusion is performed through the merging rule. The merging rule is: .

[0032] By means of the above scheme, the present invention has at least the following advantages: 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, 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, retain edge details, and ensure image quality; the O-ring and background are segmented by a fixed threshold method to generate a binary image for subsequent processing; the outer edge and the inner edge are separated by Canny edge detection and morphological refinement to improve the accuracy of edge extraction; the center point is located based on the weighted centroid method, and the weight formed by the inverse of the curvature of the edge point is considered 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 needs of high-precision measurement.

[0033] For appearance inspection: By combining edge defect detection and internal defect detection, all kinds of defects of O-rings can be detected comprehensively and accurately. Edge defect detection uses traditional algorithms such as morphological processing and regional segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, and through data preparation, model training and model optimization, it can accurately identify internal defects such as lack of glue, impurities, damage, and fracture. The result fusion and screening process further improves the accuracy of detection. By setting geometric constraints and calculating edge distances, it effectively avoids false detection and missed detection, ensuring the reliability of appearance inspection results.

[0034] 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, size 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 the Gaussian filter can be adjusted according to the actual situation of the O-ring to obtain the best image quality; in size 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 and training data of the deep learning model, it is possible to identify the defects of O-rings of different materials and shapes.

[0035] Adaptability to different defect types: The appearance inspection method of the present invention can adapt to a variety of defect types. By combining edge defect detection and internal defect detection, edge defects and internal defects of the O-ring can be detected. Edge defect detection uses morphological processing and region segmentation methods 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 of different defect types can be further improved to ensure the reliability of the detection results.

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

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

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

[0039] The appearance inspection method of the present invention can obtain reliable appearance inspection 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, which can accurately identify internal defects such as lack of glue, impurities, breakage, and fracture through steps such as data preparation, model training, and model optimization. The result fusion and screening process further improves the reliability of the inspection results. By setting geometric constraints and performing edge distance calculations, false detections and missed detections are effectively avoided, ensuring the reliability of the appearance inspection results.

[0040] 5. Easy to operate. The dimension measurement method of the present invention realizes automated measurement through steps such as image processing and calculation. The operator only needs to place the O-ring under a high-resolution industrial camera to collect images, and the subsequent steps such as image preprocessing, region of interest segmentation, edge extraction and center point determination, and dimension calculation can be automatically completed by a computer program. The entire dimension measurement process is easy to operate, without the need for complex operating skills and a large amount of manual measurement, which reduces the difficulty of operation and improves measurement efficiency. The appearance detection method of the present invention realizes automated 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 the subsequent steps such as edge defect detection, internal defect detection, result fusion and screening can be automatically completed by a computer program. The entire appearance detection process is easy to operate, without the need for complex operating skills and a large amount of manual detection, which reduces the difficulty of operation and improves detection efficiency.

[0041] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention and implement it according to the contents of the specification, the following is a detailed description of the preferred embodiments of the present invention in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 This is a schematic diagram of the O-ring after image preprocessing.

[0043] Figure 2 It is a schematic diagram of inner diameter sampling using the present invention.

[0044] Figure 3 It is a schematic diagram of outer diameter sampling using the present invention.

[0045] Figure 4 It is a schematic diagram of wire diameter sampling using the present invention.

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

[0047] Figure 6It is a schematic diagram of O-ring defect annotation displayed on the software interface after fusion and screening. DETAILED DESCRIPTION

[0048] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0049] like Figures 1 to 6 The method for measuring the size and appearance of O-rings is unique in that it includes the following steps: Carry out dimensional measurements of O-rings, including the following: First, image preprocessing is performed. A high-resolution industrial camera is used to shoot the O-ring vertically. This ensures uniform lighting and avoids shadow interference. A high-resolution industrial camera with a pixel value of no less than 20 million is preferred. Next, a Gaussian filter is used to eliminate noise and retain edge details. The formula for the Gaussian filter is: , standard deviation σ=1.5, (x, y): pixel coordinates with the kernel center as the origin (value range: x, y∈{—k,—k+1,..., k}, k is the kernel size. At the same time, the kernel size used can be preferably 5×5. According to different implementation requirements, the standard deviation σ can range from 1.0 to 2.0, which can better control the intensity of the filter, and the kernel size used ranges from 3×3 to 7×7.

[0050] After that, the region of interest (ROI) is segmented. During the implementation, the O-ring and the background are segmented by a fixed threshold method to generate a binary image. The threshold segmentation formula used is, , Among them, f(x,y) is the grayscale value of the image, T is the threshold, which is used to distinguish the O-ring from the background, and the value range can be 0 to 255. At the same time, g(x,y) represents the output binary image (0=background, 255=O-ring).

[0051] Through the closing operation, the internal holes of the 3×3 rectangular core can be filled to eliminate the small interference area. The invention relates to a small area, which refers to an area range of ≤7 pixels (approximately equivalent to a diameter of ≤3 pixels).

[0052] Next, edge extraction and center point determination are performed. Through Canny edge detection and morphological refinement, the outer edge and inner edge of the O-ring are separated. In addition, the center point of the O-ring is located by weighted centroid method. Considering the convenience of implementation, the formula used to locate the center point of the O-ring is: ,in, The weight is the inverse of the edge point curvature, and its value range is 0 to 1.

[0053] Then, the size calculation is performed to obtain the outer diameter and inner diameter of the O-ring. Specifically, the Euclidean distance from each point on the outer edge and inner edge to the center point is calculated respectively, and the outer diameter and inner diameter are obtained by taking the average value.

[0054] The outer diameter formula used is, ,in, is the center point coordinate, N is the total number of edge points, (x i ,y i ) is the coordinate of the i-th point on the outer edge.

[0055] The inner diameter formula used is, ,in, is the center point coordinate, N is the total number of edge points, (x i ,y i ) is the coordinate of the i-th point on the outer edge.

[0056] Next, calculate the wire diameter. You can sample every 10 points on the outer edge of the O-ring, calculate the shortest distance from the point to the inner edge, and take the average value as the wire diameter d. During the implementation, the calculation formula for the wire diameter d is: , where M is the total number of sampling points, is the coordinate of the inner edge point, (x i ,y i ) is the coordinate of the outer edge point, and d is the wire diameter. In this way, the measurement error caused by the deformation of the soft O-ring can be effectively solved by the average distance calculation method based on the center point.

[0057] After that, appearance inspection is carried out, and edge defect detection and internal defect detection are carried out respectively, followed by result fusion and screening. Specifically, the process of edge defect detection (traditional algorithm) adopted is to perform regional segmentation after morphological processing to detect defects on the edge of the O-ring, such as burrs, rough edges, etc. At the same time, the internal defect detection (deep learning algorithm) adopted includes data preparation, model training, and model optimization to detect defects inside 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 edge distances, and output the results comprehensively. 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 defect location, type, and confidence for subsequent quality assessment and processing.

[0058] In combination 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, which is expressed as Itophat=Ioriginal-(IoS). Among them, Ioriginal is the original grayscale image, S is the structural element, which is composed of a 5×5 circular kernel, o is the open operation operator, and Itophat is the output image after the top hat transformation. At the same time, the region segmentation adopted is to extract the defective area based on the connected domain analysis, calculate the area of ​​the connected domain, filter the noise and finally screen. During the implementation, the candidate defective area can be marked by using 8-neighborhood connectivity, which is expressed as, , in, is the kth connected domain, is the binarization threshold. Considering the convenience of implementation, It is usually taken as 1.2 times the median grayscale value of the top hat image.

[0059] At the same time, the formula used in the present invention to calculate the area of ​​the connected domain and filter the noise is: The screening criteria used are: when Area( )>5 pixels, keep the corresponding k-th connected domain .

[0060] Furthermore, in order to better conduct deep learning, a relatively good preliminary training process is required. The data preparation process used is as follows: O-ring images are collected and defect categories are marked. According to common defect conditions, the defect categories can include lack of glue, impurities, damage, and fracture. Of course, adjustments can also be made in subsequent training. After that, the training set, validation set, and test set are divided according to the defect category.

[0061] During the implementation, the relationship between the training set, validation set, and test set used is shown in Table 1 below:

[0062] The model training involved is to train the model by improving the YOLOv8 network with corresponding parameters, including 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 be preferably a momentum of 0.9 and an iteration number of 300. In addition, in order to facilitate the construction and implementation of the model, the present invention uses TensorRT to quantize the model during model optimization, and sets the inference speed to 6 to 12ms / frame, and performs layer fusion after meeting FP32 accuracy. Of course, the preferred inference speed can be 8ms / frame.

[0063] In view of the actual implementation, considering the optimization of result fusion and the data involved in the O-ring size measurement, the geometric constraints adopted are to conduct secondary screening of the deep learning detection results to eliminate suspected defects that are more than 2 mm away from the edge. In this way, false detection can be effectively avoided. At the same time, a physical space mapping formula is established for the shape of the O-ring to define the conversion coefficient from pixels to actual size. During the implementation, the following formula can be recommended: , Among them, the actual outer diameter is the outer diameter of the O-ring obtained by the size measurement module (unit: mm), 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 size. pixels is the pixel unit, indicating the number of pixels, is the image size, and mm is the millimeter unit, indicating the actual physical size.

[0064] Going further, since abnormal features such as burrs tend to occur at edge locations, these abnormalities can be defined as defect areas D. To this end, the edge distance is calculated as follows: for each defect area D, the pixel distance from its center to the nearest edge is calculated, and the formula used is: Specifically, ( , ) is the coordinate of the defect area, ( , ) are the outer edge coordinates, is the pixel distance from the defect to the edge.

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

[0066] Set filtering rules.

[0067] in, The converted physical distance, Physical distance is maintained after judging the conditions.

[0068] During the implementation of the present invention, the confidence is obtained by merging the previous detection results into rules, and the final result can be obtained through the fusion strategy. Specifically, the detection results are merged into rules, which involves defining the detection result type, including the following three situations: 1) TD double confirmation defect: Both edge defect detection and internal defect detection are detected. At the same time, for TD double confirmation defects, including formula, During the implementation period, It is the defect confidence (0 to 1) output by the deep learning model. The traditional feature score is a normalized score (0 to 100) calculated based on morphological features (such as connected domain area and aspect ratio).

[0069] 2) For single inspection defects, (T single inspection defect: edge defect detection. D single inspection defect: internal defect detection).

[0070] The formula included is as follows, , Add non-maximum suppression (NMS) to merge overlapping defects. The improved weighting formula can be used as follows: .

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

[0072] Furthermore, in order to achieve better fusion, the fusion strategy involved in the present invention includes the formula: .

[0073] in, The set of defects detected by traditional algorithms, A collection of defects detected by the deep learning algorithm, : Defects detected only by traditional algorithms (set difference). θ: Confidence threshold.

[0074] Finally, the merging rules are used for integration. During the implementation period, the merging rules adopted are: .

[0075] Similar defects: the same type and IoU ≥ 0.7 (for example, both are glue missing). Different defects: different types or IoU < 0.3.

[0076] The working principle of the present invention is as follows: like Figure 1 As shown, by image preprocessing, the outer edge and inner edge of the O-ring image are first extracted. Then, the inner diameter, outer diameter and line diameter sampling points are collected in sequence by applying the software of the present application method. The collection process is as shown in reference Figures 2 to 4 Next, refer to Figure 5 The flowchart shown is used to calculate the corresponding data and obtain the corresponding size data of the O-ring.

[0077] Afterwards, the software interface is used to identify the defect locations, similar to Figure 6 As shown. Reference frames can be added to highlight the location of defects, which provides better visualization results. At the same time, different colors and texts can be used to coordinate with each other, making it easier for users to view the corresponding defects.

[0078] The following is a detailed description of the specific process and parameter settings of the method of the present invention by taking a nitrile rubber O-ring (standard outer diameter 24 mm, wire diameter 2.4 mm) on an industrial production line as an example.

[0079] Image acquisition and preprocessing.

[0080] Industrial camera: resolution 2448×2048 pixels, frame rate 30fps, vertically mounted above the inspection table. Image preprocessing is Gaussian filtering: kernel size: 5×5 (specified in the document), standard deviation σ=1.5 (specified in the document) formula: , which is used to smooth noise and preserve edge details.

[0081] 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).

[0082] Morphological optimization is performed through the binarization formula. Using the closing operation, the internal holes are filled through the 3×3 rectangular structure element (specified in the document) to eliminate small interferences.

[0083] Edge extraction and center point calculation.

[0084] Canny edge detection was used, during which the high threshold = 100 and the low threshold = 50 (adjusted according to the experiment to ensure complete extraction of internal and external edges). wi : The inverse of the edge point curvature (the curvature is calculated using the adjacent three-point method). Combined with the center point coordinate formula, ,in, For the The curvature of the edge points, is the total number of edge points (in the example image ≈2000).

[0085] Size calculation. Outer diameter and inner diameter, calculate the Euclidean distance between all outer edge points and the center point, and take the average value: .

[0086] The inner diameter and wire diameter are calculated in the same way, and the result is Din≈18.997 mm, and the wire diameter d≈2.402. Appearance defect detection. Edge defect detection (traditional algorithm), using top hat transformation: The structural element S is a 5×5 circular core that enhances burrs and rough edges.

[0087] Through connected domain analysis: Binary threshold Tbinary = 1.2 × median grayscale = 60 T Binary=1.2×median grayscale=60. Area filter threshold>5 pixels, remove noise. 2 burr defects were detected (areas of 8 pixels and 12 pixels respectively).

[0088] Internal defect detection (deep learning).

[0089] Model configuration: Improved YOLOv8: added CBAM attention module and optimized the loss function to CIoU.

[0090] Training parameters: learning rate 0.001, momentum 0.9, iteration 300 times.

[0091] TensorRT optimization: FP32 accuracy, inference speed 8ms / frame (data in Table 2).

[0092] Test results: 1 glue deficiency defect (confidence level 0.85) and 1 impurity defect (confidence level 0.78) were detected.

[0093] Results fusion and screening. Through physical space mapping, defect to edge distance calculation: d mm = 40 × d For example, if the center of a defect is 50 pixels away from the edge, the actual distance is 1.25 mm (<2 mm, reserved).

[0094] Confidence fusion. TD double confirmation defects: 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.

[0095] D single inspection defect: impurity defect (DL_Conf=0.78): Confidence=0.9×0.78=0.702 The final threshold θ=0.6, both types of defects are retained.

[0096] NMS merging: If IoU=0.75>0.7 for defects of the same type (glue missing), they are merged into one detection frame. If IoU=0.2<0.3 for defects of different types (glue missing and impurities), they are not merged.

[0097] Output results: Dimension measurement, outer diameter: 23.997 mm (error ± 0.003 mm), inner diameter: 18.997 mm, wire diameter: 2.402 mm.

[0098] Defect Detection: Glue shortage (confidence 0.835, position (x=320, y=450)). Impurities (confidence 0.702, position (x=700, y=200)). Burrs (detected by traditional algorithm, position (x=150, y=600), (x=900, y=300)).

[0099] The key parameters are summarized in Table 2:

[0100] It can be seen from the above textual description and the accompanying drawings that the present invention has the following advantages: 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, 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, retain edge details, and ensure image quality; the O-ring and background are segmented by a fixed threshold method to generate a binary image for subsequent processing; the outer edge and the inner edge are separated by Canny edge detection and morphological refinement to improve the accuracy of edge extraction; the center point is located based on the weighted centroid method, and the weight formed by the inverse of the curvature of the edge point is considered 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 needs of high-precision measurement.

[0101] For appearance inspection: By combining edge defect detection and internal defect detection, all kinds of defects of O-rings can be detected comprehensively and accurately. Edge defect detection uses traditional algorithms such as morphological processing and regional segmentation, which can effectively detect edge defects such as burrs and rough edges; internal defect detection uses deep learning algorithms, and through data preparation, model training and model optimization, it can accurately identify internal defects such as lack of glue, impurities, damage, and fracture. The result fusion and screening process further improves the accuracy of detection. By setting geometric constraints and calculating edge distances, it effectively avoids false detection and missed detection, ensuring the reliability of appearance inspection results.

[0102] 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, size 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 the Gaussian filter can be adjusted according to the actual situation of the O-ring to obtain the best image quality; in size 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 and training data of the deep learning model, it is possible to identify the defects of O-rings of different materials and shapes.

[0103] Adaptability to different defect types: The appearance inspection method of the present invention can adapt to a variety of defect types. By combining edge defect detection and internal defect detection, edge defects and internal defects of the O-ring can be detected. Edge defect detection uses morphological processing and region segmentation methods 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 of different defect types can be further improved to ensure the reliability of the detection results.

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

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

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

[0107] The appearance inspection method of the present invention can obtain reliable appearance inspection 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, which can accurately identify internal defects such as lack of glue, impurities, breakage, and fracture through steps such as data preparation, model training, and model optimization. The result fusion and screening process further improves the reliability of the inspection results. By setting geometric constraints and performing edge distance calculations, false detections and missed detections are effectively avoided, ensuring the reliability of the appearance inspection results.

[0108] 5. Easy to operate. The dimension measurement method of the present invention realizes automated measurement through steps such as image processing and calculation. The operator only needs to place the O-ring under a high-resolution industrial camera to collect images, and the subsequent steps such as image preprocessing, region of interest segmentation, edge extraction and center point determination, and dimension calculation can be automatically completed by a computer program. The entire dimension measurement process is easy to operate, without the need for complex operating skills and a large amount of manual measurement, which reduces the difficulty of operation and improves measurement efficiency. The appearance detection method of the present invention realizes automated 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 the subsequent steps such as edge defect detection, internal defect detection, result fusion and screening can be automatically completed by a computer program. The entire appearance detection process is easy to operate, without the need for complex operating skills and a large amount of manual detection, which reduces the difficulty of operation and improves detection efficiency.

[0109] In addition, the indicated orientations or positional relationships described in the present invention are all based on the orientations or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description. They do not indicate or imply that the device or structure referred to must have a specific orientation or be operated with a specific orientation structure. Therefore, they cannot be understood as limitations on the present invention.

[0110] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the technical principles of the present invention, and these improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A method for measuring the size and appearance of an O-ring, characterized in that The following steps are involved: First, measure the size of the O-ring, including: 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; Step 2: Segment the region of interest. The O-ring and the background are segmented by the fixed threshold method to generate a binary image. Through the closing operation, the internal holes of the 3×3 rectangular kernel are filled to eliminate the small interference areas; Step 3: edge extraction and center point determination. Through Canny edge detection and morphological refinement, the outer edge and inner edge of the O-ring are separated. The center point of the O-ring is located based on the weighted centroid method. Step 4: Calculate the size. Get 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, and use the least squares method to fit the outer / inner edge circle to get the outer diameter and inner diameter values. The formula used is: , where (a, b) represents the center of the fitting circle, (x i ,y i ) is the coordinate of the i-th point on the outer edge, and R is the radius; Calculate the wire diameter, sample every 10 points on the outer edge of the O-ring, calculate the shortest distance from the point to the inner edge, and take the average value as the wire diameter d; The calculation formula of the wire diameter d is, , where M is the total number of sampling points. After that, appearance inspection is performed, edge defect detection and internal defect detection are performed respectively, and then the results are fused and screened; The process of 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 output the results comprehensively. The comprehensive output is to combine the results of edge defect detection and internal defect detection, and display and save the corresponding data of defect location, type and confidence.

2. The method for measuring the size and appearance of an O-ring according to claim 1, characterized in that: In step 1, the formula of Gaussian filtering is: , standard deviation σ=1.5, and the kernel size used is 5×5; In step 2, the threshold segmentation formula is: , In step 3, the center point of the O-ring is located using the formula: ,in, The weight is composed of the inverse of the curvature of the edge point; In step 4, the outer diameter formula used is: , in, is the center point coordinate, N is the total number of edge points, (x i ,y i ) is the coordinate of the i-th point on the outer edge, The inner diameter formula used is, , Where N is the total number of edge points.

3. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: The morphological processing is to enhance burrs and rough edge defects through top hat transformation, which is expressed as Itophat=Ioriginal-(IoS), where Ioriginal is the original grayscale image, S is a structural element composed of a 5×5 circular kernel, o is an opening operator, and Itophat is the output image after top hat transformation.

4. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: The region segmentation is to extract the defect region based on the connected domain analysis, calculate the connected domain area and filter the noise for final screening. The candidate defect areas are marked by using 8-neighborhood connectivity, which is expressed as: , in is the kth connected domain, is the binarization threshold, The formula for calculating the area of ​​the connected domain and filtering the noise is: , The screening criteria are: when Area( )>5 pixels, keep the corresponding k-th connected domain .

5. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: The data preparation includes collecting images of O-rings, marking defect categories, and dividing the images into training sets, verification sets, and test sets according to the defect categories, wherein the defect categories include glue deficiency, impurities, breakage, and fracture. The model training is performed by using an improved YOLOv8 network with corresponding parameters, wherein 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 is optimized by using TensorRT to quantize and fuse the layers of the model, and the inference speed is set to 6 to 12 ms / frame.

6. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: 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. Establish a physical space mapping formula to define the conversion coefficient from pixels to actual size, set as , where 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.

7. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: The edge distance is calculated as follows: for each defect area D, the pixel distance from its center to the nearest edge is calculated, and the formula used is: , The formula used to convert to physical distance is, , Set filtering rules. 。 8. The method for measuring the size and inspecting the appearance of an O-ring according to claim 1, characterized in that: The confidence is obtained by combining the previous detection results with rules and obtaining the final result through a fusion strategy. The detection results are combined into rules to define the detection result type, including 1) TD double confirmation defect: both edge defect detection and internal defect detection are detected. 2) T single inspection defect: edge defect detection, 3) D single inspection defect: internal defect detection, The fusion strategy includes the formula, , For TD double confirmation defects, including formula, , For single inspection defects, including formula , Add non-maximum suppression, merge overlapping defects, and use the improved weighted formula: , Finally, the fusion is performed through the merging rule, and the merging rule is: 。

Citation Information

Patent Citations

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

    CN112102278A

  • Optical machined part defect detection method based on image technology

    CN119205644A

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

    US20190204238A1

  • Crown cap surface defect online inspection method employing image processing

    WO2020248439A1

Cited By

  • Square power battery shell visual defect rapid detection method and system

    CN120318234A

  • A method and system for rapid detection of visual defects in square power battery casings

    CN120318234B

  • Sealing ring appearance detection method and detection equipment based on image processing

    CN121558751A

  • Visual detection method and system for printing defects and number of circular self-adhesive labels

    CN122115489A