A visual detection-based enameled wire skin defect detection method

CN122391099APending Publication Date: 2026-07-14湖北德重精线有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
湖北德重精线有限公司
Filing Date
2026-04-07
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing technologies for detecting defects in the outer sheath of enameled wires suffer from problems such as insufficient detection accuracy, poor environmental robustness, poor adaptability to small/scarce defect samples, and insufficient efficiency in processing complex curved surfaces.

Method used

A multi-source imaging system combined with a cylindrical coordinate transformation algorithm is used to unfold the image. Multi-level features are extracted using a Siamese neural network, and a fused feature vector is generated by weighting the channel and spatial attention. Euclidean distance is calculated to generate an initial defect response map. An adaptive dual-threshold decision logic is constructed by combining grayscale texture entropy and directional anisotropy index. An improved K-Means algorithm is used for defect clustering and classification.

Benefits of technology

It achieves high-precision and robust defect detection, can identify minor flaws and defects in complex backgrounds, provides detailed defect information, improves the practicality and intelligence of the detection system, reduces manual intervention, and realizes online real-time detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391099A_ABST
    Figure CN122391099A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of industrial machine vision detection, and discloses a varnished wire skin defect detection method based on visual detection, which comprises the following steps: acquiring a varnished wire surface original image through a multi-light source imaging system, and expanding the original image into a two-dimensional plane expansion graph by using a cylindrical coordinate transformation algorithm; constructing a twin feature extraction network; inputting the two-dimensional plane expansion graph into a first branch of the twin neural network, inputting a standard defect-free template graph into a second branch of the twin neural network, and respectively outputting multi-level feature graphs; performing channel attention weighting and spatial attention weighting on the output multi-level feature graphs to generate a fusion feature vector; calculating the Euclidean distance between the features of a to-be-detected graph and the features of a standard template graph in the fusion feature vector to generate an initial defect response graph; performing logical judgment and adaptive threshold decision; and obtaining a final defect response graph and performing defect output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial machine vision inspection technology, specifically a method for detecting surface defects in enameled wire based on vision inspection. Background Technology

[0002] Enameled wire, as a key insulating material in power equipment, motors, and electromagnetic devices, directly affects the electrical performance, safety, and service life of these products due to the integrity of its outer sheath. During production, the surface of enameled wire may develop various defects such as scratches, pits, varnish nodules, pinholes, and uneven varnish film due to factors such as process fluctuations, environmental impurities, and equipment wear. Therefore, high-speed and precise online defect detection of enameled wire on the production line is a core element in ensuring product quality.

[0003] Existing technologies for detecting defects in the sheath of enameled wire can be mainly classified into the following categories, but all of them have certain limitations: Traditional machine vision methods: Early and some existing systems mostly used traditional image processing algorithms based on gray-level thresholding, edge detection, and texture analysis (such as gray-level co-occurrence matrix). These methods are usually sensitive to changes in illumination and have poor robustness. Because enameled wire surfaces have natural textures and reflective properties, and may contain interference such as oil stains, fixed thresholds or simple texture features are difficult to reliably distinguish between the background and real defects, resulting in high false alarm and false negative rates, especially with a severely inadequate ability to detect low-contrast, minute defects.

[0004] Detection methods based on fixed thresholds or simple dynamic thresholds: Some improved methods attempt to dynamically set the segmentation threshold by calculating local gray-level statistics (such as mean and variance). However, these methods have weak semantic understanding of defects. When the gray-level difference between the defect and the background is not significant, or when the background itself has complex texture fluctuations, simple statistics cannot effectively characterize the essential features of the defect. This leads to the easy misjudgment of normal textures as defects in complex background areas, while slight anomalies may be missed in smooth areas.

[0005] Approaches based on general deep learning models: With the development of deep learning, some studies have attempted to use convolutional neural networks (CNNs) for defect classification or semantic segmentation. However, these methods typically rely heavily on large-scale, high-quality, and labeled defect samples. In real-world industrial scenarios, collecting a sufficient number of samples covering all defect types is extremely costly, and while "defect-free" samples are readily available, "defective" samples are scarce, leading to difficulties in model training and a high risk of overfitting. Furthermore, general models do not directly model "standards" and "differences," potentially overemphasizing background changes in the image that are unrelated to defects.

[0006] Regarding imaging and adaptability to specific morphologies: Enamelled wire is cylindrical, and direct imaging will cause image distortion due to the curved surface, affecting the judgment of the true shape and size of defects. Although there are methods for acquiring images using line scanning or specific optical systems, how to efficiently and without distortion convert cylindrical images into planar images that are easy to analyze, and achieve accurate detection on the unfolded planar diagram, still requires the support of better algorithms.

[0007] At the defect analysis and decision-making level: most existing methods stop at a binary judgment of "whether there is a defect or not," lacking the ability to perform refined clustering, analysis, and automatic classification of detected suspicious areas. They cannot distinguish defect types (such as pinholes, linear scratches, and blocky paint nodules), thus failing to provide in-depth information to guide process improvement, limiting the system's practical value. Furthermore, the decision-making process often uses fixed parameters, unable to adapt to the slow changes in surface characteristics caused by production line speed and material batch changes.

[0008] In summary, existing technologies have significant shortcomings in terms of detection accuracy, environmental robustness, adaptability to small / sparse defect samples, and processing efficiency for complex curved surfaces. Therefore, there is an urgent need for an intelligent detection method for enameled wire skin defects that can overcome these limitations, achieve high accuracy, high robustness, adaptability, and provide refined defect information. This invention is proposed against this backdrop. Summary of the Invention

[0009] The purpose of this invention is to address the significant shortcomings of existing technologies in terms of detection accuracy, environmental robustness, adaptability to small / scarce defect samples, and processing efficiency for complex curved surfaces. Therefore, this invention proposes a vision-based method for detecting defects in the outer sheath of enameled wire.

[0010] The technical solution of the present invention to solve the above-mentioned technical problems is as follows: A visual inspection-based method for detecting surface defects in enameled wire includes the following steps: S1: Obtain the original image of the enameled wire surface through a multi-source imaging system, and use a cylindrical coordinate transformation algorithm to unfold the original image into a two-dimensional planar unfolded image; S2: Construct a Siamese feature extraction network, input the two-dimensional planar unfolded image into the first branch of the Siamese neural network, and input the standard defect-free template image into the second branch of the Siamese neural network, and output multi-level feature maps respectively; S3: Perform channel attention weighting and spatial attention weighting on the multi-level feature map output in step S2 to generate a fused feature vector; S4: Calculate the Euclidean distance between the features of the image to be tested and the features of the standard template image in the fused feature vector, and generate the initial defect response map; S5: Logical Judgment and Adaptive Threshold Decision-Making S5.1: Divide the two-dimensional planar unfolded image into multi-scale non-overlapping local windows and calculate the grayscale texture entropy of each local window; S5.2: Derive the anisotropy index using the grayscale texture entropy of each local window. ,based on Construction complexity index ; S5.3: Construct a dual threshold comparator and set the trigger threshold. and release threshold ; S5.4: Execution logic judgment: ; First, determine whether equation (1) is true. If it is, it is determined to be a defect point; otherwise, continue to determine whether equation (2) is true. If it is, it is determined to be the background; otherwise, keep the state of the previous frame unchanged. This represents the distance value of a pixel in the initial defect response map. S6: Defect output.

[0011] Based on the above technical solution, the present invention can be further improved as follows.

[0012] Preferably, the directional anisotropy index The calculation formula is as follows: ; in, This is the window index, representing the number of the local window currently being processed. , To expand the total number of windows in the diagram, For the first The maximum value among all directional entropy values ​​in a local window. For the first The minimum value among all directional entropy values ​​in a local window. For the first The average of all directional entropy values ​​in a local window To prevent the smoothing coefficient from being divided by zero, .

[0013] Preferably, a frequency domain transformation is performed on each window to extract the proportion of high-frequency energy. ,based on and Construction complexity index The complexity index Replace with the following formula for calculation: ; in, For the first Multidirectional average entropy of a local window The directional enhancement coefficient, This is the noise suppression coefficient. Indicator functions, For the first The local window is ultimately used to determine the directional anisotropy index. Whether the dynamic threshold is significant.

[0014] Preferably, the first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? A dynamic self-calibration method based on background feedback statistics and local texture complexity modulation is used to obtain: Using the memory map of the defect state from the previous frame to filter out a queue of clean background samples, calculate their percentile statistical baseline to establish a basic statistical threshold. and background coefficient of variation , and combined with the first Multidirectional average entropy of a local window With background average entropy The deviation on the first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? Local modulation is performed, and finally smoothed by exponential weighted moving average to generate a window-level dynamic threshold that adapts to the natural fluctuations and local complexity differences of the material surface. The local modulation formula is: ; in, Based on the basic statistical threshold, This is the stability gain coefficient. The background coefficient of variation, For the complexity modulation coefficients, A nonnegative truncation function is defined only if the first... Multidirectional average entropy of a local window Higher than the background average entropy The threshold is increased only when the background level is low; if the background level is low, the threshold is not decreased to ensure the lower limit of detection sensitivity.

[0015] Preferably, the exponentially weighted moving average algorithm is used to analyze the current frame. The global complexity mean is smoothed to generate a smoothed dynamic threshold base value. The process is as follows: Calculate the current frame Global complexity average Update the smoothed complex baseline , Finally, the smoothed dynamic threshold base value is generated. ; in, To establish a smooth complexity baseline for the current frame, To smooth out the complexity of the previous frame, For smoothing coefficients, As the initial base threshold, This is the complexity gain coefficient.

[0016] Preferably, the trigger threshold and release threshold Based on the smoothed dynamic threshold base value set up: Trigger threshold ; Release threshold ; in, This represents the dynamic hysteresis bandwidth coefficient.

[0017] Preferably, the hysteresis bandwidth coefficient Combined with background variation coefficient The calculation process is as follows: ; in, The basic hysteresis coefficient, For background stability gain, The background coefficient of variation, For local toggle gain, This represents the standard deviation of the entropy within the current window's neighborhood.

[0018] Preferably, the S6 defect output also includes a classification process, which is as follows: First, extract pixels from the final defect state map to construct a three-dimensional feature vector containing spatial coordinates and gray values. Adaptively determine the number of cluster centers K using the spatial density peak method. Then, execute the improved K-Means algorithm, which introduces maximum spatial distance constraints and weighted Euclidean distance, to aggregate spatially adjacent and feature-similar defect points into independent defect clusters. Subsequently, calculate the area, aspect ratio of the bounding rectangle, and gray mean of each cluster. Finally, based on the area threshold, aspect ratio threshold, and the difference logic with the background gray mean, classify the defect clusters into the first defect cluster, the second defect cluster, and the third defect cluster.

[0019] Preferably, in step S6, the judgment logic for the defect cluster classification is as follows: like and If so, it is classified as the first defect cluster; like and If so, it is classified as the second defect cluster; like If so, it is classified as the third defect cluster; If none of the above conditions are met, it is classified as an "unknown defect" and will be manually reviewed. in, The area of ​​the cluster. The aspect ratio of the circumscribed rectangle is... Area threshold The gray mean of the cluster. The average gray level of the background. The grayscale difference threshold. , , These are the first aspect ratio coefficient, the second aspect ratio coefficient, and the third aspect ratio coefficient, respectively.

[0020] Compared with the prior art, the technical solution of this application has the following beneficial technical effects: 1. This invention uses a twin neural network to extract multi-level features and combines channel and spatial attention mechanisms for weighted fusion, enabling the network to focus on key feature regions related to defects and enhancing feature expressiveness.

[0021] 2. This invention generates a defect response by calculating the Euclidean distance between the image to be tested and the standard template image in the deep feature space. Compared with traditional methods based on grayscale or simple texture differences, it is more sensitive to semantic-level changes in defects and can effectively identify minute flaws that are difficult to distinguish with the naked eye and defects with low contrast with the background.

[0022] 3. This invention introduces an adaptive dual-threshold decision logic based on local texture complexity analysis (grayscale texture entropy, directional anisotropy index). This mechanism can dynamically adjust the judgment threshold according to the background complexity of different regions of the image, avoiding the problem of over-detection (false alarm) and under-detection in complex regions by a globally fixed threshold. The threshold is dynamically calibrated through "background feedback statistics" and historical frame information is smoothed using exponentially weighted moving average. This enables the system to learn and adapt to the inherent natural texture fluctuations, lighting gradients and slight contamination of the enameled wire surface, effectively distinguishing background noise from real defects and significantly reducing the false alarm rate.

[0023] 4. This invention employs an improved K-Means algorithm with maximum spatial distance constraints to cluster defect points, ensuring that physically continuous defects are correctly aggregated into a whole, avoiding over-segmentation, and providing accurate defect objects for subsequent analysis. Based on the area, shape (aspect ratio), and grayscale characteristics of the clustered defect clusters, automatic classification is performed according to logical rules (such as dividing them into first, second, and third defect clusters). This goes beyond simple "defect presence or absence" judgment and can directly provide key information for production process adjustment and quality root cause analysis, improving the practicality and intelligence level of the detection system.

[0024] 5. This invention employs a dual-threshold (hysteresis) comparator composed of a trigger threshold and a release threshold, and dynamically calculates the hysteresis bandwidth. This effectively filters out instantaneous jitter in the defect response caused by noise, ensuring stable and reliable determination of the defect status and resulting in cleaner output.

[0025] 6. This invention forms a complete and automated intelligent detection closed loop from image acquisition, preprocessing (cylindrical unfolding), feature extraction, similarity calculation, adaptive decision-making to defect classification. It reduces manual intervention and, while ensuring high accuracy, facilitates online real-time detection and improves production efficiency. Attached Figure Description

[0026] Figure 1 This is a schematic diagram of the process of the present invention; Figure 2 This is a schematic diagram of the logic judgment in S5.4 of the present invention. Detailed Implementation

[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0028] A visual inspection-based method for detecting surface defects in enameled wire includes the following steps: S1: Image acquisition and preprocessing: The original image of the enameled wire surface is acquired through a multi-source imaging system, and the original image is unfolded into a two-dimensional planar unfolded image using a cylindrical coordinate transformation algorithm; S2: Construct a Siamese feature extraction network, input the two-dimensional planar unfolded image into the first branch of the Siamese neural network, and input the standard defect-free template image into the second branch of the Siamese neural network, and output multi-level feature maps respectively; S3: Multi-scale attention fusion: Channel attention weighting and spatial attention weighting are applied to the multi-level feature maps output from step S2 to generate a fused feature vector; S4: Difference metric calculation: Calculate the Euclidean distance between the features of the image to be tested and the features of the standard template image in the fused feature vector, and generate the initial defect response map; S5: Logical Judgment and Adaptive Threshold Decision-Making S5.1: Divide the two-dimensional planar unfolded image into multi-scale non-overlapping local windows and calculate the grayscale texture entropy of each local window; S5.2: Derive the anisotropy index using the grayscale texture entropy of each local window. ,based on Construction complexity index ; S5.3: Construct a dual threshold comparator and set the trigger threshold. and release threshold ; S5.4: Execution logic judgment: ; First, determine whether equation (1) is true. If it is, it is determined to be a defect point; otherwise, continue to determine whether equation (2) is true. If it is, it is determined to be the background; otherwise, keep the state of the previous frame unchanged. This represents the distance value of a pixel in the initial defect response map. S6: Obtain the final defect response map and output the defect.

[0029] The multi-source imaging system described in step S1 includes a coaxial light source and a low-angle ring light source; the coaxial light source is used to illuminate the surface of the enameled wire to detect color abnormalities and paint peeling defects; the low-angle ring light source is used to generate a cutoff line between light and dark to detect scratches and protrusion defects. The cylindrical coordinate transformation algorithm specifically involves: identifying the edge contour of the enameled wire in the image, fitting the central axis, and converting the pixels in polar coordinates. Mapped to Cartesian coordinate system , where the x-axis corresponds to the axial length of the enameled wire and the y-axis corresponds to the circumferential angle of the enameled wire.

[0030] In step S2, the Siamese neural network uses an improved ResNet-18 as the backbone network; the multi-level feature maps include shallow edge feature maps and deep semantic feature maps; during the training phase, the network is constrained by a triple loss function, so that the feature distance between the unfolded map and the template map of the same sample is minimized, and the feature distance between different samples is maximized.

[0031] In step S3, the channel attention weighting uses an SE-Block structure to compress feature channels and highlight defect-related channel responses; the spatial attention weighting uses the spatial attention module in CBAM to suppress background noise regions and enhance the weights of potential defect regions; the fusion formula is: ; in, and The weight coefficients are generated by the attention mechanism. This indicates element-wise multiplication.

[0032] When calculating the grayscale texture entropy of each local window, the directional anisotropy index is derived. : ; in, This is the window index, representing the number of the local window currently being processed. , To expand the total number of windows in the diagram, For the first The maximum value among all directional entropy values ​​in a local window. For the first The minimum value among all directional entropy values ​​in a local window. For the first The average of all directional entropy values ​​in a local window To prevent the smoothing coefficient from being divided by zero, .

[0033] Perform frequency domain transformation on each window to extract the proportion of high-frequency energy. ,based on and Construction complexity index : ; in, For the first Multidirectional average entropy of a local window The directional enhancement coefficient, This is the noise suppression coefficient. Indicator functions, For the first The local window is ultimately used to determine the directional anisotropy index. The significance of the dynamic threshold is as follows: when a directional feature (suspected scratch) is detected, the complexity index increases to alert the system that the feature in that area is significant; when a high-frequency and non-directional feature (suspected noise) is detected, the complexity index is attenuated to prevent the threshold from being incorrectly raised by noise.

[0034] The first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? A dynamic self-calibration method based on background feedback statistics and local texture complexity modulation is used to obtain: Using the memory map of the defect state from the previous frame to filter out a queue of clean background samples, calculate their percentile statistical baseline to establish a basic statistical threshold. and background coefficient of variation , and combined with the first Multidirectional average entropy of a local window With background average entropy The deviation on the first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? Local modulation is performed, and finally smoothed by exponential weighted moving average to generate a window-level dynamic threshold that adapts to the natural fluctuations and local complexity differences of the material surface. The local modulation formula is: ; in, Based on the basic statistical threshold, This is the stability gain coefficient. The background coefficient of variation, For the complexity modulation coefficients, A nonnegative truncation function is defined only if the first... Multidirectional average entropy of a local window Higher than the background average entropy The threshold is increased only when the background level is low; if the background level is low, the threshold is not decreased to ensure the lower limit of detection sensitivity.

[0035] Using the exponentially weighted moving average algorithm to analyze the current frame The global complexity mean is smoothed to generate a smoothed dynamic threshold base value. The process is as follows: Calculate the current frame Global complexity average Update the smoothed complex baseline Finally, the smoothed dynamic threshold base value is generated. ; in, To establish a smooth complexity baseline for the current frame, To smooth out the complexity of the previous frame, For smoothing coefficients, As the initial base threshold, This is the complexity gain coefficient.

[0036] The trigger threshold and release threshold Based on the smoothed dynamic threshold base value set up: Trigger threshold ; Release threshold ; in, This represents the dynamic hysteresis bandwidth coefficient.

[0037] The hysteresis bandwidth coefficient Combined with background variation coefficient : ; in, The basic hysteresis coefficient, For background stability gain, The background coefficient of variation, For local toggle gain, This represents the standard deviation of the entropy within the current window's neighborhood.

[0038] The classification process first extracts pixels from the final defect state image to construct a three-dimensional feature vector containing spatial coordinates and grayscale values. The spatial density peak method is used to adaptively determine the number of cluster centers K. An improved K-Means algorithm, which introduces maximum spatial distance constraints and weighted Euclidean distance, is executed to aggregate spatially adjacent and feature-similar defect points into independent defect clusters. Then, the area, aspect ratio of the bounding rectangle, and grayscale mean of each cluster are calculated. Finally, based on the area threshold, aspect ratio threshold, and the difference logic with the background grayscale mean, the defect clusters are classified into the first defect cluster, the second defect cluster, and the third defect cluster.

[0039] The improved K-Means algorithm is implemented, which divides the three-dimensional feature vector into K clusters. The distance metric is weighted Euclidean distance. The spatial constraint is that if the spatial distance from a point to the nearest center exceeds the maximum defect radius in the allocation step, the point is not assigned to any cluster (considered as isolated noise) or is marked as a seed for a new cluster. The iterative update involves repeating the allocation and center update steps until the cluster centers converge or the maximum number of iterations is reached.

[0040] In step S6, the judgment logic for the defect cluster classification is as follows: The judgment logic for classifying defect clusters is as follows: like and If so, it is classified as the first defect cluster; like and If so, it is classified as the second defect cluster; like If so, it is classified as the third defect cluster; If none of the above conditions are met, it is classified as an "unknown defect" and will be manually reviewed. in, The area of ​​the cluster. The aspect ratio of the circumscribed rectangle is... Area threshold The gray mean of the cluster. The average gray level of the background. The grayscale difference threshold. , , These are the first aspect ratio coefficient, the second aspect ratio coefficient, and the third aspect ratio coefficient, respectively, and the area threshold. With grayscale difference threshold All parameters are obtained through an offline statistical calibration process: a historical set of defect-free background samples is collected, the upper percentile of the area distribution of the connected domain of the background noise is used as the area threshold benchmark, the standard deviation of the background grayscale fluctuation is calculated and multiplied by the confidence coefficient as the grayscale difference threshold benchmark, and then the standard defect sample library is used for actual measurement verification and fine-tuning to ensure that the threshold can both cover the minimum acceptable defect features and effectively suppress background noise. Finally, the calibrated fixed parameters are stored in the system configuration library.

[0041] The first defect cluster, the second defect cluster, and the third defect cluster correspond to pinholes, scratches, and foreign matter attachments, respectively. , , The values ​​are 0.8, 1.2, and 3 respectively, and the defect clusters are classified as pinholes, scratches, or foreign matter attachments, realizing defect instantiation and fine classification based on geometric and photometric features.

[0042] Following step S6, step S7 is also included: defect spatiotemporal continuity logic verification; step S7 specifically includes: S7.1: Establish a defect trajectory tracking queue and record the current frame. Coordinates of the detected defect center Compared to the previous frame Defect center coordinates ; S7.2: Calculate the defect vector And obtain the production line transfer speed vector. ; S7.3: Execution logic consistency judgment: If and If the included angle is less than the preset angle threshold and the modulus error is within the allowable range, the defect is determined to be a "real continuous defect" and the confidence level is increased by 1; if the included angle is greater than the preset angle threshold or the modulus error exceeds the allowable range, the defect is determined to be "random noise" and the confidence level is decreased by 1. S7.4: When the confidence level of a defect reaches the preset confirmation threshold, the defect is finally locked and removed; if the confidence level drops to 0, the defect record is cleared from the tracking queue.

[0043] Following step S7, step S8 is further included: logical inference of defect depth based on dual-source reflectance ratio; step S8 specifically includes: S8.1: Within the same field of view, extract the image grayscale values ​​under the illumination of the coaxial light source and the image grayscale values ​​under the illumination of the low-angle ring light source, respectively; S8.2: Calculate the reflection characteristic ratio ; in, To prevent the denominator from being zero, a smoothing coefficient is used; S8.3: Execute depth-based hierarchical logic judgment: If The logic determines it as a "deep structural scratch," triggering the highest level alarm; if The logic determines that it is "surface stains or shallow scratches," triggering a secondary alarm; if The logic determines it as "normal surface reflection," and no alarm is triggered; among them, and All of these are empirical thresholds obtained through training with a standard defect sample library.

[0044] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0045] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting surface defects in enameled wire based on visual inspection, characterized in that, Includes the following steps: S1: Obtain the original image of the enameled wire surface through a multi-source imaging system, and use a cylindrical coordinate transformation algorithm to unfold the original image into a two-dimensional planar unfolded image; S2: Construct a Siamese feature extraction network, input the two-dimensional planar unfolded image into the first branch of the Siamese neural network, and input the standard defect-free template image into the second branch of the Siamese neural network, and output multi-level feature maps respectively; S3: Perform channel attention weighting and spatial attention weighting on the multi-level feature map output in step S2 to generate a fused feature vector; S4: Calculate the Euclidean distance between the features of the image to be tested and the features of the standard template image in the fused feature vector, and generate the initial defect response map; S5: Logical Judgment and Adaptive Threshold Decision-Making S5.1: Divide the two-dimensional planar unfolded image into multi-scale non-overlapping local windows and calculate the grayscale texture entropy of each local window; S5.2: Derive the anisotropy index using the grayscale texture entropy of each local window. ,based on Construction complexity index ; S5.3: Construct a dual threshold comparator and set the trigger threshold. and release threshold ; S5.4: Execution logic judgment: ; First, determine whether equation (1) is true. If it is, it is determined to be a defect point; otherwise, continue to determine whether equation (2) is true. If it is, it is determined to be the background; otherwise, keep the state of the previous frame unchanged. This represents the distance value of a pixel in the initial defect response map. S6: Defect output.

2. The method for detecting surface defects of enameled wire based on visual inspection according to claim 1, characterized in that, The directional anisotropy index The calculation formula is as follows: ; in, This is the window index, representing the number of the local window currently being processed. , To expand the total number of windows in the diagram, For the first The maximum value among all directional entropy values ​​in a local window. For the first The minimum value among all directional entropy values ​​in a local window. For the first The average of all directional entropy values ​​in a local window To prevent the smoothing coefficient from being divided by zero, .

3. The method for detecting surface defects of enameled wire based on visual inspection according to claim 1, characterized in that, Perform frequency domain transformation on each window to extract the proportion of high-frequency energy. ,based on and Construction complexity index The complexity index Replace with the following formula for calculation: ; in, For the first Multidirectional average entropy of a local window The directional enhancement coefficient, This is the noise suppression coefficient. Indicator functions, For the first The local window is ultimately used to determine the directional anisotropy index. Whether the dynamic threshold is significant.

4. The method for detecting surface defects of enameled wire based on visual inspection according to claim 3, characterized in that, The first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? A dynamic self-calibration method based on background feedback statistics and local texture complexity modulation is used to obtain: Using the memory map of the defect state from the previous frame to filter out a queue of clean background samples, calculate their percentile statistical baseline to establish a basic statistical threshold. and background coefficient of variation , and combined with the first Multidirectional average entropy of a local window With background average entropy The deviation on the first The local window is ultimately used to determine the directional anisotropy index. Is the dynamic threshold significant? Local modulation is performed, and finally smoothed by exponential weighted moving average to generate a window-level dynamic threshold that adapts to the natural fluctuations and local complexity differences of the material surface. The local modulation formula is: ; in, Based on the basic statistical threshold, This is the stability gain coefficient. The background coefficient of variation, For the complexity modulation coefficients, A nonnegative truncation function is defined only if the first... Multidirectional average entropy of a local window Higher than the background average entropy The threshold is increased only when the background level is low; if the background level is low, the threshold is not decreased to ensure the lower limit of detection sensitivity.

5. A method for detecting surface defects in enameled wire based on visual inspection according to claim 1 or 3, characterized in that, Using the exponentially weighted moving average algorithm to analyze the current frame The global complexity mean is smoothed to generate a smoothed dynamic threshold base value. The process is as follows: Calculate the current frame Global complexity average Update the smoothed complex baseline , Finally, the smoothed dynamic threshold base value is generated. ; in, To establish a smooth complexity baseline for the current frame, To smooth out the complexity of the previous frame, For smoothing coefficients, As the initial base threshold, This is the complexity gain coefficient.

6. The method for detecting surface defects of enameled wire based on visual inspection according to claim 5, characterized in that, The trigger threshold and release threshold Based on the smoothed dynamic threshold base value set up: Trigger threshold ; Release threshold ; in, This represents the dynamic hysteresis bandwidth coefficient.

7. The method for detecting surface defects of enameled wire based on visual inspection according to claim 6, characterized in that, The hysteresis bandwidth coefficient Combined with background variation coefficient The calculation process is as follows: ; in, The basic hysteresis coefficient, For background stability gain, The background coefficient of variation, For local toggle gain, This represents the standard deviation of the entropy within the current window's neighborhood.

8. The method for detecting surface defects of enameled wire based on visual inspection according to claim 1, characterized in that, The S6 defect output also includes a classification process, which is as follows: First, pixels are extracted from the final defect state image to construct a three-dimensional feature vector containing spatial coordinates and gray values. The spatial density peak method is used to adaptively determine the number of cluster centers K. An improved K-Means algorithm, which introduces maximum spatial distance constraints and weighted Euclidean distance, is executed to aggregate spatially adjacent and feature-similar defect points into independent defect clusters. Then, the area, aspect ratio of the bounding rectangle, and gray mean of each cluster are calculated. Finally, based on the area threshold, aspect ratio threshold, and the difference logic with the background gray mean, the defect clusters are classified into the first defect cluster, the second defect cluster, and the third defect cluster.

9. The method for detecting surface defects of enameled wire based on visual inspection according to claim 8, characterized in that, In step S6, the judgment logic for the defect cluster classification is as follows: like and If so, it is classified as the first defect cluster; like and If so, it is classified as the second defect cluster; like If so, it is classified as the third defect cluster; If none of the above conditions are met, it will be classified as an "unknown defect" and will be manually reviewed. in, The area of ​​the cluster. The aspect ratio of the circumscribed rectangle is... Area threshold The gray mean of the cluster. The average gray level of the background. The grayscale difference threshold. , , These are the first aspect ratio coefficient, the second aspect ratio coefficient, and the third aspect ratio coefficient, respectively.