PVC pipe size detection method and device based on high-resolution semantic segmentation

Through the combination of ISDNet model and RAF module, shallow and deep features are integrated to extract high-resolution semantic segmentation results of PVC pipes, which solves the problem of low detection accuracy and reliability in traditional methods and achieves high-precision pipe size detection. .

CN118397072BActive Publication Date: 2024-10-22XIANGJIANG LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410816573.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-10-22
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

The existing technology has low detection accuracy and reliability in PVC pipe size detection, manual fixed-point measurement efficiency is low, traditional deep learning semantic segmentation methods are difficult to capture high-resolution details, and have poor anti-interference, resulting in inaccurate detection results.

Method used

A high-resolution semantic segmentation method based on the ISDNet model is used to obtain high-frequency residual images through Laplacian pyramid transform, combined with the RAF module to fuse shallow and deep features, and use parallel branches to generate attention layer parameters for channel attention. Enhanced and fused with the spatial attention module to extract pipeline edge area and size information.

Benefits of technology

It improves the accuracy and robustness of edge feature extraction of PVC pipes, achieves high-precision pipe size detection, and enhances the reliability and efficiency of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118397072B_ABST
    Figure CN118397072B_ABST
Patent Text Reader

Abstract

The present invention discloses a PVC pipe size detection method and device based on high-resolution semantic segmentation, the method steps include: step S01: obtaining an original image for transformation to obtain an image to be segmented; step S02: inputting the image to be segmented into a high-resolution semantic segmentation model for semantic segmentation, the high-resolution semantic segmentation model is based on an ISDNet model, and in a RAF module, two parallel branches are used to generate attention layer parameters for shallow and deep feature maps respectively, and MLP layer fusion is used to fuse shallow and deep channel attention parameters, and then fused with a spatial attention module to obtain the final spatial attention parameters; step S03: extracting a pipe edge area from the high-resolution semantic segmentation result; step S04. Extracting the size information of the PVC pipe from the pipe edge area. The present invention has the advantages of simple implementation method, low cost, high detection accuracy, high reliability, strong robustness, etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of visual inspection technology, and in particular to a PVC (Polyvinyl Chloride) pipe size detection method and device based on high-resolution semantic segmentation. Background Art

[0002] As a common pipe material, PVC pipe has excellent corrosion resistance, heat resistance, pressure resistance and wear resistance. It is widely used in construction, agriculture, industry, transportation, environmental protection and other fields. It can be used for drainage, ventilation, water supply, irrigation, transportation of fertilizers, chemicals, oil, natural gas, etc. In order to ensure the safety and reliability of the pipeline, it is very important to conduct relevant quality inspections on it. The size detection of PVC pipes is the focus of PVC pipe quality inspection. For the size detection of PVC pipes, it is currently usually dependent on manual use of measuring tools (such as micrometers) for relevant size detection, and the measuring tool measurement can only be fixed-point measurement. Therefore, each test requires multiple fixed-point tests and then the average is taken as the final test value. This type of manual fixed-point multiple measurement method cannot cover all the detection points of the detection object and the detection accuracy will be affected by the detection position, resulting in low accuracy and reliability of the detection results. On the other hand, the efficiency of manual detection is low, so it is generally adopted. The method of random inspection is difficult to achieve full inspection, resulting in the overall product quality being difficult to guarantee.

[0003] Visual inspection uses image processing technology to collect image data of target objects for image processing to achieve detection and analysis of target objects. Semantic segmentation is the key to visual inspection, which aims to assign each pixel in the image to one or more categories to distinguish different objects and scene elements in the image. Traditional deep learning semantic segmentation is usually trained on images within a fixed resolution range. In order to maintain the clarity and details of the image content, low resolution (less than ) segmentation and bilateral upsampling. However, the diameter of PVC pipes is large, which requires high detection accuracy and image resolution. Due to problems such as pipe manufacturing process, there will be interference such as burrs and dirt on the pipe surface, resulting in unclear features in some edge areas of the pipe. At the same time, due to the large volume of the pipe itself, it is difficult to build a black room environment. Pipe image acquisition is also easily affected by changes in ambient light. The traditional visual detection method based on deep learning semantic segmentation uses bilateral upsampling of low-resolution segmentation, which cannot fully capture the high-resolution (no less than 100) along the object boundary. ) details, resulting in inaccurate segmentation and poor anti-interference for higher-resolution images, which will make the detection accuracy and reliability low. Summary of the invention

[0004] The technical problem to be solved by the present invention is: in response to the technical problems existing in the prior art, the present invention provides a PVC pipe size detection method and device based on high-resolution semantic segmentation, which has a simple implementation method, low cost, high detection accuracy, high reliability and strong robustness.

[0005] In order to solve the above technical problems, the technical solution proposed by the present invention is:

[0006] A PVC pipe size detection method based on high-resolution semantic segmentation, comprising the following steps:

[0007] Step S01. Obtain the original PVC pipe image and perform Laplace pyramid transform to obtain the high-frequency residual image of the 0th layer, the high-frequency residual image of the 1st layer and the down-sampled original image of the 2nd layer as the image to be segmented;

[0008] Step S02: input the image to be segmented into a high-resolution semantic segmentation model for semantic segmentation, and obtain a high-resolution semantic segmentation result output;

[0009] The high-resolution semantic segmentation model is based on an ISDNet (Integrating Shallow and DeepNetworks) model, and in a RAF (Relation-Aware feature Fusion) module for fusing shallow features with deep features, two parallel branches are used to generate attention layer parameters for shallow feature maps and deep feature maps respectively, and an MLP (Multilayer Perceptron) layer is used to fuse the attention layer parameters generated by the two parallel branches to form corresponding shallow channel attention parameters and deep channel attention parameters, and the shallow channel attention parameters and the deep channel attention parameters are fused to generate attention-enhanced fused features, and then the attention-enhanced fused features are fused with a spatial attention module to obtain final spatial attention parameters, and one of the two parallel branches includes a GAP (Global Average Pooling Layer) layer and an MLP layer connected in sequence, and the other branch includes a GAP layer and a convolutional layer connected in sequence;

[0010] Step S03. Extracting the pipeline edge region from the high-resolution semantic segmentation result;

[0011] Step S04: extracting the size information of the PVC pipe from the edge area of ​​the pipe.

[0012] Furthermore, the RAF module is sequentially provided with a shallow channel submodule, a deep channel submodule, a fusion module and the spatial attention module. The shallow channel submodule and the deep channel submodule are respectively used to extract shallow features and deep features correspondingly. The fusion module fuses the extracted shallow features and deep features to obtain fused features after attention enhancement. The shallow channel module and the deep channel submodule are both provided with a channel attention unit, an addition unit and a product unit connected in sequence. The channel attention unit fuses the shallow feature map / deep feature map through the two parallel branches, and then uses the MLP layer to obtain the initial shallow / deep channel attention parameters. The addition unit receives the fused attention parameters and the initial shallow / deep channel attention parameters respectively and adds them. The product unit receives the output result of the addition unit and the original shallow / deep input feature map respectively for product calculation to obtain the final shallow / deep channel attention output. The fused attention parameters are the parameters obtained by fusing the initial shallow channel attention parameters with the initial deep channel attention parameters through the MLP layer.

[0013] Furthermore, the convolution layer is a 1×1 convolution layer, and an upsampling unit is provided at the output end of the product unit of the deep channel submodule, and the output result of the product unit is upsampled to obtain the final deep attention parameter.

[0014] Furthermore, the spatial attention module uses a feature extraction splicing layer formed by splicing a 1×1 convolutional layer, a maxpool (maximum pooling) layer, and an avgpool (average pooling) layer to extract and splice the attention-enhanced fusion features, and the 1×1 convolutional layer samples the hole convolution for convolution calculation.

[0015] Furthermore, in the high-resolution semantic segmentation model, based on the ISDNet (Integrating Shallow and Deep Networks) model, the high-frequency residual image of the first layer is upsampled and fused with the high-frequency residual image of the 0th layer, and then input into the Shallow Branch module in the ISDNet model for shallow feature map extraction, and the downsampled original image of the second layer is used as the input of the Deep Branch module in the ISDNet model. The output of the Deep Branch module is fused with the output of the Shallow Branch through upsampling and the RAF module to form a high-resolution semantic segmentation prediction. The Deep Branch module is also used to generate a low-resolution semantic segmentation prediction, which together with the high-resolution semantic segmentation prediction constitutes a cross loss, and generates a high-resolution original image to form a high-resolution reconstruction loss and a structural distillation loss.

[0016] Furthermore, step S01 includes:

[0017] For the original high-resolution image Perform Gaussian downsampling to get the first downsampled image , and the first downsampled image Gaussian upsampling is performed to obtain the image , the original high-resolution image With image Subtract to get the high-frequency residual image of layer 0 ;

[0018] For the first down-sampled image Perform Gaussian downsampling to obtain the second layer of downsampled original image ;

[0019] The second layer downsamples the original image Gaussian upsampling is performed to obtain the image , the first down-sampled image With the image Subtract to get the high-frequency residual image of the first layer .

[0020] Furthermore, the step S03 includes:

[0021] Step S301. Obtain a binary image of the pipeline area, and perform a noise interference filtering operation, and use the maximum connected domain area of ​​the binary image after the noise interference filtering as the final binary image of the pipeline area;

[0022] Step S302: performing edge detection on the binary image of the pipeline region to obtain a binary edge image;

[0023] Step S303: on the binary edge image, performing sub-pixel interpolation in the local neighborhood of each edge pixel to obtain a sub-pixel edge point set;

[0024] Step S304: thinning the sub-pixel edge point set to finally obtain the sub-pixel point set of the pipe edge;

[0025] Step S305. Obtain sub-pixel edge binary images of the inner and outer walls of the pipeline according to the sub-pixel point set of the pipeline edge and obtain a minimum circumscribed matrix to identify the inner and outer wall edge point set;

[0026] Step S306: Classify the inner edge points and outer edge points in the inner and outer edge point sets according to the outer edge point features, and finally obtain the classified inner and outer edge point sets.

[0027] Furthermore, the size information of the PVC pipe includes any one of an inner and outer diameter, a wall thickness and an outer wall out-of-roundness. The inner and outer diameters are obtained by fitting the inner and outer circles of the inner and outer wall sub-pixel edge point sets respectively and calculating the inner and outer circle diameters. The wall thickness is obtained by calculating the statistical value of the distance between the inner circle edge point set and the outer circle edge point set. The outer wall out-of-roundness is the difference between the maximum and minimum diameters on the cross section of the PVC pipe.

[0028] Furthermore, the step of extracting the out-of-roundness of the outer wall includes:

[0029] Calculate the distance from the outer edge point to the center of the outer circle, and subtract it from the outer circle radius to get the distance from the outer edge point to the outer circle edge ;

[0030] Filter the noise points in the outer edge point set to obtain the outer edge point set after the noise is filtered;

[0031] The outer edge point set after noise filtering is used to obtain the fitting ellipse of the outer edge, and the difference between the major and minor axis distances of the fitting ellipse is calculated as the out-of-roundness:

[0032]

[0033] in, Indicates out-of-roundness. represents the major axis of the ellipse, Represents the minor axis of the ellipse.

[0034] A PVC pipe size detection device based on high-resolution semantic segmentation includes a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.

[0035] Compared with the prior art, the advantages of the present invention are as follows: in the process of segmenting the PVC pipe image, the present invention uses the GAP layer + MLP layer and the GAP layer + convolution layer two parallel branches to generate attention layer parameters for the shallow and deep feature maps by the RAF module based on the ISDNet model, forming a parallel multi-model fusion strategy, and using the MLP layer to fuse the attention layer parameters generated by the two parallel branches to form channel attention parameters, which can fully and effectively fuse the global semantics and local semantics of the attention feature parameters, and improve the feature representation ability of the channel attention parameters. At the same time, by fusing the shallow and deep channel attention parameters and then fusing them with the spatial attention module to obtain the final spatial attention parameters, pixel-level attention enhancement can be achieved, and the ability to distinguish between foreground and background can be further enhanced, which can greatly improve the accuracy and robustness of PVC pipe edge feature extraction, and then extract the pipe edge area based on the semantic segmentation result, and then based on the pipe edge area, the PVC pipe size can be detected quickly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a schematic diagram of the implementation process of the PVC pipe size detection method based on high-resolution semantic segmentation in this embodiment.

[0037] Figure 2 It is a schematic diagram of the structural principle of the data acquisition system constructed in this embodiment.

[0038] Figure 3 It is a schematic diagram of a PVC pipe image collected in a specific application embodiment of the present invention.

[0039] Figure 4 Schematic diagram of the camera calibration process in this embodiment.

[0040] Figure 5 Schematic diagram of a chessboard image used for calibration in this embodiment.

[0041] Figure 6 It is a schematic diagram of the process of performing Laplace pyramid transformation in this embodiment.

[0042] Figure 7 Schematic diagram of the structural principle of the high-resolution semantic segmentation model used in this embodiment.

[0043] Figure 8 It is a schematic diagram of the structural principle of the RAF module used in this embodiment.

[0044] Fig. 9 Schematic diagram of the structural principle of the SAM module used in this embodiment.

[0045] Fig.10It is a schematic diagram of the detailed steps of extracting internal and external edge point sets in this embodiment. DETAILED DESCRIPTION

[0046] The present invention is further described below in conjunction with the accompanying drawings and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.

[0047] like Figure 1 As shown, the steps of the PVC pipe size detection method based on high-resolution semantic segmentation in this embodiment include:

[0048] Step S01: Obtain the original PVC pipe image and perform Laplace pyramid transform to obtain the high-frequency residual image of the 0th layer , the high-frequency residual image of the first layer And the second layer downsamples the original image And as the image to be segmented.

[0049] Since the pipe is generally 4-5m long and has a maximum diameter of 160mm, it is difficult to build a darkroom environment and the influence of ambient light on the pipe image cannot be avoided. In order to obtain clear and characteristic PVC pipe images for subsequent PVC pipe size detection, this embodiment first constructs a data acquisition system consisting of an LED ring light source, an industrial color camera, a PVC pipe V-shaped support device, an automatic lifting baffle, etc. Figure 2 As shown, the industrial camera is parallel to the front of the PVC pipe and maintains a fixed object distance. The industrial camera is located at the central axis of the ring-shaped light source to ensure that the pipeline area is well-lit as much as possible and to capture a clear pipeline image. A V-shaped support device is provided to fix and support the PVC pipe. At the same time, a baffle that can be automatically raised and lowered is provided to adapt to the length changes of different PVC pipes. When the PVC pipe hits the baffle, the baffle automatically drops to ensure that the camera can capture the front of the pipe and keep the object distance unchanged. The PVC pipe image captured in the specific application embodiment is shown in FIG. Figure 3 shown.

[0050] Considering that the maximum diameter of the PVC pipe to be detected is 160mm and the detection accuracy is 0.1mm, the physical distance represented by a single pixel must be <= 0.1mm. In order to ensure the detection accuracy, the minimum physical size of the camera field of view is , the camera resolution used in this embodiment is greater than .

[0051] The camera needs to be calibrated before data collection. Camera calibration mainly includes two parts: calculation of distortion coefficient and calculation of physical distance represented by a single pixel at a specific object distance. The distortion of the camera lens includes radial distortion and tangential distortion. Since radial distortion is much larger than tangential distortion, the impact of radial distortion on image quality is mainly considered. Radial distortion is mainly caused by different radial curvatures of the lens. This embodiment uses the classic Zhang Zhengyou calibration algorithm to calculate the radial distortion coefficient of the camera, such as Figure 4 As shown, the detailed steps are:

[0052] (1) Obtain chessboard images from different perspectives: Take a chessboard image (such as Figure 5 The chessboard is placed on a plane and a camera is used to take several chessboard pictures from different angles.

[0053] (2) Obtaining checkerboard image feature points: Use the relevant feature point extraction algorithm to extract checkerboard feature points.

[0054] (3) Solve the intrinsic and extrinsic parameters of the camera under ideal conditions: Determine the pixel coordinates and world coordinates of the extracted checkerboard feature points, solve the intrinsic and extrinsic parameters of the camera under ideal conditions, and use maximum likelihood estimation to improve accuracy.

[0055] (4) Calculate the actual radial distortion coefficient: Use the least squares method to calculate the actual radial distortion coefficient.

[0056] (5) Optimize camera calibration parameters: Comprehensively consider internal parameters, external parameters, and distortion coefficients, and use the maximum likelihood estimation method to estimate parameters and improve estimation accuracy.

[0057] In this embodiment, when calculating the physical distance represented by a single pixel at a specific object distance, the camera plane is ensured to be parallel to the chessboard plane at the specific object distance, and the physical distance represented by a single pixel is calculated using the following formula (1):

[0058] (1)

[0059] Where d represents the physical distance represented by each pixel; S represents the actual physical distance represented by n pixels in the image plane.

[0060] It is understandable that the composition structure and construction method of the above-mentioned data acquisition system and the camera calibration method can be implemented in other ways according to actual needs.

[0061] After building a data acquisition system and calibrating the camera according to the above steps, the image of the PVC pipe to be tested is acquired to obtain the original PVC pipe image, and then the original PVC pipe image is transformed by Laplace pyramid, as shown in the figure. Figure 6 As shown, the specific steps include:

[0062] For the original high-resolution image Perform Gaussian downsampling to get the first downsampled image , and the first downsampled image Gaussian upsampling is performed to obtain the image , the original high-resolution image With image Subtract to get the high-frequency residual image of layer 0 ;

[0063] For the first downsampled image Perform Gaussian downsampling to obtain the second layer of downsampled original image ;

[0064] Downsample the original image in layer 2 Gaussian upsampling is performed to obtain the image , the first downsampled image With image Subtract to get the high-frequency residual image of the first layer .

[0065] According to the above method, the high-frequency residual image of layer 0 is obtained High-frequency residual image of layer 1 And the second layer downsamples the original image After that, the , and As input to a high-resolution semantic segmentation model.

[0066] Step S02: Input the image to be segmented into a high-resolution semantic segmentation model for semantic segmentation, and obtain a high-resolution (no less than ) is the semantic segmentation result output. The high-resolution semantic segmentation model is based on the ISDNet model, and in the RAF module used to fuse shallow features and deep features, two parallel branches are used to generate attention layer parameters for the shallow feature map and the deep feature map respectively, and the MLP layer is used to fuse the attention layer parameters generated by the two parallel branches to form the corresponding shallow channel attention parameters and deep channel attention parameters. The shallow channel attention parameters and the deep channel attention parameters are fused to generate the fused features after attention enhancement, and then the fused features after attention enhancement are fused with the spatial attention module to obtain the final spatial attention parameters. One of the two parallel branches includes a GAP layer and an MLP layer connected in sequence, and the other branch includes a GAP layer and a convolutional layer connected in sequence.

[0067] The ISDNet model is a framework for ultra-high-resolution image segmentation. For a given high-resolution image, it first decomposes it into a Laplacian pyramid to obtain an RGB downsampled low-frequency image and a high-frequency residual. The high-frequency residual is processed by a shallow network, and the RGB downsampled low-frequency image is processed by a deep network. Then, the RAF module fuses features from different branches to enhance the performance and robustness of the model. The RAF module receives feature maps from the shallow network and the deep network, and uses the GAP+MLP layer to perform channel-level attention operations on the feature maps from the deep and shallow networks to highlight important features and suppress unimportant features. Then, the correlation matrix between the shallow features and the deep features is calculated to quantify the relationship between different feature maps. Then, the weights of different feature maps are dynamically adjusted according to the correlation matrix using operations such as inner product. The fused feature map will contain both high-frequency detail information from the shallow layer and high-level semantic information from the deep layer, thereby providing richer feature representations for subsequent segmentation tasks. However, the RAF module in the traditional ISDNet model only uses the GAP+MLP layer to generate channel attention parameters, which cannot effectively integrate the global semantics and local semantics of the channel feature attention parameters, making it difficult to improve the feature representation ability of the channel feature attention parameters. The diameter of PVC pipes is large, and there may be interference such as burrs and dirt on the pipe surface. The features of some edge areas of the pipe are not obvious, so the edge detection accuracy of the pipe area segmented directly using the traditional ISDNet model needs to be further improved.

[0068] In order to further improve the edge detection accuracy of pipeline area, Figure 7 , 8As shown, this embodiment improves the RAF module based on the ISDNet model to form a high-resolution semantic segmentation model that can achieve high-resolution semantic segmentation. In this model, the RAF module uses two parallel branches to generate attention layer parameters for shallow feature maps and deep feature maps, respectively. The two parallel branches correspond to the GAP layer + MLP layer and the GAP layer + convolution layer, respectively, to form a multi-model fusion strategy of GAP + MLP layer and GAP + convolution layer in parallel. The MLP layer is used to fuse the attention layer parameters generated by the two parallel branches to form channel attention parameters. Compared with the traditional single model to generate channel attention parameters, this embodiment can fully and effectively fuse the global semantics and local semantics of the attention feature parameters through the multi-model fusion strategy, further improve the channel attention parameter feature representation ability, and improve the algorithm model generalization ability. At the same time, this embodiment fuses the shallow channel attention parameters and the deep channel attention parameters to obtain the feature layer after the channel attention is enhanced, and then fuses them with the spatial attention module (SAM) to obtain the final spatial attention parameters, which can achieve pixel-level attention enhancement and further enhance the ability to distinguish between foreground and background. By combining the channel attention mechanism and the spatial attention mechanism, the model feature representation ability can be greatly improved, and the robustness and accuracy of PVC pipe edge feature extraction can be improved.

[0069] like Figure 7 As shown, in the high-resolution semantic segmentation model in this embodiment, the high-frequency residual image of the first layer is converted based on the ISDNet model. Upsample and compare with the high-frequency residual image at layer 0 After fusion, the shallow branch module in the ISDNet model is input to extract shallow feature maps, and the second layer is downsampled to the original image. As the input of the Deep Branch module in the ISDNet model, the Deep Branch module is used to fuse the output of the Deep Branch module with the output of the Shallow Branch through upsampling and the RAF module to form a high-resolution semantic segmentation prediction. The Deep Branch module is also used to generate low-resolution semantic segmentation predictions, and together with the high-resolution semantic segmentation predictions, form a cross loss, and generate high-resolution original images to form high-resolution reconstruction losses and structural distillation losses. That is, the output of DeepBranch has three main uses: the first is to generate low-resolution semantic segmentation predictions, and together with subsequent high-resolution semantic segmentation predictions, form a segmentation loss (cross loss); the second is to generate high-resolution original images to form high-resolution reconstruction losses. and structural distillation losses Since Deep Branch uses low-resolution images as input, it will produce noisy features, especially around the boundaries. This embodiment can form a more accurate representation by using high-resolution reconstruction loss and structural distillation loss during model training. The third is to fuse it with the output of Shallow Branch through upsampling and RAF modules to form a high-resolution semantic segmentation prediction.

[0070] In this embodiment, the training loss function of the entire high-resolution semantic segmentation model consists of four types of loss functions: high-resolution semantic segmentation loss , high-resolution semantic segmentation auxiliary loss , high-resolution reconstruction loss and structural distillation losses ), the overall loss function calculation formula can be specifically expressed as:

[0071] (2)

[0072] in, represents the original image, Represents the reconstructed image.

[0073] (3)

[0074] in, Output feature layer for Deep Branch, The feature layer after downsampling of the super-resolution reconstruction feature layer (size and consistent).

[0075] (4)

[0076] in, represents the high-resolution semantic segmentation cross loss, represents the cross loss for low-resolution semantic segmentation.

[0077] like Figure 8As shown, in the RAF module of this embodiment, a shallow channel submodule, a deep channel submodule, a fusion module and a spatial attention module are sequentially arranged. The shallow channel submodule and the deep channel submodule are respectively used to extract shallow features and deep features correspondingly. The fusion module fuses the extracted shallow features and deep features to obtain fused features after attention enhancement. The shallow channel module and the deep channel submodule are both provided with a channel attention unit, an addition unit and a product unit connected in sequence. The channel attention unit fuses the shallow feature map / deep feature map through two parallel branches, and then uses the MLP layer to obtain the initial shallow / deep channel attention parameters. The addition unit receives the fused attention parameters and the initial shallow / deep channel attention parameters respectively and adds them. The product unit receives the output result of the addition unit and the original shallow / deep input feature map respectively to perform product calculation to obtain the final shallow / deep channel attention output. The fused attention parameter is the parameter obtained by fusing the initial shallow channel attention parameter with the initial deep channel attention parameter through the MLP layer. In this embodiment, the convolution layer is specifically a 1×1 convolution layer, and an upsampling unit is further provided at the output end of the product unit of the deep channel submodule, and the output result of the product unit is upsampled to obtain the final deep attention parameter. The product unit specifically performs a Schur product operation.

[0078] Specifically, the shallow channel submodule passes the input shallow feature map through two parallel branches (GAP layer + MLP layer and GAP layer + convolution layer), and then uses the MLP layer to fuse it to obtain the initial shallow channel attention parameters. The initial shallow channel attention parameters are fused with the initial deep channel attention parameters to form fused attention parameters. The fused attention parameters are converted into one-dimensional data and added to the initial shallow channel attention parameters after passing through MLP, and then the Schur product operation is performed with the original shallow feature map to obtain the final shallow attention parameters; correspondingly, the deep channel submodule passes the input deep feature map through two parallel branches (GAP layer + MLP layer and GAP layer + convolution layer), and then uses the MLP layer to fuse it to obtain the initial deep channel attention parameters. The initial shallow channel attention parameters are fused with the initial deep channel attention parameters to form fused attention parameters. The fused attention parameters are converted into one-dimensional data and added to the initial deep channel attention parameters after passing through MLP, and then the Schur product operation is performed with the original deep feature map to obtain the final deep attention parameters.

[0079] Traditional segmentation models usually directly use the Concat (connection) and Add (addition) methods to fuse features from different branches or apply the attention mechanism to re-weight different channels for each feature map. However, the premise of this type of method is to assume that the features from deep branches and shallow branches contribute equally to feature fusion, which is actually unreasonable. Figure 8 , where the upper and lower branches correspond to the processing of the input feature map by the shallow and deep branches respectively. This embodiment dynamically fuses the feature information under different branches by utilizing the relationship between shallow features (detailed spatial information) and deep features (high-level semantic information) in the RAF module, and uses the MLP layer to further fuse the attention layer parameters generated by multiple parallel models through a multi-model (MLP layer, 1x1 convolution layer in parallel) fusion strategy to form channel attention parameters. Compared with the generation of channel attention parameters by a single model, the global semantics and local semantics of the attention feature parameters can be fully and effectively fused, thereby improving the feature representation capability of the channel attention parameters and the model generalization capability.

[0080] like Fig. 9 As shown, the spatial attention module (SAM module) in this embodiment specifically uses a feature extraction splicing layer formed by splicing a 1×1 convolution layer, a maxpool layer, and an avgpool layer to extract and splice the fused features after attention enhancement, and the sampling hole convolution in the 1×1 convolution layer performs convolution calculation. Compared with the traditional SAM module using maxpool and avgpool for feature extraction and feature splicing, the SAM module in this embodiment adds conv 1x1 convolution for further feature extraction and splices with the maxpool and avgpool extracted features to obtain a new feature layer, which can effectively reduce the feature loss caused by maxpool and avgpool. At the same time, a dilated convolution (specifically, the convolution kernel is 7x7, and the hole rate rate=1) is used to increase the convolution receptive field to achieve further feature extraction and fusion of the new feature layer. Compared with the same size receptive field of traditional convolution, the use of hole convolution can enhance the connection between feature points without increasing calculation parameters, and can also improve the generalization ability of the model. Finally, the sigmoid function is used to normalize the fused feature layer to obtain the final spatial attention parameters. By combining the channel attention mechanism with the spatial attention mechanism, the model feature representation capability can be greatly improved, thereby improving the robustness and accuracy of PVC pipe edge feature extraction.

[0081] Step S03: extracting the pipeline edge region from the high-resolution semantic segmentation result.

[0082] like Fig.10 As shown, the detailed steps of extracting the pipeline edge area from the high-resolution semantic segmentation result in this embodiment are:

[0083] Step S301. Binary image preprocessing: Obtain a binary image of the pipeline area, and perform a noise interference filtering operation, and use the maximum connected domain area of ​​the binary image after the noise interference is filtered out as the final binary image of the pipeline area.

[0084] Specifically, operations such as corrosion, expansion, and filtering of small objects are performed on the binary image of the pipeline area to filter out related noise interference, and the maximum connected domain area of ​​the binary image after filtering out the interference is obtained as the final binary image of the pipeline area.

[0085] Step S302. Pixel edge extraction: edge detection is performed on the binary image of the pipeline area to obtain a binary edge image.

[0086] Step S303: Sub-pixelization of edge pixels: on the binary edge image, sub-pixel interpolation is performed in the local neighborhood of each edge pixel to obtain a sub-pixel edge point set.

[0087] Step S304: Edge refinement: refine the sub-pixel edge point set to finally obtain the sub-pixel point set of the pipe edge.

[0088] Since the PVC pipe size detection accuracy requirement is high, improving the size detection accuracy by increasing the camera resolution will increase the hardware cost and reduce the algorithm operation efficiency. In order to achieve a higher size detection accuracy without increasing the hardware cost and reducing the algorithm operation efficiency, this embodiment uses a sub-pixel edge detection algorithm to sub-pixelize the pipe edge points. First, an edge detection algorithm (such as Sobel, Canny, etc.) is used to perform edge detection on the pipe binary image to obtain a binary edge image. Then, on the binary edge image, sub-pixel interpolation is performed in the local neighborhood of each edge pixel. The sub-pixel position of the edge pixel is fitted by using a cubic spline interpolation operation or the like. Then, a mathematical morphology thinning algorithm is used to thin the sub-pixel edge point set to reduce noise and redundant information, improve edge positioning accuracy, and finally obtain a sub-pixel point set of the pipe edge.

[0089] Step S305. Obtain sub-pixel edge binary images of the inner and outer walls of the pipeline according to the sub-pixel point set of the pipeline edge and obtain a minimum circumscribed matrix, and identify the inner and outer wall edge point sets by the minimum circumscribed matrix.

[0090] Step S306: Classify the inner edge points and outer edge points in the inner and outer edge point sets according to the outer edge point features, and finally obtain the classified inner and outer edge point sets.

[0091] Since the semantic segmentation model may have certain misrecognition or omission of some pipeline edge areas, resulting in certain noise and incompleteness in the inner and outer wall edge point sets, the inner and outer edge point sets cannot be directly distinguished. In this embodiment, the inner and outer edge point sets are distinguished according to the outer edge point features (the coordinate point set of the first sub-pixel edge point is searched in the positive and reverse directions along the horizontal axis of the minimum circumscribed moment of the outer edge of the pipeline) to obtain the inner and outer edge point sets.

[0092] Step S04: Extracting the size information of the PVC pipe from the edge area of ​​the pipe.

[0093] Specifically, the dimensional information of the PVC pipe includes the inner and outer diameters, wall thickness and outer wall out-of-roundness, etc. The inner and outer diameters are obtained by fitting the inner and outer circles with the sub-pixel edge point sets of the inner and outer walls respectively and calculating the inner and outer circle diameters. The wall thickness is the distance between the edges of the inner and outer circles. The wall thickness is obtained by calculating the statistical value of the distance between the inner circle edge point set and the outer circle edge point set. The outer wall out-of-roundness is the difference between the maximum and minimum diameters on the cross section of the PVC pipe, which is also the ellipticity or out-of-roundness.

[0094] In a specific application embodiment, the inner and outer circles can be obtained by fitting the inner and outer circles respectively using the sub-pixel edge point sets of the inner and outer walls by least squares or Hough transform, and then calculating the inner and outer circle diameters.

[0095] In a specific application embodiment, due to the problem of the PVC tube manufacturing process, the inner and outer circles are not concentric circles, and the diameter uses the difference between the radii, which will cause theoretical calculation errors. In this embodiment, the average value of the distance between the inner circle edge point set and the outer circle edge point set is calculated as the wall thickness of the final PVC tube. The specific steps are:

[0096] Step 1) Discretization of inner and outer circles: Discretize the inner and outer circles according to a certain angular spacing to obtain the inner and outer circle discrete point sets.

[0097] Step 2) Distance between the inner and outer circle edges: Find the minimum distance from each point on the inner circle to the outer circle edge .

[0098] Step 3) Calculate the wall thickness: sum the minimum distance sets in 2 and take the average as the wall thickness .

[0099] (5)

[0100] In the formula represents the minimum distance from the jth inner circle edge point to the outer circle edge, and n represents the number of inner circle edge points.

[0101] In this embodiment, the out-of-roundness is obtained by using the fitting ellipse of the outer wall edge points according to the definition of out-of-roundness. The detailed steps include:

[0102] Calculate the distance from the outer edge point to the center of the outer circle, and subtract it from the outer circle radius to get the distance from the outer edge point to the outer circle edge ;

[0103] (6)

[0104] In the formula, x and y represent the coordinates of the outer edge points. , represents the center of the outer fitting circle, and R represents the radius of the outer circle.

[0105] Filter the noise points in the outer edge point set to obtain the outer edge point set after the noise is filtered;

[0106] Due to the limitations of the segmentation algorithm and the presence of interference in the image, some edge points of the edge point set are not real edge points, so they need to be filtered out to avoid affecting the calculation of the out-of-roundness. In this embodiment, the outer edge points with a spacing greater than 1.5d (which can be configured according to actual needs) are filtered out by calculating the mean d of the spacing between the outer edge point set and the outer circle edge, and finally the outer edge point set after filtering the noise is obtained.

[0107] The outer edge point set after filtering noise is used to obtain the fitting ellipse of the outer edge by using the least square method or Hough transform, and the difference between the major and minor axis distances of the fitting ellipse is calculated as the out-of-roundness, as shown in the following formula:

[0108] (7)

[0109] In the formula Indicates out-of-roundness. represents the major axis of the ellipse, Represents the minor axis of the ellipse.

[0110] The PVC pipe size detection device based on high-resolution semantic segmentation in this embodiment includes:

[0111] The transformation module is used to obtain the original PVC pipe image and perform Laplace pyramid transformation to obtain the high-frequency residual images of the 0th and 1st layers and the downsampled original image of the 2nd layer as the image to be segmented;

[0112] A high-resolution semantic segmentation module is used to input the image to be segmented into a high-resolution semantic segmentation model for semantic segmentation, and obtain a high-resolution semantic segmentation result output; the high-resolution semantic segmentation model is based on the ISDNet model, and in the RAF module used to fuse shallow features and deep features, two parallel branches are used to generate attention layer parameters for shallow features and deep features respectively, and the MLP layer is used to fuse the attention layer parameters generated by the two parallel branches to form channel attention parameters, and the feature layer after channel attention enhancement is obtained, and then the feature layer after channel attention enhancement is fused with the spatial attention module to achieve pixel-level attention enhancement, and the final spatial attention parameters are obtained. One of the two parallel branches includes a GAP layer and an MLP layer connected in sequence, and the other branch includes a GAP layer and a convolution layer connected in sequence;

[0113] The edge extraction module is used to extract the pipeline edge area from the high-resolution semantic segmentation results;

[0114] The size detection module is used to extract the size information of the PVC pipe from the edge area of ​​the pipe.

[0115] The PVC pipe size detection system based on high-resolution semantic segmentation in this embodiment corresponds one to one with the above-mentioned PVC pipe size detection method based on high-resolution semantic segmentation, and will not be described one by one here.

[0116] In another embodiment, the PVC pipe size detection system based on high-resolution semantic segmentation of the present invention may also include a processor and a memory, the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.

[0117] Those skilled in the art should understand that the above-mentioned embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0118] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.

Claims

1. A PVC pipe size detection method based on high-resolution semantic segmentation, characterized in that the steps include: Step S01. Obtain the original PVC pipe image and perform Laplace pyramid transform to obtain the high-frequency residual image of the 0th layer, the high-frequency residual image of the 1st layer and the down-sampled original image of the 2nd layer as the image to be segmented; Step S02: input the image to be segmented into a high-resolution semantic segmentation model for semantic segmentation, and obtain a high-resolution semantic segmentation result output; The high-resolution semantic segmentation model is based on the ISDNet model, and in the RAF module for fusing shallow features and deep features, two parallel branches are used to generate attention layer parameters for the shallow feature map and the deep feature map respectively, and the MLP layer is used to fuse the attention layer parameters generated by the two parallel branches to form corresponding shallow channel attention parameters and deep channel attention parameters, and the shallow channel attention parameters and the deep channel attention parameters are fused to generate attention-enhanced fused features, and then the attention-enhanced fused features are fused with the spatial attention module to obtain the final spatial attention parameters, and one of the two parallel branches includes a GAP layer and an MLP layer connected in sequence, and the other branch includes a GAP layer and a convolutional layer connected in sequence; Step S03. Extracting the pipeline edge region from the high-resolution semantic segmentation result; Step S04. Extracting the size information of the PVC pipe from the edge area of ​​the pipe; The RAF module is sequentially provided with a shallow channel submodule, a deep channel submodule, a fusion module and the spatial attention module. The shallow channel submodule and the deep channel submodule are respectively used to extract shallow features and deep features correspondingly. The fusion module fuses the extracted shallow features and deep features to obtain fused features after attention enhancement. The shallow channel module and the deep channel submodule are both provided with a channel attention unit, an addition unit and a product unit connected in sequence. The channel attention unit fuses the shallow feature map / deep feature map through the two parallel branches and obtains the initial shallow / deep channel attention parameters through the MLP layer. The addition unit receives the fused attention parameters and the initial shallow / deep channel attention parameters respectively and adds them. The product unit receives the output result of the addition unit and the original shallow / deep input feature map respectively for product calculation to obtain the final shallow / deep channel attention output. The fused attention parameters are the parameters obtained by fusing the initial shallow channel attention parameters with the initial deep channel attention parameters through the MLP layer.

2. The PVC pipe size detection method based on high-resolution semantic segmentation according to claim 1 is characterized in that: The convolution layer is a 1×1 convolution layer, and an upsampling unit is further provided at the output end of the product unit of the deep channel submodule, and the output result of the product unit is upsampled to obtain the final deep feature.

3. The PVC pipe size detection method based on high-resolution semantic segmentation according to claim 1 is characterized in that: The spatial attention module uses a feature extraction splicing layer formed by splicing a 1×1 convolutional layer, a maxpool layer, and an avgpool layer to extract and splice the attention-enhanced fusion features, and the 1×1 convolutional layer samples the hole convolution for convolution calculation.

4. The PVC pipe size detection method based on high-resolution semantic segmentation according to claim 1 is characterized in that: In the high-resolution semantic segmentation model, the high-frequency residual image of the first layer is upsampled based on the ISDNet model and fused with the high-frequency residual image of the 0th layer, and then input into the Shallow Branch module in the ISDNet model for shallow feature map extraction, and the downsampled original image of the second layer is used as the input of the Deep Branch module in the ISDNet model. The output of the Deep Branch module is fused with the output of the Shallow Branch through upsampling and the RAF module to form a high-resolution semantic segmentation prediction. The Deep Branch module is also used to generate a low-resolution semantic segmentation prediction, which together with the high-resolution semantic segmentation prediction constitutes a cross loss, and generates a high-resolution original image to form a high-resolution reconstruction loss and a structural distillation loss.

5. The PVC pipe size detection method based on high-resolution semantic segmentation according to any one of claims 1 to 4, characterized in that: Step S01 includes: For the original high-resolution image Perform Gaussian downsampling to get the first downsampled image , and the first downsampled image Gaussian upsampling is performed to obtain the image , the original high-resolution image With image Subtract to get the high-frequency residual image of layer 0 ; For the first down-sampled image Perform Gaussian downsampling to obtain the second layer of downsampled original image ; The second layer downsamples the original image Gaussian upsampling is performed to obtain the image , the first down-sampled image With the image Subtract to get the high-frequency residual image of the first layer .

6. The PVC pipe size detection method based on high-resolution semantic segmentation according to any one of claims 1 to 4, characterized in that: The step S03 comprises: Step S301. Obtain a binary image of the pipeline area, and perform a noise interference filtering operation, and use the maximum connected domain area of ​​the binary image after the noise interference filtering as the final binary image of the pipeline area; Step S302: performing edge detection on the binary image of the pipeline region to obtain a binary edge image; Step S303: on the binary edge image, performing sub-pixel interpolation in the local neighborhood of each edge pixel to obtain a sub-pixel edge point set; Step S304: thinning the sub-pixel edge point set to finally obtain the sub-pixel point set of the pipe edge; Step S305. Obtain sub-pixel edge binary images of the inner and outer walls of the pipeline according to the sub-pixel point set of the pipeline edge and obtain a minimum circumscribed matrix to identify the inner and outer wall edge point set; Step S306: Classify the inner edge points and outer edge points in the inner and outer edge point sets according to the outer edge point features, and finally obtain the classified inner and outer edge point sets.

7. The PVC pipe size detection method based on high-resolution semantic segmentation according to any one of claims 1 to 4, characterized in that: The size information of the PVC pipe includes any one of the inner and outer diameters, wall thickness and outer wall out-of-roundness. The inner and outer diameters are obtained by fitting the inner and outer circles of the inner and outer wall sub-pixel edge point sets respectively and calculating the inner and outer circle diameters. The wall thickness is obtained by calculating the statistical value of the distance between the inner circle edge point set and the outer circle edge point set. The outer wall out-of-roundness is the difference between the maximum and minimum diameters on the cross section of the PVC pipe.

8. The PVC pipe size detection method based on high-resolution semantic segmentation according to claim 7 is characterized in that: The step of extracting the out-of-roundness of the outer wall comprises: Calculate the distance from the outer edge point to the center of the outer circle, and subtract it from the outer circle radius to get the distance from the outer edge point to the outer circle edge ; Filter the noise points in the outer edge point set to obtain the outer edge point set after the noise is filtered; The outer edge point set after noise filtering is used to obtain the fitting ellipse of the outer edge, and the difference between the major and minor axis distances of the fitting ellipse is calculated as the out-of-roundness: in, Indicates out-of-roundness. represents the major axis of the ellipse, Represents the minor axis of the ellipse.

9. A PVC pipe size detection device based on high-resolution semantic segmentation, comprising a processor and a memory, wherein the memory is used to store a computer program, characterized in that: The processor is configured to execute the computer program to perform the method according to any one of claims 1 to 8.