Method and device for detecting length and width of concrete crack
By improving the YOLOv11 algorithm and using the C3k2_ContextGuided module and the Segment_LSCD module for crack segmentation, the problem of insufficient recognition capability in the existing technology is solved, and efficient and accurate detection of small cracks is achieved.
Patent Information
- Application Number
- CN202511702745.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies for detecting concrete cracks have limitations, including low identification capability, particularly for small cracks, and measurement accuracy is affected by subjective factors of the inspectors, making it difficult to meet the needs of large-scale inspections.
An improved YOLOv11 algorithm is adopted, replacing the C3k2 module in the backbone network with the C3k2_ContextGuided module, and using Segment_LSCD as the head network. The feature representation is enhanced by the ContextGuided module, and the Segment_LSCD module is used for crack segmentation to extract crack length and width.
It improves the ability and accuracy of identifying small cracks, reduces the amount of computation and parameters, and achieves efficient and accurate crack detection.
Smart Images

Figure CN121639595A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of concrete structure detection and image processing, and particularly relates to a detection method and device for concrete crack length and width. BACKGROUND
[0002] Among a large number of structure types involved in the field of construction, concrete structures have been widely used in various engineering projects due to their own characteristics. However, due to long-term use and the combined influence of various external environmental factors such as temperature change, humidity fluctuation, external force, etc., cracks often occur in concrete structures. The specific parameters such as length and width of these cracks are of great significance for scientifically evaluating the safety, durability and stability of concrete structures and other key performance indicators. In the past, the traditional method of manual on-site measurement was mainly used to detect concrete structure cracks. However, this method has obvious defects. On the one hand, the detection efficiency is low, which is difficult to meet the needs of large-scale detection; on the other hand, the measurement accuracy is easily affected by the subjective factors of the detector, resulting in certain problems in the reliability of the detection results.
[0003] With the rapid development of computer vision technology, the use of image processing technology to realize automatic detection and quantitative analysis of concrete cracks has gradually become a new research hotspot and development direction in this field. However, there are still many areas to be improved in the existing related algorithms in dealing with complex features such as cracks. Especially in the accurate extraction and precise measurement of crack features, there are still many challenges. The specific manifestations are as follows: when in a complex background environment, the existing algorithms have insufficient recognition ability for small cracks, and the recognition accuracy is low; for small cracks with small minimum width, the existing algorithms have great difficulty in the identification process, and also face many technical difficulties in extracting crack contour features. SUMMARY
[0004] The present application provides a detection method and device for concrete crack length and width, which can solve the technical problem of low crack recognition ability in the prior art.
[0005] In a first aspect, the embodiments of the present application provide a method for detecting the length and width of a concrete crack, comprising: establishing a crack image segmentation network based on an improved YOLOv11 algorithm, constructing a concrete crack image sample library to train the crack image segmentation network, and obtaining a trained crack image segmentation network; inputting a crack image to be detected into the trained crack image segmentation network to obtain a segmentation result of the crack image to be detected; and obtaining the length and width of the crack according to the segmentation result; wherein at least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced by a C3k2_ContextGuided module, and Segment_LSCD is used as a head network to obtain the improved YOLOv11 algorithm.
[0006] In combination with the first aspect, in an implementation manner, the crack segmentation image network is specifically configured to: extract semantic information of an input image through a backbone network comprising a C3k2_ContextGuided module, perform multi-scale feature fusion and feature refinement on the extracted semantic information, and output a first feature map; input the first feature map into a neck network to perform multiple upsampling, feature splicing, and C3k2 module processing, and output a second feature map; input the second feature map into a head network, perform crack segmentation on the second feature map by using a Segment_LSCD module, and output a segmentation result, wherein the segmentation result comprises a crack segmentation mask, position information, and category information.
[0007] In combination with the first aspect, in an implementation manner, the semantic information of the input image is extracted through the backbone network comprising the C3k2_ContextGuided module, wherein the C3k2_ContextGuided module is specifically configured to: for input features The C3k2_ContextGuided module uses context information to improve the effectiveness of feature representation, and outputs a result Specifically,
[0008] wherein, represents a C3k operation, represents a ContextGuided operation, and specifically,
[0009]
[0010] wherein, represents a feature after convolution and nonlinear transformation, , represents a convolution kernel of multiple scales and parameters and a nonlinear activation operation, denotes local features obtained by local convolution, denotes surrounding features obtained by convolution with different dilation rates, denotes a fusion and refinement operation on local features and surrounding features, and a ContextGuided module is added in a Bottleneck layer in the C3k2 module to obtain a C3k2_ContextGuided module.
[0011] In combination with the first aspect, in an implementation, a Segment_LSCD module is used for crack segmentation on the second feature map, where the Segment_LSCD module is specifically used for: for input features , the Segment_LSCD module fuses the predicted crack position and category information with the prototype representation of the crack, and outputs a segmentation result of the crack , specifically,
[0012] wherein, denotes a plurality of convolution and normalization operations, denotes a prototype representation operation of generating a crack, specifically,
[0013] wherein, denotes the number of prototypes, denotes the number of masks; The Segment_LSCD module includes a Detect_LSCD submodule for predicting crack position and category information and a prototype network for generating a prototype representation of a crack.
[0014] In combination with the first aspect, in an implementation, obtaining the crack length and the crack width according to the segmentation result includes: performing crack contour extraction and post-processing operations on the segmentation result; extracting a bone line of the crack according to the crack contour, and taking the length of the bone line as the crack length; obtaining two nearest points on the crack contour, and taking the distance between the two nearest points as the crack width; wherein the segmentation result includes a segmentation mask, position information and category information of the crack.
[0015] In combination with the first aspect, in an implementation, the crack contour extraction and post-processing operations are performed on the segmentation result, and the processing process of the crack contour extraction is:
[0016] wherein, This represents the set of all crack contours in the segmentation result. This represents the contour search algorithm. Indicates the segmentation mask; The segmentation results are subjected to crack contour extraction and post-processing. The post-processing procedure is as follows:
[0017] in, The collection of all crack profiles after post-processing. Represents a set Each crack outline in the image, Represents the area of the outline. This represents the minimum area threshold.
[0018] In conjunction with the first aspect, in one embodiment, extracting the bone line of the crack based on the crack profile includes: Convert the segmentation mask into a binary image, specifically...
[0019] in, Binary image; Morphological erosion is performed on a binary image. Specifically,
[0020] in, Image after morphological erosion. Morphological etching operation, Indicates corrosion nucleus, , Indicates the number of iterations. ; Extract the bone lines that define the crack outline, specifically...
[0021] in, bone line, Morphological bone delineation algorithm; Calculate the length of the bone line, specifically...
[0022] in, Bone line length, Located on the ossicular line Point at the location.
[0023] In conjunction with the first aspect, in one embodiment, obtaining the two nearest points on the crack profile and using the distance between the two nearest points as the crack width includes: Each bone line point is calculated using a weighted average method. neighborhood The width inside, specifically.
[0024] in, Indicates bone line points neighborhood width, Indicates weight, Indicates bone line points neighborhood One point inside, Point The corresponding value in the distance transformation matrix D, i.e., the point The distance to the crack profile, where, , This represents the set standard deviation. Indicates bone line points and points The distance between them; Obtain the normal direction of each bone line point, specifically... , in, Indicates bone line points The normal vector, Indicates bone line points The component in the horizontal axis direction, express The component of a point along the vertical axis. Represents the gradient. , Represents partial derivatives, This represents the components of the gradient vector on the horizontal axis. , This represents the components of the gradient vector on the horizontal axis. ; Find the two closest points on the crack profile along the normal direction. and Calculate the distance between two nearest points. , specifically
[0025] Among them, the maximum width on the bone line , This represents the maximum value function, and the maximum width. Corresponding maximum width point coordinates , This represents the component of the point of maximum width on the horizontal axis. This represents the component of the point with the maximum width along the vertical axis.
[0026] In conjunction with the first aspect, in one implementation, it further includes: The pixel dimensions of the crack length and crack width are converted to physical dimensions. The conversion process is as follows: For a point on the segmented image containing the segmentation results coordinates in the camera coordinate system In for:
[0027] in, Represents the camera intrinsic parameter matrix. , Represents the extrinsic parameter matrix. This indicates the focal length along the horizontal axis. Indicates the focal length along the vertical axis. Indicates the coordinates of the optical center along the horizontal axis. Indicates the coordinates of the optical center along the vertical axis. Represents the rotation matrix. Represents the translation vector. express Coordinates in the world coordinate system; Crack length and crack width The pixel dimensions are converted to physical dimensions, specifically...
[0028]
[0029] in, Indicates crack length Physical dimensions Indicates crack width Physical dimensions As a scaling factor, , This represents the distance from the camera to the object.
[0030] Secondly, embodiments of this application provide a concrete crack length and crack width detection device, comprising: a construction module, which is used to establish a crack image segmentation network based on an improved YOLOv11 algorithm, construct a concrete crack image sample library to train the crack image segmentation network, and obtain a trained crack image segmentation network; an execution module, which is used to input the crack image to be detected into the trained crack image segmentation network and obtain the segmentation result of the crack image to be detected; and an acquisition module, which is used to acquire the crack length and crack width according to the segmentation result; wherein, at least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced with a C3k2_ContextGuided module, and Segment_LSCD is used as the head network to obtain the improved YOLOv11 algorithm.
[0031] The beneficial effects of the technical solutions provided in this application include: This application employs an improved YOLOv11 algorithm to establish a crack image segmentation network. At least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced with a C3k2_ContextGuided module, and Segment_LSCD is used as the head network. Specifically, a ContextGuided module is added to the Bottleneck layer of the original C3k2 module to form the C3k2_ContextGuided module. The ContextGuided module enhances feature representation. Simultaneously, using Segment_LSCD as the head network reduces the number of parameters and computational cost of the crack image segmentation network while maintaining good detection performance, thereby improving the ability to identify small cracks and increasing the recognition accuracy. Attached Figure Description
[0032] Figure 1 A schematic diagram of the method for detecting the length and width of concrete cracks provided in this application; Figure 2 A schematic diagram of the crack image segmentation network provided in this application; Figure 3 This is a schematic diagram of the structure of the ContextGuided module provided in this application; Figure 4 This is a schematic diagram of the structure of the Segment_LSCD module provided in this application; Figure 5 For this application Figure 1 A detailed flowchart of step S3; Figure 6 This is a schematic diagram of the functional modules of an embodiment of the concrete crack length and width detection device of this application. Detailed Implementation
[0033] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0034] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0035] In one aspect, embodiments of this application provide a method for detecting the length and width of concrete cracks.
[0036] In one embodiment, reference is made to Figure 1 , Figure 1 This is a schematic diagram illustrating the process for detecting the length and width of concrete cracks provided in this application. Figure 1 As shown, the methods for detecting the length and width of concrete cracks include: In step S1, a crack image segmentation network is established based on the improved YOLOv11 algorithm, and a concrete crack image sample library is constructed to train the crack image segmentation network, resulting in a trained crack image segmentation network.
[0037] In step S2, the crack image to be detected is input into the trained crack image segmentation network to obtain the segmentation result of the crack image to be detected.
[0038] In step S3, the crack length and crack width are obtained based on the segmentation results.
[0039] In this method, at least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced with a C3k2_ContextGuided module, and Segment_LSCD is used as the head network to obtain the improved YOLOv11 algorithm.
[0040] Specifically, the construction process of the concrete crack image sample library includes: In step S101, images of surface defects in the steel structure are obtained from multiple data sources to establish an original crack image dataset.
[0041] The data sources include images from structural monitoring systems, images collected on-site, and publicly available image data from the internet. Specifically, the raw crack image dataset may include images containing cracks downloaded periodically from building structure monitoring systems, crack images taken on-site using professional cameras at various building structures, and publicly available building structure crack image datasets searched from the internet.
[0042] In step S102, the crack images in the original crack image dataset are preprocessed.
[0043] Specifically, preprocessing may include normalization, cropping, and enhancement operations on the crack image.
[0044] Normalization of crack images involves normalizing the pixel values of the crack image to... Intervals, for example, for crack images in the original crack image dataset. The image after normalization. It can be represented as:
[0045] in, and These are the minimum and maximum pixel values of the image, respectively.
[0046] Cropping operations can remove irrelevant parts of an image, depending on the specific application scenario and network input size requirements. Enhancement operations can employ techniques such as random rotation, flipping, and illumination adjustment to increase the diversity of the original crack image dataset and the generalization ability of the crack image segmentation network.
[0047] In step S103, the preprocessed crack image dataset is divided into a training set, a validation set, and a test set according to a preset ratio. The training set is used as a concrete crack image sample library to train the crack image segmentation network, resulting in a trained crack image segmentation network.
[0048] Specifically, the images can be divided into training, validation, and test sets in a ratio of 70%:15%:15% to ensure that the network is adequately trained and effectively evaluated during the training process.
[0049] Figure 2 A schematic diagram of the structure of the crack image segmentation network provided in this application. Figure 2 In this context, Upsample represents upsampling, Concat represents feature fusion, Conv represents convolution, and Segment represents segmentation. Adding the ContextGuided module to the Bottleneck layer in the C3k2 module results in the C3k2_ContextGuided module.
[0050] The crack segmentation image network is specifically used for: extracting semantic information from the input image through a backbone network containing the C3k2_ContextGuided module; performing multi-scale feature fusion and feature refinement on the extracted semantic information to output a first feature map; inputting the first feature map into the neck network for multiple upsampling, feature concatenation, and processing by the C3k2 module to output a second feature map; inputting the second feature map into the head network and using the Segment_LSCD module to segment the cracks in the second feature map, outputting the segmentation result, which includes the crack segmentation mask, location information, and category information.
[0051] The following describes the structure of a crack segmentation image network in one embodiment, using the code that implements the process of outputting segmentation results.
[0052] In the feature extraction stage (head network): - [-1, 1, Conv, [64, 3, 2]] represents the first convolutional operation. Using this first convolutional layer halves the size of the input feature map, expands the number of channels to 64, and sets the kernel size to 3. Its output can be represented as... ,in For the input feature map, The size is half the size of the input feature map, and the number of channels is 64; - [-1, 1, Conv, [128, 3, 2]] represents the second convolutional operation, using the second convolutional layer to... The size is halved, the number of channels is expanded to 128, and the kernel size is 3. Its output can be represented as... ; - [-1, 2, C3k2_ContextGuided, [256, False, 0.25]] represents the operation of the C3k2_ContextGuided module, which uses the C3k2_ContextGuided module in conjunction with context information to... Feature extraction and fusion are performed, and the output can be represented as The number of channels has been adjusted to 256. This indicates that residual connections are not applicable, the channel expansion rate is 0.25, and the output of the C3k2_ContextGuided module can be based on... Adjustments are made to leverage contextual information to improve the effectiveness of feature representations; - [-1, 1, Conv, [256, 3, 2]] represents the third convolutional operation, using the third convolutional layer to... The size is halved, the number of channels is expanded to 256, and the kernel size is 3. Its output can be represented as ; - [-1, 2, C3k2, [512, False, 0.25]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: ; - [-1, 1, Conv, [512, 3, 2]] represents the fourth convolutional operation, using the fourth convolutional layer to... The size is halved, the number of channels is expanded to 512, and the kernel size is 3. Its output can be represented as... ; - [-1, 2, C3k2, [512, True]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: ; - [-1, 1, Conv, [1024, 3, 2]] represents the fifth convolutional operation, using the fifth convolutional layer to... The size is halved, the number of channels is expanded to 1024, and the kernel size is 3. Its output can be represented as ; - [-1, 2, C3k2, [1024, True] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as: ; - [-1, 1, SPPF, [1024, 5]] represents the SPPF module operation, which uses features at different scales of the SPPF module for pooling and fusion operations. Its output can be represented as... ; - [-1, 2, C2PSA,
[1024] ] represents the C2PSA module operation. The C2PSA module is a feature extraction and processing module with an attention mechanism, which can further enhance the feature extraction capability of the model. Its output can be represented as .
[0053] In the upsampling and feature fusion stage (neck network): - [-1, 1, nn.Upsample, [None, 2, "nearest"]] represents an upsampling operation, which enlarges the feature map size by a factor of 2. Its output can be represented as... ; - [[-1, 6], 1, Concat, [1]] is the feature concatenation operation, which concatenates the upsampled feature map. and By concatenating channels, its output can be represented as ; - [-1, 2, C3k2, [512, False]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: ; - [-1, 1, nn.Upsample, [None, 2, "nearest"]] represents an upsampling operation, which enlarges the feature map size by a factor of 2. Its output can be represented as... ; - [[-1, 4], 1, Concat, [1]] is the feature concatenation operation, which concatenates the upsampled feature map. and By concatenating channels, its output can be represented as ; - [-1, 2, C3k2, [256, False]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: ; - [-1, 1, Conv, [256, 3, 2]] represents a convolution operation, which converts the feature map... The number of channels is expanded to 256, while the size is halved. Its output can be represented as... ; - [[-1, 13], 1, Concat, [1]] is the feature concatenation operation, which concatenates the feature maps. and By concatenating channels, its output can be represented as ; - [-1, 2, C3k2, [512, False]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: ; - [-1, 1, Conv, [512, 3, 2]] represents a convolution operation, which converts the feature map... The number of channels is expanded to 512, while the size is halved. Its output can be expressed as... ; - [[-1, 10], 1, Concat, [1]] is the feature concatenation operation, which concatenates the feature maps. and By concatenating channels, its output can be represented as ; - [-1, 2, C3k2, [1024, True]] represents the C3k2 module operation. Feature extraction using the C3k2 module can be represented as follows: .
[0054] In the segmentation phase (head network): - [[16, 19, 22], 1, Segment_LSCD, [nc, 32, 256, 256]] is used to process multi-scale feature maps using the Segment_LSCD module. , and After fusion, crack segmentation is performed, and the segmentation result is output, which can be represented as follows: ,in This represents the final crack segmentation mask.
[0055] The C3k2 module, by combining variable convolutional kernels (e.g., 3×3, 5×5) and channel separation strategies, provides more powerful feature extraction capabilities, making it particularly suitable for more complex scenarios and deep feature extraction tasks. The C3k2 module typically divides the input features into two parts: one part is directly passed through ordinary convolution operations, while the other part undergoes deep feature extraction using multiple C3K structures (when the C3K parameter is set to True) or Bottleneck structures. Finally, the two feature parts are concatenated and fused using a 1x1 convolution. This structure maintains lightweight design while effectively extracting deep features. The C3k2 module improves feature extraction efficiency through parallel convolution design and flexible parameter configuration.
[0056] In conjunction with the first aspect, in one implementation, semantic information of the input image is extracted through a backbone network including the C3k2_ContextGuided module, wherein the C3k2_ContextGuided module is specifically used for: for input features The C3k2_ContextGuided module utilizes contextual information to improve the effectiveness of feature representations, and the output results... , specifically
[0057] in, This indicates the C3k operation. This indicates a ContextGuided operation, specifically...
[0058]
[0059] in, express go through Features after convolution and nonlinear transformation , Represents convolution kernels and nonlinear activation operations with various scales and parameters. This represents local features obtained through local convolution. This represents the surrounding features obtained through convolutions with different dilation rates. This indicates that local features and surrounding features are being fused and refined.
[0060] Continue to refer to Figure 2 The existing YOLOv11 algorithm's head network includes four C3k2 modules. In this embodiment, at least one C3k2 module in the head network is replaced with a C3k2_ContextGuided module. Specifically, one C3k2 module in the head network can be replaced with a C3k2_ContextGuided module, or all four C3k2 modules in the head network can be replaced with C3k2_ContextGuided modules. This embodiment replaces one C3k2 module in the head network with a C3k2_ContextGuided module. This ensures that the crack image segmentation network built using the improved YOLOv11 algorithm can extract small cracks, while also preventing the overall structure of the defect image segmentation network from becoming more complex, thus avoiding a more complicated defect information extraction process.
[0061] Add the ContextGuided module to the Bottleneck layer in the C3k2 module to obtain the C3k2_ContextGuided module. Figure 3 This is a structural diagram of the ContextGuided module provided in this application. (Reference) Figure 3 The ContextGuided module processes the input features as follows: the input features are passed through a 1×1 convolutional layer to adjust the number of channels while maintaining the spatial size of the feature map; the adjusted feature map is then passed through a 3×3 standard convolutional layer. This is used to extract local features and capture detailed information from the input feature map. Simultaneously, the adjusted feature map also undergoes a 3×3 dilated convolution. This is used to extract surrounding contextual information, expand the receptive field, and capture a wider range of contextual information; the extracted local features and contextual features are concatenated along the channel dimension to form joint features; batch normalization (BatchNorm 2d) is applied to the concatenated joint features to accelerate training and improve generalization ability, and then nonlinearity is introduced through an activation function (Act, such as ReLU); a global contextual information fusion module is used ( Further optimize joint features and enhance the expressive power of features.
[0062] The code that implements the ContextGuided module operation process is as follows:
[0063] In conjunction with the first aspect, in one implementation, the Segment_LSCD module is used to perform crack segmentation on the second feature map. Specifically, the Segment_LSCD module is used for: for the input features... The Segment_LSCD module fuses the predicted crack location and category information with the crack prototype representation, outputting the crack segmentation result. , specifically
[0064] in, This represents multiple convolution and normalization operations. The prototype representation of the operation that generates cracks, specifically...
[0065] in, Indicates the number of prototypes. Indicates the number of masks; The Segment_LSCD module includes the Detect_LSCD submodule for predicting crack location and category information, and a prototype network for generating a prototype representation of the crack. . Figure 4 This is a schematic diagram of the structure of the Segment_LSCD module provided in this application. (Reference) Figure 4 In Conv_GN + Share Conv, Conv represents the convolution operation used for feature extraction. GN (Group Normalization) divides the input feature map into several groups, and the elements within each group are normalized independently. Share Conv indicates a shared convolutional layer, which uses the same convolutional weights in multiple branches or stages, thereby reducing the number of parameters and improving computational efficiency. In Conv2d + Scale + DFL, Conv2d represents the standard two-dimensional convolution operation used to extract local features from the feature map. Scale indicates scaling the convolution output, which may be used to adjust the scale or intensity of features to suit subsequent operations. DFL (Distributed Focal Loss) represents a loss function for bounding box regression, which models the location of the bounding box as a probability distribution and improves localization accuracy by optimizing this distribution. Conv_GN + Share Conv and Conv2d + Scale + DFL work together to implement the Segment_LSCD module, which fuses the predicted crack location and category information with the prototype representation of the crack, and outputs the crack segmentation result, thereby improving the recognition ability and efficiency of the crack image segmentation network.
[0066] For input features During training, the output prediction results are achieved. and mask coefficients and prototype The code for the process is:
[0067]
[0068]
[0069] Figure 5 For this application Figure 1 A detailed flowchart of step S3. (Reference) Figure 5 In conjunction with the first aspect, in one embodiment, step S3, obtaining the crack length and crack width based on the segmentation results, includes: In step S31, the segmentation results are subjected to crack contour extraction and post-processing operations.
[0070] In step S32, the bone line of the crack is extracted based on the crack contour, and the length of the bone line is taken as the crack length.
[0071] In step S33, the two closest points on the crack profile are obtained, and the distance between the two closest points is taken as the crack width.
[0072] The segmentation results include the segmentation mask, location information, and category information of the cracks.
[0073] In step S31, crack contour extraction and post-processing are performed on the segmentation results. The crack contour extraction process is as follows:
[0074] in, This represents the set of all crack contours in the segmentation result. This represents the contour search algorithm. This represents a segmentation mask; findContours can extract contours from a binary image, that is, the boundaries of objects in the image.
[0075] Specifically, in step S31, the segmentation result undergoes crack contour extraction and post-processing. The post-processing procedure is as follows:
[0076] in, The collection of all crack profiles after post-processing. Represents a set Each crack outline in the image, Represents the area of the outline. This represents the minimum area threshold.
[0077] In step S32, extracting the bone line of the crack based on the crack contour includes the following refinement steps: In step S321, the segmentation mask is converted into a binary image. Specifically,
[0078] in, Binary image.
[0079] In step S322, a morphological erosion operation is performed on the binary image. Specifically,
[0080] in, Image after morphological erosion. Morphological etching operation, Indicates corrosion nucleus, , Indicates the number of iterations. ; The code that implements the morphological erosion operation is as follows:
[0081] In step S323, the bone lines of the crack contour are extracted, specifically...
[0082] in, bone line, Morphological bone delineation algorithm; The code for extracting bone lines to achieve the crack contour is as follows:
[0083] In step S324, the length of the bone line is calculated, specifically...
[0084] in, Bone line length, Located on the ossicular line The point at the location; The code that implements the process of calculating the length of the bone line is as follows:
[0085] In step S33, the two nearest points on the crack profile are obtained, and the distance between the two nearest points is taken as the crack width. This specifically includes the following refinement steps: In step S331, a weighted average is used to calculate the value of each bone line point. neighborhood The width inside, specifically.
[0086] in, Indicates bone line points neighborhood width, Indicates weight, Indicates bone line points neighborhood One point inside, Point The corresponding value in the distance transformation matrix D, i.e., the point The distance to the crack profile, where, , This represents the set standard deviation. Indicates bone line points and points The distance between them.
[0087] The code that calculates the width of each bone line point within its neighborhood is as follows:
[0088] The code for calculating the maximum width of a bone line point within its neighborhood is as follows:
[0089] In step S332, the normal direction of each bone line point is obtained. Specifically,
[0090] in, Indicates bone line points The normal vector, Indicates bone line points The component in the horizontal axis direction, express The component of a point along the vertical axis. Represents the gradient. , Represents partial derivatives, This represents the components of the gradient vector on the horizontal axis. , This represents the components of the gradient vector on the horizontal axis. ; Achieve maximum width point Normal vector in the neighborhood The code for the calculation process is as follows:
[0091] in, Representing the domain point, , , , and .
[0092] In step S333, the two closest points on the crack profile are found in the normal direction. and Calculate the distance between two nearest points. , specifically
[0093] Among them, the maximum width on the bone line , This represents the maximum value function, and the maximum width. Corresponding maximum width point coordinates , This represents the component of the point of maximum width on the horizontal axis. This represents the component of the point with the maximum width along the vertical axis. Extending a certain length along the normal direction, the starting point is calculated. and end point And find the point on the outline that is closest to these two points. and The code to implement this process is as follows:
[0094]
[0095]
[0096]
[0097] in, The inch function calculates the point on the contour closest to the straight line, resulting in the final precise width. The code for calculating the distance between these two points is as follows:
[0098] in, It represents the Euclidean norm (i.e., the straight-line distance between two points).
[0099] In conjunction with the first aspect, in one implementation, it further includes: The pixel dimensions of the crack length and crack width are converted to physical dimensions. The conversion process is as follows: For a point on the segmented image containing the segmentation results coordinates in the camera coordinate system In for:
[0100] in, Represents the camera intrinsic parameter matrix. , Represents the extrinsic parameter matrix. This indicates the focal length along the horizontal axis. Indicates the focal length along the vertical axis. Indicates the coordinates of the optical center along the horizontal axis. Indicates the coordinates of the optical center along the vertical axis. Represents the rotation matrix. Represents the translation vector. express Coordinates in the world coordinate system; Crack length and crack width The pixel dimensions are converted to physical dimensions, specifically...
[0101]
[0102] in, Indicates crack length Physical dimensions Indicates crack width Physical dimensions As a scaling factor, , This represents the distance from the camera to the object.
[0103] This application employs an improved YOLOv11 algorithm to establish a crack image segmentation network. At least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced with a C3k2_ContextGuided module, and Segment_LSCD is used as the head network. Specifically, a ContextGuided module is added to the Bottleneck layer of the original C3k2 module to form the C3k2_ContextGuided module. The ContextGuided module enhances feature representation. Using Segment_LSCD as the head network reduces the number of parameters and computational cost of the crack image segmentation network while maintaining good detection performance, thereby improving the ability to identify small cracks and increasing recognition accuracy. Furthermore, this application discloses the process of converting the pixel dimensions of crack length and width into physical dimensions after extraction by the crack image segmentation network, achieving efficient detection and accurate quantification of concrete cracks, providing a strong basis for the safety assessment of concrete structures.
[0104] Secondly, embodiments of this application also provide a device for detecting the length and width of concrete cracks.
[0105] In one embodiment, reference is made to Figure 6 , Figure 6 This is a functional module diagram of an embodiment of the concrete crack length and width detection device of this application. Figure 6 As shown, the device for detecting the length and width of concrete cracks includes: a construction module, which is used to establish a crack image segmentation network based on the improved YOLOv11 algorithm, construct a concrete crack image sample library to train the crack image segmentation network, and obtain the trained crack image segmentation network; an execution module, which is used to input the crack image to be detected into the trained crack image segmentation network and obtain the segmentation result of the crack image to be detected; and an acquisition module, which is used to obtain the crack length and crack width based on the segmentation result; wherein, at least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced with a C3k2_ContextGuided module, and Segment_LSCD is used as the head network to obtain the improved YOLOv11 algorithm.
[0106] The functions of each module in the above-mentioned concrete crack length and width detection device correspond to the steps in the above-mentioned concrete crack length and width detection method embodiment. The functions of each module in the concrete crack length and width detection device can be found in the above-mentioned embodiment, and will not be repeated here.
[0107] Thirdly, embodiments of this application provide a device for detecting the length and width of concrete cracks. The device for detecting the length and width of concrete cracks can be a personal computer (PC), a laptop computer, a server, or other device with data processing capabilities.
[0108] In this embodiment of the application, the device for detecting the length and width of concrete cracks may include a processor, a memory, a communication interface, and a communication bus.
[0109] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.
[0110] The communication interface includes input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting internal components of the concrete crack length and width detection equipment, as well as interfaces for interconnecting the equipment with other devices (such as other computing devices or user equipment). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user equipment can be displays, keyboards, etc.
[0111] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0112] The processor can be a general-purpose processor, which can call the detection program for the length and width of concrete cracks stored in memory and execute the method for detecting the length and width of concrete cracks provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the detection program for the length and width of concrete cracks is called can refer to the various embodiments of the method for detecting the length and width of concrete cracks in this application, and will not be repeated here.
[0113] Fourthly, embodiments of this application also provide a computer-readable storage medium.
[0114] The present application has a computer-readable storage medium storing a program for detecting the length and width of concrete cracks, wherein when the program for detecting the length and width of concrete cracks is executed by a processor, the steps of the method for detecting the length and width of concrete cracks as described above are implemented.
[0115] The method implemented when the concrete crack length and width detection procedure is executed can refer to the various embodiments of the concrete crack length and width detection method of this application, and will not be repeated here.
[0116] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0117] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0118] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0119] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0120] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0121] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0122] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method of detecting the length and width of a crack in concrete, characterized by, The method comprises the following steps: An improved YOLOv11 algorithm is used to establish a crack image segmentation network, a concrete crack image sample library is constructed to train the crack image segmentation network, and a trained crack image segmentation network is obtained; A to-be-detected crack image is input into the trained crack image segmentation network, and a segmentation result of the to-be-detected crack image is obtained; A crack length and a crack width are obtained according to the segmentation result. At least one C3k2 module in the backbone network of the YOLOv11 algorithm is replaced by a C3k2_ContextGuided module, and a Segment_LSCD is used as a head network to obtain the improved YOLOv11 algorithm.
2. The method of claim 1, wherein the step of detecting the length and width of the concrete crack is performed by using a laser sensor. The crack segmentation image network is specifically used for: Semantic information of an input image is extracted by a backbone network comprising a C3k2_ContextGuided module, multi-scale feature fusion and feature refinement are performed on the extracted semantic information, and a first feature map is output; The first feature map is input into a neck network, and multiple upsampling, feature splicing and C3k2 module processing are performed, and a second feature map is output; The second feature map is input into a head network, a Segment_LSCD module is used to perform crack segmentation on the second feature map, and a segmentation result is output, wherein the segmentation result comprises a crack segmentation mask, position information and category information.
3. The method of claim 2, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. The semantic information of the input image is extracted through the backbone network comprising the C3k2_ContextGuided module, wherein the C3k2_ContextGuided module is specifically configured to: for input features The C3k2_ContextGuided module improves the effectiveness of the feature representation by using context information, and outputs a result Specifically, wherein, represents a C3k operation, represents a ContextGuided operation, in particular, wherein, denotes after convolution and nonlinear transformation, , denotes convolution kernels of multiple scales and parameters and nonlinear activation operations, denotes local features obtained by local convolution, denotes surrounding features obtained by convolution with different expansion rates, denotes fusion and refinement operations on local features and surrounding features, and a ContextGuided module is added in the bottleneck layer in the C3k2 module to obtain a C3k2_ContextGuided module.
4. The method of claim 2, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. The second feature map is subjected to crack segmentation by using a Segment_LSCD module, wherein the Segment_LSCD module is specifically configured to: for an input feature The Segment_LSCD module fuses the predicted crack position and category information with the prototype representation of the crack, and outputs a segmentation result of the crack Specifically, wherein, denotes a plurality of convolution and normalization operations, denotes a prototype representation operation that generates a crack, in particular, wherein, denotes the number of prototypes, denotes the number of masks; The Segment_LSCD module includes a Detect_LSCD submodule for predicting crack location and class information and a prototype network for generating a prototype representation of the crack .
5. The method of claim 1, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. The crack length and the crack width are obtained according to the segmentation result, which comprises: Crack contour extraction and post-processing operations are performed on the segmentation result; A skeleton line of the crack is extracted from the crack contour, and a length of the skeleton line is taken as the crack length; Two nearest points on the crack contour are obtained, and a distance between the two nearest points is taken as the crack width. The segmentation result comprises a crack segmentation mask, position information and category information.
6. The method for detecting the crack length and the crack width of the concrete according to claim 5, wherein: The crack contour extraction and post-processing operations are performed on the segmentation result, wherein a processing procedure of the crack contour extraction is as follows: wherein, represents a set of all crack contours in the segmentation result, represents a contour finding algorithm, represents a segmentation mask; The crack contour extraction and post-processing operations are performed on the segmentation result, wherein a processing procedure of the post-processing operation is as follows: wherein, a set of all crack profiles after the post-processing operation, denotes each crack profile in the set denotes the area of the profile, denotes the area of the profile, denotes a minimum area threshold.
7. The method of claim 5, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. The skeleton line of the crack is extracted from the crack contour, which comprises: The segmentation mask is converted into a binary image, specifically, wherein binary image; A morphological erosion operation is performed on the binary image, specifically, wherein, performing a morphological erosion operation on the image, a morphological erosion operation, representing an erosion kernel, , representing the number of iterations, ; The skeleton line of the crack contour is extracted, specifically, wherein, bone line, morphological bone line algorithm; The length of the skeleton line is calculated, specifically, wherein, bone line length, a point on the bone line at point.
8. The method of claim 5, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. The two nearest points on the crack contour are obtained, and the distance between the two nearest points is taken as the crack width, which comprises: The width in the neighborhood of each bone line point is calculated in a weighted average manner In particular, wherein denotes the neighborhood width of a bone line point , denotes a weight, denotes a point within the neighborhood of a bone line point , denotes a point within the neighborhood of a bone line point , denotes the corresponding value in the distance transform matrix D, i.e. the distance of the point to the crack profile, wherein , denotes a set standard deviation, denotes the distance between a bone line point and a point ; A normal direction of each skeleton line point is obtained, specifically, , wherein represents a normal vector of the bone line point , represents a component of the bone line point in the transverse axis direction, represents a component of the point in the longitudinal axis direction, represents a gradient, , represents a partial derivative, represents a component of the gradient vector in the transverse axis, , represents a component of the gradient vector in the transverse axis, ; Finding the two nearest points on the crack profile in the normal direction and calculating the distance between the two nearest points In particular, where, for the maximum width on the bone line , denotes the maximum width function, the maximum width the corresponding maximum width point coordinates , denotes the component of the maximum width point on the horizontal axis, denotes the component of the maximum width point in the vertical axis direction.
9. The method of claim 5, wherein the step of detecting the length and width of the crack in the concrete is performed by using a crack detector. Further comprising: Pixel sizes of the crack length and the crack width are converted into physical sizes, and the conversion procedure is as follows: For a point on a segmented image containing a segmentation result In the camera coordinate system In the camera coordinate system is: wherein, denotes a camera intrinsic matrix, , denotes an extrinsic matrix, denotes a focal length in the horizontal axis direction, denotes a focal length in the vertical axis direction, denotes a coordinate of the optical center in the horizontal axis direction, denotes a coordinate of the optical center in the vertical axis direction, denotes a rotation matrix, denotes a translation vector, denotes a coordinate in the world coordinate system; converting the pixel size of the crack length and crack width into physical size, specifically, wherein, represents the length of a crack a physical dimension of, represents the width of a crack a physical dimension of, is a scale factor, , is the distance of the camera to the object.
10. A concrete crack length and crack width detection apparatus characterized by, The method comprises the following steps: A crack image segmentation network is established based on an improved YOLOv11 algorithm, a concrete crack image sample library is constructed to train the crack image segmentation network, and a trained crack image segmentation network is obtained. The execution module is configured to input a crack image to be detected into the trained crack image segmentation network to obtain a segmentation result of the crack image to be detected; The acquisition module is configured to acquire a crack length and a crack width according to the segmentation result. In the improved YOLOv11 algorithm, at least one C3k2 module in a backbone network of the YOLOv11 algorithm is replaced by a C3k2_ContextGuided module, and a Segment_LSCD is used as a head network.