A method and system for online detection of elbow pipe size
By using adaptive equalization processing and convolutional neural network segmentation to generate uniform point clouds, the accuracy and stability issues of bending pipe dimension measurement in complex industrial scenarios are solved, and efficient bending pipe geometric dimension detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 山东宏力异型钢管有限公司
- Filing Date
- 2026-03-10
- Publication Date
- 2026-06-19
AI Technical Summary
Existing technologies struggle to reliably and accurately detect the geometric dimensions of bent pipes in complex industrial settings, especially under conditions of uneven lighting, surface oil contamination, and small radii with large bending angles, resulting in insufficient measurement accuracy and stability.
Adaptive equalization processing combined with convolutional neural networks is used for image segmentation to generate initial point cloud data. The point cloud is then homogenized through density statistics and fitting interpolation. Finally, centerline fitting and calibration are performed, and dimensional parameters such as bending angle and radius of curvature are calculated.
It significantly improves the accuracy and stability of pipe bending dimension measurement, solves the systematic error caused by centerline deviation, adapts to the needs of industrial online inspection, and improves inspection efficiency and batch production quality control.
Smart Images

Figure CN122243899A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pipe bending quality inspection technology, and in particular to an online pipe bending dimension inspection method and system. Background Technology
[0002] Currently, pipe bends are core components of pipeline systems in aerospace, petrochemical, and other fields, and their geometric dimensional accuracy directly affects the system's assembly quality and safety. Industrial vision-based pipe bend dimensional inspection technology is widely used due to its non-contact and high-efficiency advantages, and its accuracy and stability are crucial for quality control in high-end equipment manufacturing.
[0003] In one existing technology, traditional optical methods such as contact measurement or fixed templates are used to detect the dimensions of bent pipes. Parameters such as the inner and outer diameters and bending angles of the bent pipe are obtained through comparison with a contact probe or a preset template. This type of method relies on manual positioning or a fixed imaging perspective, has a simple working principle, and is low-cost, making it widely used in static inspection scenarios involving regular surfaces and large-radius bent pipes. However, in real industrial production scenarios, the surface of bent pipes is prone to oil contamination and minor scratches. Furthermore, small-radius, large-bending-angle bent pipes are susceptible to perspective distortion and self-occlusion, making it difficult for this method to reliably distinguish the pipe wall edge from the background. The acquired images are severely affected by uneven lighting, leading to uneven, sparse, or even missing point cloud density distributions in the 3D reconstruction. Traditional fitting algorithms cannot balance global constraints and local accuracy, ultimately causing the centerline to deviate from the true axis, resulting in systematic errors in dimensional measurement and affecting the batch product qualification rate.
[0004] In summary, existing technologies struggle to fully extract the pipe body region from interfered images and reconstruct the true centerline of the bend based on uneven point clouds in complex industrial scenarios, resulting in insufficient accuracy and stability in dimensional measurement. Summary of the Invention
[0005] This invention provides an online detection method and system for pipe bend dimensions to solve the problem of insufficient accuracy and stability in pipe bend dimension measurement under complex industrial scenarios.
[0006] Firstly, in order to solve the above-mentioned technical problems, the present invention provides an online detection method for pipe bending dimensions, comprising: The original image data of the bent pipe is acquired, and the original image data is subjected to adaptive equalization processing to obtain enhanced image data; The gray-level gradient distribution data of the enhanced image data is obtained, and the gray-level gradient distribution data is used to perform region segmentation and extract the edge coordinate set to obtain the tube region boundary data. The region defined by the boundary data of the tube body area is captured and parsed to obtain absolute phase data, and initial point cloud data is generated by combining it with preset system calibration parameters; Density statistics are performed on the initial point cloud data to obtain density distribution characteristics. Sparse boundary point sets are then selected by combining the preset density threshold. Fitting and interpolating the sparse boundary point sets yields homogenized point cloud data. The homogenized point cloud data is fitted with a centerline to obtain preliminary path data, and the preliminary path data is then subjected to continuous filtering to obtain filtered path data. The local geometric features of the filtered path data are obtained, and the filtered path data is calibrated and adjusted based on the local geometric features to determine the target centerline position data. The size is calculated based on the target centerline position to obtain a set of size parameters.
[0007] Secondly, the present invention provides an online pipe bending dimension detection system, comprising: The image equalization module is used to acquire the original image data of the curved pipe, and perform adaptive equalization processing on the original image data to obtain enhanced image data. The region segmentation module is used to acquire the gray-level gradient distribution data of the enhanced image data, perform region segmentation on the gray-level gradient distribution data using a preset convolutional neural network model, and extract the edge coordinate set to obtain the tube region boundary data. The three-dimensional reconstruction module is used to capture and analyze the area defined by the boundary data of the pipe body region to obtain absolute phase data, and generate initial point cloud data by combining it with preset system calibration parameters. The point cloud optimization module is used to perform density statistics on the initial point cloud data to obtain density distribution characteristics, and to filter out sparse boundary point sets by combining a preset density threshold. The sparse boundary point sets are then fitted and interpolated to obtain homogenized point cloud data. The centerline fitting module is used to perform centerline fitting processing on the homogenized point cloud data to obtain preliminary path data, and to perform continuous filtering processing on the preliminary path data to obtain filtered path data. The path calibration module is used to acquire the local geometric features of the filtered path data, and to perform calibration and adjustment processing on the filtered path data based on the local geometric features to determine the target centerline position data. The dimension calculation module is used to perform dimension calculations based on the target centerline position to obtain a set of dimension parameters.
[0008] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention performs adaptive histogram equalization on the original image of the bent pipe and extracts the edge features of the pipe body by combining gray-level gradient distribution data. This overcomes the shortcomings of traditional optical methods in the prior art, which are easily affected by uneven lighting and surface oil stains and scratches. It effectively highlights the distinction between the edge of the pipe body and the background, solves the problem of the pipe body area being difficult to completely separate in complex scenes, provides a high-quality image foundation for subsequent accurate segmentation and three-dimensional reconstruction, and improves the integrity and stability of the extracted pipe body area.
[0009] (2) The present invention performs three-dimensional reconstruction based on the boundary data of the pipe area, and then performs interpolation processing based on the density distribution characteristics of the initial point cloud to obtain uniform point cloud data. This makes up for the shortcomings of the existing technology in three-dimensional reconstruction point cloud, which suffers from uneven density and local sparseness due to perspective distortion and self-occlusion. By interpolating and filling to balance the point cloud quality on the inner and outer sides of the bend, it provides uniform and complete point cloud support for centerline fitting, and avoids interference of sparse point cloud and noise on fitting accuracy.
[0010] (3) The present invention obtains preliminary path data by fitting the centerline of the homogenized point cloud, and then determines the target centerline by continuous filtering and local geometric feature calibration. This breaks through the limitation of the existing traditional fitting algorithm that cannot take into account both global shape constraints and local geometric accuracy. First, noise points are removed by filtering, and then the curvature change region is accurately calibrated, which effectively avoids the centerline from deviating from the real axis or jittering, and significantly improves the accuracy of the centerline position.
[0011] (4) This invention calculates dimensions based on a high-precision target centerline and extracts key dimensional parameters such as bending angle and radius of curvature. This specifically solves the problem of systematic errors in dimensional measurement caused by centerline deviation in existing technologies, and can stably output a set of accurate dimensional parameters, providing a reliable basis for determining the pass rate of batch bent pipe products. At the same time, it adapts to the needs of industrial online inspection, improving inspection efficiency and the level of quality control in batch production. Attached Figure Description
[0012] Figure 1 This is a schematic diagram of the online pipe bending dimension detection method provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of the online pipe bending dimension detection system provided in the second embodiment of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] Reference Figure 1 The first embodiment of the present invention provides an online detection method for pipe bending dimensions, comprising the following steps: S11, acquire the original image data of the bent pipe, and perform adaptive equalization processing on the original image data to obtain enhanced image data; S12, acquire the gray-level gradient distribution data of the enhanced image data, perform region segmentation on the gray-level gradient distribution data using a preset convolutional neural network model and extract the edge coordinate set to obtain the tube region boundary data; S13, capture and analyze the region defined by the boundary data of the tube area to obtain absolute phase data, and generate initial point cloud data by combining it with preset system calibration parameters; S14, perform density statistics on the initial point cloud data to obtain density distribution characteristics, and filter out sparse boundary point sets by combining preset density thresholds, and perform fitting interpolation on the sparse boundary point sets to obtain homogenized point cloud data. S15, perform centerline fitting processing on the homogenized point cloud data to obtain preliminary path data, and perform continuous filtering processing on the preliminary path data to obtain filtered path data. S16, Obtain the local geometric features of the filtered path data, and perform calibration and adjustment processing on the filtered path data according to the local geometric features to determine the target centerline position data; S17, Perform size calculation processing based on the target centerline position to obtain a set of size parameters.
[0015] In step S11, the original image data of the bent pipe is acquired, and adaptive equalization processing is performed on the original image data to obtain enhanced image data, including: S111, acquire a sequence of bent pipe images containing information on differences in light intensity, determine the original image data based on the bent pipe image sequence, and extract the surface reflectance data from the original image data; S112, the original image data is divided into grids based on the surface reflectance data to obtain grid data, and the grid data is processed by limiting contrast adaptive histogram equalization to obtain an intermediate enhanced image; S113, calculate the edge gradient magnitude of the intermediate enhanced image, and convert the edge gradient magnitude greater than a preset gradient threshold into enhanced pixel values to obtain enhanced image data.
[0016] In step S111, a sequence of images of the bent pipe containing information on differences in illumination intensity is acquired. Specifically, a multi-angle ring lighting method is used to control the light source to illuminate the surface of the bent pipe at different incident angles, capturing multiple frames of original images of the bent pipe with complementary light and shadow characteristics. The multi-angle ring lighting system uses eight evenly distributed LED light sources to form a ring lighting device. The ring radius is 1.5 times the diameter of the bent pipe to be detected. The incident angle between each light source and the surface of the bent pipe can be adjusted within the range of 30°-75° (the angle between adjacent light sources is 45°). The light source intensity corresponding to the strong light frame is 800 lux, and the light source intensity corresponding to the weak light frame is 200 lux. The light source intensity is precisely controlled by pulse width modulation (PWM) to ensure that only the illumination intensity differs between the two frames, while other shooting parameters (exposure time, focal length, and ISO) remain consistent.
[0017] It is worth noting that the setting of the ring radius takes into account that if the radius is too small, the incident angle of the light source may be too large, forming a deep shadow in the groove area of the bend; if the radius is too large, the light intensity will be reduced and space will be occupied. Through simulation and experimental verification, when the radius is 1.5 times the pipe diameter, it can provide a balanced lighting distance and angle for each incident angle (30 degrees-75 degrees) within the common pipe diameter range (such as 50-200mm), ensuring that the difference in illuminance between the inner and outer arc surfaces of the bend is minimized.
[0018] For example, when acquiring the first frame of the sequence, strong side lighting is used to achieve high brightness saturation on the convex area of the bend, while the concave area appears as a dark shadow. When acquiring the second frame, the position or intensity of the light source is adjusted in reverse to transform the dark areas in the first frame into bright areas. By comparing the pixel brightness changes of the same coordinate point in the image sequence under different lighting conditions, areas of uneven lighting caused by curvature changes are identified and located. These areas are typically concentrated in the transition zone between the inner and outer arcs of the bend and near the weld.
[0019] Based on this, surface reflectance data is extracted from the original image data. Specifically, a simplified physical model based on the bidirectional reflectance distribution function (BRDF) is used to estimate the inherent reflectance properties of the object's surface using the brightness ratio of the same spatial point in the sequence under strong and weak light frames. During the calculation, the ratio of the brightness of the target pixel in the weak light frame to the brightness of that pixel in the strong light frame is first calculated. The square root of this ratio is then multiplied by a normalization coefficient to obtain the relative reflectance. The relative reflectance ranges from 0 to 1. The brightness of the target pixel in both the weak and strong light frames is measured in grayscale (range 0-255). The normalization coefficient is 0.95, a value obtained through experimental calibration of the diffuse reflection characteristics of metallic materials, which can accurately match the material properties of the metal bend to be tested.
[0020] In step S112, the original image data is segmented into a grid based on the surface reflectance data. Specifically, according to the numerical distribution characteristics of reflectance, the reflectance values are divided into multiple logical intervals, such as a low reflectance interval (0 to 0.3), a medium reflectance interval (0.3 to 0.6), and a high reflectance interval (0.6 to 1.0). This division has been experimentally verified to accurately correspond to the inner arc shadow area, transition area, and outer arc highlight area of the curved pipe. For pixels within the same interval, the data is divided into grid data of a fixed size according to the spatial neighborhood connectivity criterion.
[0021] The grid size is selected based on the image resolution and detection accuracy requirements of the bent pipe. When the image resolution is 1920×1080 pixels and small scratches with a width ≥0.1mm need to be detected, a 4×4 pixel grid is used; when the detection accuracy requirement is lower (scratch width ≥0.2mm), an 8×8 pixel grid is used. The spatial neighborhood connectivity criterion adopts the 8-neighborhood connectivity determination, that is, when a pixel is in the same reflectivity range as at least 3 of its 8 neighboring pixels, it is determined to be a connected pixel and assigned to the same grid area. This ensures that the segmented grid can accurately correspond to the optical property partitions of the bent pipe surface, so that the low reflectivity grid accurately corresponds to the inner arc shadow area, while the high reflectivity grid corresponds to the outer arc highlight area. Eight-neighbor connectivity can cover all peripheral directions of a pixel, which better matches the continuous optical property distribution of the curved tube surface than four-neighbor connectivity. The "at least three" judgment threshold was experimentally set to avoid false connectivity caused by single pixel noise, while ensuring the complete division of the real continuous area. This ensures that the segmented grid can accurately correspond to the optical property partitions of the curved tube surface, so that the low reflectivity grid accurately corresponds to the inner arc shadow area, while the high reflectivity grid corresponds to the outer arc highlight area.
[0022] Furthermore, the grid data is processed using the Limiting Contrast Adaptive Histogram Equalization (CLAHE) algorithm. A pixel grayscale histogram is calculated for each independent local grid, and a contrast limiting factor is introduced to suppress noise amplification. Preferably, the contrast limiting factor is set to 2.5. This value is based on experimental statistical optimization results. Testing was conducted on 50 sets of curved pipe images containing shadows and scratches. When the limiting factor is between 2.0 and 3.0, it effectively suppresses noise amplification while enhancing details in shadow areas. Selecting 2.5 as the optimal value increases the contrast of shadow areas (the ratio of the maximum to the minimum grayscale value within the area) from the original 3.0 (unitless) to over 12.0, and expands the local dynamic range (grayscale range) from 20-50 to 20-140, significantly enhancing the visual characteristics of the pipe surface texture and fine scratches. Simultaneously, a bilinear interpolation algorithm (interpolation step size set to 1 pixel) is used to eliminate the blocky effect between grids, outputting a corrected intermediate enhanced image.
[0023] In step S113, the edge gradient magnitude of the intermediate enhanced image is calculated. Specifically, a 3×3 Sobel operator is used to perform horizontal and vertical convolution operations on the intermediate enhanced image. The horizontal convolution kernel uses the standard matrix [-1,0,1;-2,0,2;-1,0,1], and the vertical convolution kernel uses the standard matrix [-1,-2,-1;0,0,0;1,2,1], all of which are industry-standard Sobel convolution kernel matrices, effectively extracting edges in both horizontal and vertical directions. After the convolution operation, the gradient magnitude is obtained by calculating the square root of the sum of the squares of the horizontal and vertical gradient components, and a gradient magnitude map is constructed. The gradient magnitude, horizontal gradient components, and vertical gradient components are all expressed in gray-level difference per pixel. After the convolution operation, the gradient magnitude is obtained by calculating the square and square root of the horizontal and vertical gradient components, and a gradient magnitude map is constructed. The gradient magnitude, horizontal gradient components, and vertical gradient components are all expressed in gray level difference per pixel.
[0024] It is worth noting that the selection of the preset gradient threshold is based on the statistical analysis and detection requirements of the proportion of strong gradient pixels in the image. First, 100 sets of enhanced intermediate images of metal bends of different specifications (diameter 50-200mm, radius of curvature 100-500mm) were acquired. The gradient amplitude distribution of each image was calculated using the aforementioned 3×3 Sobel operator, and the gradient amplitude concentration range was statistically found to be 10-80 (unit: gray level difference / pixel). Second, using the gradient amplitude of target features such as welds and minor scratches as anchor points, the impact of different thresholds on the target feature recognition rate was verified through experiments. When the threshold was below 35, the false detection rate of noise points exceeded 15%, and when the threshold was above 55, the missed detection rate of minor scratches exceeded 20%. Therefore, the preset gradient threshold baseline value was determined to be 45 (unit: gray level difference / pixel). Finally, considering the difference in reflectivity of different bend materials (such as stainless steel and carbon steel), the threshold adjustment range was set to 40-50. It can be finely adjusted by linear interpolation based on the statistical results of the gradient amplitude of the actual detected material (e.g., carbon steel material has lower reflectivity and the overall gradient amplitude is lower, so the threshold can be lowered to 40-42).
[0025] When a gradient magnitude of 78 is detected at a certain edge location, the point is determined to be a significant edge. The value of 78 is determined based on the statistical range of gradient magnitudes (10-80) from the previous 100 sets of images, falling within the typical range of gradient magnitudes at weld edges (60-85). This value clearly distinguishes it from noise gradients (usually below 30) while remaining within a reasonable gradient distribution range, thus accurately classifying it as a valid edge. A pixel mapping operation is then performed to convert the edge gradient magnitude at that location into an enhanced pixel value. Specifically, a linear stretching function is used to map the gradient value to a high-brightness range above 220. 220 is the critical value for the high-brightness range of the image (the upper limit of image grayscale is 255). Mapping to this range creates a strong grayscale contrast between the edge and the background while avoiding pixel oversaturation and loss of detail, thereby sharpening the originally blurred pipe boundary in grayscale space. For example, in the detection scenario of weld seams in metal bends, after this gradient enhancement processing, the grayscale difference (grayscale level) of the fusion line on both sides of the weld in the original image after reflectance extraction can be increased from approximately 25 to approximately 110. Among them, approximately 25 represents the measured average grayscale difference of the weld seam in the original image, which is in the low contrast range due to uneven lighting and differences in material reflection; approximately 110 represents the measured value after enhancement. Experiments have verified that this grayscale difference ensures that the weld seam edge is clearly distinguishable in complex visual environments, while also conforming to the optimal grayscale difference range (80-120) for metal pipe image enhancement. Through this step-by-step, targeted pixel enhancement processing, false detections caused by uneven lighting can be effectively suppressed while preserving the true reflective characteristics of the material, significantly improving the stability and robustness of the geometric accuracy of metal bends in complex visual inspection environments.
[0026] In step S12, grayscale gradient distribution data of the enhanced image data is obtained. A preset convolutional neural network model is used to segment the grayscale gradient distribution data into regions and extract edge coordinate sets to obtain the pipe region boundary data, including: S121, perform gradient extraction on the enhanced image data to obtain grayscale gradient distribution data; S122, construct the gray-level gradient distribution data into a gradient feature tensor, input the gradient feature tensor into a preset convolutional neural network model for region segmentation, and output mask data; S123, extract the edge coordinate set based on the mask data, perform curve fitting interpolation correction on the discontinuous distortion points in the edge coordinate set, and determine the boundary data of the pipe area.
[0027] In step S121, gradient extraction is performed on the enhanced image data to obtain grayscale gradient distribution data. Specifically, pixel-level gradient calculations are performed on the enhanced image output from the previous step, using the Sobel operator to calculate the horizontal and vertical components within a 3x3 local window. Specifically, the square root of the sum of the squares of the horizontal and vertical gradients is calculated and used as the gradient magnitude of that pixel. Further, the frequency of gradient magnitude occurrences across the entire image is statistically analyzed to construct a gradient distribution histogram. Based on the statistical characteristics of industrial metal appearance, gradient magnitudes typically exhibit a long-tailed distribution; for example, approximately 78% of pixel gradient values are concentrated in the 0 to 60 range, representing smooth areas or background, while only about 4.2% of strong gradient pixels (such as pixels with gradient values greater than 80) correspond to the actual geometric edges of the pipe.
[0028] In step S122, the constructed gradient feature tensor is input into a pre-defined convolutional neural network model for region segmentation. This convolutional neural network model employs a depth-symmetric encoder-decoder structure.
[0029] Specifically, the model's front-end compression path consists of four levels of convolutional coding units. The first level contains two 3x3 convolutional layers with 32 kernels each, designed to extract shallow textures and preliminary edge features from the curved pipe surface. The number of kernels in the second to fourth levels increases geometrically in the sequence of 64, 128, and 256. Each level consists of two 3x3 convolutional layers, supplemented by batch normalization and ReLU activation to enhance non-linear expressive power. At the end of each level, dimensionality reduction is performed using a 2x2 max pooling operation with a stride of 2, halving the width and height of the feature map at each level. This four-layer downsampling depth setting is based on the high-resolution characteristics (e.g., 1920x1080 pixels) typically found in curved pipe images. Through a total of four pooling operations, the model achieves a 16-fold increase in receptive field, thereby capturing the overall macroscopic topological structure of the curved pipe in the deepest feature map.
[0030] Meanwhile, the model's expansion path consists of four corresponding upsampling units. Each layer first uses a 2x2 transposed convolution operation to double the feature map size, ensuring its spatial resolution matches the corresponding layer in the compression path. Subsequently, a skip connection mechanism is used to perform channel-level depth concatenation between the feature map of the same layer in the compression path and the currently upsampled feature map. The physical significance of this mechanism is to use the high-frequency spatial details (such as pixel-level gradients at the pipe edge) preserved by the shallow convolutional layers to compensate for the localization accuracy lost by the deep network after multiple pooling, thus maintaining pixel-level boundary recognition accuracy even in complex industrial lighting environments. After four layers of upsampling to restore the original image size, the model's output layer uses a 1x1 convolutional kernel to compress and map the 256-channel feature vectors into a single-channel probability map, and uses a Sigmoid activation function to limit the output value to the (0,1) interval, which represents the probability density of each pixel in the image belonging to the curved pipe region.
[0031] To make the model resilient to various pipe materials and lighting interferences, a rigorous training process was performed before pre-configuring the model. Specifically, the training dataset included thousands of images of bent metal pipes collected under different environmental conditions. During training, a joint loss function was used to iteratively optimize the network parameters. This loss function consisted of a binary cross-entropy loss and a DiceLoss loss weighted in a 1:1 ratio. DiceLoss effectively addressed the gradient vanishing problem caused by the imbalance between the pipe target and background pixels in the image by maximizing the intersection ratio between the predicted mask and the ground truth region. For optimization, the Adam adaptive moment estimator was used with an initial learning rate of 0.001, coupled with a learning rate decay strategy. Specifically, if the loss value on the validation set did not decrease within 10 consecutive epochs, the learning rate was reduced using a decay coefficient of 0.1. Through approximately 150 epochs of iterative training on the NVIDIA computing platform, the model's loss function on the independent validation set converged to a preset minimum value, thus locking the model parameters.
[0032] During the inference phase of step S122, the system retrieves the trained model parameters and performs forward computation on the real-time input gradient feature tensor. After the model outputs a single-channel probability map, the map is binarized and truncated using a preset global decision threshold. Preferably, based on the response features obtained from experimental statistics, this threshold is set to 0.5. This threshold has been validated with 500 test samples, balancing the recall and precision of the tube region and avoiding background misjudgments and missed tube detections. Pixels with a response value greater than or equal to 0.5 are marked as candidate tube regions, while those with a response value less than 0.5 are classified as background noise. Subsequently, morphological closing operations are performed on the initially generated binarized results. Specifically, a 5x5 square structuring element is used to perform dilation followed by erosion on the binary image, utilizing the connectivity of neighboring pixels to fill the recognition holes caused by localized high-gloss reflections on the metal surface. Finally, a complete, continuous mask data that accurately covers the main body of the curved tube is output.
[0033] It should be noted that the training dataset images extensively cover the variations that may occur in the target application scenario, including but not limited to different pipe diameters, different bending angles and radii, common surface conditions such as clean, with light oil stains or scratches, and various typical industrial lighting conditions, to ensure the robustness of the model in practical applications; using gradient feature tensors instead of the original images as input can directly enhance the model's attention to the edge features of the pipe, reduce the impact of color and absolute brightness changes, and thus improve the stability of segmentation accuracy under complex lighting conditions.
[0034] In step S123, an edge coordinate set is extracted based on the mask data. Specifically, a boundary tracking algorithm is used to traverse the boundary pixels of the connected region from the first pixel of the binary mask in a clockwise or counterclockwise direction, recording the horizontal and vertical coordinates of all edge points to form an ordered sequence of edge points. In practice, for a standard-sized metal bend, this sequence typically contains 1800 to 3200 coordinate points.
[0035] Furthermore, curve fitting and interpolation correction are performed on discontinuous distortion points in the edge pixel coordinate set. Due to perspective projection or wide-angle lens distortion during camera shooting, the edge sequence may exhibit sudden jumps in spatial distribution. In specific processing, cubic spline curves are used to globally segment and fit the entire boundary. During the fitting process, the rate of curvature change between two adjacent points in the ordered sequence is first calculated. If the local rate of curvature change exceeds a preset rate of change threshold (e.g., 0.18), this threshold is statistically determined based on the normal curvature distribution of the curved pipe and can distinguish between real edge transitions and distortion points. The adjustment range for curved pipes with different curvatures is 0.15-0.22; then this local interval is marked as a distortion segment. Subsequently, the spline parameters of the normal segment adjacent to the distortion segment are extracted, and a system of linear equations is solved using a tridiagonal matrix algorithm. The interpolated coordinates within the distortion segment are recalculated, and the original coordinates are smoothly replaced. For example, when an outer arc segment experiences a coordinate jump of approximately 12 pixels due to perspective stretching, the deviation after cubic spline correction can be reduced to within 2 pixels. Through the above correction process, the boundary data of the complete pipe area unaffected by perspective distortion were finally determined, which significantly reduced the detection error caused by geometric distortion and provided a high-precision geometric reference for subsequent weld tracking and three-dimensional measurement.
[0036] In step S13, the region defined by the boundary data of the pipe body area is captured and parsed to obtain absolute phase data, and combined with preset system calibration parameters, initial point cloud data is generated, including: S131, a multi-frequency phase-shifted stripe sequence is projected onto the region defined by the boundary data of the tube body region to capture a group of deformed stripe images; S132, Analyze the deformed stripe image group to obtain absolute phase data; S133, generate a surface sampling point set based on the absolute phase data and preset system calibration parameters, and perform spatial filtering on the surface sampling point set based on the pipe area boundary data to generate initial point cloud data.
[0037] In step S131, a multi-frequency phase-shifted fringe sequence is projected onto the area defined by the boundary data of the pipe region. Specifically, based on the principle of non-contact structured light measurement, a preset fringe coding pattern is projected onto the surface of the curved pipe using a digital projection device. To balance the measurement range and local accuracy, multi-frequency heterodyne technology is preferably used to project three sets of sinusoidal fringes with different spatial frequencies, corresponding to low frequency, medium frequency, and high frequency, respectively, with spatial periods set to 70, 64, and 59 pixels, respectively. The parameters were optimized through multiple rounds of comparative experiments. During the experiments, metal bends of different specifications were used as test objects, and multiple spatial period combinations (covering a range of 50-80 pixels) were debugged. By comparing the 3D reconstruction results under each combination, the measurement range coverage and depth measurement accuracy of key areas such as pipe edges and welds were verified. Finally, a combination of 70, 64, and 59 pixels was selected. This combination can ensure a large measurement range through low-frequency fringes, adapting to the overall measurement needs of bends with different curvatures, while also using mid-frequency and high-frequency fringes to compensate for local detail measurement accuracy, effectively improving the depth resolution of concave and convex parts of the pipe and around the weld. Each frequency group contains four frames of sinusoidal fringe patterns with a phase shift step of π / 2, which is an industry-standard phase shift configuration to ensure accurate phase extraction.
[0038] During projection, dynamic light field masking is performed using a binarized mask of the tube area obtained in the previous step, ensuring that only the stripe sequence covers the main body of the tube, effectively avoiding interference from background noise on stripe resolution. At this time, due to the undulations in the curvature of the curved tube surface, the sinusoidal stripes projected onto the tube surface will undergo geometric distortion. These deformed stripe image sets are simultaneously captured using an industrial camera with a resolution set to 1920x1080 pixels, consistent with the resolution of the previous images. The exposure time is dynamically adjusted based on the average reflectivity of the tube's metal surface, for example, set to 20 milliseconds. This duration, after testing, ensures that the highlight area does not overflow and the shadow area has a sufficient signal-to-noise ratio, fully recording the distortion characteristics reflecting the depth changes of the tube. Specifically, the tube area boundary data is represented as a binarized mask image, where white pixels represent the tube area.
[0039] In step S132, the deformed fringe image group is analyzed to obtain absolute phase data. Specifically, a four-step phase-shifting method is first used to extract the phase of the deformed fringe pattern for each frequency group, calculating the wrap-around phase value at that frequency. Since the wrap-around phase value is limited to... Within the interval, a periodic step distribution is observed, therefore further phase unwrapping processing is required.
[0040] Specifically, utilizing the multi-frequency heterodyne principle, the wrapper phases of low-frequency, mid-frequency, and high-frequency banding are superimposed and differentially analyzed to calculate a composite equivalent phase with a longer wavelength. This eliminates phase discontinuities pixel by pixel, resulting in globally unique absolute phase data. This absolute phase map physically characterizes the three-dimensional topological change trend of the curved pipe surface. For example, in the outer arc region of a stainless steel curved pipe, its absolute phase value exhibits a smooth and continuous gradient distribution, gradually changing from -3.14 radians to 3.14 radians. This directly reflects the geometric logic of the depth in this region gradually transitioning from the near end to the far end.
[0041] In step S133, a surface sampling point set is generated based on the absolute phase data and preset system calibration parameters. Specifically, the system calibration parameters are obtained in advance through multi-pose acquisition of a high-precision Zhang calibration plate, including the camera focal length (e.g., 8.5 mm), optical distortion coefficient, and spatial extrinsic parameter matrix between the projector and the camera (baseline distance set to 200 mm). This set of calibration parameters is adapted to a 1920x1080 pixel resolution and, after calibration, ensures the accuracy of 3D reconstruction. Based on the principle of triangulation, the phase information of each pixel in the absolute phase map is combined with the camera image plane coordinates. By calculating the spatial intersection coordinates of the projection ray and the camera's line of sight, the pixels in the image coordinate system are mapped to 3D coordinate points in the world coordinate system.
[0042] The generated surface sampling point set typically contains hundreds of thousands to millions of discrete points. Based on this, spatial constraint filtering is applied to the surface sampling point set according to the boundary data of the pipe region. The 3D sampling points are back-projected back onto the 2D image plane using a camera intrinsic model, and it is determined whether their projection positions fall within the pipe region boundary determined in the previous steps. Points located outside the boundary are identified as false feature points due to environmental reflection or occlusion and are discarded. For example, in a reconstruction task, the initial point set contains 1.2 million points. After boundary spatial constraint filtering, approximately 850,000 feature points accurately covering the core area of the curved structure are retained, thus constructing the initial 3D point cloud model. It is worth noting that the final obtained initial point cloud data exhibits a distribution characteristic highly consistent with the physical surface of the pipe. For example, the point density in the flat area in the middle of the pipe can reach 500 points per cubic centimeter. This density meets the accuracy requirements of subsequent size calculations and centerline fitting, laying a solid data foundation for subsequent processing.
[0043] In step S14, density statistics are performed on the initial point cloud data to obtain density distribution characteristics. A sparse boundary point set is then selected based on a preset density threshold. The sparse boundary point set is then fitted and interpolated to obtain homogenized point cloud data, including: S141, perform density statistical processing on the initial point cloud data according to the preset local search neighborhood to obtain density distribution characteristics; S142, The density distribution features are filtered according to a preset density threshold to obtain a sparse boundary point set; S143, Perform surface fitting processing on the sparse boundary point set to obtain surface equation data; S144, perform coordinate sampling processing based on the surface equation data to obtain filled coordinate data, and fuse the filled coordinate data into the initial point cloud data to obtain homogenized point cloud data.
[0044] In step S141, after obtaining the initial 3D point cloud model, the local point cloud density value of each sampling point is first calculated. Specifically, based on the spatial neighborhood search algorithm (using a combination of K-nearest neighbors and spherical search to improve search accuracy and efficiency), a spherical region with a radius of 5 mm is set as the preset local search neighborhood, centered on each sampling point. This neighborhood radius was determined through targeted experiments. The experiments used the initial point clouds of metal bends of different specifications as test objects, and adjusted multiple sets of radius parameters within the range of 4-8 mm. By comparing the density statistics under each parameter, two points were verified: first, whether the density difference between dense and sparse areas can be accurately distinguished; and second, whether the statistically obtained density value is stable and without significant fluctuations. Finally, 5 mm was determined to be the optimal radius. This radius, combined with the density characteristic of 500 points per cubic centimeter in the flat area in the middle of the pipe, can ensure that the number of points in the neighborhood of dense areas is moderate (facilitating density statistics), while accurately capturing the difference in the number of points in sparse areas, avoiding the local sparse characteristics being masked by an excessively large radius and the statistical errors caused by an excessively small radius. Within this neighborhood, the number of neighboring points is counted, and this number is used as a distribution characteristic representing the density of that point location. It is worth noting that due to the drastic changes in the curvature of the curved pipe surface, the original point cloud often exhibits non-uniform characteristics. For example, in the flat area in the middle of the pipe, this 5 mm radius neighborhood typically contains about 45 neighboring points; while at the abrupt bend of the outer arc of the pipe or in the deep shadow area of the inner arc, the number of neighboring points may drastically decrease to about 12 due to the influence of the structured light projection angle and occlusion. This density fluctuation characteristic is an important basis for subsequent identification of sparse voids.
[0045] In step S142, the density distribution features are filtered according to a preset density threshold. The preset density threshold is preferably set to 200 points per cubic centimeter. This threshold was determined with reference to the minimum stability requirements of the input data for the subsequent centerline fitting algorithm. Extensive experimental verification was conducted, selecting point cloud data of metal bent pipes of different specifications (diameter 50-200mm, radius of curvature 100-500mm), and testing was performed with thresholds of 150-250 points / square centimeter. The radial deviation of the centerline fitting results was compared. When the threshold was below 200 points / square centimeter, the radial deviation of the fitting model generally exceeded 0.1mm, failing to meet the accuracy requirements of industrial inspection. When it was above 200 points / square centimeter, although the deviation was controllable, it would excessively discard effective points, reducing the point cloud utilization rate. Therefore, 200 points / square centimeter was determined as the optimal threshold. By traversing the initial point cloud, sampling points with local density values below this threshold were extracted and categorized to form a sparse boundary point set. For example, in a set of stainless steel bend point cloud data, after screening, it was found that about 8% of the points were located in the sparse boundary point set, and these points showed obvious clustering characteristics, mainly concentrated in the transition zone at the bend with a small radius of curvature.
[0046] In step S143, after extracting the sparse boundary point set, a surface equation reflecting the local geometric features of the tube is constructed. Specifically, for each sparse region, a local quadratic surface fitting method is used for geometric reconstruction. Dense point clouds within a 10 mm radius of the sparse region are automatically retrieved as reference samples. This 10 mm radius, optimized experimentally, ensures that the reference samples cover the complete local geometry of the sparse region while avoiding the introduction of irrelevant distant point clouds that could interfere with the fitting accuracy. Using the least squares principle, a surface equation that best approximates the local tube shape is fitted, such as an elliptical cylindrical segment equation or a hyperboloid equation. The specific equation type is adaptively selected based on the curvature characteristics of the sparse region (elliptical cylindrical surfaces are suitable for flat areas, and hyperboloids are suitable for complex bending areas). The physical significance of this step lies in using known, high-precision geometric structures in the surrounding area to mathematically reconstruct missing surfaces caused by scanning blind spots or lighting limitations. The fitted surface equation not only maintains the continuity of the tangent with the surrounding dense region, but also ensures that the fitted surface has a smoothness that conforms to the physical properties of the tube (the smoothness is controlled by the curvature deviation threshold, and the deviation does not exceed 0.05 radians).
[0047] In step S144, coordinate sampling is performed according to the surface equation to obtain filling coordinate data. Specifically, within the parameter space defined by the surface equation, uniform coordinate calculation is performed according to a preset sampling step size (e.g., 0.8 mm interval). The 0.8 mm step size is set in conjunction with the density requirements of the pipe's point cloud, which allows the filling points to match the density of the surrounding dense point cloud, avoiding excessively dense filling that increases the computational load and excessively sparse filling that leads to new sparse regions. A series of interpolated filling points located on the ideal surface of the pipe are generated. Subsequently, these filling coordinate data are fused into the initial three-dimensional point cloud model to obtain uniform point cloud data with eliminated sparse holes and balanced density differences.
[0048] In a specific example, after this homogenization process, the average point spacing in the inner recess was effectively reduced from 2.1 mm to approximately 1.0 mm, and the point spacing in the outer curved area was also adjusted to approximately 1.1 mm. The standard deviation of the point cloud density across the entire tube surface was significantly reduced. This improvement in density consistency eliminates computational singularities caused by abrupt changes in input data in subsequent algorithms, enabling stable and high-fidelity data sources for subsequent curvature calculations and dimensional measurements. In particular, the geometric description accuracy at complex bends can be improved by more than 25%, a value verified through comparative experiments of measurement deviations at the same location before and after processing.
[0049] In step S15, the homogenized point cloud data is subjected to centerline fitting processing to obtain preliminary path data, and the preliminary path data is subjected to continuous filtering processing to obtain filtered path data, including: S151, perform iterative random sampling on the homogenized point cloud data to obtain the fitting model parameter data; S152, Determine the axis equation based on the fitted model parameter data, and connect the geometric centers of the slices based on the axis equation to obtain preliminary path data; S153, calculate the curvature change characteristics of the preliminary path data, and remove and repair nodes whose curvature change characteristics exceed a preset rate of change threshold to obtain filtered path data.
[0050] In step S151, the Random Sampling Consensus Algorithm (RANSAC) is used to perform iterative random sampling on the homogenized point cloud data. Specifically, robust model estimation is performed on a noisy 3D dataset based on RANSAC. In practice, a global geometric constraint model is established for a tube point cloud dataset with, for example, 100,000 sampling points. Each time, the algorithm randomly selects a preset number (e.g., 100) of sampling points from the dataset as the original subset. The number of 100 sampling points is determined through experimental adaptation. On the one hand, the fitting of the tube geometric model needs to meet the minimum number of points requirement (e.g., at least 6 points are required for fitting a cylindrical surface), and 100 points is much higher than the minimum value, which can reduce the random error of a single sampling. On the other hand, considering the point cloud scale of 100,000 points, the proportion of the 100-point subset is moderate. It can quickly complete the initial model construction, avoid excessive sampling leading to a surge in computation time, and cover the geometric features of different regions of the tube, ensuring the reliability of the initial model fitting.
[0051] After constructing a preliminary geometric model based on this subset, the spatial distance from the remaining points in the full point cloud to the model is calculated. The number of inliers with a distance less than a preset deviation threshold is counted to evaluate the consistency of the current model. The preset deviation threshold is set at 0.2 mm, a value precisely determined through multiple rounds of comparative experiments. The experiment uses metal bent pipes of different specifications as test objects. Combining the accuracy of the 3D reconstruction in the preceding steps (after improving geometric description accuracy by approximately 25%, the error can be controlled within 0.1 mm), multiple sets of threshold parameters within the range of 0.1-0.3 mm are adjusted. Two key verification points are: first, whether it can effectively distinguish outliers caused by equipment vibration and surface reflection (the deviation of such noise points is usually greater than 0.2 mm) from real pipe points (the error is mostly within 0.1 mm); and second, whether it can ensure a sufficient number of inliers so that the model converges to the global optimum. Finally, 0.2 mm is determined as the optimal threshold, which avoids incorrectly eliminating valid points due to an excessively small threshold, leading to model fitting deviation, and also avoids retaining too many noise points due to an excessively large threshold, affecting model robustness, thus fully meeting the accuracy requirements of industrial bent pipe inspection.
[0052] To ensure the model accurately eliminates outliers caused by scanning equipment jitter and converges to the global optimum, the number of iterations was optimized to approximately 500 after multiple rounds of comparative experiments. Experiments were conducted using point clouds of curved pipes with varying noise levels as test subjects, adjusting the number of iterations within the range of 300-800. The model's convergence speed and interior point recognition accuracy were compared, ultimately determining that 500 iterations were sufficient to achieve both efficiency and convergence to the global optimum, avoiding model bias due to insufficient iterations and resource waste due to excessive iterations. Finally, the model parameters with the highest number of consistent interior points were selected as the fitted model parameters. This iterative sampling method effectively eliminates false feature points generated by secondary reflections from the metal surface, ensuring that the fitted parameters accurately reflect the macroscopic topological structure of the pipe.
[0053] It should be noted that the fitting model parameter data obtained through the RANSAC algorithm, such as the parameters of a segmented cylindrical model, is first used to determine the approximate orientation of the tube in three-dimensional space, and based on this, a set of equally spaced cross-sectional planes perpendicular to the approximate orientation of the tube, i.e., slices, is defined. Then, for the intersection point set of each slice plane and the homogenized point cloud data, its geometric center is calculated. Finally, these slice geometric centers are connected in sequence to form the preliminary path data. This method combines the orientation guidance of the global model with the centroid calculation of the local point cloud data, taking into account both noise resistance and adaptability to local details.
[0054] In step S152, the axis equation is determined based on the fitted model parameter data. Specifically, the center guide trajectory of the tube is defined in three-dimensional space using the geometric constraints locked by the fitted model parameters. The space is divided along the tube length at fixed intervals (e.g., 2 cm) to generate multiple parallel cross-sectional slices. The 2 cm interval was determined through experimental optimization. Using metal bends of 0.5-2 meters in length as test objects, multiple sets of interval parameters within the range of 1-3 cm were adjusted. Combined with the density characteristics of the preceding homogenized point cloud (500 points per cubic centimeter), the 2 cm interval can accurately capture the bending details of the bend while controlling the number of cross-sectional slices (e.g., 60 slices for a 1.2-meter tube). This avoids node redundancy and a surge in computation due to excessively small intervals, while also preventing the omission of geometric features at complex bends due to excessively large intervals, thus achieving a balance between axis description accuracy and computational efficiency.
[0055] For each slice region, the geometric center of the slice is determined by calculating the weighted average spatial position of all sampling points within it. If the total length of the pipe is, for example, 1.2 meters, an ordered sequence of nodes consisting of 60 center points can be obtained. Subsequently, the geometric centers of each slice are connected according to the node order to construct preliminary path data. This preliminary path data describes the overall orientation of the pipe in the form of a set of discrete nodes. It is worth noting that in the straight sections of the pipe, this method of connecting slice centers has extremely high positional stability and can provide a reference orientation for the subsequent calibration of complex curved sections.
[0056] In step S153, the curvature variation characteristics of the preliminary path data are calculated. Specifically, the smoothness of the path in three-dimensional space is evaluated by analyzing the tangent angle offset between adjacent path nodes in the preliminary path data. In practice, three consecutive path nodes are extracted to form a local polyline segment, and the rate of change of the included angle between two adjacent polyline segments is calculated.
[0057] If the rate of change of angle within a unit length of a certain path exceeds a preset rate of change threshold (e.g., 0.3 radians per centimeter), this threshold is determined statistically based on the normal angle change range of bends with different curvatures. It is adapted to the bending characteristics of conventional bends and can accurately distinguish between real bends and noise interference. The adjustment range is 0.2-0.4 radians per centimeter. If the node is affected by local scanning blind spots or abnormal fluctuations in the point cloud, it is marked as a noise interference point.
[0058] Furthermore, nodes exceeding a threshold are removed and repaired to obtain filtered path data. Outliers marked as noise are removed, and the resulting gaps are reconstructed using local smoothing techniques. If, for example, three noise nodes are removed consecutively, five valid nodes before and after the gap are identified as reference samples. The number of five reference nodes has been experimentally verified to ensure that the interpolation curve closely matches the actual pipe orientation, avoiding interpolation deviations caused by insufficient reference points. A quadratic curve interpolation algorithm based on the least squares criterion is used for path completion, calculating new node coordinates that meet curvature continuity constraints. This processing method ensures that the centerline path maintains a physically smooth transition even in areas of sharp pipe curvature or incomplete point cloud, eliminating computational jumps. The final filtered path data not only reflects the actual geometric orientation of the pipe but also possesses good second-derivative continuity, providing reliable input features for subsequent high-precision calibration of the target centerline position.
[0059] In step S16, local geometric features of the filtered path data are acquired, and the filtered path data is calibrated and adjusted based on the local geometric features to determine the target centerline position data, including: S161, Analyze the node tangent features and curvature features of the filtered path data to obtain local geometric features; S162, the local geometric features are filtered according to a preset curvature threshold to determine the data to be corrected in the interval, and a source point set and a target point set are constructed for the data to be corrected in the interval. S163, perform iterative nearest point processing on the source point set and the target point set to obtain transformation matrix data; S164, calibrate the node coordinates within the interval data to be corrected based on the transformation matrix data to determine the target centerline position data.
[0060] In step S161, the node tangent and curvature features of the filtered path data are analyzed to obtain local geometric features. Specifically, based on the principle of discrete differential geometry, the shape changes of each node on the filtered path and its neighborhood window are quantitatively described. In practice, a local sliding window interval is formed by the current path node and its three adjacent nodes before and after it. The number of sliding window nodes is determined experimentally. Using standard curved pipe paths with different curvatures as test objects, multiple combinations of 2-4 adjacent nodes are debugged. The stability of the fitted vector field and the accuracy of local feature calculation are compared. Finally, three adjacent nodes are selected, which can cover enough geometric information around the node to stabilize the fitted vector field, and avoid the introduction of irrelevant nodes at a distance that interfere with the local feature calculation. The local spatial vector field is constructed using least squares fitting, and then the unit tangent vector at the node is calculated. By analyzing the direction deviation of the tangent vectors between adjacent nodes and combining the arc length information between nodes, the local radius of curvature and the rate of change of direction at that position are estimated. These local geometric features not only encompass the instantaneous bending intensity of the path, but also reflect the stability of the spacing between adjacent nodes, providing a multi-dimensional feature description for identifying geometric anomalies at complex bends in the path.
[0061] In step S162, local geometric features are filtered according to a preset curvature threshold to determine the data range to be corrected. Specifically, the preset curvature threshold is determined based on the maximum allowable curvature in the standard pipe bending process parameters and the tolerance range of the image acquisition resolution, for example, it is set to a local curvature radius that is less than 0.8 times the design radius. This threshold is experimentally calibrated by selecting multiple sets of pipe bending samples that meet industrial standards, covering different design curvature radius ranges. Combining the inherent error of 3D reconstruction and path fitting (approximately 0.1 mm), multiple thresholds ranging from 0.7 to 0.9 times the design radius are adjusted to verify its ability to distinguish between normal bending and abnormal distortion (caused by point cloud noise). Finally, 0.8 times is determined to be the optimal value, which not only meets the process tolerance requirements but also accurately eliminates noise interference. By comparing the real-time curvature features of each node with this threshold, areas with abrupt curvature changes or that do not conform to the physical bending logic of the pipe are identified.
[0062] After identifying the high-curvature section to be corrected, a source point set and a target point set are constructed for this section. The source point set directly selects the coordinates of the original path nodes within the section to be corrected. The target point set is generated using geometric extrapolation techniques. Five normal path nodes in a smoothed state are extracted before and after the section to be corrected. This number is optimized experimentally. Using sections of different lengths to be corrected as test objects, combinations of 3-7 reference nodes are adjusted to compare the fit between the extrapolated curve and the actual axis of the tube. Five nodes can ensure extrapolation accuracy while avoiding excessive computation due to too many reference points and extrapolation deviation due to too few. Using the cubic Hermite interpolation algorithm or a curvature flow-based smoothing strategy, the ideal node coordinates that conform to the physical axis of the tube within this section are derived. By constructing this correspondence between the source point set and the target point set, a data benchmark is provided for subsequent precise alignment.
[0063] In step S163, iterative nearest neighbor (ICP) processing is performed on the source and target point sets. Specifically, an iterative optimization strategy based on minimizing point-to-point distance is adopted to calculate the rigid body transformation matrix required to transform the source point set to the target point set. During algorithm execution, the algorithm continuously searches for the nearest neighbor of each node in the source point set within the target point set, constructs corresponding point pairs, and uses singular value decomposition (SVD) to solve for the optimal rotation matrix and translation vector. To ensure calibration accuracy, the iteration stopping criterion is set to a root mean square error change between two iterations of less than 10 to the power of -5, or reaching a preset upper limit of 50 iterations. This stopping criterion was determined experimentally, using multiple sets of point sets with slight offsets as test objects. The combination of the error threshold and the iteration upper limit was adjusted; the error threshold of 10 to the power of -5 meets the requirements of industrial-grade high-precision calibration, and the 50-iteration upper limit ensures accuracy while avoiding excessive iteration and wasting computational resources, balancing efficiency and reliability. This processing method can finely adjust the slight distortion of the path at bends, aligning the calculated axis position with the true geometric center of the pipe.
[0064] In step S164, the node coordinates within the data to be corrected are calibrated based on the transformation matrix data. Specifically, the calculated rigid body transformation matrix is applied to the original nodes within the data to be corrected, and calibrated path node coordinates are generated through rotation and translation transformations. These new coordinates are then used to replace the original abnormal nodes in the filtered path. After replacement, a global spline smoothing process is performed on the entire path to ensure that the transition between the corrected and normal intervals achieves second-derivative continuity, meeting the requirements for axis smoothness in subsequent dimensional measurements. The final determined target centerline position data effectively eliminates axis offset caused by uneven point cloud distribution or perspective residual deviations, especially in areas of sharp pipe curvature, significantly improving the geometric consistency of the centerline position. This precise target centerline position data not only accurately restores the physical axis of the pipe but also provides a stable and reliable reference for subsequent high-precision measurements of bending angles and radii of curvature.
[0065] In step S17, the size is calculated based on the target centerline position to obtain a set of size parameters.
[0066] Specifically, the ordered discrete node coordinates of the target centerline position are first obtained. For each pair of adjacent nodes in this sequence, a local tangent vector is constructed by calculating the difference between their three-dimensional spatial coordinates. This vector accurately describes the instantaneous extension direction of the path in this infinitesimal segment.
[0067] In practice, the bending angle is obtained by calculating the spatial angle between adjacent local tangent vectors. To ensure the robustness of the angle calculation and suppress minor oscillations caused by discrete sampling, a moving average filtering algorithm is typically used to smooth the initial angle sequence. The size of the filtering window is determined experimentally. Using centerline data with different node densities as test objects, window combinations of 3-5 nodes are debugged, and finally, a window of 3 nodes is selected. This effectively smooths oscillation noise while avoiding blurring of the true bending features by using an excessively large window. For example, for a set of centerline data containing 50 nodes, if the angle between the tangent vector formed by a node and the nodes before and after it reaches 15 degrees, this location is marked as a significant bending point to characterize the key geometric feature of the pipe's turning direction.
[0068] Further, the local curvature intensity is calculated based on the bending angle value and the arc length differential between nodes. The arc length differential is defined as the Euclidean geometric distance between adjacent nodes. Physically, curvature intensity reflects the degree of drastic change in angle within a unit arc length. Subsequently, the local curvature intensity is converted into a series of curvature radius values. Specifically, the curvature radius is taken as the reciprocal of the curvature intensity. For example, within a local section of the pipe path, the node spacing is preset to 2.5 mm. This spacing was determined through experimental optimization: combining the previous 2 cm slice interval and the density characteristics of the homogenized point cloud (500 points per cubic centimeter), multiple sets of spacing parameters within the range of 1.5-3.5 mm were adjusted using pipes with different degrees of curvature as test objects, and the accuracy and computational efficiency of curvature radius calculation were compared. A 2.5 mm spacing precisely matches the point cloud density, ensuring that adjacent nodes completely cover local geometric changes. This avoids the computational burden of excessively small spacing and the omission of subtle bending features due to excessively large spacing, achieving a balance between accuracy and efficiency. With a corresponding cumulative bending angle change of 10 degrees, the radius of curvature of the region can be estimated through the geometric mapping relationship between arc length and angle. This numerical sequence can intuitively and accurately reconstruct the true physical morphology of the pipe in complex bending sections, providing a quantitative basis for subsequent precise quality assessment.
[0069] Based on this, extreme values in the bending angle and radius of curvature value sequences are extracted to form a high-precision set of dimensional parameters. An extreme value detection algorithm (using a first-order difference method combined with threshold determination; the threshold is experimentally calibrated to 1.5 times the rate of curvature change; the experiment uses multiple sets of standard bent pipe curvature change data as samples, adjusting multiple coefficients from 1.2 to 1.8 times; 1.5 times can accurately distinguish between normal curvature fluctuations and extreme point abrupt changes, neither missing true extreme values nor misjudging small fluctuations as extreme values) identifies the minimum point in the radius of curvature sequence and the maximum point in the bending angle sequence. These extreme points typically correspond to the weakest parts of the bent pipe most prone to deformation or stress concentration during processing. For example, if the radius of curvature value of a certain node is identified in the detection data as only 5 mm, far below the preset average reference value (e.g., 20 mm), this feature value is recorded as a key dimensional parameter.
[0070] Subsequently, the set of high-precision dimensional parameters is compared with the preset standard tolerance range. If all parameters are within the tolerance range, the result is marked as qualified. The preset standard tolerance range is a threshold range pre-set based on industrial design requirements and pipe fitting assembly standards, and is determined through verification using multiple sets of qualified / unqualified samples. A total of 200 sets of bent pipe samples (50 sets of qualified and 50 sets of unqualified samples each, covering different processing batches, materials (stainless steel, carbon steel), and specifications) are selected. These samples are combined with industry-standard pipe fitting assembly gaps (e.g., allowable gap for pipe connections ≤ 0.2mm) and the upper limit of bending machine processing capacity (e.g., minimum bending radius tolerance ± 0.5mm) to adjust multiple tolerance range parameters. By comparing the pass rate of qualified samples and the misjudgment rate of unqualified samples for each range, the final determined range is determined to be neither too strict as to exceed the achievable range of the processing technology, avoiding excessive stringency leading to misjudgment of qualified samples, nor too wide to meet actual assembly accuracy requirements, preventing the omission of unqualified products due to excessively wide ranges, thus balancing processing feasibility and assembly reliability. For example, if the acceptable radius of curvature is set to 10 mm to 30 mm, and the measured extreme points all fall within this range, then the single product is judged to meet the specifications in terms of geometric dimensions.
[0071] Finally, the percentage of qualified samples is calculated to output the batch product qualification rate. In practice, automated cyclical analysis of the pipe path data across the entire production line is performed to calculate the ratio of qualified samples to the total number of samples collected. For example, if 85 out of 100 samples are found to have dimensional parameters within tolerance limits, the batch product qualification rate is 85%. It's worth noting that this result not only provides crucial feedback for real-time quality control on the production line but also guides the optimization of process parameters in front-end processing equipment (such as adjusting the pressure or feed speed of the pipe bending machine) by identifying common characteristics of non-conforming paths.
[0072] Furthermore, from the core solution to extended applications, for paths marked as unqualified, further local sampling adjustments or interval refitting can be performed. This refined correction further verifies the nature of geometric deviations, thereby maximizing the production efficiency and judgment accuracy of batch inspection while ensuring data reliability. Through the aforementioned multi-dimensional calculations and statistics, a complete technical closed loop from discrete point clouds to industrial evaluation indicators is achieved, significantly improving the automation level and measurement consistency of pipe bending dimension inspection.
[0073] In summary, this invention discloses an online method for detecting the dimensions of bent pipes, including steps such as image acquisition and reflectivity extraction, pipe body region segmentation, 3D point cloud reconstruction and optimization, centerline fitting calibration, and dimension calculation and determination. This invention achieves accurate segmentation by combining multi-angle ring lighting with an improved U-Net model, and constructs high-precision point clouds and centerlines using multi-frequency phase-shifting technology and ICP calibration. This effectively overcomes the pain points of uneven lighting and sparse point clouds in industrial scenarios, realizing fully automated detection of bent pipe dimensions, significantly improving detection accuracy and efficiency, and providing reliable support for production line quality control and process optimization.
[0074] Reference Figure 2 The second embodiment of the present invention provides an online pipe bending dimension detection system, comprising: The image equalization module is used to acquire the original image data of the curved pipe, and perform adaptive equalization processing on the original image data to obtain enhanced image data. The region segmentation module is used to acquire the gray-level gradient distribution data of the enhanced image data, perform region segmentation on the gray-level gradient distribution data using a preset convolutional neural network model, and extract the edge coordinate set to obtain the tube region boundary data. The three-dimensional reconstruction module is used to capture and analyze the area defined by the boundary data of the pipe body region to obtain absolute phase data, and generate initial point cloud data by combining it with preset system calibration parameters. The point cloud optimization module is used to perform density statistics on the initial point cloud data to obtain density distribution characteristics, and to filter out sparse boundary point sets by combining a preset density threshold. The sparse boundary point sets are then fitted and interpolated to obtain homogenized point cloud data. The centerline fitting module is used to perform centerline fitting processing on the homogenized point cloud data to obtain preliminary path data, and to perform continuous filtering processing on the preliminary path data to obtain filtered path data. The path calibration module is used to acquire the local geometric features of the filtered path data, and to perform calibration and adjustment processing on the filtered path data based on the local geometric features to determine the target centerline position data. The dimension calculation module is used to perform dimension calculations based on the target centerline position to obtain a set of dimension parameters.
[0075] It should be noted that the online pipe bending dimension detection system provided in this embodiment of the invention is used to execute all the process steps of the online pipe bending dimension detection method in the above embodiment. The working principle and beneficial effects of the two are one-to-one, so they will not be described again.
[0076] It should be noted that the system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0077] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for online detection of pipe bend dimensions, characterized in that, include: The original image data of the bent pipe is acquired, and the original image data is subjected to adaptive equalization processing to obtain enhanced image data; The gray-level gradient distribution data of the enhanced image data is obtained, and the gray-level gradient distribution data is used to perform region segmentation and extract the edge coordinate set to obtain the tube region boundary data. The region defined by the boundary data of the tube body area is captured and parsed to obtain absolute phase data, and initial point cloud data is generated by combining it with preset system calibration parameters; Density statistics are performed on the initial point cloud data to obtain density distribution characteristics. Sparse boundary point sets are then selected by combining the preset density threshold. Fitting and interpolating the sparse boundary point sets yields homogenized point cloud data. The homogenized point cloud data is fitted with a centerline to obtain preliminary path data, and the preliminary path data is then subjected to continuous filtering to obtain filtered path data. The local geometric features of the filtered path data are obtained, and the filtered path data is calibrated and adjusted based on the local geometric features to determine the target centerline position data. The size is calculated based on the target centerline position to obtain a set of size parameters.
2. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process of acquiring the original image data of the bent pipe and performing adaptive equalization processing on the original image data to obtain enhanced image data includes: A sequence of bent pipe images containing information on differences in light intensity is obtained; original image data is determined based on the bent pipe image sequence; and surface reflectance data is extracted from the original image data. The original image data is divided into grids based on the surface reflectance data to obtain grid data. The grid data is then processed using contrast-limited adaptive histogram equalization to obtain an intermediate enhanced image. Calculate the edge gradient magnitude of the intermediate enhanced image, and convert the edge gradient magnitude greater than a preset gradient threshold into enhanced pixel values to obtain enhanced image data.
3. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process of acquiring the grayscale gradient distribution data of the enhanced image data, performing region segmentation on the grayscale gradient distribution data using a preset convolutional neural network model, and extracting the edge coordinate set to obtain the pipe region boundary data includes: Gradient extraction is performed on the enhanced image data to obtain grayscale gradient distribution data; The gray-level gradient distribution data is constructed into a gradient feature tensor, and the gradient feature tensor is input into a preset convolutional neural network model for region segmentation, and the mask data is output. The edge coordinate set is extracted based on the mask data, and the discontinuous distortion points in the edge coordinate set are corrected by curve fitting interpolation to determine the boundary data of the pipe area.
4. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process involves capturing and parsing the region defined by the boundary data of the pipe body area to obtain absolute phase data, and then combining this data with preset system calibration parameters to generate initial point cloud data, including: A multi-frequency phase-shifted stripe sequence is projected onto the region defined by the boundary data of the tube body area to capture a group of deformed stripe images; The absolute phase data is obtained by analyzing the deformed stripe image group; A surface sampling point set is generated based on the absolute phase data and preset system calibration parameters. The surface sampling point set is then spatially filtered based on the pipe region boundary data to generate initial point cloud data.
5. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process of performing density statistics on the initial point cloud data to obtain density distribution characteristics, and then filtering out sparse boundary point sets based on a preset density threshold, followed by fitting and interpolating the sparse boundary point sets to obtain homogenized point cloud data, includes: The initial point cloud data is subjected to density statistical processing based on a preset local search neighborhood to obtain density distribution characteristics; The density distribution features are filtered according to a preset density threshold to obtain a sparse boundary point set; The sparse boundary point set is subjected to surface fitting processing to obtain surface equation data; Coordinate sampling is performed on the surface equation data to obtain filled coordinate data, and the filled coordinate data is then fused into the initial point cloud data to obtain homogenized point cloud data.
6. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process of performing centerline fitting on the homogenized point cloud data to obtain preliminary path data, and then performing continuous filtering on the preliminary path data to obtain filtered path data, includes: The homogenized point cloud data is subjected to iterative random sampling to obtain the fitting model parameter data; The axis equation is determined based on the fitted model parameter data, and the geometric centers of the slices are connected according to the axis equation to obtain preliminary path data; The curvature change characteristics of the preliminary path data are calculated, and nodes whose curvature change characteristics exceed a preset rate of change threshold are removed and repaired to obtain filtered path data.
7. The online detection method for pipe bend dimensions according to claim 1, characterized in that, The process of acquiring the local geometric features of the filtered path data and calibrating and adjusting the filtered path data based on the local geometric features to determine the target centerline position data includes: Analyze the node tangent features and curvature features of the filtered path data to obtain local geometric features; The local geometric features are filtered according to a preset curvature threshold to determine the data in the interval to be corrected, and a source point set and a target point set are constructed for the data in the interval to be corrected. Iterative nearest-point processing is performed on the source point set and the target point set to obtain transformation matrix data; The node coordinates within the data interval to be corrected are calibrated based on the transformation matrix data to determine the target centerline position data.
8. An online pipe bending dimension detection system, characterized in that, include: The image equalization module is used to acquire the original image data of the curved pipe, and perform adaptive equalization processing on the original image data to obtain enhanced image data; The region segmentation module is used to acquire the gray-level gradient distribution data of the enhanced image data, perform region segmentation on the gray-level gradient distribution data using a preset convolutional neural network model, and extract the edge coordinate set to obtain the tube region boundary data. The three-dimensional reconstruction module is used to capture and analyze the area defined by the boundary data of the pipe body region to obtain absolute phase data, and generate initial point cloud data by combining it with preset system calibration parameters. The point cloud optimization module is used to perform density statistics on the initial point cloud data to obtain density distribution characteristics, and to filter out sparse boundary point sets by combining a preset density threshold. The sparse boundary point sets are then fitted and interpolated to obtain homogenized point cloud data. The centerline fitting module is used to perform centerline fitting processing on the homogenized point cloud data to obtain preliminary path data, and to perform continuous filtering processing on the preliminary path data to obtain filtered path data. The path calibration module is used to acquire the local geometric features of the filtered path data, and to perform calibration and adjustment processing on the filtered path data based on the local geometric features to determine the target centerline position data. The dimension calculation module is used to perform dimension calculations based on the target centerline position to obtain a set of dimension parameters.