Defect detection method, device and equipment for annular workpiece and computer program product
By generating the ring mask images of the ring-shaped workpiece and calculating the adaptive threshold, the error detection problem caused by imaging instability in the prior art is solved, and the defect detection accuracy and stability of the ring-shaped workpiece are improved.
Patent Information
- Application Number
- CN202510315266.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-06-13
AI Technical Summary
When detecting defects of annular workpieces, the prior art is affected by unstable mechanical structure and lighting conditions, resulting in unstable imaging, which in turn causes misdetecting problems, such as "miss killing" and "overkilling".
By acquiring the original image of the ring workpiece, using a preset image processing strategy to generate each ring mask image, and adjust the strategy based on the adaptive threshold, calculate the adaptive threshold value based on the self-information of each ring and adjacent ring information, and finally perform defect detection.
The defect detection accuracy of the annular workpiece is improved, the error detection rate is reduced, and the stability and reliability of the detection results are enhanced.
Smart Images

Figure CN120147296A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of defect detection, and particularly relates to a method, device, equipment, and computer program product for defect detection of annular workpieces. Background Art
[0002] Defect detection of annular workpieces (such as glue overflow defect detection of data lines, defect detection of photovoltaic panels, etc.) is a key link to ensure the quality of workpieces leaving the factory. Taking the glue overflow defect detection of data lines as an example, in order to detect the glue overflow area on the surface of the data line, a 2D camera and UV (ultraviolet) light are generally used to collect images of the glue overflow on the data line, and then a method based on a single threshold is used for defect detection.
[0003] However, in real scenarios, unstable mechanical structures and unstable lighting will cause unstable imaging problems, and unstable imaging will further cause misdetection in the traditional single-threshold method. As Figure 1 shown, a schematic diagram of the defect workpiece detection effect of an existing solution under different lighting conditions is provided. The defect area under low exposure conditions cannot be accurately located, which will cause "missing detection", and non-defect areas under overexposure conditions are easily misdetected as defect areas, which will cause "overdetection". Summary of the Invention
[0004] Embodiments of the present application provide a method, device, equipment, and computer program product for defect detection of annular workpieces to improve the defect detection accuracy of annular workpieces.
[0005] Embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, embodiments of the present application provide a method for defect detection of an annular workpiece, and the method for defect detection of the annular workpiece includes:
[0007] Obtain the original image of the annular workpiece;
[0008] According to the original image of the annular workpiece, generate mask images of each ring of the annular workpiece by using a preset image processing strategy;
[0009] According to the original image of the annular workpiece and the mask images of each ring of the annular workpiece, calculate the adaptive threshold of each ring by using an adaptive threshold adjustment strategy, and the adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring based on the own information of each ring and the corresponding adjacent ring information;
[0010] Perform defect detection according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece, and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece.
[0011] Optionally, generating each ring mask image of the annular workpiece based on the original image of the annular workpiece by using a preset image processing strategy includes:
[0012] Preprocessing the original image of the annular workpiece by using an image preprocessing strategy and generating a global mask image of the annular workpiece;
[0013] Based on the designed thickness of each ring in the annular workpiece, processing the global mask image of the annular workpiece by using a distance transformation method to generate each ring mask image of the annular workpiece.
[0014] Optionally, calculating the adaptive threshold of each ring by using an adaptive threshold adjustment strategy based on the original image of the annular workpiece and each ring mask image of the annular workpiece includes:
[0015] Traversing each ring of the annular workpiece according to the relative position relationship between the rings and a preset traversal order;
[0016] When the current ring being traversed is the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring;
[0017] When the current ring being traversed is not the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring, and the defect area image information of the previous ring.
[0018] Optionally, when the current ring being traversed is the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring includes:
[0019] Calculating the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring;
[0020] Calculating the adaptive threshold of the current ring by using a preset first mapping relationship according to the gray value of the current ring.
[0021] Optionally, when the current ring being traversed is not the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring, and the defect area image information of the previous ring includes:
[0022] Calculating the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring;
[0023] Calculating the first threshold of the current ring by using a preset first mapping relationship according to the gray value of the current ring;
[0024] Calculating the area of the defect area of the previous ring;
[0025] Calculate the second threshold of the current ring according to the defect area of the previous ring by using a preset second mapping relationship;
[0026] Calculate the adaptive threshold of the current ring according to the first threshold of the current ring and the second threshold of the current ring by using a preset third mapping relationship.
[0027] Optionally, the preset first mapping relationship is obtained in the following way:
[0028] Obtain multiple original images of the annular workpiece collected under preset calibration conditions;
[0029] Calculate the gray values of each ring in each original image according to the multiple original images of the annular workpiece;
[0030] Generate the preset first mapping relationship according to the gray values of each ring in each original image and the empirical values of the segmentation thresholds corresponding to each ring.
[0031] Optionally, the calculation of the defect area of the previous ring includes:
[0032] Obtain the mask image of the previous ring and the adaptive threshold of the previous ring;
[0033] Perform threshold segmentation on the original image of the annular workpiece according to the mask image of the previous ring and the adaptive threshold of the previous ring to obtain the defect area image of the previous ring;
[0034] Calculate the defect area of the previous ring according to the defect area image of the previous ring.
[0035] Optionally, the calculation of the second threshold of the current ring according to the defect area of the previous ring by using a preset second mapping relationship includes:
[0036] Compare the defect area of the previous ring with the first defect area threshold;
[0037] If the defect area of the previous ring is less than the first defect area threshold, assign a value greater than 0 to the second threshold of the current ring;
[0038] Otherwise, assign a value of 0 to the second threshold of the current ring.
[0039] Optionally, the defect detection of the annular workpiece according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece, and the adaptive thresholds of each ring to obtain the defect detection result of the annular workpiece includes:
[0040] Perform threshold segmentation on the original image of the annular workpiece according to the mask images of each ring of the annular workpiece and the adaptive thresholds of each ring to obtain the defect area images of each ring;
[0041] Overlay the defect area images of each ring to generate the defect area image of the annular workpiece;
[0042] Calculate the defect area of the annular workpiece according to the defect area image of the annular workpiece;
[0043] Determine the defect detection result of the annular workpiece according to the defect area of the annular workpiece and the second defect area threshold.
[0044] In a second aspect, an embodiment of the present application further provides a defect detection device for an annular workpiece. The defect detection device for the annular workpiece includes:
[0045] An acquisition unit configured to acquire the original image of the annular workpiece;
[0046] A generation unit configured to generate mask images of each ring of the annular workpiece according to the original image of the annular workpiece by using a preset image processing strategy;
[0047] An adaptive threshold adjustment unit configured to calculate the adaptive threshold of each ring according to the original image of the annular workpiece and the mask images of each ring of the annular workpiece by using an adaptive threshold adjustment strategy, where the adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring based on the own information of each ring and the corresponding adjacent ring information;
[0048] A defect detection unit configured to perform defect detection according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece, and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece.
[0049] In a third aspect, an embodiment of the present application further provides a device, including:
[0050] A processor; and a memory arranged to store computer-executable instructions, where the executable instructions, when executed, cause the processor to execute any one of the foregoing defect detection methods for the annular workpiece.
[0051] In a fourth aspect, an embodiment of the present application further provides a computer program product, including computer programs / instructions, where the computer programs / instructions, when executed by a processor, implement any one of the foregoing defect detection methods for the annular workpiece.
[0052] The above at least one technical solution adopted in the embodiments of the present application can achieve the following beneficial effects: In the method for defect detection of an annular workpiece in the embodiments of the present application, first, the original image of the annular workpiece is obtained; then, according to the original image of the annular workpiece, each ring mask image of the annular workpiece is generated by using a preset image processing strategy; after that, according to the original image of the annular workpiece and each ring mask image of the annular workpiece, an adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring, and the adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring based on the own information of each ring and the corresponding adjacent ring information; finally, defect detection is performed according to the original image of the annular workpiece, each ring mask image of the annular workpiece, and the adaptive threshold of each ring, and the defect detection result of the annular workpiece is obtained. The method for defect detection of an annular workpiece in the embodiments of the present application separates each ring of the annular workpiece for processing, adaptively adjusts the segmentation threshold of each ring by combining the own information of each ring and the corresponding adjacent ring information, and performs defect detection separately, improving the defect detection accuracy of the annular workpiece and solving problems such as limited application of traditional methods. Description of the Drawings
[0053] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation of the present application. In the drawings:
[0054] Figure 1 It is a schematic diagram of the defect workpiece detection effect of the existing solution under different lighting conditions;
[0055] Figure 2 It is a schematic flowchart of a method for defect detection of an annular workpiece in the embodiments of the present application;
[0056] Figure 3 It is a schematic diagram of splitting a ring based on a distance transformation method in the embodiments of the present application;
[0057] Figure 4 It is a schematic diagram of the global mask image corresponding to the data line interface end and the mask images of each ring in the embodiments of the present application;
[0058] Figure 5 It is a schematic flowchart of calculating the adaptive threshold of each ring in the embodiments of the present application;
[0059] Figure 6 It is a schematic flowchart of the defect detection process of an annular workpiece in the embodiments of the present application;
[0060] Figure 7 It is a schematic diagram of the defect detection result of an annular workpiece in the embodiments of the present application;
[0061] Figure 8Schematic structural diagram of a defect detection device for an annular workpiece in an embodiment of the present application;
[0062] Figure 9 Schematic structural diagram of a device in an embodiment of the present application. Detailed implementation manners
[0063] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0064] The following will describe in detail the technical solutions provided by each embodiment of the present application in conjunction with the drawings.
[0065] Currently, there are mainly the following three defect detection methods for annular workpieces:
[0066] 1) Traditional detection method based on a single threshold
[0067] This type of method is suitable for workpieces of various shapes. However, this type of method is sensitive to the preset threshold and has high requirements for imaging stability. Therefore, for the scenario where the gray values of different ring regions of an annular workpiece are different, this type of method is not suitable.
[0068] 2) Detection method based on deep learning
[0069] This type of method has many advantages as a general detection method. However, this type of method is relatively dependent on data. Due to the lack of marked defect samples on site, the application of this type of method is relatively limited.
[0070] 3) Detection method based on template matching
[0071] This type of method is specifically designed for ring-shaped workpieces. This type of method unfolds a circular region into a rectangular image and constructs an adaptive template image for defect detection. However, this type of method requires that the shape of the workpiece must be a ring, which limits the application of this type of method in non-ring-shaped scenarios.
[0072] Based on this, the embodiments of the present application provide a defect detection method for an annular workpiece. As Figure 2 shown, a flowchart of a defect detection method for an annular workpiece in an embodiment of the present application is provided. The defect detection method for the annular workpiece at least includes the following steps S210 to step S240:
[0073] Step S210, obtain the original image of the annular workpiece.
[0074] When performing defect detection on a ring-shaped workpiece, it is necessary to first collect the original image of the ring-shaped workpiece. For example, a 2D camera and UV light can be used to collect the image of the ring-shaped workpiece to obtain the original image of the ring-shaped workpiece.
[0075] It should be noted that the "ring-shaped workpiece" defined in the embodiments of the present application can be a circular ring-shaped workpiece or a non-circular ring-shaped workpiece (such as an elliptical workpiece formed at one end of a data cable, a rectangular workpiece on a photovoltaic panel, etc.). Moreover, the defect detection method for the ring-shaped workpiece in the embodiments of the present application is not limited to the defect detection of a closed ring-shaped workpiece, and can also be applied to the defect detection of a non-closed ring-shaped workpiece with an opening.
[0076] Step S220: Generate respective ring mask images of the ring-shaped workpiece according to the original image of the ring-shaped workpiece by using a preset image processing strategy.
[0077] A mask can be used to extract the region of interest (i.e., the region with a value of 1) and shield the unnecessary regions. A mask image is usually a binary or Boolean image of the same size as the original image, where the selected region is marked as 1 and the remaining regions are marked as 0.
[0078] Based on this, in the embodiments of the present application, the ring-shaped workpiece in the original image is decomposed into one or more ring regions (depending on the actual number of rings included in the ring-shaped workpiece), the ring-shaped workpiece in the original image is split according to the dimension of the rings, and then the mask technology is used to only retain the information within the respective regions of each ring in the dimension of the rings, and the other regions are set to black or transparent, thereby obtaining the mask images of the respective rings included in the ring-shaped workpiece, which is convenient for subsequent processing and calculation of each ring respectively.
[0079] Step S230: Calculate the adaptive threshold of each ring according to the original image of the ring-shaped workpiece and the respective ring mask images of the ring-shaped workpiece by using an adaptive threshold adjustment strategy, and the adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring based on the own information of each ring and the corresponding adjacent ring information.
[0080] After obtaining the mask images of the respective rings of the ring-shaped workpiece, in combination with the original image of the ring-shaped workpiece, the adaptive threshold adjustment strategy defined in the embodiments of the present application is used to calculate the adaptive threshold of each ring respectively. The adaptive threshold is the basis for subsequent defect segmentation. For example, if the pixel value is higher than the segmentation threshold, the position corresponding to the pixel value will be marked as the defect position, thereby realizing defect segmentation detection.
[0081] The adaptive threshold adjustment strategy of the embodiments of the present application not only considers the self-information of each ring, but also considers the information of the adjacent rings corresponding to each ring. By combining the self-information of each ring and the information of the corresponding adjacent rings, the segmentation threshold of each ring is adaptively adjusted, which can adapt to scene changes and improve the defect detection accuracy.
[0082] Step S240, perform defect detection on the basis of the original image of the annular workpiece, the mask images of the rings of the annular workpiece, and the adaptive threshold of each ring, to obtain the defect detection result of the annular workpiece.
[0083] The adaptive threshold is used to perform defect segmentation on the original image of the annular workpiece. The role of the mask image is to limit the region obtained by threshold segmentation to the region where the value of the mask image corresponding to the original image is 1. Therefore, by combining the mask images of the rings of the annular workpiece and the adaptive threshold of each ring, defect segmentation detection can be performed on each ring in the original image respectively. Finally, by integrating the defect detection results of all rings, the defect detection result of the entire annular workpiece can be obtained.
[0084] The defect detection method of the annular workpiece in the embodiments of the present application separates each ring of the annular workpiece for processing, adaptively adjusts the segmentation threshold of each ring by combining the self-information of each ring and the information of the corresponding adjacent rings, and performs defect detection respectively, improving the defect detection accuracy of the annular workpiece and solving problems such as limited application of traditional methods.
[0085] In some embodiments of the present application, the generating the mask images of the rings of the annular workpiece according to the original image of the annular workpiece by using a preset image processing strategy includes: preprocessing the original image of the annular workpiece by using an image preprocessing strategy and generating a global mask image of the annular workpiece; based on the designed thickness of each ring in the annular workpiece, processing the global mask image of the annular workpiece by using a distance transformation method to generate the mask images of the rings of the annular workpiece.
[0086] When generating the mask images of each ring, the original image of the annular workpiece can be preprocessed first. The purpose of image preprocessing is to improve the quality of the original image so that subsequent processing can more accurately identify the features of the annular workpiece. For example, it can include processing such as denoising and grayscale conversion to highlight the structural features of the annular workpiece and reduce background interference.
[0087] After preprocessing the annular workpiece image, it is necessary to further perform mask processing on the preprocessed annular workpiece image by using a mask technology to generate a global mask image of the annular workpiece. In this global mask image, the part of the entire annular workpiece is retained and highlighted, while the background or other irrelevant parts are suppressed or removed.
[0088] After obtaining the global mask image of the annular workpiece, based on the designed thickness of each ring in the annular workpiece, the global mask image of the annular workpiece is further segmented into mask images of each ring by using the distance transformation method, and each mask image corresponds to a ring in the annular workpiece. The distance transformation method here can find the 0-pixel point closest to each non-0 pixel point and calculate the distance between the two. According to the distance between the two and the designed thickness of each ring in the annular workpiece, the mask images of each ring can be generated by using the set separation threshold.
[0089] For the convenience of understanding the above embodiments, as Figure 3 shown, a schematic diagram of splitting rings based on the distance transformation method in an embodiment of the present application is provided. It is assumed that the unit of the ring thickness is the same as the unit of the image pixel, both being pixel. Figure 3 The annular workpiece shown in [the figure] contains two rings. It is assumed that the thickness of ring 1 is 2 and the thickness of ring 2 is 1. Then the order of obtaining the mask images of each ring is from the outside to the inside: first, obtain the mask image of ring 2. At this time, for example, set the lower separation threshold to 0 and the upper threshold to 1. At this time, the values in the distance image that are greater than 0 and less than or equal to 1 will be retained, corresponding to Figure 3 ring 2 shown in the lower left corner of [the figure]. Then obtain ring 1. At this time, set the lower separation threshold to 1 and the upper threshold to 3. At this time, the values in the distance image that are greater than 1 and less than or equal to 3 will be retained, corresponding to Figure 3 ring 1 shown in the lower right corner.
[0090] As Figure 4 shown, a schematic diagram of the global mask image corresponding to the data line interface end and the mask images of each ring in an embodiment of the present application is provided. Since the cross-section of the data line interface end contains two rings, namely an inner ring and an outer ring, the mask images of the two rings can be correspondingly generated.
[0091] Through image preprocessing, the interference of background noise and irrelevant information is reduced, and the accuracy of subsequent processing is improved. By using the distance transformation method and the designed thickness information of each ring, the mask image of the entire annular workpiece can be accurately split into mask images of each ring, which serves as the basis for subsequent adaptive threshold adjustment of each ring.
[0092] In some embodiments of the present application, calculating the adaptive threshold of each ring by using the adaptive threshold adjustment strategy according to the original image of the annular workpiece and the mask images of each ring of the annular workpiece includes: traversing each ring of the annular workpiece according to the relative position relationship between the rings and the preset traversal order; when the current ring being traversed is the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring; when the current ring being traversed is not the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring, and the defect area image information of the previous ring.
[0093] Continuing to refer to Figure 3 , the relative position relationship defined between each ring in the embodiments of the present application mainly refers to the adjacent relationship between the rings. For example, Figure 3 the adjacent ring corresponding to Ring 2 in the figure is Ring 1. Combining the characteristics of the actual application scenario, such as the detection of the overflow glue defect of the data line, the embodiments of the present application also define the processing order when calculating the adaptive threshold of each ring as from the inside to the outside, that is, traversing Ring 1 and Ring 2 in sequence from the inside to the outside. The calculation of the adaptive threshold of the current ring depends on the processing result of the previous ring. For example, when the current ring being traversed is Ring 1, since Ring 1 is the first ring and there is no corresponding previous ring but only the next ring, and the adaptive threshold information of the next ring has not been determined yet, therefore, for Ring 1, the adaptive threshold of the current ring can be directly calculated according to the image information of the original image of the annular workpiece and the mask image of the current ring.
[0094] If the current ring being traversed is not the first ring, such as Ring 2, since there is the adaptive threshold information of the corresponding previous ring for Ring 2, and the adaptive threshold information of the previous ring is accurate information that has been determined, and then the defect area image information of the previous ring can be determined according to the adaptive threshold of the previous ring. Therefore, the segmentation threshold of the current ring can be adaptively adjusted by using the accurate defect area information of the previous ring, thereby improving the accuracy of the calculation of the segmentation threshold of the current ring.
[0095] By splitting the annular workpiece into multiple rings and processing them separately, and adaptively adjusting the calculation of its own segmentation threshold by combining the information of adjacent rings, the accuracy of the calculation of the segmentation threshold is improved, and further the accuracy of defect segmentation is improved.
[0096] In some embodiments of the present application, when the current ring being traversed is the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring includes: calculating the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring; calculating the adaptive threshold of the current ring by using the preset first mapping relationship according to the gray value of the current ring.
[0097] Combined with Figure 5, a schematic diagram of the calculation process of the adaptive threshold for each ring in the embodiments of the present application is provided. If the current ring is the first ring and there is no corresponding previous ring, the gray value of the current ring can be calculated first according to the original image of the annular workpiece and the mask image of the current ring. The methods for calculating the image gray value of the current ring include, but are not limited to, the following two:
[0098] 1) Determine the area of the current ring in the original image according to the mask image of the current ring, and calculate the average value of the overall pixels in this area as the gray value of the current ring;
[0099] 2) Determine the area of the current ring in the original image according to the mask image of the current ring, and use the relevant statistical values (average value, maximum value, etc.) of the non-defective area obtained by clustering the frequency distribution histogram of the pixels in this area as the gray value of the current ring.
[0100] After calculating the gray value of the current ring, the adaptive threshold of the current ring can be calculated based on the previously determined first mapping relationship. The first mapping relationship represents the mapping relationship between the gray value and the adaptive threshold, which can be calibrated offline in advance. When the gray value of the current ring is known, the corresponding adaptive threshold can be determined based on this first mapping relationship.
[0101] The embodiments of the present application can calculate the adaptive threshold of the ring by using the gray information of the annular area, and can perform defect detection according to the actual gray characteristics of the annular area, thereby improving the accuracy of defect detection.
[0102] In some embodiments of the present application, when the current ring traversed is not the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring, and the defect area image information of the previous ring includes: calculating the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring; calculating the first threshold of the current ring by using the preset first mapping relationship according to the gray value of the current ring; calculating the area of the defect area of the previous ring; calculating the second threshold of the current ring by using the preset second mapping relationship according to the area of the defect area of the previous ring; calculating the adaptive threshold of the current ring by using the preset third mapping relationship according to the first threshold and the second threshold of the current ring.
[0103] Continue to refer to Figure 5 , if the current ring traversed is not the first ring, that is, there is a corresponding previous ring. In this case, the calculation of the adaptive threshold of the current ring comes from two aspects. On the one hand, a first threshold is calculated based on the own information of the current ring, and on the other hand, a second threshold is calculated based on the information of the previous ring of the current ring. Finally, the final adaptive threshold of the current ring is determined by combining the first threshold and the second threshold.
[0104] For the first aspect above, the processing logic is the same as that of the foregoing embodiments. That is, the first threshold of the current ring is determined by using the calculated gray value of the current ring and a preset first mapping relationship. The specific implementation details can be referred to the description of the foregoing embodiments and will not be elaborated here.
[0105] For the second aspect above, since the accurate adaptive threshold of the previous ring corresponding to the current ring has been calculated, the defect area of the previous ring can be calculated based on the adaptive threshold of the previous ring and the mask image of the previous ring. Furthermore, the second threshold of the current ring can be calculated according to the defect area of the previous ring by using a preset second mapping relationship. The second mapping relationship here is a preset piecewise condition, and each piecewise condition is set with a corresponding fixed value. For example, when condition 1 is satisfied, the second threshold is assigned as a1, and when condition 2 is satisfied, the second threshold is assigned as a2. Therefore, the piecewise condition satisfied by the defect area of the previous ring can be determined, and then the corresponding second threshold value can be determined.
[0106] After calculating the above first threshold and second threshold, the first threshold can be adaptively adjusted by using the second threshold, so as to improve the accuracy of calculating the segmentation threshold of the current ring. The specific adaptive adjustment method can be to add the first threshold and the second threshold as the final threshold of the current ring.
[0107] By comprehensively considering the gray characteristics of the current ring and the defect information of the previous ring, the segmentation threshold of the current ring can be adaptively adjusted, thereby improving the accuracy of defect detection. The adaptive threshold can better adapt to the gray change and defect distribution characteristics between different rings of the annular workpiece, making the detection result more stable and reliable.
[0108] In some embodiments of the present application, the preset first mapping relationship is obtained in the following manner: obtaining multiple original images of the annular workpiece collected under preset calibration conditions; calculating the gray values of each ring in each original image according to the multiple original images of the annular workpiece; generating the preset first mapping relationship according to the gray values of each ring in each original image and the empirical values of the segmentation thresholds corresponding to each ring.
[0109] The first mapping relationship of the embodiments of the present application can be obtained by offline calibration in the following manner:
[0110] 1) Select a defective annular workpiece and place it at a position far from the camera, at a standard distance, and close to the camera to capture multiple images;
[0111] 2) Based on the above multiple images, calculate the gray value of each ring i on each image j
[0112] 3) Then, manually determine the appropriate segmentation threshold of each ring i on each image j according to experience
[0113] Among them, n is the number of loops in the image, and m is the number of images.
[0114] 4) More data can be obtained by repeating the above process by selecting more defective workpieces
[0115] 5) Based on the above steps, the first mapping relationship mapping 1 can be obtained by the polynomial fitting method, which represents a monotonically increasing function relationship. At least 4 sets of point pairs are required to obtain the four parameters a, b, c, and d. The final first mapping relationship mapping 1 For example, it can be expressed in the following form:
[0116] thld = mapping 1 (x) = ax 3 + bx 2 + cx + d. Of course, it should be noted that the above embodiments are only examples of constructing the first mapping relationship in this application. Specifically, how to determine the mapping relationship between the grayscale value and the adaptive threshold can be flexibly set by those skilled in the art according to actual needs.
[0117] By pre-calibrating the mapping relationship between the grayscale value and the segmentation threshold offline, the accuracy and efficiency of the adaptive threshold calculation are improved, and thus the accuracy and efficiency of the defect detection and segmentation of the annular workpiece are improved.
[0118] In some embodiments of the present application, the calculating the defect area of the previous loop includes: obtaining the mask image of the previous loop and the adaptive threshold of the previous loop; performing threshold segmentation on the original image of the annular workpiece according to the mask image of the previous loop and the adaptive threshold of the previous loop to obtain the defect area image of the previous loop; calculating the defect area of the previous loop according to the defect area image of the previous loop.
[0119] When calculating the defect area of the previous loop, the defect segmentation of the mask image of the previous loop can be first performed by using the adaptive threshold of the previous loop, so that the defect area image of the previous loop (i.e., the area with a value of 1) can be segmented, and then the defect area of the previous loop is further calculated. Here, the defect area of the previous loop can be obtained by counting the number of values of 1.
[0120] By calculating the defect area of the previous loop, a basis is provided for the subsequent adaptive adjustment of the first threshold, and thus the accuracy of the adaptive threshold calculation is improved.
[0121] In some embodiments of the present application, calculating the second threshold of the current ring according to the defect area of the previous ring by using a preset second mapping relationship includes: comparing the defect area of the previous ring with a first defect area threshold; if the defect area of the previous ring is less than the first defect area threshold, assigning a value greater than 0 to the second threshold of the current ring; otherwise, assigning 0 to the second threshold of the current ring.
[0122] The second mapping relationship defined in the embodiments of the present application can be understood as the corresponding relationship between the comparison result of the defect area and the first defect area threshold and the threshold value. When calculating the second threshold of the current ring, the defect area of the previous ring calculated in the foregoing embodiments can be first compared with the set first defect area threshold. If the defect area of the previous ring is less than the set first defect area, it indicates that there is probably no defect in the current ring. Therefore, to avoid the occurrence of the "overkill" situation, the second threshold can be set to a value greater than 0, so as to positively adjust the first threshold by using the second threshold, increase the final adaptive threshold of the current ring, avoid misdetecting non-defect areas under conditions such as overexposure as defect areas, and improve the defect detection accuracy.
[0123] Conversely, if the defect area of the previous ring is greater than or equal to the set first defect area, it indicates that the defect area of the previous ring is large, and then the probability of the current ring having a defect is also large. The threshold can be not adjusted, that is, the second threshold is set to 0. Then, the calculation of the adaptive threshold of the current ring still depends on the gray level information of the current ring itself. Thus, the adaptive adjustment of the segmentation threshold of the current ring is realized, and the defect segmentation accuracy is improved.
[0124] Based on the above embodiments, on the one hand, when there is low exposure and overexposure, the overall average gray level value on the ring will correspondingly decrease or increase. In the case of low exposure, if the threshold remains at a high value, the defect area will be smaller than the actual area, resulting in the situation of "missing detection"; similarly, in the case of overexposure, if the threshold remains at a low value, the defect area will be larger than the actual area, resulting in the situation of "overkill". Based on this, the first mapping relationship constructed in the present application can dynamically adjust the segmentation threshold by calculating the gray level values of each ring, correspondingly realizing the decrease and increase of the threshold, so as to accurately locate the defect area.
[0125] On the other hand, considering the correlation of the defect regions of adjacent rings, that is, if a ring has a defect region, then the adjacent ring is likely to have a defect region as well, and if a ring has no defect region, then the adjacent ring is likely not to have a defect region either. Based on this, the present application constructs a second mapping relationship. The second mapping relationship needs to calculate the area of the defect region. When the area of the defect region of the previous ring corresponding to a ring is small, it is likely that the current ring will not have a defect either, so the corresponding segmentation threshold can be set slightly higher to prevent the current ring from misdetecting normal regions as abnormal regions and reduce the possibility of "overkill".
[0126] By setting the first mapping relationship and the second mapping relationship, the adaptive adjustment of the segmentation threshold can be realized, the influence of factors such as illumination change can be reduced, and thus the defect segmentation accuracy is improved.
[0127] In some embodiments of the present application, the defect detection of the annular workpiece according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece, and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece includes: performing threshold segmentation on the original image of the annular workpiece according to the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain the defect region images of each ring; superimposing the defect region images of each ring to generate the defect region image of the annular workpiece; calculating the area of the defect region of the annular workpiece according to the defect region image of the annular workpiece; and determining the defect detection result of the annular workpiece according to the area of the defect region of the annular workpiece and the second defect region area threshold.
[0128] Combined Figure 6 , a schematic diagram of the defect detection process of an annular workpiece in an embodiment of the present application is provided. First, the mask images of each ring and the corresponding adaptive threshold are used to determine the defect regions in the mask images of each ring. Specifically, the pixel values in the mask image can be compared with the adaptive threshold. Pixels higher than the threshold are marked as defect pixels (for example, set to 1), and pixels lower than the threshold are marked as non-defect pixels (for example, set to 0). In this way, a corresponding defect region image will be generated for each annular region, which only contains defect pixels.
[0129] Then, the defect region images of all annular regions are superimposed. Considering that there will be partial overlap in the edge parts between the rings, the superimposing operation can be a logical "OR" operation, that is, as long as the mask image of one annular region is marked as a defect pixel at a certain position, then the final generated defect region image of the annular workpiece will also be marked as a defect pixel at this position. In this way, a mask image containing all the defect regions of the entire annular workpiece is obtained.
[0130] After that, morphological processing is performed on the defect area image of the entire annular workpiece to connect the defect areas adjacent to each ring, and the defect area of the complete annular workpiece is generated.
[0131] Finally, calculate the area of the defect area of the entire annular workpiece. Here, the area of the defect area of the entire annular workpiece can also be obtained by counting the number of values of 1 in the defect area of the entire annular workpiece. Compare the area of the defect area of the entire annular workpiece with the set second defect area threshold. If the detected area of the defect area of the annular workpiece is greater than the set second defect area threshold, it is determined that the annular workpiece is a defective product; otherwise, it is a qualified product. For the convenience of understanding the embodiments of the present application, as Figure 7 shown, a schematic diagram of the defect detection result of an annular workpiece in the embodiments of the present application is provided.
[0132] By combining the mask images of each ring and the adaptive threshold to determine the defect area, the defect area on the annular workpiece can be more accurately identified, reducing the possibility of over-inspection and missed inspection, and improving the accuracy of defect detection.
[0133] The embodiments of the present application also provide a defect detection device 800 for an annular workpiece. As Figure 8 shown, a schematic structural diagram of a defect detection device for an annular workpiece in the embodiments of the present application is provided. The defect detection device 800 for the annular workpiece includes: an acquisition unit 810, a generation unit 820, an adaptive threshold adjustment unit 830, and a defect detection unit 840, where:
[0134] The acquisition unit 810 is configured to acquire the original image of the annular workpiece;
[0135] The generation unit 820 is configured to generate the mask images of each ring of the annular workpiece according to the original image of the annular workpiece by using a preset image processing strategy;
[0136] The adaptive threshold adjustment unit 830 is configured to calculate the adaptive threshold of each ring according to the original image of the annular workpiece and the mask images of each ring of the annular workpiece by using an adaptive threshold adjustment strategy, and the adaptive threshold adjustment strategy is used to calculate the adaptive threshold of each ring based on the own information of each ring and the corresponding adjacent ring information;
[0137] The defect detection unit 840 is configured to perform defect detection according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece, and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece.
[0138] In some embodiments of the present application, the generating unit 820 is specifically configured to: preprocess the original image of the annular workpiece by using an image preprocessing strategy and generate a global mask image of the annular workpiece; and process the global mask image of the annular workpiece by using a distance transformation method based on the designed thickness of each ring in the annular workpiece to generate a mask image of each ring of the annular workpiece.
[0139] In some embodiments of the present application, the adaptive threshold adjustment unit 830 is specifically configured to: traverse each ring of the annular workpiece according to the relative position relationship between the rings and a preset traversal order; when the current ring being traversed is the first ring, calculate the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring; and when the current ring being traversed is not the first ring, calculate the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring, and the defect region image information of the previous ring.
[0140] In some embodiments of the present application, the adaptive threshold adjustment unit 830 is specifically configured to: calculate the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring; and calculate the adaptive threshold of the current ring by using a preset first mapping relationship according to the gray value of the current ring.
[0141] In some embodiments of the present application, the adaptive threshold adjustment unit 830 is specifically configured to: calculate the gray value of the current ring according to the original image of the annular workpiece and the mask image of the current ring; calculate a first threshold of the current ring by using a preset first mapping relationship according to the gray value of the current ring; calculate the defect region area of the previous ring; calculate a second threshold of the current ring by using a preset second mapping relationship according to the defect region area of the previous ring; and calculate the adaptive threshold of the current ring by using a preset third mapping relationship according to the first threshold and the second threshold of the current ring.
[0142] In some embodiments of the present application, the preset first mapping relationship is obtained by the following method: acquiring multiple original images of the annular workpiece collected under preset calibration conditions; calculating the gray value of each ring in each original image according to the multiple original images of the annular workpiece; and generating the preset first mapping relationship according to the gray value of each ring in each original image and the empirical value of the segmentation threshold corresponding to each ring.
[0143] In some embodiments of the present application, the adaptive threshold adjustment unit 830 is specifically configured to: acquire the mask image of the previous ring and the adaptive threshold of the previous ring; perform threshold segmentation on the original image of the annular workpiece according to the mask image of the previous ring and the adaptive threshold of the previous ring to obtain the defect region image of the previous ring; and calculate the defect region area of the previous ring according to the defect region image of the previous ring.
[0144] In some embodiments of the present application, the adaptive threshold adjustment unit 830 is specifically configured to: compare the defect area of the previous ring with a first defect area threshold; if the defect area of the previous ring is less than the first defect area threshold, assign a value greater than 0 to the second threshold of the current ring; otherwise, assign a value of 0 to the second threshold of the current ring.
[0145] In some embodiments of the present application, the defect detection unit 840 is specifically configured to: perform threshold segmentation on the original image of the annular workpiece according to the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain defect area images of each ring; superimpose the defect area images of each ring to generate a defect area image of the annular workpiece; calculate the defect area of the annular workpiece according to the defect area image of the annular workpiece; and determine the defect detection result of the annular workpiece according to the defect area of the annular workpiece and a second defect area threshold.
[0146] It can be understood that the above-mentioned defect detection device for the annular workpiece can implement each step of the defect detection method for the annular workpiece provided in the foregoing embodiments. The relevant explanations regarding the defect detection method for the annular workpiece are applicable to the defect detection device for the annular workpiece, and will not be elaborated herein.
[0147] Figure 9 is a schematic structural diagram of a device in an embodiment of the present application. As Figure 9 shown, the device includes one or more processors (or processing units), and may further include one or more memories coupled to the processor, and may further include a communication module coupled to the processor.
[0148] The communication module can be used to communicate with other devices or apparatuses, such as sending or receiving data and / or signals. The communication module may have at least one communication module for communication. The communication module may include any interface necessary for communicating with other devices. Exemplarily, the communication module may be a transceiver, a circuit, a bus, a module, or other types of communication modules.
[0149] The processor may include, but is not limited to, at least one of the following: a general-purpose computer, a special-purpose computer, a microcontroller, a digital signal controller (Digital Signal Processor, DSP), or one or more in a multi-core controller architecture based on a controller. The device may have multiple processors, such as an application-specific integrated circuit chip, which is subordinate to a clock synchronized with the main processor in time.
[0150] The memory may include one or more non-volatile memories and one or more volatile memories. Examples of non-volatile memories include, but are not limited to, at least one of the following: Read-Only-Memory (ROM), Electrically Programmable Read-Only-Memory (EPROM), flash memory, hard disk, Compact Disc (CD), Digital Video Disk (DVD), or other magnetic storage and / or optical storage. Examples of volatile memories include, but are not limited to, at least one of the following: Random Access Memory (RAM), or other volatile memories that do not persist during a power outage duration.
[0151] The computer program includes computer-executable instructions executed by an associated processor. The program can be stored in the ROM. The processor can perform any suitable actions and processing by loading the program into the RAM.
[0152] Possible implementations of the present application can be realized by means of a program, such that the communication device can perform any process discussed in the foregoing embodiments. Possible implementations of the present application can also be realized by hardware or by a combination of software and hardware.
[0153] In some embodiments, the program can be tangibly embodied in a computer-readable storage medium, which can be included in the device (such as in the memory) or other storage devices accessible by the device. The program can be loaded from the computer-readable storage medium into the RAM for execution. The computer-readable storage medium can include any type of tangible non-volatile memory, such as ROM, EPROM, flash memory, hard disk, CD, DVD, etc.
[0154] The embodiments of the present application also provide a computer-readable storage medium, on which computer instructions or program codes are stored. When the processor runs the instructions or the program codes, the processor is caused to execute the methods and functions involved in any of the above embodiments. The computer-readable medium can be any tangible medium that contains or stores a program for or related to an instruction execution system, apparatus, or device. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any suitable combination thereof. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that incorporates one or more available media. More specific examples of the computer-readable storage medium include electrical connections with one or more wires, magnetic media (such as disks, floppy disks, hard disks, magnetic tapes, magnetic storage devices), optical media (such as optical storage devices, DVDs), semiconductor media (such as solid-state drives), random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), or any suitable combination thereof, etc.
[0155] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The embodiments of the present application also provide at least one computer program product tangibly stored on a non-transitory computer-readable storage medium. The computer program product includes one or more computer-executable instructions, such as instructions included in program modules, which are executed in a device on a target real or virtual processor to execute the processes, methods, and functions involved in any of the above embodiments. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, fiber optic, digital subscriber line) or wirelessly (such as infrared, wireless, microwave, etc.).
[0156] The embodiments of the present application also propose a computer program product, including a computer program or instruction. When the computer program or instruction runs on a computer, it enables the computer to execute the processes, methods, and functions in the above embodiments. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. In various embodiments, the functions of program modules can be combined or divided as needed. The machine-executable instructions for program modules can be executed within local or distributed devices. In a distributed device, program modules can be located in local and remote storage media.
[0157] Generally, the various embodiments of the present application can be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects can be implemented in hardware, while other aspects can be implemented in firmware or software, which can be executed by a controller, a microprocessor, or other computing devices. Although the various aspects of the embodiments of the present disclosure are shown and described as block diagrams, flowcharts, or using some other graphical representation, it should be understood that the blocks, devices, systems, technologies, or methods described herein can be implemented as, by way of non-limiting example, hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or a controller or other computing devices, or some combination thereof.
[0158] It should be noted that although the embodiments of the present application are described above in conjunction with the accompanying drawings respectively, the above embodiments are not independent of each other, and they can also be combined to obtain other embodiments. The manners, situations, categories, and the division of embodiments in the embodiments of the present application are only for the convenience of description and should not constitute a special limitation. The features in various manners, categories, situations, and embodiments can be combined with each other under logical conditions. The various embodiments of the present application can be combined arbitrarily to achieve different technical effects. The embodiments of the present application will no longer list various combinations.
[0159] In addition, although the operations of the methods of the present disclosure are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flowchart can be changed in the order of execution. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.
[0160] It should also be noted that the term "comprise", "include" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the phrase "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising said element.
[0161] The above are only examples of the present application and are not intended to limit the present application. For those skilled in the art, various modifications and changes can be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A defect detection method for an annular workpiece, characterized in that: The defect detection method of the annular workpiece comprises: Acquire the original image of the annular workpiece; Generate each ring mask image of the ring-shaped workpiece by using a preset image processing strategy according to the original image of the ring-shaped workpiece; According to the original image of the annular workpiece and the mask images of each ring of the annular workpiece, an adaptive threshold value of each ring is calculated using an adaptive threshold value adjustment strategy, wherein the adaptive threshold value adjustment strategy is used to calculate the adaptive threshold value of each ring based on the self information of each ring and the corresponding adjacent ring information; Defect detection is performed according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain a defect detection result of the annular workpiece.
2. The defect detection method for annular workpiece according to claim 1, characterized in that: The step of generating each ring mask image of the ring-shaped workpiece by using a preset image processing strategy according to the original image of the ring-shaped workpiece comprises: Preprocessing the original image of the annular workpiece by using an image preprocessing strategy and generating a global mask image of the annular workpiece; Based on the designed thickness of each ring in the annular workpiece, the global mask image of the annular workpiece is processed by using a distance transformation method to generate mask images of each ring of the annular workpiece.
3. The defect detection method for annular workpiece according to claim 1, characterized in that: The step of calculating the adaptive threshold of each ring by using an adaptive threshold adjustment strategy according to the original image of the annular workpiece and the mask images of each ring of the annular workpiece includes: Traversing each ring of the annular workpiece according to the relative position relationship between the rings and a preset traversal order; When the current ring being traversed is the first ring, calculating an adaptive threshold of the current ring according to the original image of the ring-shaped workpiece and the mask image of the current ring; When the current ring being traversed is not the first ring, the adaptive threshold of the current ring is calculated according to the original image of the ring-shaped workpiece, the mask image of the current ring and the defective area image information of the previous ring.
4. The defect detection method for annular workpiece according to claim 3, characterized in that: In the case where the current ring being traversed is the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece and the mask image of the current ring includes: Calculating the grayscale value of the current ring according to the original image of the ring-shaped workpiece and the mask image of the current ring; According to the grayscale value of the current ring, an adaptive threshold of the current ring is calculated using a preset first mapping relationship.
5. The defect detection method for annular workpiece according to claim 3, characterized in that: When the current ring being traversed is not the first ring, calculating the adaptive threshold of the current ring according to the original image of the annular workpiece, the mask image of the current ring and the image information of the defective area of the previous ring includes: Calculating the grayscale value of the current ring according to the original image of the ring-shaped workpiece and the mask image of the current ring; Calculate a first threshold of the current ring using a preset first mapping relationship according to the gray value of the current ring; Calculate the defect area of the previous ring; Calculating a second threshold of the current ring using a preset second mapping relationship according to the defect area of the previous ring; According to the first threshold of the current ring and the second threshold of the current ring, an adaptive threshold of the current ring is calculated using a preset third mapping relationship.
6. The defect detection method for annular workpiece according to claim 4 or 5, characterized in that: The preset first mapping relationship is obtained in the following manner: Acquire multiple original images of the annular workpiece collected under preset calibration conditions; Calculating the grayscale value of each ring in each original image according to the multiple original images of the annular workpiece; The preset first mapping relationship is generated according to the grayscale value of each ring in each original image and the segmentation threshold empirical value corresponding to each ring.
7. The defect detection method for annular workpiece according to claim 5, characterized in that: The calculation of the defect area of the previous ring includes: Obtain the mask image of the previous ring and the adaptive threshold of the previous ring; Performing threshold segmentation on the original image of the annular workpiece according to the mask image of the previous ring and the adaptive threshold of the previous ring to obtain a defective area image of the previous ring; The area of the defective region of the previous ring is calculated based on the defective region image of the previous ring.
8. The defect detection method for annular workpiece according to claim 5, characterized in that: Calculating the second threshold of the current ring by using a preset second mapping relationship according to the defect area of the previous ring includes: Comparing the defect region area of the previous ring with a first defect region area threshold; If the defect area of the previous ring is smaller than the first defect area threshold, assigning the second threshold of the current ring a value greater than 0; Otherwise, the second threshold of the current ring is assigned to 0.
9. The defect detection method for annular workpiece according to claim 1, characterized in that: The defect detection is performed according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece, which includes: Performing threshold segmentation on the original image of the annular workpiece according to the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain a defect area image of each ring; Superimposing the defect area images of each ring to generate a defect area image of the annular workpiece; Calculating the defect area of the annular workpiece according to the defect area image of the annular workpiece; The defect detection result of the annular workpiece is determined according to the defect region area of the annular workpiece and a second defect region area threshold.
10. A defect detection device for an annular workpiece, characterized in that: The defect detection device for the annular workpiece comprises: An acquisition unit, used for acquiring an original image of the annular workpiece; A generating unit, configured to generate each ring mask image of the ring-shaped workpiece according to the original image of the ring-shaped workpiece by using a preset image processing strategy; An adaptive threshold adjustment unit, configured to calculate an adaptive threshold of each ring according to the original image of the annular workpiece and the mask images of each ring of the annular workpiece using an adaptive threshold adjustment strategy, wherein the adaptive threshold adjustment strategy is configured to calculate an adaptive threshold of each ring based on its own information and corresponding adjacent ring information; The defect detection unit is used to perform defect detection according to the original image of the annular workpiece, the mask images of each ring of the annular workpiece and the adaptive threshold of each ring to obtain the defect detection result of the annular workpiece.
11. A device comprising: processor; and a memory arranged to store computer executable instructions, wherein when the executable instructions are executed, the processor executes the defect detection method for an annular workpiece according to any one of claims 1 to 9.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the defect detection method for an annular workpiece according to any one of claims 1 to 9 is implemented.