A pipe defect detection method and system

By acquiring and processing polarization image sequences, and combining local standard deviation maps of polarization angles with structured light projection, reliable detection of defects in high-reflectivity pipes was achieved. This solved the problems of polarization failure and false detection of electrostatic particles in the detection of mirror-finish pipes, and improved detection accuracy and production line efficiency.

CN122244001APending Publication Date: 2026-06-19陕西昌升通特新材料科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
陕西昌升通特新材料科技有限公司
Filing Date
2026-04-28
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies fail to detect polarization when inspecting high-reflectivity pipe surfaces because the diffuse reflection component approaches zero, electrostatic adsorption of particles causes false detections, and structured light full-field projection has low efficiency, which cannot meet the real-time requirements of high-speed production lines.

Method used

By acquiring a sequence of polarization images of the pipe surface, a polarization feature image is synthesized. Based on the local standard deviation map of the polarization angle, candidate areas for static defects are screened. Structured light stripes are projected and a surface height map is generated to extract the real defect areas.

Benefits of technology

It enables reliable detection of defects such as tiny polishing marks and pinholes in mirror-finished pipes, eliminates interference from electrostatic adsorption particles, improves detection accuracy and production efficiency, avoids missed detections and false detections, and meets the real-time requirements of high-speed production lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122244001A_ABST
    Figure CN122244001A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for detecting defects in pipes, relating to the field of image analysis technology. The method includes the following steps: acquiring a sequence of polarized images of the pipe surface, preprocessing it to obtain a denoised polarized image sequence; synthesizing a polarization feature image based on the denoised polarized image sequence; and extracting candidate defect regions based on the polarization degree image. This invention effectively solves the problem in existing technologies where the diffuse reflection component of ultra-precision polished pipes such as mirror-finish stainless steel pipes and chrome-plated pipes is close to zero, resulting in completely black images or complete omission of noise and defects in the anti-glare enhancement image. It achieves reliable detection of minute polishing marks and pinholes in mirror-finished pipes. Furthermore, it eliminates Mie scattering interference caused by electrostatically adsorbed submicron-sized carbon particles under polarized light irradiation, and only performs structured light projection on the selected static defect candidate regions, significantly reducing computational resource consumption and meeting the real-time requirements of high-speed production lines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image analysis technology, and in particular to a method and system for detecting defects in pipes. Background Technology

[0002] In the production and inspection of metal pipes, coated pipes, and pipes with smooth inner walls, to achieve automated detection of surface defects in high-reflectivity pipes and ensure product quality, an adaptive imaging technology based on photometric stereo vision and dynamic exposure fusion is commonly used. The core principle of this technology is as follows: When constructing a light reflection model of the pipe surface, to eliminate the masking effect of specular reflection glare on minor defects, it is usually assumed that the pipe surface has sufficient diffuse reflection components to support the application of the Lambertian reflection model. This involves illuminating the pipe surface with a linearly polarized light source in a single direction, and using a split-focus plane polarization camera to acquire images of different polarization directions in a single exposure. Stokes parameters are then calculated to obtain polarization degree and polarization angle images, avoiding motion artifacts caused by time-division acquisition from multiple light sources. This allows for the synthesis of a diffuse reflection enhanced image that eliminates specular reflection components. Simultaneously, multi-exposure high dynamic range fusion technology is used to recover details in overexposed and underexposed areas. Finally, the glare-reduced enhanced image is fed into a deep learning network to complete defect identification. However, in actual industrial testing scenarios, the surface condition of pipes and environmental conditions often exhibit complex and variable characteristics. When the pipe surface undergoes ultra-precision polishing or electroplating to achieve a near-ideal mirror finish, such as mirror-finish stainless steel pipes and chrome-plated pipes, the surface produces almost no diffuse reflection. In images illuminated by light sources at any angle, only specular highlights and dark areas exist, and the diffuse reflection component is negligible. Since the aforementioned techniques rely on the Lambertian volume reflection model to analyze the diffuse reflection component, when the diffuse reflection component approaches zero, the equations for solving the normal vector from multi-angle images become ill-conditioned. The specular reflection separation algorithm based on the two-color reflection model completely fails, and the diffuse reflection enhanced image appears completely black or noisy, unable to reveal any surface texture or defect information. Furthermore, under dry climatic conditions, the friction between the pipe and the conveyor belt generates high-voltage static electricity, adsorbing submicron-sized carbon particles from the environment. These particles randomly adhere to the pipe surface and dynamically migrate with the centrifugal force of rotation. Existing polarization imaging schemes typically employ a time-division acquisition strategy. When dynamically migrating adsorbed particles are present on the pipe surface, the particle positions shift across different image frames, causing the same pixel coordinates to be aliased with polarization information from different particles. Stokes parameter calculations generate motion artifacts, and the measured values ​​of polarization degree and polarization angle cannot accurately reflect the polarization characteristics of the particles. Small particle clusters are misidentified as pinhole defects. For the inspection of mirror-finished pipes, structured light 3D measurement obtains surface height information by projecting coded stripes onto the pipe surface and analyzing the phase changes of deformed stripes. This technique does not rely on diffuse reflection components and is suitable for quantifying defect depth in mirror-finished pipes. However, existing structured light methods typically employ a uniform projection strategy across the entire field of view, projecting stripes of the same density onto the entire surface area of ​​the pipe. This results in a significant consumption of computational resources in defect-free, normal areas, leading to low detection efficiency and difficulty in meeting the real-time requirements of high-speed production lines. This issue directly and severely impacts the accuracy and production reliability of pipe defect detection systems: In mirror-finish pipe inspection scenarios, the system outputs completely black or noisy images, causing the subsequent defect detection network to fail completely, resulting in the missed detection of defects such as tiny polishing marks and pinholes; in electrostatic adsorption particle interference scenarios, the system continuously outputs a large number of false defect alarms, each false defect area being similar in size to a real pinhole, making it impossible for quality inspectors to distinguish them, forcing them to stop the machine for manual verification, leading to a decrease in production line efficiency. If defective pipes that are missed and enter the market, tiny pinholes in high-pressure gas pipeline applications may cause burst accidents; if real defects are mistakenly identified as dust and ignored, they will also create safety hazards. The above situations not only reduce the quality control level of pipe manufacturers, but also directly threaten the personal and property safety of people and property in pipeline usage scenarios, failing to meet the core requirements for defect detection accuracy and reliability under high-gloss pipe conditions and complex environmental conditions. Summary of the Invention

[0003] The purpose of this invention is to solve the problems of polarization detection failure when the diffuse reflection component of high reflectivity pipe surface approaches zero, false detection caused by particle interference, and low efficiency of structured light full-field projection in the prior art, and to propose a new pipe defect detection method and system.

[0004] To achieve the above objectives, the present invention employs the following technology: a method for detecting defects in pipes, characterized by comprising the following steps: A sequence of polarization images of the pipe surface is acquired and preprocessed to obtain a denoised polarization image sequence. A polarization feature image is synthesized based on the denoised polarization image sequence; Candidate defect regions are extracted based on the polarization degree image; the local standard deviation of each pixel is calculated based on the polarization angle image to generate a local standard deviation map of polarization angle. Based on the local standard deviation map of polarization angle and candidate defect regions, static defect candidate regions are selected. Based on each static defect candidate region, the fringe direction and exposure time of the structured light projection are determined. Based on the stripe direction and exposure time, structured light stripes are projected onto the static defect candidate region to acquire deformed stripe images. Based on the deformed stripe images, the absolute phase is obtained and converted into a surface height map. Based on the surface height map, the actual defect area is extracted and defect marking data is generated. Based on the defect marking data, the sorting mechanism is triggered to remove unqualified pipes.

[0005] Furthermore, based on each candidate region of static defects, the method for determining the fringe direction and exposure time of structured light projection includes: The fringe direction of the structured light projection is determined based on the average polarization angle direction of each static defect candidate region. The exposure time of structured light projection is determined based on the polarization degree value of the static defect candidate region.

[0006] Furthermore, the method for determining the fringe direction of structured light projection based on the average polarization angle direction of each static defect candidate region includes: Based on the boundary contours of each static defect candidate region, the pixel set of each candidate region is extracted, and the polarization angle values ​​of all pixels in the pixel set are calculated by arithmetic mean to obtain the average polarization angle direction value of each static defect candidate region. Based on the average polarization angle direction value of each static defect candidate region, a reference baseline perpendicular to the average polarization angle direction value is selected, and the angle difference between the reference baseline and the axial centerline of the pipe is calculated to obtain the stripe direction deflection angle of each static defect candidate region. The stripe direction deflection angle of each static defect candidate region is input to the drive controller of the projector. The drive controller adjusts the rotation angle of the sinusoidal stripe pattern on the digital micromirror according to the deflection angle value to generate a sinusoidal stripe projection sequence. Based on the sinusoidal fringe projection sequence, the phase gradient direction of each fringe is extracted, and it is determined whether the phase gradient direction is perpendicular to the average polarization angle direction of the corresponding static defect candidate region. If the angle between the phase gradient direction and the average polarization angle direction is perpendicular, then the rotation angle corresponding to the phase gradient direction is the projection fringe direction of the structured light projection.

[0007] Furthermore, methods for determining the exposure time of structured light projection based on the polarization degree values ​​of static defect candidate regions include: Obtain the pre-calibrated baseline exposure time and reference polarization value characterizing the standard polarization value of the normal mirror area when the camera acquires images in the normal mirror area; The arithmetic mean of the polarization values ​​of all pixels within each static defect candidate region is calculated to obtain the average polarization value of each static defect candidate region. Based on the reference polarization degree value and the average polarization degree, a ratio calculation is performed to obtain the polarization degree ratio of each static defect candidate region; Based on the polarization ratio of each static defect candidate region, a power operation is performed to obtain the exposure time adjustment coefficient for each static defect candidate region; The structured light projection exposure time for each static defect candidate region is calculated based on the baseline exposure time and exposure time adjustment coefficient for each static defect candidate region.

[0008] Furthermore, methods for extracting candidate defect regions based on polarization images include: Based on the polarization degree image, normalization processing is performed to obtain a normalized polarization degree image; Based on the normalized polarization degree image, calculate the local variance of grayscale for all pixels and generate a local variance map; The local variance value of each pixel in the local variance map is compared with a pre-defined second threshold. If the local variance value is less than the second threshold, the corresponding pixel is marked as a candidate seed point. Based on each candidate seed point, the initial set of connected regions is calculated; Based on the initial set of connected regions, the average polarization degree value of each initial connected region is calculated, and the average polarization degree value of each initial connected region is compared with a preset third threshold. If the average polarization degree value is not greater than the third threshold, the output initial connected region is the candidate defect region.

[0009] Furthermore, methods for generating a local standard deviation map of polarization angles by calculating the local standard deviation of each pixel based on the polarization angle image include: Based on the polarization angle image, a square local neighborhood window is established for each target pixel in the polarization angle image; The local mean is obtained by calculating the arithmetic mean of the polarization angle values ​​based on a local neighborhood window. The local variance is calculated based on the local mean. Based on the local variance, the square root operation is performed to obtain the local standard deviation value of the target pixel position; The local standard deviation value is assigned to the pixel position with the same coordinates as the target pixel in the output image. After traversing all pixels in the polarization angle image, the output image is the local standard deviation map of the polarization angle.

[0010] Furthermore, based on the local standard deviation map of polarization angle and candidate defect regions, methods for selecting candidate regions for static defects include: Based on the candidate defect region and the local standard deviation map of the polarization angle, the local standard deviation sequence of all pixels in the candidate defect region is extracted. Based on the local standard deviation sequence of each candidate defect region, the arithmetic mean is calculated to obtain the average local standard deviation of each candidate defect region. The average local standard deviation of each candidate defect region is compared with a preset first threshold; wherein the first threshold is determined by the lower limit of the local standard deviation distribution of polarization angle in the dynamic particle region on the pipe surface. If the average local standard deviation is less than the first threshold, the corresponding candidate defect region is output as a static defect candidate region; if the average local standard deviation is not less than the first threshold, the corresponding candidate defect region is removed.

[0011] Furthermore, based on the deformed fringe image, the absolute phase is obtained, and the method for converting the absolute phase into a surface height map includes: Based on the deformed stripe image, the phase-shifting method is used for demodulation to extract the wrapping phase value of each pixel; Based on the wrapper phase value of each pixel, a phase unrolling operation is performed to obtain the absolute phase of each pixel; Based on the absolute phase of each pixel and the preset reference plane absolute phase map, the absolute phase of each pixel is subtracted from the reference absolute phase of the corresponding pixel to obtain the phase difference value of each pixel; Based on the phase difference value of each pixel, a height conversion is performed to obtain the surface height value of each pixel; Arrange the surface height values ​​of all pixels according to the coordinates of the original image to obtain the surface height map.

[0012] Furthermore, methods for extracting the actual defect region and generating defect labeling data based on the surface height map include: Based on the surface height map, global threshold segmentation is performed on the surface height map to obtain pixels with abnormal height. Based on highly anomalous pixels, perform connected component analysis to obtain a set of highly anomalous regions; Based on the set of highly anomalous regions, multiple highly anomalous regions were obtained through filtering. For each retained height anomaly region, calculate the arithmetic mean of the height values ​​of all pixels within the height anomaly region to obtain the average defect depth of the height anomaly region, and compare the average defect depth with the preset depth alarm threshold. If the average defect depth exceeds the depth alarm threshold, the highly abnormal area is marked as a real defect area, and defect labeling data is generated for each real defect area. The defect marking data includes the set of boundary contour coordinates of the actual defect area, the average defect depth, and the maximum defect depth.

[0013] In summary, due to the adoption of the above-mentioned technology in the pipe defect detection method and system, the beneficial effects of this invention are: This invention synthesizes polarization degree and polarization angle images by acquiring a sequence of polarization images. It then uses a local standard deviation map of the polarization angle combined with candidate defect regions to screen for static defect candidate regions. Next, structured light stripes are projected onto these static defect candidate regions to generate surface height maps, ultimately extracting the actual defect regions. This scheme does not rely on diffuse reflection components, effectively solving the problem in existing technologies where the diffuse reflection component of ultra-precision polished pipes such as mirror-finish stainless steel pipes and chrome-plated pipes is close to zero, resulting in completely black images or complete missed detection of noise and defects in the anti-glare enhancement image. This enables reliable detection of minute polishing marks and pinholes in mirror-finished pipes. This invention generates a local standard deviation map of polarization angles by calculating the local standard deviation of each pixel based on a polarization angle image. Utilizing the physical characteristic that the local standard deviation of polarization angles in static defect regions is significantly smaller than that in dynamic particle regions, the average local standard deviation of candidate defect regions is compared with a first threshold to eliminate dynamic particle regions and filter out static defect candidate regions. This scheme eliminates Mie scattering interference caused by electrostatically adsorbed submicron-sized carbon powder particles under polarized light irradiation, solving the problems in existing technologies where dynamically migrating particles are misjudged as pinhole defect clusters and the system continuously outputs a large number of false defect alarms. This invention sets the structured light stripe direction perpendicular to the average polarization angle direction of the static defect candidate region, aligning the phase gradient direction with the direction of maximum defect depth change rate, thereby maximizing phase modulation sensitivity. Simultaneously, it maps the exposure time based on the power law of the polarization degree value of the static defect candidate region, extending the exposure time in weakly reflective areas to ensure stripe contrast and avoiding overexposure in strongly reflective areas. Compared to existing full-field uniform projection strategies, this invention only performs structured light projection on the selected static defect candidate regions, significantly reducing computational resource consumption and meeting the real-time requirements of high-speed production lines. Furthermore, the vertical mapping rule improves the depth measurement signal-to-noise ratio to the theoretical peak. This invention converts the absolute phase obtained from the deformation stripe image into a surface height map. It extracts height anomaly regions through global threshold segmentation and connected component analysis, calculates the average defect depth, and compares it with a depth alarm threshold. This generates defect marker data containing boundary contour coordinates, average defect depth, and maximum defect depth, triggering a sorting mechanism to reject substandard pipes. This solution automates the entire process from defect identification to depth quantification and automatic rejection, preventing undetected pipes from entering the market and causing high-pressure gas pipeline ruptures. It also eliminates the risk of misidentifying real defects as dust and ignoring them, significantly improving the quality control level of pipe manufacturers and the safety of personnel and property in pipeline usage scenarios. Attached Figure Description

[0014] Figure 1 A flowchart of the present invention is shown; Figure 2 A system block diagram of the present invention is shown. Detailed Implementation

[0015] The following will describe, with reference to the accompanying drawings of the embodiments of the present invention, a method and system for detecting pipe defects according to the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0016] To more clearly and intuitively demonstrate the practical application effects and advantages of the pipe defect detection method and system of the present invention, and to verify its feasibility and effectiveness, the present invention will be further described below in conjunction with embodiments. Through specific scenario simulations and data calculations, the system is explained in detail how it plays a role in actual pipe defect detection, helping readers to better understand the technical details and practical value of the invention. The present invention will be further described below in conjunction with embodiments;

[0017] Example 1: See Figure 1 A method for detecting defects in pipes, comprising the following steps: The polarization image sequence of the pipe surface under illumination from multiple angle light sources was collected, and preprocessed to obtain a denoised polarization image sequence. It should be noted that the methods for acquiring polarization image sequences of the pipe surface under illumination from multiple angles, and performing preprocessing to obtain denoised polarization image sequences include: When an industrial camera illuminates the surface of a pipe with multiple light sources from different angles in sequence, it captures a frame of original polarization image corresponding to each light source angle, thus obtaining a sequence of original polarization images. Dark current correction is performed on each frame of the original polarization image in the original polarization image sequence. The dark current correction operation is to subtract the black level image acquired by the camera under completely dark conditions to obtain the polarization image sequence after dark current correction. Based on the pixel grayscale value of each frame in the polarization image sequence after dark current correction, the neighborhood weighted average value of each pixel is calculated using the Gaussian kernel function to obtain the polarization image sequence after Gaussian filtering and denoising. Based on the spatial resolution of each frame in the polarization image sequence after Gaussian filtering and denoising, and combined with the gain parameters recorded by the camera sensor during acquisition, pixel response non-uniformity correction is performed to obtain the polarization image sequence after gain uniformity correction. Based on the gray values ​​of the same pixel coordinates in multiple consecutive frames of polarization image sequence after gain consistency correction, the median gray value of each pixel position is calculated to obtain a single-frame polarization image after median fusion. Based on the gray value of each pixel in the single-frame polarization image after median fusion, and combined with the reference gray range of the defect-free area on the pipe surface, abnormal pixel replacement is performed, replacing the abnormal pixels with the gray average of the adjacent normal pixels, thus obtaining each frame of the denoised polarization image sequence. The denoised polarization image sequence is arranged in order of light source angle to obtain a denoised polarization image sequence that corresponds one-to-one with multiple light sources at different angles. This sequence is used as input data for subsequent Stokes parameter calculation.

[0018] Specifically, this invention aims to eliminate motion artifacts introduced by dynamically migrating particles in polarization image sequence acquisition while preserving the physical meaning of polarization information. It employs a single-direction linearly polarized light source in conjunction with a focal plane polarization camera for single-exposure acquisition. The linearly polarized light source consists of a ring-shaped LED light panel and a linear polarizer covering it. Light emitted from all LEDs passes through the same linear polarizer to become illumination light with the same polarization direction. The image sensor surface of the focal plane polarization camera integrates a micro-nano polarization array, with each pixel corresponding to one of four polarization directions: 0°, 45°, 90°, and 135°, arranged periodically in a checkerboard pattern. During acquisition, all LEDs are lit, but the incident light polarization direction is consistent, allowing the focal plane polarization camera to acquire one frame of raw polarization image in a single exposure. This raw polarization image undergoes polarization de-mosaic processing. Based on the arrangement of the polarization array, pixels corresponding to the four polarization directions (0°, 45°, 90°, and 135°) are extracted, and four complete resolution sub-images of the polarization directions are reconstructed using an interpolation algorithm. Since the four sub-images originate from the same exposure and the incident light direction is unique, the calculation of Stokes parameters and polarization degree and polarization angle images has clear physical meaning. At the same time, the positions of the dynamic particles in each sub-image are completely consistent, and there is no motion offset. As a verification, submicron-sized carbon powder particles were artificially attached to the pipe surface and allowed to roll and migrate. Comparative experiments were conducted using a traditional time-division acquisition scheme and a single-shot acquisition scheme using a focal plane polarization camera, as described in this scheme. In the traditional scheme, the positional deviation of the migrating particles in different frames reached tens of pixels. The local standard deviation values ​​of the migrating particle region in the calculated local standard deviation map of the polarization angle overlapped with the local standard deviation values ​​of the actual static defect region, making effective differentiation impossible. In this scheme, the local standard deviation value of the polarization angle of the migrating particles in a single acquisition only reflects the random fluctuations in the polarization state caused by Mie scattering, and its value is significantly higher than that of the static defect region, thus achieving effective differentiation.

[0019] Based on the denoised polarization image sequence, the Stokes parameter of each pixel is calculated, and the polarization degree image and polarization angle image are synthesized based on the Stokes parameter to obtain the polarization feature image. This invention synthesizes polarization degree image and polarization angle image by acquiring polarization image sequence, without relying on diffuse reflection component. It effectively solves the problem in the prior art that the surface of ultra-precision polished pipes such as mirror stainless steel pipes and chrome-plated pipes is completely black or noise and defects are completely missed due to the diffuse reflection component approaching zero. This lays the foundation for the reliable detection of defects such as tiny polishing marks and pinholes in mirror pipes. Based on the polarization degree image, local variance analysis is performed to extract candidate defect regions; based on the polarization angle image, the local standard deviation of each pixel is calculated to generate a local standard deviation map of polarization angle. It should be noted that the methods for extracting candidate defect regions based on polarization images include: The polarization image is normalized by performing grayscale value normalization, which linearly maps the polarization value of each pixel to the range of zero to one, thus obtaining a normalized polarization image. On the normalized polarization degree image, a sliding window of fixed size is used to traverse each pixel, calculate the local variance of gray level of all pixels in the window, and assign the calculation result to the center pixel of the window to generate a local variance map. Before calculating the local variance map, a boundary mirroring operation is first performed on the normalized polarization image. Let the side length of the sliding window be W pixels, where W is an odd number and not less than three. The fill width is W minus one divided by two. For example, if the side length of the sliding window is nine pixels, this value is determined by statistically analyzing the correspondence between the minimum size of typical defects on the pipe surface and the image resolution, ensuring that the window size is less than half the minimum defect size, thus guaranteeing the sensitivity of local variance to defect edges. The mirroring is performed as follows: the pixel values ​​outside the upper boundary of the normalized polarization image are set to the pixel values ​​at the corresponding mirror positions inside the upper boundary. The lower, left, and right boundaries are treated similarly, and the four corner regions are obtained through two mirroring operations. After filling, the filled polarization image is obtained, with each side of the image size increased by twice the fill width compared to the original size. Then, on the filled polarization image, the center pixel of the sliding window only traverses the pixel positions within the range of the original image, and all pixels within the window are obtained from the filled image, ensuring that each original pixel position can obtain the complete set of window pixels, thereby calculating the effective local variance value; The local variance value of each pixel in the local variance map is compared with a pre-defined second threshold. The second threshold is determined by statistically analyzing the standard polarization fluctuation range of the defect-free area on the pipe surface. Pixels with local variance values ​​less than the second threshold are marked as candidate seed points. Starting with each candidate seed point, a four-connected region growth algorithm is used to merge adjacent pixels that are also marked as candidate seed points into the same connected component. This merging process is repeated until all candidate seed points are assigned to a connected component, thus obtaining the initial set of connected regions. Calculate the average polarization degree value of the pixels contained in each initial connected region in the initial connected region set, and compare the average polarization degree value with a preset third threshold, which is set to 0.3. Initial connected regions with average polarization values ​​higher than the third threshold are removed, while initial connected regions with average polarization values ​​less than or equal to the third threshold are retained. These retained regions are then output as candidate defect regions.

[0020] Specifically, methods for obtaining the initial set of connected regions using the four-connected region growing algorithm include: Push the growth starting point into the queue. When the queue is not empty, pop the first pixel and check the adjacent pixels in the four neighborhood directions of that pixel. If the label value of an adjacent pixel in the label map is zero, then calculate the absolute difference between the local variance value of the adjacent pixel in the local variance map and the average local variance value of the current growing region. If the absolute difference is less than the preset similarity tolerance threshold, then the label value of the adjacent pixel is set as the current connected region number and pushed into the queue; Repeat this process until the queue is empty. After growth is complete, the initial connected region is obtained. Based on all the initial connected regions, we obtain the set of initial connected regions.

[0021] Specifically, the similarity tolerance threshold is calibrated using the following method: Select pipe samples containing typical defects and manually mark the complete outline of the defect area; The polarization image sequence was acquired and the local variance map was calculated. Starting from different sets of candidate seed points, different similarity tolerance thresholds were used to conduct region growth experiments. The growth results were compared with manually annotated contours, and the integrity index of defect region extraction was calculated. The minimum tolerance value that achieves an integrity index of 95% or higher is selected as the similarity tolerance threshold. This calibration method ensures that pixels with local variance values ​​exceeding the second threshold within a defective region can be included in the same connected region through similarity criteria, thus preventing the defective region from being incorrectly split.

[0022] It should be noted that the methods for calculating the local standard deviation of each pixel based on the polarization angle image and generating a local standard deviation map of the polarization angle include: Obtain a polarization angle image. The gray value of each pixel in the polarization angle image represents the polarization angle of the light reflected from the surface at that location. The polarization angle value ranges from zero to one hundred and eighty degrees. For each target pixel in the polarization angle image, a square local neighborhood window is established with the target pixel as the center. The number of pixels on the side of the window is an odd number and not less than five. Within a local neighborhood window, collect the polarization angle values ​​of all valid pixels within the window, and calculate the arithmetic mean of these polarization angle values ​​to obtain the local mean. Using the local mean, the square of the difference between the polarization angle value of each effective pixel in the window and the local mean is calculated. The sum of all the squared values ​​is then divided by the total number of effective pixels in the window to obtain the local variance. The local standard deviation of the target pixel location is obtained by taking the square root of the local variance. The calculated local standard deviation value is assigned to the pixel position with the same coordinates as the target pixel in the output image. After traversing all pixels in the polarization angle image, the output image is the local standard deviation map of the polarization angle.

[0023] Specifically, polarization angles exhibit periodicity, and zero degrees and 180 degrees are physically equivalent. Directly calculating the arithmetic mean and standard deviation of polarization angle values ​​can lead to erroneous results due to numerical jumps at the boundaries of the angular period. For example, the actual physical difference between one degree and 179 degrees is only two degrees, but a direct subtraction yields 178 degrees. By using the unit vector method to map each polarization angle to a point on the unit circle, and eliminating the ambiguity caused by the angular periodicity through vector operations, the calculated local standard deviation can accurately reflect the dispersion of the polarization angle within its neighborhood. As an example, if a local neighborhood window contains two pixels with polarization angles of 1 degree and 179 degrees respectively, directly calculating their arithmetic mean yields 90 degrees, which differs from the actual directions of both angles by 90 degrees, resulting in a physical error. Using the unit vector method, the unit vectors corresponding to 1 degree are cosine 1 degree and sine 1 degree, and the unit vectors corresponding to 179 degrees are cosine 179 degrees and sine 179 degrees. The average of these two unit vectors is approximately zero, and the corresponding average angle is undefined. The Euclidean distances are 1 and 1, respectively, and the sum of the squares of 1 is 2. Dividing by 2 gives a local variance of 1, and taking the square root gives a local standard deviation of 1. This result correctly reflects the dispersion between two angles with opposite directions.

[0024] Specifically, the unit vector method, with a concrete example as follows: The unit vector method involves five layers: First, an input polarization angle image is used, where each pixel represents the polarization angle of the reflected light at that location. Second, a square local neighborhood window is created for each target pixel, containing the polarization angle values ​​of multiple pixels. Third, each polarization angle value within the window is converted into a unit vector. The conversion method involves determining a point on a unit circle with the angle value as the direction, where the x-coordinate is the cosine of the angle and the y-coordinate is the sine of the angle. Fourth, the average coordinate of all unit vectors within the window is calculated to obtain the average vector. The Euclidean distance between each unit vector and the average vector is then calculated, and the sum of the squares of these distances is divided by the total number of pixels within the window to obtain the local variance. Finally, the square root is taken to obtain the local standard deviation. Fifth, this local standard deviation is assigned to the corresponding pixel in the output image, and the entire image is traversed to obtain the local standard deviation map of the polarization angle. Training steps for the unit vector method: No training is required, but the window side length needs to be calibrated. Select pipe samples containing typical static defects and dynamic particles, and calculate the local standard deviation maps under different window side lengths. The optimal window side length is determined by maximizing the separation of the local standard deviation distributions between the dynamic particle region and the static defect region. The separation is defined as the ratio of the difference between the means and the sum of the standard deviations of the two regions. The window side length that maximizes the separation is selected through grid search and fixed for subsequent detection. Key parameters of the unit vector method: window side length, in pixels, odd number; precision of trigonometric function operations in unit vector conversion; square root operation in Euclidean distance calculation; The unit vector method takes polarization angle images as input data, with pixel values ​​ranging from angle values. Its output is a local standard deviation map of polarization angles, where pixel values ​​represent the degree of dispersion without units; larger values ​​indicate more chaotic local polarization angles. The unit vector method is used to distinguish between static defects and dynamic particles. Static defect regions exhibit regular polarization angle variations and small local standard deviations; dynamic particles, due to Mie scattering, cause random fluctuations in polarization angles, resulting in large local standard deviations. The output map serves as the basis for subsequent screening of candidate static defect regions. The unit vector mapping eliminates periodic boundary jumps in the input angle, ensuring that the local standard deviation accurately reflects the degree of angular dispersion. The output value is negatively correlated with the local consistency of the input angle. This setting is because polarization angles have periodic characteristics; zero degrees is equivalent to 180 degrees. Directly calculating the arithmetic mean and standard deviation would produce errors. The unit vector method, a standard method in directional statistics, guarantees the correctness of the physical meaning.

[0025] Based on the local standard deviation map of polarization angle and candidate defect regions, candidate defect regions with standard deviations less than the first threshold are marked as static defect candidate regions; It should be noted that the methods for selecting candidate regions for static defects based on the local standard deviation map of the polarization angle and the candidate defect region include: For each candidate defect region in the candidate defect region set, based on the set of pixel coordinates contained in the candidate defect region, the local standard deviation value of the corresponding coordinate position is extracted from the local standard deviation map of the polarization angle to obtain the local standard deviation value sequence of all pixels in the candidate defect region. The arithmetic mean of the local standard deviation values ​​for each candidate defect region is calculated to obtain the average local standard deviation value for each candidate defect region. The average local standard deviation of each candidate defect region is compared with a preset first threshold, which is determined by statistically analyzing the difference in the local standard deviation distribution between static defect regions and dynamic particle regions on the pipe surface. Candidate defect regions with average local standard deviation values ​​less than the first threshold are retained, while candidate defect regions with average local standard deviation values ​​greater than or equal to the first threshold are removed. These retained candidate defect regions are then output as static defect candidate regions.

[0026] Specifically, the calibration method for the first threshold is shown in the following example: Prepare pipe samples containing normal mirror areas, known static defect areas, and dynamic particle areas; acquire polarization image sequences and synthesize polarization angle images. In the dynamic particle region, calculate the local standard deviation of the polarization angle at each pixel location, statistically analyze the distribution of the local standard deviations of all dynamic particle regions, and take the fifth percentile of this distribution as the first threshold. This calibration method ensures that the local standard deviation of more than 95% of dynamic particle regions is greater than the first threshold, thus being eliminated during screening. At the same time, the local standard deviation of static defect regions and normal mirror regions is less than the first threshold, and they are retained in the static defect candidate region. The particle size, material and environmental conditions in the actual production line may differ from the calibration sample. It is recommended to periodically recalibrate the first threshold or combine it with polarization information for joint judgment to improve accuracy.

[0027] This invention generates a local standard deviation map of polarization angles by calculating the local standard deviation of each pixel based on a polarization angle image. Utilizing the physical characteristic that the local standard deviation of polarization angles in static defect regions is significantly smaller than that in dynamic particle regions, the average local standard deviation of candidate defect regions is compared with a first threshold to eliminate dynamic particle regions and filter out static defect candidate regions. This scheme eliminates Mie scattering interference caused by electrostatically adsorbed submicron-sized carbon powder particles under polarized light irradiation, solving the problems in existing technologies where dynamically migrating particles are misjudged as pinhole defect clusters, the system continuously outputs a large number of false defect alarms leading to shutdowns for manual verification, and reduced production line efficiency.

[0028] The fringe direction of the structured light projection is determined based on the average polarization angle direction of each static defect candidate region, and the exposure time of the structured light projection is determined based on the polarization degree value of the static defect candidate region. It should be noted that the specific mapping relationship between the local standard deviation map of the polarization angle and the structured light projection parameters is designed, as shown in the following example: The local standard deviation map of polarization angle is used to guide three key parameters of structured light projection: spatial priority, fringe direction, and exposure time. This mapping relationship is not a conventional choice for those skilled in the art. In existing technologies, structured light projection typically uses a fixed fringe direction, such as horizontal fringe, or an empirical direction based on the object's geometry; exposure time is usually determined through global automatic exposure or based on the average image brightness; and the spatial projection range is typically a full-field scan or coarse positioning based on pre-scanning. The specific mapping proposed in this solution from the local standard deviation map of polarization angle to spatial priority, from the average polarization angle to the fringe direction, and from the degree of polarization value to the exposure time requires justification for its rationality and non-obviousness from both physical principles and experimental verification perspectives. The physical basis for setting the stripe direction perpendicular to the average polarization angle direction. In polarization imaging, the polarization angle at a point on a surface is determined by the polarization direction of the reflected light at that point. For metal surfaces, the polarization angle is related to the incident plane. When there are minute defects on the surface, such as scratches or pits, the microscopic geometry of the defect region changes the distribution of the local surface normal vector, causing a deflection of the polarization direction of the reflected light. Experimental studies show that there is a perpendicular constraint relationship between the major axis direction of slender scratch-like defects and the average polarization angle direction of the defect region. The specific physical mechanism is as follows: When linearly polarized light shines on a metal surface, the polarization direction of the specular reflected light is mainly parallel to the incident plane. The surface normal vector at the edge of the scratch undergoes a sudden change, forming a new local incident plane. The major axis direction of the scratch is perpendicular to the principal direction of the edge normal vector. Through extensive experimental statistics, the average polarization angle direction of the scratch region is basically parallel to the major axis direction of the scratch, with an error within ten degrees. This relationship has been confirmed by relevant literature. To further demonstrate the optimizing effect of the vertical mapping rule on the signal-to-noise ratio of depth measurement, a quantitative derivation is performed based on Fresnel reflection theory and the principle of structured light phase modulation. For a metal surface, the polarization direction of the reflected light is determined by both the incident plane and the surface normal vector. When scratch-like defects exist on the surface, the surface normal vector in the defect region is deflected. Let the deflection angle be delta, then there is a linear relationship between the change in the polarization angle of the reflected light and the deflection angle of the normal vector, with the proportionality coefficient determined by the complex refractive index of the metal. Simultaneously, the phase change of the structured light fringes is most sensitive to the height gradient of the object's surface along the direction perpendicular to the fringe, and the phase gradient amplitude is proportional to the cosine value of the fringe direction. Assume the long axis of the scratch is parallel to the direction of the average polarization angle, and the direction of the maximum depth change rate of the scratch is perpendicular to the long axis of the scratch. If the fringe direction is set to have an angle of cesta with the direction of the average polarization angle, then the angle between the phase gradient direction and the direction of the maximum depth change rate is 90 degrees minus cesta, and the phase modulation sensitivity is proportional to the sine value of this angle. When the Sita equals zero degrees (i.e., the fringe direction is parallel to the average polarization angle), the phase gradient direction is perpendicular to the direction of maximum depth change rate, the phase modulation sensitivity is zero, and the defect is unmeasurable. When the Sita equals ninety degrees (i.e., the fringe direction is perpendicular to the average polarization angle), the phase gradient direction is parallel to the direction of maximum depth change rate, the phase modulation sensitivity reaches its maximum value, and the depth measurement signal-to-noise ratio reaches its theoretical peak. In conventional techniques, the fringe direction is usually set empirically to be horizontal or vertical, or based on the macroscopic geometry of the object, without considering the polarization characteristics of the defect region. This scheme demonstrates through the above quantitative relationship that a deviation from a ninety-degree angle will cause the phase modulation sensitivity to decrease sinusoidally. For example, when the angle is forty-five degrees, the sensitivity is only 0.707 times the maximum value, equivalent to a decrease in depth measurement signal-to-noise ratio of about three decibels. When the angle is thirty degrees, the sensitivity drops to 0.5 times, and the signal-to-noise ratio decreases by about six decibels. Therefore, the signal-to-noise ratio gain brought by the vertical mapping rule is significant and quantifiable, and cannot be achieved through conventional selection; the comparison with conventional selection further verifies the non-obviousness of this mapping rule. Conventional Option 1 uses a fixed horizontal stripe direction, parallel to the axial centerline of the pipe. The long axis of scratch-like defects on the pipe surface is usually at a random angle to the axial centerline; therefore, the probability of the fixed horizontal stripe direction being perpendicular to the average polarization angle direction is only 50% of a random event, and the average phase modulation sensitivity is only 0.636 times the maximum value. Conventional Option 2 uses an active adjustment method based on the defect's long axis direction, but this requires additional image analysis steps, and the parallelism between the defect's long axis direction and the average polarization angle direction needs to be verified. This solution directly utilizes the directional information contained in the polarization angle image, eliminating the need for additional detection of the defect's long axis direction, and achieving optimal sensitivity through vertical mapping. This technical approach skips the intermediate step of detecting the defect's long axis direction, reducing computational overhead, and avoiding the propagation and amplification effect of defects in the long axis direction detection. Meanwhile, in structured light 3D measurement, the phase change of the projected sinusoidal fringes is most sensitive to the height gradient of the object surface along the direction perpendicular to the fringes. When the fringe direction is perpendicular to the height change direction of the object surface, the phase modulation amplitude is the largest, and the depth measurement signal-to-noise ratio is the highest. For scratch-type defects, the direction of the largest height change is perpendicular to the long axis of the scratch, i.e., the depth direction of the scratch. Therefore, to maximize the sensitivity of scratch depth measurement, the structured light fringe direction should be perpendicular to the long axis of the scratch, i.e., perpendicular to the average polarization angle direction of the scratch region. Combining the above two physical laws, the core mapping rule of this scheme is obtained: set the structured light fringe direction to be perpendicular to the average polarization angle direction of the defect candidate region. The physical basis of this mapping relationship can be further derived through Fresnel formula and phase modulation theory. For metal surfaces, the polarization state of reflected light is determined by the Fresnel reflection coefficient. The scratch region can be regarded as a tiny wedge structure, and there is a positive correlation between its depth change rate and polarization angle change rate. Setting the fringe direction to be perpendicular to the average polarization angle direction is equivalent to aligning the phase gradient direction of the fringe with the direction of the largest depth change rate, thereby obtaining the optimal phase calculation sensitivity; Regarding the mapping relationship between polarization degree and exposure time: Polarization degree reflects the proportion of linearly polarized components in reflected light. For metal surfaces, polarization degree is related to surface roughness, incident angle, and material. In defect areas, due to the destruction of the surface microstructure, diffuse reflection and depolarization effects occur, significantly reducing the polarization degree. Simultaneously, the lower the polarization degree, the weaker the light intensity reflected back to the camera from that area, and the lower the signal-to-noise ratio of the structured light fringes. To ensure sufficient fringe contrast in weakly reflective areas while avoiding overexposure in strongly reflective areas, the camera's exposure time needs to be dynamically adjusted based on the polarization degree value of the candidate defect area. The mapping rule used in this scheme is: the adjusted exposure time equals the reference exposure time multiplied by the power of the ratio of the reference polarization degree value to the average polarization degree value of the candidate area. The reference exposure time is obtained through calibration and is applicable to the standard polarization degree value of normal mirror areas; the typical reference polarization degree value is 0.8, representing the polarization degree of normal mirror areas; the exponent is between 0.5 and 1.0, with 0.8 being preferred in this scheme. The physical basis of this mapping rule is that the reflected light intensity is proportional to the exposure time. When the average polarization degree value of the candidate region is small, it means that the diffuse reflection component accounts for a higher proportion, the specular reflection component is lower, and the total reflected light intensity is weaker. To obtain the same stripe contrast, the exposure time needs to be extended proportionally. The introduction of the power exponent is to avoid overexposure: when the polarization degree value is extremely low, if linear mapping is used, the exposure time extension factor is too large, which may introduce motion blur; using a power exponent of 0.8 can achieve a balance between signal-to-noise ratio and motion blur. Regarding the mapping relationship of spatial priority, the local standard deviation of the polarization angle reflects the dispersion of the polarization angle within a local region. For dynamic particle regions, the polarization angle fluctuates randomly, resulting in the largest local standard deviation. For static defect regions, although the polarization angle deflects overall relative to the normal mirror region, the direction of deflection exhibits spatial regularity within the defect region, with the next largest local standard deviation. For defect-free normal mirror regions, the polarization angle distribution is the most uniform, with the smallest local standard deviation. Therefore, the local standard deviation of the polarization angle alone cannot distinguish between static defect regions and normal mirror regions; a combined judgment based on the degree of polarization is necessary. This scheme defines the spatial priority score function for defect candidate regions as follows: the spatial priority score equals the reciprocal of the average degree of polarization value of the region multiplied by the average local standard deviation value of the region.

[0029] The spatial priority scoring function is a parameterless model that requires no training. The first layer takes a static defect candidate region as input. The second layer extracts the polarization degree values ​​of all pixels in the region from the polarization degree image and calculates the arithmetic mean to obtain the average polarization degree value. The third layer extracts the local standard deviation values ​​of all pixels in the region from the local standard deviation map of the polarization angle and calculates the arithmetic mean to obtain the average local standard deviation value. The fourth layer calculates the reciprocal of the average polarization degree value. The fifth layer multiplies the reciprocal by the average local standard deviation value to obtain the spatial priority score. The sixth layer sorts the scores from highest to lowest and performs structured light projection sequentially, skipping projection of regions with scores below a preset threshold.

[0030] This spatial priority score is used to allocate structured light projection resources. Only regions that simultaneously meet the criteria of low polarization degree and small local standard deviation of polarization angle can receive a high score. Low polarization degree indicates weak reflected light, suggesting a high probability of defects; a small local standard deviation of polarization angle indicates a regular polarization angle variation, suggesting static defects rather than dynamic particles. Operationally, priority should be given to detecting regions most likely to be actual defects to improve detection efficiency.

[0031] The smaller the average polarization degree value in the input data, the larger its reciprocal, and the higher the score; the smaller the average local standard deviation value, the higher the score. Multiplying the two implements an AND logic, meaning that normal polarization degree or large local standard deviation will cause the score to approach zero; this setting is because the weighted sum form is easily dominated by a single feature and misjudged, while the product form forces both features to be satisfied simultaneously, which is more in line with the physical nature of static defects and avoids dynamic particles or normal regions being mistakenly assigned high priority; In this spatial priority scoring function, a smaller average polarization degree value indicates weaker reflected light intensity and a higher probability of being a defect; its reciprocal is used as a weight to amplify the score. A larger average local standard deviation value indicates more significant polarization angle fluctuations. In candidate regions that have passed the first threshold screening, a larger average local standard deviation is more likely to indicate the presence of static defects. Therefore, a higher score value indicates a higher probability that the region belongs to a static defect, and structured light projection is performed sequentially from highest to lowest score. Regions with scores lower than a preset threshold are skipped from projection. This mapping relationship is significantly different from the full-field projection or spatial selection based on grayscale variance in existing technologies. Existing technologies cannot use the joint information of polarization angle and polarization degree to quantify the defect probability. This solution uses this scoring function to achieve priority ranking and dynamic allocation of structured light projection resources, minimizing the amount of data for structured light projection while ensuring that no defects are missed. It is important to further clarify that the product-based scoring function used in this scheme differs fundamentally from the conventional weighted sum-based scoring function. The weighted sum-based scoring function is defined as the first weight multiplied by the reciprocal of the local standard deviation of the polarization angle, plus the second weight multiplied by the difference between the polarization degree and the first weight. Its physical characteristic is that a high score is obtained when either feature value performs exceptionally well. For example, if a region has extremely poor polarization angle consistency but extremely low polarization degree, the weighted sum-based function may still give a high score, leading to the incorrect allocation of high priority to dynamic particle regions. In contrast, in the product-based scoring function, the local standard deviation of the polarization angle appears in the denominator, and the polarization degree appears in the subtrahend. Only when both conditions are simultaneously met—that is, a small local standard deviation and a low polarization degree—will the score be significantly higher than zero; if either condition is not met, the score approaches zero. This product-based form achieves fusion judgment with logic, strictly adhering to the requirement that static defect candidate regions must simultaneously possess both good polarization angle consistency and low polarization degree. Those skilled in the art, when facing multi-feature fusion, prefer the weighted sum-based form because its mathematical processing is simple and the weights are adjustable. This solution breaks with conventional choices, employing a product-based approach and achieving a level of purity that weighted sum methods cannot reach. Specifically, dynamic particle regions score close to zero due to excessively large local standard deviations in polarization angles, and normal mirror regions score close to zero due to excessively high polarization values; only static defect regions achieve significantly high scores. This technical effect cannot be achieved by simply adjusting the weighting parameters of a weighted sum, resulting in unexpected technical benefits. The non-obviousness of the above mapping relationship is reflected in the following aspects. First, the innovative mapping across physical quantities. In existing technologies, the direction of structured light fringes is usually set according to the geometry of the object or experience, the exposure time is set according to the global brightness, and the spatial priority is set according to grayscale or edge information. This scheme establishes a direct physical mapping relationship between the average polarization angle direction and the fringe direction, the polarization degree value and the exposure time, and the local standard deviation of the polarization angle and the polarization degree, and the spatial priority, which belongs to cross-domain parameter coupling between different physical domains. Second, the physical counterintuitiveness of the perpendicular mapping. It is generally believed that structured light fringes should be perpendicular to the long axis of the defect to maximize depth sensitivity, while the polarization angle direction is parallel to the long axis of the defect. Setting the fringe direction to be perpendicular to the average polarization angle direction is equivalent to indirectly realizing that the fringes are perpendicular to the long axis of the defect. This indirect mapping path requires a deep understanding of both polarization optics and structured light measurement principles, and requires experimental verification of the correlation between the two, which is not a conventional technical means. Third, the originality of the joint scoring function. The scoring function uses a product form, which means that a high score is achieved only when both conditions are met simultaneously: good polarization angle consistency and low polarization degree. Failure to meet either condition will cause the score to approach zero. This product-based fusion with logic has unique advantages in defect detection, while those skilled in the art, when faced with multi-feature fusion, prefer a weighted summation form rather than a product form. In summary, the specific mapping relationship between the local standard deviation map of the polarization angle and the structured light projection parameters proposed in this scheme, including the average polarization angle mapping the fringe direction perpendicular to the polarization degree, the power-law mapping the exposure time, and the joint score product mapping the spatial priority, has clear physical basis and experimental verification. Furthermore, it differs from the conventional choices in existing technologies, exhibiting both non-obviousness and significant technical effects. These mapping relationships collectively constitute the core innovation of this scheme.

[0032] Specifically, methods for determining the fringe direction of structured light projection based on the average polarization angle direction of each static defect candidate region include: The pixel set of each candidate region is extracted based on the boundary contour of each static defect candidate region. The arithmetic mean of the polarization angle values ​​of all pixels in the pixel set is calculated to obtain the average polarization angle direction value of each static defect candidate region. Based on the average polarization angle direction value of each static defect candidate region, a straight line perpendicular to the average polarization angle direction value is selected within the region as a reference baseline. The angle difference between the reference baseline and the axial centerline of the pipe is calculated to obtain the stripe direction deflection angle of each static defect candidate region. The stripe direction deflection angle of each static defect candidate region is input to the digital micromirror drive controller of the projector. The drive controller adjusts the rotation angle of the sinusoidal stripe pattern on the digital micromirror according to the deflection angle value to generate a rotated sinusoidal stripe projection sequence. Based on the phase gradient direction of each fringe in the rotated sinusoidal fringe projection sequence, the perpendicular relationship between this direction and the average polarization angle direction of the corresponding static defect candidate region is verified. When the angle between the two is 90 degrees, the rotation angle is locked as the projection fringe direction of the structured light projection. The projection fringe direction of the locked structured light projection is bound and stored with the spatial coordinates of the static defect candidate region. During the structured light projection execution phase, the corresponding fringe direction is called according to the bound spatial coordinates for projection.

[0033] Specifically, methods for determining the exposure time of structured light projection based on the polarization degree value of static defect candidate regions include: The reference exposure time pre-calibrated when the camera acquires images in the normal mirror area and the reference polarization value characterizing the standard polarization value of the normal mirror area are obtained. The reference polarization value is 0.8. The polarization degree values ​​of all pixels in each static defect candidate region are extracted from the polarization degree image, and the arithmetic mean of these polarization degree values ​​is calculated to obtain the average polarization degree value of each static defect candidate region. Using the reference polarization degree value as the numerator and the average polarization degree value of each static defect candidate region as the denominator, a ratio calculation is performed to obtain the polarization degree ratio of each static defect candidate region. The polarization ratio of each static defect candidate region is raised to a power, with the power exponent being 0.8. The result is used as the exposure time adjustment coefficient for each static defect candidate region. The structured light projection exposure time for each static defect candidate region is obtained by multiplying the baseline exposure time of each static defect candidate region by the corresponding exposure time adjustment factor. The structured light projection exposure time of each static defect candidate area is bound to the spatial coordinates of that area and stored. During the structured light projection execution phase, the corresponding exposure time is called according to the spatial coordinates of the current projection area to set the camera parameters.

[0034] Specifically, the choice of a power exponent of 0.8 is based on the following theoretical derivation and experimental verification, as shown in the example below: Let the baseline exposure time be Tbase, the reference polarization degree be Dreference, and the average polarization degree of the candidate region be Dcandidate. The adjusted exposure time Tadjustment satisfies the relationship Tadjustment equals Tbase multiplied by Dreference divided by Dcandidate raised to the power of K, where K is the power of the exponent. A larger extension of the exposure time results in a higher stripe contrast signal-to-noise ratio in the weakly reflective region, but excessively long exposure times introduce motion blur, leading to phase measurement errors. The signal-to-noise ratio gain function is defined as G, which equals Dreference divided by Dcandidate raised to the power of K. The motion blur cost function is defined as M, which equals K multiplied by Tbase multiplied by Dreference divided by Dcandidate raised to the power of K, multiplied by the ratio of pipe transport speed to pixel resolution. The joint cost function is negative G plus a weighting coefficient multiplied by M. Under typical detection parameters, the pipe transport speed is 0.5 m / s, the camera resolution is 5 pixels per millimeter, and the weighting coefficient is 0.1. By differentiating the joint cost function and solving for the optimal K value, the optimal K value is found to be 0.79. Considering the differences in parameters between different production lines, the value of K ranges from 0.6 to 0.9, with 0.8 being the generally recommended value. Furthermore, this solution provides an adaptive calibration method for power exponents. During the pipe production line startup phase, standard test pipes are sent to the inspection station. The surface of the test pipes has multiple calibration areas with known polarization values. The initial value of the power exponent is set to 0.5, gradually increasing to 1.0 in increments of 0.01. For each power exponent, structured light fringe images of each calibration area are acquired, and the fringe contrast signal-to-noise ratio and phase error are calculated. The power exponent that results in a signal-to-noise ratio greater than 30 decibels for all calibration areas and minimizes the maximum phase error is selected as the optimal value for the production line. After calibration, this value is stored in the system configuration file for subsequent inspection. This calibration method ensures that the optimal exposure time adjustment coefficient can be obtained for inspection scenarios with different transmission speeds and pipe materials.

[0035] This invention sets the structured light stripe direction perpendicular to the average polarization angle of the static defect candidate region, aligning the phase gradient direction with the direction of maximum defect depth change rate, thereby maximizing phase modulation sensitivity. Simultaneously, it uses a power-law mapping of the polarization degree value of the static defect candidate region to map the exposure time, extending the exposure time in weakly reflective areas to ensure stripe contrast and avoiding overexposure in strongly reflective areas. Compared to existing full-field uniform projection strategies, this invention only projects structured light onto the selected static defect candidate regions, significantly reducing computational resource consumption and meeting the real-time requirements of high-speed production lines. Furthermore, the vertical mapping rule improves the depth measurement signal-to-noise ratio to its theoretical peak.

[0036] Based on the fringe direction and exposure time of structured light projection, structured light fringes are projected onto the static defect candidate area on the pipe surface, deformed fringe images are acquired, the wrapping phase is calculated and unfolded based on the deformed fringe images, the absolute phase is obtained, and the absolute phase is converted into a surface height map. It should be noted that, based on the deformed fringe image, the wrapped phase is calculated and unfolded to obtain the absolute phase. The method for converting the absolute phase into a surface height map includes: The deformed stripe image is obtained by the camera after the projector projects structured light stripes onto the static defect candidate area. The gray value of each pixel in the deformed stripe image changes sinusoidally due to the height modulation of the pipe surface. The phase-shifting method is used to demodulate the deformed stripe image and extract the wrapping phase value of each pixel. The wrapping phase value is restricted to the principal value range from negative π to π. The phase expansion operation is performed on the wrapper phase value of each pixel by using the multi-frequency heterodyne method or the spatial phase expansion algorithm to eliminate the two-way ambiguity in the wrapper phase and obtain the absolute phase of each pixel. Obtain a pre-defined absolute phase map of a reference plane. The reference plane absolute phase map represents the absolute phase distribution obtained by collecting and unfolding the data under the condition that there are no defects on the surface of a standard flat pipe. The absolute phase of each pixel is subtracted from the reference absolute phase of the corresponding pixel in the absolute phase map of the reference plane to obtain the phase difference value of each pixel; Based on the pre-calibrated phase height mapping relationship, the phase difference value of each pixel is converted into the corresponding surface height value. The phase height mapping relationship is determined by the triangulation principle combined with the geometric parameters of the projector and the camera. Arrange the surface height values ​​of all pixels according to the original image coordinates to generate a surface height map. The gray value of each pixel in the surface height map represents the height value of that position relative to the reference plane.

[0037] Based on the surface height map, areas with height values ​​exceeding the safety threshold are extracted as actual defect areas, and defect marking data is generated. Based on the defect marking data, the sorting mechanism is triggered to remove unqualified pipes.

[0038] It should be noted that the methods for extracting the actual defect region and generating defect marker data based on the surface height map include: Obtain the generated surface height map, where the grayscale value of each pixel in the surface height map represents the height of that position on the pipe surface relative to the reference plane; Global threshold segmentation is performed on the surface height map. The height value of each pixel is compared with a preset safety threshold. The safety threshold is determined by statistically analyzing the upper limit of the height fluctuation range of the surface of defect-free pipes. Pixels with height values ​​exceeding the safety threshold are retained as height abnormal pixels. Perform connected component analysis on the pixels with height anomalies, and use the eight-connected neighborhood rule to merge adjacent pixels with height anomalies into the same connected component. Repeat this merging process until all pixels with height anomalies are assigned to a connected component, and obtain a set of height anomaly regions. Calculate the total number of pixels contained in each height abnormal region in the set of height abnormal regions, and compare the total number of pixels with the preset minimum defect area threshold. The minimum defect area threshold is calculated based on the minimum defect size allowed in the pipe defect acceptance standard. Remove height abnormal regions with a total number of pixels lower than the minimum defect area threshold. For each retained height anomaly region, calculate the arithmetic mean of the height values ​​of all pixels in that region to obtain the average defect depth of that region, and compare the average defect depth with the preset depth alarm threshold. Highly abnormal regions with average defect depth exceeding the depth alarm threshold are retained and marked as real defect regions. Defect labeling data is generated for each real defect region, which includes the set of boundary contour coordinates, average defect depth, and maximum defect depth of the real defect region.

[0039] This invention converts the absolute phase obtained from the deformation stripe image into a surface height map. It extracts height anomaly regions through global threshold segmentation and connected component analysis, calculates the average defect depth, and compares it with a depth alarm threshold. This generates defect marker data containing boundary contour coordinates, average defect depth, and maximum defect depth, triggering a sorting mechanism to reject substandard pipes. This solution automates the entire process from defect identification to depth quantification and automatic rejection, preventing undetected pipes from entering the market and causing high-pressure gas pipeline ruptures. It also eliminates the risk of misidentifying real defects as dust and ignoring them, significantly improving the quality control level of pipe manufacturers and the safety of personnel and property in pipeline usage scenarios.

[0040] It should be noted that the origin and derivation of the unit vector method are illustrated in the following example: In this scheme, the local standard deviation of the polarization angle is calculated using the unit vector method to eliminate numerical jumps caused by the periodic boundaries of the angle. This method originates from directional statistics, also known as circular statistics theory, which specifically deals with periodic angle data. In directional statistics, a set of angles cannot be directly averaged. Instead, each angle is first mapped to a point on a unit circle, its coordinates consisting of the cosine and sine values ​​of the angle. Then, the arithmetic mean of the coordinate vectors of these points is calculated to obtain the coordinates of the average vector. Finally, the average angle is obtained using the arctangent function. The local standard deviation is defined as the root mean square of the Euclidean distance between the unit vector corresponding to each angle and the average vector. This scheme applies this classical method directly without modification. In the specific calculation, for each target pixel in the polarization angle image, a square local neighborhood window is established centered on that pixel. The polarization angle of each pixel within the window is converted into a unit vector. The average coordinate of all unit vectors is calculated, and then the Euclidean distance between each unit vector and the average vector is calculated. The squares of all Euclidean distances are summed and divided by the number of pixels within the window. Finally, the square root is taken to obtain the local standard deviation of the pixel location. In this calculation process, after the angle is converted into a unit vector, the dimensions disappear, and only the numerical calculation is retained, thus ensuring dimensional consistency. The core relationship for determining the exposure time of structured light projection based on polarization degree values ​​is illustrated in the following example: The adjusted exposure time is equal to the power of the ratio of the reference polarization value to the average polarization value of the candidate region, multiplied by the baseline exposure time. This relationship originates from the exposure formula in optical imaging, where image brightness is directly proportional to exposure time and the intensity of reflected light from the object's surface. For metal surfaces, there is a negative correlation between reflected light intensity and polarization degree; the lower the polarization degree, the higher the proportion of diffuse reflection, and the lower the specular reflection component, the weaker the total reflected light intensity. This scheme models this negative correlation as a power-law mapping, where the exposure time extension factor and the polarization degree ratio are power functions. The introduction of the power exponent aims to achieve sufficient signal-to-noise ratio in weakly reflective regions while avoiding overexposure that leads to motion blur. The optimal value of this exponent is derived by constructing a joint cost function: the signal-to-noise ratio gain function is defined as the power of the polarization degree ratio; the motion blur cost function is defined as the product of the exposure time extension factor, the pipe transmission speed, and the camera resolution; and the joint cost function is the sum of the negative of the signal-to-noise ratio gain and the weighted motion blur cost. By differentiating the joint cost function and setting the derivative to zero, the optimal power exponent is found to be approximately 0.8. In a specific calculation embodiment, assuming the baseline exposure time is 10 milliseconds, the reference polarization degree is 0.8, and the average polarization degree of a certain static defect candidate region is 0.2, then the polarization degree ratio is 0.8 divided by 0.2 equals 4. 4 to the power of 0.8 is approximately equal to 3. Therefore, the adjusted exposure time is 10 milliseconds multiplied by 3 equals 30 milliseconds. If the average polarization degree of another candidate region is 0.6, then the ratio is 1.33. 1.33 to the power of 0.8 is approximately equal to 1.26, and the exposure time is adjusted to 12.6 milliseconds. In this calculation process, the dimension of the exposure time is time units, while the polarization degree is dimensionless, the ratio is dimensionless, and the power operation remains dimensionless; therefore, the dimensions are consistent. An example of a spatial priority scoring function for static defect candidate regions is shown below: The product of the reciprocal of the average polarization degree value and the average local standard deviation is calculated. This function originates from the multi-feature fusion theory in defect detection, and its physical meaning is that only regions that simultaneously satisfy both low polarization degree and small local standard deviation of the polarization angle receive high scores. The reciprocal of the average polarization degree value reflects the intensity of reflected light in the region; the lower the polarization degree, the larger the reciprocal, indicating a higher probability that the region is a defect. The average local standard deviation reflects the dispersion of the polarization angle within the region. Static defect regions exhibit a regular polarization angle distribution with relatively small dispersion, while dynamic particle regions show random fluctuations and larger dispersion. Multiplying the two products will only result in a significantly greater than zero product if both the average polarization degree value and the average local standard deviation are small. If either condition is not met—for example, normal polarization degree but small local standard deviation, or low polarization degree but large local standard deviation—the product will approach zero. This product form is equivalent to a logical AND operation, unlike the conventional weighted sum form. This scheme does not derive or modify this function; it directly applies the above product definition. In a specific calculation embodiment, the average polarization degree of a certain static defect candidate region is set to 0.2, its reciprocal to 5, and the average local standard deviation to 2. The score is then 5 multiplied by 2 equals 10. Another dynamic particle region has an average polarization degree of 0.3, its reciprocal to 3.33, and an average local standard deviation to 8. The score is 3.33 multiplied by 8, approximately 26.6. However, since this region did not pass the first threshold screening (i.e., its average local standard deviation is greater than the first threshold), it will not be included in the static defect candidate region and therefore will not participate in the score ranking. The normal mirror region has an average polarization degree of 0.8, its reciprocal to 1.25, and an average local standard deviation to 1.5, resulting in a score of 1.875, significantly lower than the static defect region. In this scoring function, the average polarization degree is dimensionless, its reciprocal is dimensionless, the local standard deviation is dimensionless, and the product is dimensionless; all dimensions are consistent. The conversion from phase difference to surface height is illustrated in the following example: This scheme converts the absolute phase difference into surface height based on a phase-height mapping relationship, which originates from the triangulation principle in structured light 3D measurement. With the relative positions of the projector and camera fixed, changes in the height of the object's surface cause phase changes in the projected fringes. The relationship between the two is determined by the system's geometric parameters and can be expressed as height equal to the phase difference multiplied by a calibration coefficient. This coefficient is calculated from parameters such as the baseline distance between the projector and camera, the distance between the projector and the reference plane, and the fringe period. This scheme directly adopts this classic triangulation formula without modification. In a specific calculation embodiment, assuming the phase-height conversion coefficient obtained from system calibration is 0.5 mm per radian, and the difference between the absolute phase of a pixel and the absolute phase of the reference plane is 1.2 radians, then the surface height is 0.5 multiplied by 1.2 equals 0.6 mm. In this calculation process, the phase difference is dimensionless (i.e., radians are considered dimensionless), the height dimension is length units, and the conversion coefficient dimension is length units per radian, ensuring consistent dimensions. The above formulas are sequentially linked according to the detection process. The formula for calculating the local standard deviation of the polarization angle is used to generate a local standard deviation map of the polarization angle. This local standard deviation map of the polarization angle, together with the polarization degree image, is input into the spatial priority scoring function to filter and sort candidate regions for static defects. For each selected candidate region for static defects, the exposure time of the structured light projection is calculated using the formula for the power of the polarization degree ratio, while the fringe direction is determined using the perpendicular relationship between the average polarization angle direction and the fringe direction. After acquiring the deformed fringe image, the phase difference is converted into a surface height value using the phase height conversion formula. In the entire process, the output of the previous stage formula serves as the input parameter for the next stage formula, resulting in a clear logical chain.

[0041] Example 2: See Figure 2 A pipe defect detection system, comprising: The acquisition and synthesis module is used to acquire a polarization image sequence of the pipe surface, perform preprocessing to obtain a denoised polarization image sequence; and synthesize a polarization feature image based on the denoised polarization image sequence, wherein the polarization feature image includes a polarization degree image and a polarization angle image. The candidate extraction module is used to extract candidate defect regions based on the polarization degree image; calculate the local standard deviation of each pixel based on the polarization angle image to generate a local standard deviation map of polarization angle; and filter static defect candidate regions based on the local standard deviation map of polarization angle and the candidate defect regions. The parameter determination module is used to determine the fringe direction and exposure time of the structured light projection based on each static defect candidate region; The projection height measurement module is used to project structured light stripes onto the static defect candidate area based on the stripe direction and exposure time, and acquire deformed stripe images; based on the deformed stripe images, the absolute phase is obtained, and the absolute phase is converted into a surface height map; The defect sorting module is used to extract the actual defect area based on the surface height map and generate defect marking data. Based on the defect marking data, the sorting mechanism is triggered to remove unqualified pipes.

[0042] 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 present invention's method for detecting pipe defects and its inventive concept, should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting defects in pipes, characterized in that, Includes the following steps: A sequence of polarization images of the pipe surface is acquired and preprocessed to obtain a denoised polarization image sequence. A polarization feature image is synthesized based on the denoised polarization image sequence; Candidate defect regions are extracted based on the polarization degree image; the local standard deviation of each pixel is calculated based on the polarization angle image to generate a local standard deviation map of polarization angle. Based on the local standard deviation map of polarization angle and candidate defect regions, static defect candidate regions are selected. Based on each static defect candidate region, the fringe direction and exposure time of the structured light projection are determined. Based on the stripe direction and exposure time, structured light stripes are projected onto the static defect candidate region to acquire deformed stripe images. Based on the deformed stripe images, the absolute phase is obtained and converted into a surface height map. Based on the surface height map, the actual defect area is extracted and defect marking data is generated. Based on the defect marking data, the sorting mechanism is triggered to remove unqualified pipes.

2. The pipe defect detection method according to claim 1, characterized in that, Methods for determining the fringe direction and exposure time of structured light projection based on each static defect candidate region include: The fringe direction of the structured light projection is determined based on the average polarization angle direction of each static defect candidate region. The exposure time of structured light projection is determined based on the polarization degree value of the static defect candidate region.

3. The pipe defect detection method according to claim 2, characterized in that, Methods for determining the fringe direction of structured light projection based on the average polarization angle direction of each static defect candidate region include: Based on the boundary contours of each static defect candidate region, the pixel set of each candidate region is extracted, and the polarization angle values ​​of all pixels in the pixel set are calculated by arithmetic mean to obtain the average polarization angle direction value of each static defect candidate region. Based on the average polarization angle direction value of each static defect candidate region, a reference baseline perpendicular to the average polarization angle direction value is selected, and the angle difference between the reference baseline and the axial centerline of the pipe is calculated to obtain the stripe direction deflection angle of each static defect candidate region. The stripe direction deflection angle of each static defect candidate region is input to the drive controller of the projector. The drive controller adjusts the rotation angle of the sinusoidal stripe pattern on the digital micromirror according to the deflection angle value to generate a sinusoidal stripe projection sequence. Based on the sinusoidal fringe projection sequence, the phase gradient direction of each fringe is extracted, and it is determined whether the phase gradient direction is perpendicular to the average polarization angle direction of the corresponding static defect candidate region. If the angle between the phase gradient direction and the average polarization angle direction is perpendicular, then the rotation angle corresponding to the phase gradient direction is the projection fringe direction of the structured light projection.

4. The pipe defect detection method according to claim 2, characterized in that, Methods for determining the exposure time of structured light projection based on the polarization degree value of static defect candidate regions include: Obtain the pre-calibrated baseline exposure time and reference polarization value characterizing the standard polarization value of the normal mirror area when the camera acquires images in the normal mirror area; The arithmetic mean of the polarization values ​​of all pixels within each static defect candidate region is calculated to obtain the average polarization value of each static defect candidate region. Based on the reference polarization degree value and the average polarization degree, a ratio calculation is performed to obtain the polarization degree ratio of each static defect candidate region; Based on the polarization ratio of each static defect candidate region, a power operation is performed to obtain the exposure time adjustment coefficient for each static defect candidate region; The structured light projection exposure time for each static defect candidate region is calculated based on the baseline exposure time and exposure time adjustment coefficient for each static defect candidate region.

5. The pipe defect detection method according to claim 1, characterized in that, Methods for extracting candidate defect regions based on polarization images include: Based on the polarization degree image, normalization processing is performed to obtain a normalized polarization degree image; Based on the normalized polarization degree image, calculate the local variance of grayscale for all pixels and generate a local variance map; The local variance value of each pixel in the local variance map is compared with a pre-defined second threshold. If the local variance value is less than the second threshold, the corresponding pixel is marked as a candidate seed point. Based on each candidate seed point, the initial set of connected regions is calculated; Based on the initial set of connected regions, the average polarization degree value of each initial connected region is calculated, and the average polarization degree value of each initial connected region is compared with a preset third threshold. If the average polarization degree value is not greater than the third threshold, the output initial connected region is the candidate defect region.

6. The pipe defect detection method according to claim 1, characterized in that, Methods for calculating the local standard deviation of each pixel based on the polarization angle image and generating a local standard deviation map of the polarization angle include: Based on the polarization angle image, a square local neighborhood window is established for each target pixel in the polarization angle image; The local mean is obtained by calculating the arithmetic mean of the polarization angle values ​​based on a local neighborhood window. The local variance is calculated based on the local mean. Based on the local variance, the square root operation is performed to obtain the local standard deviation value of the target pixel position; The local standard deviation value is assigned to the pixel position with the same coordinates as the target pixel in the output image. After traversing all pixels in the polarization angle image, the output image is the local standard deviation map of the polarization angle.

7. The pipe defect detection method according to claim 1, characterized in that, Methods for selecting static defect candidate regions based on local standard deviation maps of polarization angles and candidate defect regions include: Methods for selecting static defect candidate regions based on local standard deviation maps of polarization angles and candidate defect regions include: Based on the candidate defect region and the local standard deviation map of the polarization angle, the local standard deviation sequence of all pixels in the candidate defect region is extracted. Based on the local standard deviation sequence of each candidate defect region, the arithmetic mean is calculated to obtain the average local standard deviation of each candidate defect region. The average local standard deviation of each candidate defect region is compared with a preset first threshold; wherein the first threshold is determined by the lower limit of the local standard deviation distribution of polarization angle in the dynamic particle region on the pipe surface. If the average local standard deviation is less than the first threshold, the corresponding candidate defect region is output as a static defect candidate region; if the average local standard deviation is not less than the first threshold, the corresponding candidate defect region is removed.

8. The pipe defect detection method according to claim 1, characterized in that, Methods for obtaining absolute phase based on deformed fringe images and converting absolute phase into surface height maps include: Based on the deformed stripe image, the phase-shifting method is used for demodulation to extract the wrapping phase value of each pixel; Based on the wrapper phase value of each pixel, a phase unrolling operation is performed to obtain the absolute phase of each pixel; Based on the absolute phase of each pixel and the preset reference plane absolute phase map, the absolute phase of each pixel is subtracted from the reference absolute phase of the corresponding pixel to obtain the phase difference value of each pixel; Based on the phase difference value of each pixel, a height conversion is performed to obtain the surface height value of each pixel; Arrange the surface height values ​​of all pixels according to the coordinates of the original image to obtain the surface height map.

9. The pipe defect detection method according to claim 1, characterized in that, Methods for extracting the true defect region and generating defect labeling data based on surface height maps include: Based on the surface height map, global threshold segmentation is performed on the surface height map to obtain pixels with abnormal height. Based on highly anomalous pixels, perform connected component analysis to obtain a set of highly anomalous regions; Based on the set of highly anomalous regions, multiple highly anomalous regions were obtained through filtering. For each retained height anomaly region, calculate the arithmetic mean of the height values ​​of all pixels within the height anomaly region to obtain the average defect depth of the height anomaly region, and compare the average defect depth with the preset depth alarm threshold. If the average defect depth exceeds the depth alarm threshold, the highly abnormal area is marked as a real defect area, and defect labeling data is generated for each real defect area. The defect marking data includes the set of boundary contour coordinates of the actual defect area, the average defect depth, and the maximum defect depth.

10. A pipe defect detection system, characterized in that, Used to perform the method according to any one of claims 1-9.