A method and system for detecting surface defects of a stainless steel pipe

By using pixel-level fusion of dark and bright field images and a cylindrical unfolding perceptual attention mechanism, combined with an improved Swing Transformer module, the image processing challenges under high reflectivity and rotational motion in stainless steel pipe inspection were solved, achieving high-precision defect detection and measurement.

CN121095233BActive Publication Date: 2026-04-21NINGBO MINGYANG STAINLESS STEEL PIPE
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NINGBO MINGYANG STAINLESS STEEL PIPE
Filing Date
2025-10-22
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing stainless steel pipe inspection methods struggle to obtain complete and uniform surface information in environments with high reflectivity, cylindrical curvature, and rotational motion, resulting in loss of image details and blurred defect boundaries. Furthermore, existing detection algorithms struggle to balance the visibility and recognition accuracy of different types of surface defects, exhibiting low defect segmentation and measurement precision and lacking correlation with cylindrical coordinates.

Method used

By employing pixel-level fusion of dark and bright field images and a cylindrical unfolding perceptual attention mechanism, combined with an improved Swing Transformer module, and through angular displacement synchronous stitching and adaptive weighted fusion, the reflection suppression and circumferential continuous feature extraction of the stainless steel pipe surface are achieved, thereby improving detection accuracy and stability.

Benefits of technology

It achieves high-precision defect identification on the surface of stainless steel pipes, significantly improving detection accuracy and robustness. It can suppress reflection and perform continuous imaging in the whole circumference under high-speed rotation environment, improving the extraction accuracy of defect areas and industrial applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121095233B_ABST
    Figure CN121095233B_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for detecting surface defects in stainless steel pipes, comprising: S1, acquiring line scan images of stainless steel pipes under dark and bright illumination; S2, stitching the line scan images into dark and bright cylindrical unfolded images, and performing brightness equalization and reflection suppression processing; S3, performing pixel-level fusion of the dark and bright cylindrical unfolded images according to set weights; S4, inputting the fused cylindrical unfolded image into the backbone of a YOLO network integrating a Swing Transformer module to extract multi-scale feature maps; S5, performing feature fusion and bounding box prediction, and outputting the bounding box, confidence score, and category label of the defect; S6, performing semantic segmentation and grayscale segmentation in the detection box region and weighted fusion to generate a final defect mask; S7, calculating the area, length, width, and centroid coordinates of the defect, and converting them into actual dimensions and spatial positions. This invention improves the accuracy and stability of stainless steel pipe surface defect identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision inspection and industrial automation inspection technology, and in particular to a method and system for detecting surface defects in stainless steel pipes. Background Technology

[0002] With the continuous improvement of industrial automation and product quality inspection standards, intelligent visual inspection technology for defects on the outer surface of stainless steel pipes has received widespread attention. Existing stainless steel pipe inspection methods mostly employ two-dimensional planar images or local sampling, using fixed-angle illumination imaging combined with traditional convolutional neural networks for defect identification. However, in actual production environments, the surface of stainless steel pipes exhibits strong reflectivity, cylindrical curvature, and rotational motion characteristics, making it difficult for traditional image acquisition methods to obtain complete and uniform surface information. Problems such as uneven exposure, shadow occlusion, and oversaturation of reflective light often occur, resulting in loss of image details and blurred defect boundaries. Furthermore, existing imaging schemes using single bright or dark illumination modes struggle to ensure visibility of different types of surface defects. In bright mode, specular reflection interference is severe, while in dark mode, low-contrast scratches and pitting are difficult to detect, and the inspection results are significantly affected by fluctuations in illumination conditions.

[0003] In image processing, traditional planar stitching methods ignore the surface development relationships of cylindrical workpieces, causing circumferential seam misalignment and axial distortion, making it impossible to achieve accurate spatial coordinate correspondence. Meanwhile, most existing image fusion algorithms employ fixed weights or simple averaging strategies, failing to consider local brightness and reflection differences, resulting in decreased contrast in detailed areas and weakened defect texture features in the fusion result. Regarding defect detection networks, existing YOLO object detection algorithms are generally trained on planar images, lacking structural adaptation for cylindrical unfolded images. The discontinuous circumferential information during feature extraction affects the model's accuracy in recognizing long strips or arc-shaped defects. Furthermore, traditional convolutional structures have limited local receptive fields when processing complex textures on stainless steel surfaces, making it difficult to capture cross-regional contextual feature relationships and insufficient ability to identify weak defects or reflective interference areas.

[0004] In the subsequent defect segmentation and measurement stages, existing methods generally employ single semantic segmentation networks or threshold-based grayscale segmentation, which are prone to region adhesion, boundary fragmentation, and false detections due to noise, resulting in low accuracy in morphological extraction of defect regions. Furthermore, since defect detection results are mostly output in pixel coordinate form, lacking correlation with cylindrical coordinates and spatial geometric parameters, it is difficult to achieve a quantitative assessment of the actual size and spatial location of defects, thus limiting the application of detection results in industrial measurement and automatic rejection processes.

[0005] Therefore, how to provide a method and system for detecting surface defects in stainless steel pipes is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0006] One objective of this invention is to propose a method and system for detecting surface defects in stainless steel pipes. This invention integrates an improved Swing Transformer module into the YOLO detection framework, combining pixel-level fusion of dark and bright field images with a cylindrical unfolding perceptual attention mechanism to achieve reflection suppression and circumferential continuous feature extraction from the stainless steel pipe surface. Image uniformity is improved through angular displacement synchronous stitching and adaptive weighted fusion. Local feature gradient correction and multi-scale fusion are introduced in the feature extraction and detection stages to enhance defect recognition accuracy. This enables continuous circumferential detection of highly reflective cylindrical surfaces, significantly improving defect recognition accuracy and detection stability.

[0007] A method for detecting surface defects in stainless steel pipes according to an embodiment of the present invention includes the following steps:

[0008] S1. Acquire line scan images of the outer surface of the stainless steel tube under dark and bright illumination respectively, and record the angular displacement pulse signal.

[0009] S2. The line scan images are stitched together to form a dark-field cylindrical unfolded image and a bright-field cylindrical unfolded image, and brightness equalization and reflection suppression processing are performed.

[0010] S3. The dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image are fused pixel-level according to a set weight to generate a fused cylindrical unfolded image.

[0011] S4. Input the fused cylinder unfolded image into the detection network of the YOLO network backbone with integrated improved Swin Transformer module to extract multi-scale feature maps that maintain circumferential continuity.

[0012] S5. Input the feature map into the feature fusion layer and detection head of the YOLO network, and output the bounding box, confidence score and category label of the defect;

[0013] S6. Perform semantic segmentation and grayscale segmentation in the detection box area and then perform weighted fusion to generate the final defect mask;

[0014] S7. Calculate the area, length, width, and centroid coordinates of the defect, and convert them to actual dimensions and spatial location.

[0015] Optionally, step S1 includes:

[0016] S11. A circumferential encoder is installed on the stainless steel tube rotating device, and the circumferential encoder outputs a pulse signal that is proportional to the rotational angular displacement.

[0017] S12. Connect the line scan camera to the circumferential encoder, and set each pulse signal to trigger the line scan camera to acquire one line of images;

[0018] S13. Set up a dark field lighting device and a bright field lighting device. The dark field lighting device consists of a ring LED array and is installed in an inclined direction between the camera and the surface of the stainless steel tube. The bright field lighting device consists of a surface light source and is installed in the direction of the camera's optical axis.

[0019] S14. Rotate the stainless steel tube under dark lighting conditions and acquire a line scan image sequence under dark lighting conditions. The line scan image sequence corresponds one-to-one with the angular displacement pulse signal.

[0020] S15. Rotate the stainless steel tube under bright field illumination conditions and acquire a line scan image sequence of the bright field illumination state, wherein the line scan image sequence corresponds one-to-one with the angular displacement pulse signal.

[0021] S16. During the acquisition process, synchronously record the angular displacement pulse signal, the line array camera row number, and the lighting status to generate an image dataset containing the acquisition sequence, rotation angle, and lighting information.

[0022] Optionally, step S2 includes:

[0023] S21. Generate an angular displacement sequence index based on the angular displacement pulse signals in the image dataset. The index records the sequence number, timestamp, and line scan camera row number corresponding to each pulse.

[0024] S22. Arrange the line scan images in the dark field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the line scan camera row number, and stitch them together to form a dark field cylindrical unfolded image.

[0025] S23. Arrange the line scan images of the bright field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the row number of the line scan camera, and stitch them together to form a bright field cylindrical unfolded image.

[0026] S24. Perform circumferential boundary stitching correction, missing row interpolation, and duplicate row removal on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image, and establish a cylindrical unfolded coordinate system with the circumferential direction as the horizontal direction and the axial direction as the vertical direction.

[0027] S25. Perform brightness equalization processing on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, including background brightness estimation and local contrast limitation.

[0028] S26. Construct a high-reflectivity candidate region mask based on the intensity difference between the dark field and the bright field, and perform reflection suppression processing on the high-reflectivity candidate region;

[0029] S27. Establish an inspection-free mask, which calibrates the weld seam area and the coding area, and overlays it with the dark field cylindrical unfolded image and the bright field cylindrical unfolded image to obtain a preprocessed cylindrical unfolded image.

[0030] Optionally, step S3 includes:

[0031] S31. Spatial registration is performed on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, and the image edge offset and angle error are corrected so that the pixel positions of the two images correspond to each other in the cylindrical unfolded coordinate system.

[0032] S32. Perform grayscale normalization on the registered dark-field cylindrical unfolded image and bright-field cylindrical unfolded image in pixel coordinates to unify the grayscale distribution range.

[0033] S33. Perform pixel-level weighted fusion at the corresponding pixel positions according to the preset weight coefficient to generate a fused cylindrical unfolded image;

[0034] S34. Perform local adaptive smoothing processing on the fused cylindrical unfolded image to eliminate brightness abrupt changes in the illumination transition region;

[0035] S35. Inherit the shielding information of the inspection-free mask and the high-reflectivity candidate region mask on the fused cylindrical unfolded image to obtain the shielded fused cylindrical unfolded image.

[0036] Optionally, step S4 includes:

[0037] S41. Establish a defect detection network based on the YOLO structure, wherein the detection network includes an input layer, a backbone feature extraction layer, a feature fusion layer, and a detection head;

[0038] S42. An improved Swin Transformer module is embedded in the backbone feature extraction layer. The improved Swin Transformer module adopts a hierarchical window attention structure to perform multi-layer convolution and window self-attention calculation on the input fused cylindrical unfolded image, extract feature maps at different scales, and simultaneously retain local texture information and cross-window global semantic features.

[0039] S43. Perform window sliding operations within each level to establish cross-window feature associations;

[0040] S44. In the improved Swing Transformer module, a cylinder unfolding perception attention mechanism is introduced. The cylinder unfolding perception attention mechanism establishes circumferential and axial position encoding based on cylinder coordinates, and performs cyclic mapping on the circumferential direction in the self-attention calculation to maintain the circumferential continuity of the cylinder unfolding image.

[0041] S45. After channel alignment, the multi-scale feature maps output from each level are input into the convolutional layer of the YOLO backbone network to extract edge details and texture structure features.

[0042] Optionally, step S5 includes:

[0043] S51. Input the multi-scale feature map processed by the improved Swin Transformer module into the feature fusion layer of the YOLO network, perform upsampling and cross-layer concatenation operations on the feature maps of each layer, establish multi-scale feature connections from details to semantics, and form fused features.

[0044] S52. Perform channel attention weighting and spatial feature reconstruction in the fusion features to align the axial and circumferential features of the cylinder unfolded image;

[0045] S53. Calculate the local feature gradient in the fusion feature, wherein the local feature gradient characterizes the rate of change of the features of the cylinder unfolded image in the axial and circumferential directions;

[0046] S54. Input the fused features into the detection head structure, wherein the detection head includes a main detection branch and a coordinate correction branch;

[0047] S55. The main detection branch generates defect candidate bounding boxes, confidence scores, and category response maps through convolution operations. The category response maps correspond to different types of defect features on the surface of the stainless steel pipe.

[0048] S56. The coordinate correction branch performs secondary position regression on the bounding box output by the main detection branch, calculates the defect edge morphology deviation based on the local feature gradient, and corrects the bounding box coordinates.

[0049] S57. The training of the detection network adopts a category-weighted configuration, and dynamic weights are assigned according to the occurrence ratio of each defect category in the samples.

[0050] S58. Based on the combined output of the main detection branch and the coordinate correction branch, determine the final bounding box, confidence level, and category label of the defect.

[0051] Optionally, step S6 includes:

[0052] S61. Extract the corresponding region on the fused cylindrical unfolded image based on the bounding box coordinates in the detection results, and establish a detection box region set.

[0053] S62. Input the detection box region set into the segmentation sub-network. The segmentation sub-network includes an encoding layer and a decoding layer. The encoding layer extracts multi-scale features, the decoding layer reconstructs pixel-level segmentation results, and outputs a semantic mask for each detection box region.

[0054] S63. Perform multi-scale filtering and adaptive threshold segmentation on the fused cylindrical unfolded image to generate a grayscale mask, wherein the grayscale mask characterizes the changes in image brightness and differences in surface texture;

[0055] S64. Perform weighted fusion of the semantic mask and the grayscale mask in pixel coordinates to form a joint mask. The weight ratio is determined based on the semantic segmentation confidence and the local grayscale gradient.

[0056] S65. Perform connected component labeling, hole filling, and noise point removal on the joint mask to obtain a set of candidate defect regions;

[0057] S66. Perform size screening and shape constraints on the candidate defect region set, remove regions smaller than the set area or that do not conform to the preset shape ratio, and generate the final defect mask.

[0058] Optionally, step S7 includes:

[0059] S71. Calculate the pixel area, perimeter, and minimum bounding rectangle size of the defect region in the defect mask, wherein the minimum bounding rectangle size includes the axial length and circumferential width of the defect.

[0060] S72. Calculate the centroid coordinates within the defect area. The centroid coordinates are represented by a cylindrical coordinate system, where the horizontal coordinates correspond to the circumferential position and the vertical coordinates correspond to the axial position.

[0061] S73. Calculate the axial and circumferential lengths of the defect based on the camera pixel size, and convert the circumferential length into spatial arc length by combining it with the radius of the stainless steel pipe.

[0062] S74. Using the unfolded coordinates of the defect centroid as a reference, calculate the spatial polar coordinates of the defect based on the angular displacement index of the fused cylindrical unfolded image to obtain the three-dimensional position parameters of the defect on the outer surface of the stainless steel tube.

[0063] S75. Output the area, axial length, circumferential width, and spatial centroid coordinates of each defect to form a defect geometric feature set.

[0064] A stainless steel pipe surface defect detection system according to an embodiment of the present invention includes:

[0065] The image acquisition module is used to acquire line scan images of stainless steel pipelines under both dark and bright lighting conditions.

[0066] The image stitching module is used to index and stitch the line scan images according to the angular displacement order, generate dark field cylindrical unfolded images and bright field cylindrical unfolded images, and perform brightness equalization and reflection suppression.

[0067] The image fusion module is used to perform spatial registration and pixel-level weighted fusion on the dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image to generate a fused cylindrical unfolded image.

[0068] The feature extraction module is used to input the fused cylinder unfolded image into the YOLO network backbone with the integrated improved Swing Transformer module to extract multi-scale feature maps;

[0069] The defect detection module is used to perform feature fusion and bounding box prediction on multi-scale feature maps, and output the bounding box, confidence score and category label of the defect;

[0070] The defect segmentation module is used to perform semantic segmentation and grayscale segmentation in the detection box region and then perform weighted fusion to generate the final defect mask.

[0071] The defect measurement module is used to calculate the area, length, width, and centroid coordinates of defects, and convert them into actual dimensions and spatial positions.

[0072] The beneficial effects of this invention are:

[0073] This invention integrates an improved Swin Transformer module into the YOLO detection framework and combines pixel-level fusion of dark and bright field images with a cylinder unfolding perceptual attention mechanism. Addressing the issues of high reflectivity interference, uneven illumination, and lack of circumferential continuity on stainless steel pipe surfaces, it constructs a dual-modal line-scan imaging and unfolding stitching method based on synchronous angular displacement. This achieves high-precision geometric mapping from curved surfaces to planes and illumination consistency processing. In the image fusion stage, an adaptive weighted pixel-level weighting strategy and local smoothing constraints significantly improve the contrast and texture integrity of surface detail areas. In the feature extraction stage, a hierarchical window attention and cylinder coordinate position encoding mechanism are introduced to achieve cyclic association of circumferential features in the cylinder unfolding image, maintaining global contextual continuity across windows. In the detection stage, a local feature gradient-driven bounding box correction branch improves the accuracy of defect edge localization, and multi-scale feature fusion enhances the recognition of minor scratches, pitting, and arc-shaped cracks. In the segmentation stage, a weighted fusion of semantic masks and grayscale masks, combined with connected component labeling and morphological constraints, achieves high-precision extraction of defect areas and noise removal. Ultimately, this invention enables reflection suppression, full-circumferential continuous imaging, and highly robust intelligent defect identification in high-speed rotating stainless steel pipe inspection environments, significantly improving inspection accuracy and industrial applicability. Attached Figure Description

[0074] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0075] Figure 1 This is an overall flowchart of a method for detecting surface defects in stainless steel pipes proposed in this invention;

[0076] Figure 2This is a schematic diagram of the YOLO detection network structure integrating the improved Swing Transformer module in this invention;

[0077] Figure 3 This is a schematic diagram of the stainless steel pipe surface defect detection system proposed in this invention. Detailed Implementation

[0078] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0079] refer to Figure 1-3 A method for detecting surface defects in stainless steel pipes, comprising the following steps:

[0080] S1. Acquire line scan images of the outer surface of the stainless steel tube under dark and bright illumination respectively, and record the angular displacement pulse signal.

[0081] S2. The line scan images are stitched together to form a dark-field cylindrical unfolded image and a bright-field cylindrical unfolded image, and brightness equalization and reflection suppression processing are performed.

[0082] S3. The dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image are fused pixel-level according to a set weight to generate a fused cylindrical unfolded image.

[0083] S4. Input the fused cylinder unfolded image into the detection network of the YOLO network backbone with integrated improved Swin Transformer module to extract multi-scale feature maps that maintain circumferential continuity.

[0084] S5. Input the feature map into the feature fusion layer and detection head of the YOLO network, and output the bounding box, confidence score and category label of the defect;

[0085] S6. Perform semantic segmentation and grayscale segmentation in the detection box area and then perform weighted fusion to generate the final defect mask;

[0086] S7. Calculate the area, length, width, and centroid coordinates of the defect, and convert them to actual dimensions and spatial location.

[0087] In this invention, a linear scan camera and a circumferential encoder are connected via pulse synchronization triggering. Each angular displacement pulse triggers the camera to acquire one line of images, establishing a correspondence between angular displacement and image acquisition. The acquired dark and bright field line scan images are stitched together into a cylindrical unfolded image based on the angular displacement index, establishing an unfolded coordinate system with the circumferential direction as the horizontal axis and the axial direction as the vertical axis. The dark and bright field unfolded images are adaptively weighted and fused according to local brightness and contrast to generate a fused cylindrical unfolded image. The fusion result is input into a YOLO network integrating an improved Swing Transformer module to extract multi-scale features while maintaining circumferential continuity, outputting defect bounding boxes and categories. Weighted fusion is performed by combining semantic masks and grayscale masks to obtain the final defect region. Based on the relationship between the angular displacement index and the cylindrical coordinates, the actual size and three-dimensional spatial position of the defect are calculated.

[0088] In this embodiment, step S1 includes:

[0089] S11. A circumferential encoder is installed on the stainless steel tube rotating device, and the circumferential encoder outputs a pulse signal that is proportional to the rotational angular displacement.

[0090] S12. Connect the line scan camera to the circumferential encoder, and set each pulse signal to trigger the line scan camera to acquire one line of images;

[0091] S13. Set up a dark field lighting device and a bright field lighting device. The dark field lighting device consists of a ring LED array and is installed in an inclined direction between the camera and the surface of the stainless steel tube. The bright field lighting device consists of a surface light source and is installed in the direction of the camera's optical axis.

[0092] S14. Rotate the stainless steel tube under dark lighting conditions and acquire a line scan image sequence under dark lighting conditions. The line scan image sequence corresponds one-to-one with the angular displacement pulse signal.

[0093] S15. Rotate the stainless steel tube under bright field illumination conditions and acquire a line scan image sequence of the bright field illumination state, wherein the line scan image sequence corresponds one-to-one with the angular displacement pulse signal.

[0094] S16. During the acquisition process, synchronously record the angular displacement pulse signal, the line array camera row number, and the lighting status to generate an image dataset containing the acquisition sequence, rotation angle, and lighting information.

[0095] In this invention, the trigger acquisition of the line scan camera and the angular displacement pulse signal of the circumferential encoder are synchronously controlled to ensure a one-to-one correspondence between the image rows and angular positions during the rotation of the stainless steel tube. Line scan images acquired alternately under dark and bright illumination conditions are bound to angular displacement information to form an image dataset containing the acquisition sequence, rotation angle, and illumination state. This dataset serves as the geometric index basis for the cylinder unfolding, providing temporal matching and spatial positioning support for accurate stitching of dark and bright images and subsequent pixel-level fusion, thereby ensuring the integrity and geometric accuracy of the unfolded surface image.

[0096] In this embodiment, step S2 includes:

[0097] S21. Generate an angular displacement sequence index based on the angular displacement pulse signals in the image dataset. The index records the sequence number, timestamp, and line scan camera row number corresponding to each pulse.

[0098] S22. Arrange the line scan images in the dark field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the line scan camera row number, and stitch them together to form a dark field cylindrical unfolded image.

[0099] S23. Arrange the line scan images of the bright field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the row number of the line scan camera, and stitch them together to form a bright field cylindrical unfolded image.

[0100] S24. Perform circumferential boundary stitching correction, missing row interpolation, and duplicate row removal on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image, and establish a cylindrical unfolded coordinate system with the circumferential direction as the horizontal direction and the axial direction as the vertical direction.

[0101] S25. Perform brightness equalization processing on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, including background brightness estimation and local contrast limitation.

[0102] S26. Construct a high-reflectivity candidate region mask based on the intensity difference between the dark field and the bright field, and perform reflection suppression processing on the high-reflectivity candidate region;

[0103] S27. Establish an inspection-free mask, which calibrates the weld seam area and the coding area, and overlays it with the dark field cylindrical unfolded image and the bright field cylindrical unfolded image to obtain a preprocessed cylindrical unfolded image.

[0104] In this invention, a cylindrical unfolded coordinate system is established by stitching together dark and bright field line scan images in angular displacement order to achieve planar reconstruction of the outer surface of the stainless steel pipe. The system performs brightness equalization and reflection suppression processing on the unfolded image to eliminate uneven illumination and high reflection interference; a high-reflection candidate region mask is generated based on the intensity difference between the dark and bright fields to reduce the impact of specular reflection on subsequent detection; at the same time, an inspection-free mask is established to calibrate and shield the weld area and the coding area to ensure accurate and effective detection.

[0105] In this embodiment, step S3 includes:

[0106] S31. Spatial registration is performed on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, and the image edge offset and angle error are corrected so that the pixel positions of the two images correspond to each other in the cylindrical unfolded coordinate system.

[0107] S32. Perform grayscale normalization on the registered dark-field cylindrical unfolded image and bright-field cylindrical unfolded image in pixel coordinates to unify the grayscale distribution range.

[0108] S33. Perform pixel-level weighted fusion at the corresponding pixel positions according to the preset weight coefficient to generate a fused cylindrical unfolded image;

[0109] S34. Perform local adaptive smoothing processing on the fused cylindrical unfolded image to eliminate brightness abrupt changes in the illumination transition region;

[0110] S35. Inherit the shielding information of the inspection-free mask and the high-reflectivity candidate region mask on the fused cylindrical unfolded image to obtain the shielded fused cylindrical unfolded image.

[0111] In this invention, the dark-field and bright-field cylindrical unfolded images need to be spatially registered before fusion to eliminate pixel misalignment caused by rotational synchronization errors or assembly deviations. The registration process is based on the cylindrical unfolded coordinate system, achieving pixel-level alignment through the correspondence between angular displacement index and axial projection. After registration, grayscale normalization is performed on the two images to unify the brightness range and reduce imaging dynamic differences. Subsequently, weighted fusion is performed at corresponding pixel positions according to weight coefficients. The weights are determined based on the local brightness contrast of the dark-field and bright-field images to enhance the structural texture of low-reflection areas and suppress overexposure in high-reflection areas. The fused image then undergoes local adaptive smoothing, performing brightness adjustment on the illumination transition edge areas to ensure that the fusion result is continuous in the circumferential direction and maintains consistent texture details. Finally, the inspection-free mask and high-reflection area shielding information are inherited in the fused cylindrical unfolded image.

[0112] In this embodiment, step S4 includes:

[0113] S41. Establish a defect detection network based on the YOLO structure, wherein the detection network includes an input layer, a backbone feature extraction layer, a feature fusion layer, and a detection head;

[0114] S42. An improved Swin Transformer module is embedded in the backbone feature extraction layer. The improved Swin Transformer module adopts a hierarchical window attention structure to perform multi-layer convolution and window self-attention calculation on the input fused cylindrical unfolded image, extract feature maps at different scales, and simultaneously retain local texture information and cross-window global semantic features.

[0115] S43. Perform window sliding operations within each level to establish cross-window feature associations;

[0116] S44. In the improved Swing Transformer module, a cylinder unfolding perception attention mechanism is introduced. The cylinder unfolding perception attention mechanism establishes circumferential and axial position encoding based on cylinder coordinates, and performs cyclic mapping on the circumferential direction in the self-attention calculation to maintain the circumferential continuity of the cylinder unfolding image.

[0117] S45. After channel alignment, the multi-scale feature maps output from each level are input into the convolutional layer of the YOLO backbone network to extract edge details and texture structure features.

[0118] In this invention, a cylinder unfolding awareness attention mechanism is introduced into the Swin Transformer module. This mechanism encodes the coordinates of the cylinder surface, mapping the positional information of image pixels in the circumferential angle and axial height into learnable vectors. During self-attention calculation, the attention weight matrix is ​​cyclically shifted in the circumferential direction, establishing cyclic connections between the left and right boundary features of the unfolded cylinder image. Simultaneously, attention weights are assigned based on the relative distances in the axial and circumferential directions, achieving joint modeling of the spatial relationships on the cylinder surface. This mechanism improves the network's detection accuracy for defects such as circumferential cracks and scratches while maintaining the circumferential continuity of the unfolded cylinder image.

[0119] In this embodiment, step S5 includes:

[0120] S51. Input the multi-scale feature map processed by the improved Swin Transformer module into the feature fusion layer of the YOLO network, perform upsampling and cross-layer concatenation operations on the feature maps of each layer, establish multi-scale feature connections from details to semantics, and form fused features.

[0121] S52. Perform channel attention weighting and spatial feature reconstruction in the fusion features to align the axial and circumferential features of the cylinder unfolded image;

[0122] S53. Calculate the local feature gradient in the fusion feature. The local feature gradient is obtained by performing spatial difference calculation on the feature values ​​of candidate regions in the fusion feature map. Specifically, in the axial and circumferential directions of the cylindrical unfolded image, the difference between the feature values ​​of adjacent pixels is calculated to obtain the gradient components in the two directions; then, the comprehensive gradient field is obtained based on the gradient magnitude and direction distribution of each channel. The gradient field characterizes the rate of change and principal direction of the surface features of the stainless steel pipe in local space, reflecting the texture transition and reflection difference characteristics of the defect edge. This local feature gradient serves as the basis for edge morphology deviation calculation, providing a quantitative basis for the secondary position regression of the bounding box.

[0123] S54. Input the fused features into the detection head structure, wherein the detection head includes a main detection branch and a coordinate correction branch;

[0124] S55. The main detection branch generates defect candidate bounding boxes, confidence scores, and category response maps through convolution operations. The category response maps correspond to different types of defect features on the surface of the stainless steel pipe.

[0125] The main detection branch receives the fused feature map and performs convolution operations on feature regions of different sizes through multi-scale convolutional layers. It outputs corresponding bounding box parameters, confidence scores, and category response values ​​for each feature unit. The bounding box parameters include center coordinates and size information; the confidence score represents the probability that the region contains a defect; and the category response map corresponds to different defect types on the stainless steel pipe surface. During the detection process, the bounding box is offset and regressed based on a preset anchor frame matching mechanism, combined with cylindrical expansion coordinate constraints to ensure the continuity of the bounding box in the circumferential direction.

[0126] S56. The coordinate correction branch performs secondary position regression on the bounding box output by the main detection branch, calculates the defect edge morphology deviation based on the local feature gradient, and corrects the bounding box coordinates.

[0127] The coordinate correction branch uses the candidate box of the main detection branch as the region index to extract local feature regions from the fused feature map and calculates the local feature gradients of each channel in the circumferential and axial directions of the cylindrical unfolded image. Based on the gradient magnitude and direction distribution, the edge main response band is determined, and the average displacement difference between the center of this response band and the candidate box boundary in the two directions is calculated as the edge morphology deviation. The center position and size of the candidate box are corrected according to the deviation, achieving high-precision position correction of the defect edges on the stainless steel pipe surface.

[0128] S57. The training of the detection network adopts a category-weighted configuration, and dynamic weights are assigned according to the occurrence ratio of each defect category in the samples.

[0129] S58. Based on the combined output of the main detection branch and the coordinate correction branch, determine the final bounding box, confidence level, and category label of the defect.

[0130] In this invention, the feature fusion layer of the YOLO network upsamples and stitches feature maps at different scales to obtain fused features that combine local details and global semantics. The detection head consists of a main detection branch and a coordinate correction branch. The main detection branch is responsible for generating defect candidate boxes and category response maps, while the coordinate correction branch corrects the positions of the candidate boxes based on local gradient information. During the training phase, the network weights the loss functions for different defect categories, allowing rare defect categories to obtain higher gradient weights during backpropagation, thereby improving the detection accuracy of small-area cracks, fine scratches, and reflective points.

[0131] In this embodiment, step S6 includes:

[0132] S61. Extract the corresponding region on the fused cylindrical unfolded image based on the bounding box coordinates in the detection results, and establish a detection box region set.

[0133] S62. Input the detection box region set into the segmentation sub-network. The segmentation sub-network includes an encoding layer and a decoding layer. The encoding layer extracts multi-scale features, the decoding layer reconstructs pixel-level segmentation results, and outputs a semantic mask for each detection box region.

[0134] S63. Perform multi-scale filtering and adaptive threshold segmentation on the fused cylindrical unfolded image to generate a grayscale mask, wherein the grayscale mask characterizes the changes in image brightness and differences in surface texture;

[0135] S64. Perform weighted fusion of the semantic mask and the grayscale mask in pixel coordinates to form a joint mask. The weight ratio is determined based on the semantic segmentation confidence and the local grayscale gradient.

[0136] S65. Perform connected component labeling, hole filling, and noise point removal on the joint mask to obtain a set of candidate defect regions;

[0137] S66. Perform size screening and shape constraints on the candidate defect region set, remove regions smaller than the set area or that do not conform to the preset shape ratio, and generate the final defect mask.

[0138] In this invention, a multi-scale image sequence in cylindrical unfolded coordinates is first constructed. A bidirectional combined filtering approach, employing circumferential guiding filtering and axial detail preservation, is used at each scale to form a detail response map. This map is then weighted and superimposed across scales to obtain a multi-scale response map. Pixels overlapping with high-reflectivity candidate regions have their response weights reduced to suppress specular interference. Subsequently, in the adaptive threshold segmentation stage, local background and contrast are calculated based on a circumferentially larger sliding window. A threshold is generated for each pixel, and initial binarization is performed. The binarized results are then subjected to connected component removal, fine-line connection, and hole filling. An inspection-free mask is then superimposed to perform shielding and circumferential boundary consistency correction, resulting in a grayscale mask.

[0139] In this embodiment, step S7 includes:

[0140] S71. Calculate the pixel area, perimeter, and minimum bounding rectangle size of the defect region in the defect mask, wherein the minimum bounding rectangle size includes the axial length and circumferential width of the defect.

[0141] S72. Calculate the centroid coordinates within the defect area. The centroid coordinates are represented by a cylindrical coordinate system, where the horizontal coordinates correspond to the circumferential position and the vertical coordinates correspond to the axial position.

[0142] S73. Calculate the axial and circumferential lengths of the defect based on the camera pixel size, and convert the circumferential length into spatial arc length by combining it with the radius of the stainless steel pipe.

[0143] S74. Using the unfolded coordinates of the defect centroid as a reference, calculate the spatial polar coordinates of the defect based on the angular displacement index of the fused cylindrical unfolded image to obtain the three-dimensional position parameters of the defect on the outer surface of the stainless steel tube.

[0144] S75. Output the area, axial length, circumferential width, and spatial centroid coordinates of each defect to form a defect geometric feature set.

[0145] In this invention, the calculation of defect geometric features is based on the pixel distribution of connected regions in the final defect mask. The axial length and circumferential width of the defect are obtained by calculating the pixel area, perimeter, and minimum bounding rectangle size of each connected region. The centroid coordinates are obtained by a weighted average of pixel positions and expressed as circumferential and axial coordinates in a cylindrical unfolded coordinate system. Combining the camera pixel size and the radius of the stainless steel tube, the axial and circumferential pixel distances are converted into spatial length and arc length, respectively, achieving a transformation from two-dimensional pixel coordinates to three-dimensional spatial coordinates. Using the centroid as a reference, a polar coordinate relationship is established through angular displacement indexing to obtain the actual spatial position of the defect on the outer surface of the stainless steel tube, thereby generating a defect geometric feature set containing area, size, and spatial centroid for subsequent statistical analysis and quality assessment.

[0146] A stainless steel pipe surface defect detection system, comprising:

[0147] The image acquisition module is used to acquire line scan images of stainless steel pipelines under both dark and bright lighting conditions.

[0148] The image stitching module is used to index and stitch the line scan images according to the angular displacement order, generate dark field cylindrical unfolded images and bright field cylindrical unfolded images, and perform brightness equalization and reflection suppression.

[0149] The image fusion module is used to perform spatial registration and pixel-level weighted fusion on the dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image to generate a fused cylindrical unfolded image.

[0150] The feature extraction module is used to input the fused cylinder unfolded image into the YOLO network backbone with the integrated improved Swing Transformer module to extract multi-scale feature maps;

[0151] The defect detection module is used to perform feature fusion and bounding box prediction on multi-scale feature maps, and output the bounding box, confidence score and category label of the defect;

[0152] The defect segmentation module is used to perform semantic segmentation and grayscale segmentation in the detection box region and then perform weighted fusion to generate the final defect mask.

[0153] The defect measurement module is used to calculate the area, length, width, and centroid coordinates of defects, and convert them into actual dimensions and spatial positions.

[0154] Example 1:

[0155] To verify the feasibility of this invention in practice, it was applied to the online surface quality inspection process of a large stainless steel pipe manufacturing enterprise. The enterprise's pipe specifications range from φ108mm to φ219mm, with a production cycle of 12 seconds per pipe. Common surface defects include scratches, dents, porosity, oxide spots, and circumferential cracks. Due to the strong reflective properties of stainless steel, traditional visual inspection systems are prone to producing false defects, feature breaks, and identification misalignments under high-light interference conditions, resulting in an accuracy rate of less than 85% and significant missed detections, failing to meet the enterprise's high-precision quality control requirements.

[0156] This invention addresses this problem by constructing a dual-light source line scan imaging + cylinder unfolding sensing YOLO-Swin detection framework, achieving a complete innovation from image acquisition to defect measurement. The system is installed on an automated conveyor line after the polishing section, with the stainless steel tube rotating at 120 rpm. Synchronous triggering of acquisition is achieved through a high-precision circumferential encoder mounted on the rotating spindle and a line scan camera. Each angular displacement pulse signal triggers the acquisition of one line of images, with a sampling frequency of 30 kHz and a resolution of 4096 × 1. The dark-field annular LED array is tilted at 35°, while the bright-field planar light source is coaxially arranged with the camera's optical axis. High dynamic range surface imaging is achieved through the complementary reflection characteristics of the two illumination modes.

[0157] During the data acquisition phase, the system simultaneously records angular displacement pulse signals, row numbers, and illumination status. An image index sequence is generated using an algorithm and stitched together to form dark-field and bright-field cylindrical unfolded images. After brightness equalization and reflection suppression processing, the brightness fluctuation range in reflective areas is reduced from ±52 gray levels in the original image to ±14 gray levels. Next, the dark-field and bright-field images are spatially registered in pixel coordinates and then fused using pixel-level weighted fusion to generate a fused cylindrical unfolded image. The fused image exhibits approximately 47% improved contrast and 74% reduction in high-reflectivity artifacts, significantly improving feature integrity and providing a clearer data foundation for subsequent detection.

[0158] In the detection phase, this invention integrates a YOLO detection network with an improved Swing Transformer module, which incorporates a fused cylindrical unfolded image input. This module employs a hierarchical window attention mechanism and introduces a cylindrical unfolding-aware attention mechanism into its self-attention computation. It constructs circumferential and axial positional encodings using cylindrical coordinates and performs cyclic mapping in the circumferential direction, enabling continuous circumferential semantic awareness in feature extraction. This design overcomes the local discontinuity problem in traditional planar detection networks when processing ring-shaped targets, achieving seamless detection of defects on the cylindrical surface. This invention also adds a local feature gradient correction mechanism to the YOLO detection head. This mechanism calculates the defect edge morphology deviation based on the gradient changes of the fused features and performs secondary correction in coordinate regression, thereby improving the accuracy and stability of the bounding box.

[0159] In the segmentation and measurement stages, the semantic mask output by the segmentation sub-network and the grayscale mask obtained by adaptive threshold segmentation are weighted and fused together. Combined with connected component labeling and morphological filtering, a high-precision defect mask is finally generated. This mask not only improves the continuity of defect edge recognition but also provides a reliable basis for geometric measurement.

[0160] To more comprehensively verify the practical effect of the method of the present invention, 500 stainless steel pipes were selected as samples, with a total of 2980 defect samples, including linear scratches, circumferential cracks, indentations, and oxide spots. The traditional single-light source system, the YOLOv5 model, and the model of the present invention were used for detection, and the experimental results are shown in Table 1.

[0161] Table 1. Performance Comparison of Different Detection Methods

[0162] Comparison indicators Traditional single light source YOLOv5 model Method of the present invention Average detection accuracy (%) 83.2 89.3 97.9 False negative rate (%) 11.8 8.7 2.3 False positive rate (%) 8.5 6.4 1.8 Effective recognition rate of reflective areas (%) 61.9 74.2 96.8 Mean bounding box deviation (mm) 1.24 0.92 0.35

[0163] As shown in Table 1, this invention demonstrates significant advantages in detection performance, accuracy stability, and anti-reflective capabilities. The average detection accuracy of this invention reaches 97.9%, an improvement of 14.7 percentage points compared to traditional single-light source systems and 8.6 percentage points compared to the YOLOv5 model. This indicates that by introducing the Swing Transformer module and the cylindrical unfolding perception attention mechanism, the model's feature extraction capability under complex lighting conditions is significantly enhanced, enabling accurate identification of low-contrast defects such as minor scratches and microcracks on highly reflective stainless steel surfaces. Regarding false negatives and false positives, this invention reduces the false negative rate to 2.3% and the false positive rate to 1.8%. Compared to the YOLOv5 model, the false negative rate decreases by approximately 6.4 percentage points, indicating that the cylindrical unfolding perception mechanism effectively solves the false negative problem caused by feature breaks in the circumferential structure of traditional planar convolutional networks. Simultaneously, the weighted fusion design of semantic masks and grayscale masks improves the continuity of boundary recognition, significantly reducing false positives in complex background textures. In terms of effective recognition rate in reflective areas, this invention achieves 96.8%, an improvement of approximately 35 percentage points compared to traditional systems. This performance improvement is mainly attributed to the dual-light source fusion imaging strategy, which achieves high dynamic range imaging through complementary information from dark and bright fields, effectively reducing saturation interference caused by specular reflection. Brightness equalization and reflection suppression processing enhance image contrast by 47%, significantly improving the consistency of detected features. Regarding positioning accuracy, the average bounding box deviation of this invention is only 0.35mm, a reduction of nearly 62% compared to the 0.92mm of the traditional model, demonstrating the effectiveness of the local feature gradient correction mechanism. By introducing gradient deviation correction and coordinate quadratic regression into the detection head, this invention can still achieve high-precision position regression even under conditions of blurred edges and uneven grayscale, significantly improving the fit between the detection box and the actual defect.

[0164] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting surface defects in stainless steel pipes, characterized in that, Includes the following steps: S1. Acquire scan images of stainless steel pipelines under dark and bright illumination, and record angular displacement pulse signals; S2. The line scan images are stitched together to form a dark-field cylindrical unfolded image and a bright-field cylindrical unfolded image, and brightness equalization and reflection suppression processing are performed. S3. The dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image are fused pixel-level according to a set weight to generate a fused cylindrical unfolded image. S4. Input the fused cylinder unfolded image into the YOLO network backbone with the integrated improved Swin Transformer module to extract multi-scale feature maps that maintain circumferential continuity. S5. Input the feature map into the feature fusion layer and detection head of the YOLO network, and output the bounding box, confidence score and category label of the defect; S6. Perform semantic segmentation and grayscale segmentation in the detection box area and then perform weighted fusion to generate the final defect mask; S7. Calculate the area, length, width, and centroid coordinates of the defect, and convert them to actual dimensions and spatial location; S1 specifically includes: S11. A circumferential encoder is installed on the stainless steel tube rotating device, and the circumferential encoder outputs a pulse signal that is proportional to the rotational angular displacement. S12. Connect the line scan camera to the circumferential encoder, and set each pulse signal to trigger the line scan camera to acquire one line of images; S13. Set up a dark field lighting device and a bright field lighting device. The dark field lighting device consists of a ring LED array and is installed in an inclined direction between the camera and the surface of the stainless steel tube. The bright field lighting device consists of a surface light source and is installed in the direction of the camera's optical axis. S14. Rotate the stainless steel tube under dark lighting conditions and acquire a line scan image sequence under dark lighting conditions. The line scan image sequence corresponds one-to-one with the angular displacement pulse signal. S15. Rotate the stainless steel tube under bright field illumination conditions and acquire a line scan image sequence of the bright field illumination state, wherein the line scan image sequence corresponds one-to-one with the angular displacement pulse signal. S16. During the acquisition process, the angular displacement pulse signal, the line array camera row number and the lighting status are recorded synchronously to generate an image dataset containing the acquisition sequence, rotation angle and lighting information. S2 specifically includes: S21. Generate an angular displacement sequence index based on the angular displacement pulse signals in the image dataset. The index records the sequence number, timestamp, and line scan camera row number corresponding to each pulse. S22. Arrange the line scan images in the dark field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the line scan camera row number, and stitch them together to form a dark field cylindrical unfolded image. S23. Arrange the line scan images of the bright field illumination state in the circumferential direction according to the angular displacement order index, and accumulate them in the axial direction according to the row number of the line scan camera, and stitch them together to form a bright field cylindrical unfolded image. S24. Perform circumferential boundary stitching correction, missing row interpolation, and duplicate row removal on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image, and establish a cylindrical unfolded coordinate system with the circumferential direction as the horizontal direction and the axial direction as the vertical direction. S25. Perform brightness equalization processing on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, including background brightness estimation and local contrast limitation. S26. Construct a high-reflectivity candidate region mask based on the intensity difference between the dark field and the bright field, and perform reflection suppression processing on the high-reflectivity candidate region; S27. Establish an inspection-free mask, which calibrates the weld seam area and the coding area, and overlays it with the dark field cylindrical unfolded image and the bright field cylindrical unfolded image to obtain a preprocessed cylindrical unfolded image.

2. The method for detecting surface defects in stainless steel pipes according to claim 1, characterized in that, S3 specifically includes: S31. Spatial registration is performed on the dark field cylindrical unfolded image and the bright field cylindrical unfolded image respectively, and the image edge offset and angle error are corrected so that the pixel positions of the two images correspond to each other in the cylindrical unfolded coordinate system. S32. Perform grayscale normalization on the registered dark-field cylindrical unfolded image and bright-field cylindrical unfolded image in pixel coordinates to unify the grayscale distribution range. S33. Perform pixel-level weighted fusion at the corresponding pixel positions according to the preset weight coefficient to generate a fused cylindrical unfolded image; S34. Perform local adaptive smoothing processing on the fused cylindrical unfolded image to eliminate brightness abrupt changes in the illumination transition region; S35. Inherit the shielding information of the inspection-free mask and the high-reflectivity candidate region mask on the fused cylindrical unfolded image to obtain the shielded fused cylindrical unfolded image.

3. The method for detecting surface defects in stainless steel pipes according to claim 1, characterized in that, S4 specifically includes: S41. Establish a defect detection network based on the YOLO structure, wherein the defect detection network based on the YOLO structure includes an input layer, a backbone feature extraction layer, a feature fusion layer, and a detection head; S42. An improved Swin Transformer module is embedded in the backbone feature extraction layer. The improved Swin Transformer module adopts a hierarchical window attention structure to perform multi-layer convolution and window self-attention calculation on the input fused cylindrical unfolded image, extract feature maps at different scales, and simultaneously retain local texture information and cross-window global semantic features. S43. Perform window sliding operations within each level to establish cross-window feature associations; S44. In the improved Swing Transformer module, a cylinder unfolding perception attention mechanism is introduced. The cylinder unfolding perception attention mechanism establishes circumferential and axial position encoding based on cylinder coordinates, and performs cyclic mapping on the circumferential direction in the self-attention calculation to maintain the circumferential continuity of the cylinder unfolding image. S45. After channel alignment, the multi-scale feature maps output from each level are input into the convolutional layer of the YOLO backbone network to extract edge details and texture structure features.

4. The method for detecting surface defects in stainless steel pipes according to claim 1, characterized in that, S5 specifically includes: S51. Input the multi-scale feature map processed by the improved Swin Transformer module into the feature fusion layer of the YOLO network, perform upsampling and cross-layer concatenation operations on the feature maps of each layer, establish multi-scale feature connections from details to semantics, and form fused features. S52. Perform channel attention weighting and spatial feature reconstruction in the fusion features to align the axial and circumferential features of the cylinder unfolded image; S53. Calculate the local feature gradient in the fusion feature, wherein the local feature gradient characterizes the rate of change of the features of the cylinder unfolded image in the axial and circumferential directions; S54. Input the fused features into the detection head structure, wherein the detection head includes a main detection branch and a coordinate correction branch; S55. The main detection branch generates defect candidate bounding boxes, confidence scores, and category response maps through convolution operations. The category response maps correspond to different types of defect features on the surface of the stainless steel pipe. S56. The coordinate correction branch performs secondary position regression on the bounding box output by the main detection branch, calculates the defect edge morphology deviation based on the local feature gradient, and corrects the bounding box coordinates. S57. The training of the defect detection network based on the YOLO structure adopts a category-weighted configuration, and dynamic weights are assigned according to the proportion of each defect category in the samples. S58. Based on the combined output of the main detection branch and the coordinate correction branch, determine the final bounding box, confidence level, and category label of the defect.

5. The method for detecting surface defects in stainless steel pipes according to claim 1, characterized in that, S6 specifically includes: S61. Extract the corresponding region on the fused cylindrical unfolded image based on the bounding box coordinates in the detection results, and establish a detection box region set. S62. Input the detection box region set into the segmentation sub-network. The segmentation sub-network includes an encoding layer and a decoding layer. The encoding layer extracts multi-scale features, the decoding layer reconstructs pixel-level segmentation results, and outputs a semantic mask for each detection box region. S63. Perform multi-scale filtering and adaptive threshold segmentation on the fused cylindrical unfolded image to generate a grayscale mask, wherein the grayscale mask characterizes the changes in image brightness and differences in surface texture; S64. Perform weighted fusion of the semantic mask and the grayscale mask in pixel coordinates to form a joint mask. The weight ratio is determined based on the semantic segmentation confidence and the local grayscale gradient. S65. Perform connected component labeling, hole filling, and noise point removal on the joint mask to obtain a set of candidate defect regions; S66. Perform size screening and shape constraints on the candidate defect region set, remove regions smaller than the set area or that do not conform to the preset shape ratio, and generate the final defect mask.

6. The method for detecting surface defects in stainless steel pipes according to claim 1, characterized in that, Specifically, S7 includes: S71. Calculate the pixel area, perimeter, and minimum bounding rectangle size of the defect region in the defect mask, wherein the minimum bounding rectangle size includes the axial length and circumferential width of the defect. S72. Calculate the centroid coordinates within the defect area. The centroid coordinates are represented by a cylindrical coordinate system. The horizontal coordinates in the centroid coordinates correspond to the circumferential position, and the vertical coordinates correspond to the axial position. S73. Calculate the axial and circumferential lengths of the defect based on the camera pixel size, and convert the circumferential length into spatial arc length by combining it with the radius of the stainless steel pipe. S74. Using the unfolded coordinates of the defect centroid as a reference, calculate the spatial polar coordinates of the defect based on the angular displacement index of the fused cylindrical unfolded image to obtain the three-dimensional position parameters of the defect on the outer surface of the stainless steel tube. S75. Output the area, axial length, circumferential width, and spatial centroid coordinates of each defect to form a defect geometric feature set.

7. A stainless steel pipe surface defect detection system, comprising the stainless steel pipe surface defect detection method according to any one of claims 1 to 6, characterized in that, include: The image acquisition module is used to acquire line scan images of stainless steel pipelines under both dark and bright lighting conditions. The image stitching module is used to index and stitch the line scan images according to the angular displacement order, generate dark field cylindrical unfolded images and bright field cylindrical unfolded images, and perform brightness equalization and reflection suppression. The image fusion module is used to perform spatial registration and pixel-level weighted fusion on the dark-field cylindrical unfolded image and the bright-field cylindrical unfolded image to generate a fused cylindrical unfolded image. The feature extraction module is used to input the fused cylinder unfolded image into the YOLO network backbone with the integrated improved Swing Transformer module to extract multi-scale feature maps; The defect detection module is used to perform feature fusion and bounding box prediction on multi-scale feature maps, and output the bounding box, confidence score and category label of the defect; The defect segmentation module is used to perform semantic segmentation and grayscale segmentation in the detection box region and then perform weighted fusion to generate the final defect mask. The defect measurement module is used to calculate the area, length, width, and centroid coordinates of defects, and convert them into actual dimensions and spatial positions.

Citation Information

Patent Citations

  • Detection defect image fusion method based on multi-sensor fusion

    CN115100140A

  • Three-dimensional detection device and method for surface defects of large-aperture curved-surface optical element

    CN118882520A