A pier crack detection method based on improved YOLOv8n
By improving the YOLOv8n model, embedding the MA-ECA module and the asymptotic feature pyramid network, and combining adaptive spatial weight allocation and the MPD-IoU loss function, the accuracy and efficiency problems of bridge pier crack detection were solved, achieving efficient and accurate crack detection and quantification, reducing costs, and extending the service life of bridges.
Patent Information
- Application Number
- CN202511553197.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-10-29
AI Technical Summary
Existing methods for detecting cracks in bridge piers suffer from insufficient accuracy, low efficiency, high cost, and significant safety risks, and cannot provide quantitative parameters of cracks that meet engineering accuracy requirements.
An improved YOLOv8n model is adopted, embedding the MA-ECA module and the asymptotic feature pyramid network. Combined with adaptive spatial weight allocation and MPD-IoU loss function, bounding box regression is performed, and sub-pixel segmentation is performed through the YOLOv8-Seg model to extract the physical width information of the cracks.
It enables efficient and accurate detection of bridge pier cracks, reduces detection costs, improves detection efficiency, can identify early micro-cracks, extends the service life of bridges, and ensures traffic safety.
Smart Images

Figure CN121033027B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image or video processing, and in particular to a pier crack detection method based on improved YOLOv8n. BACKGROUND
[0002] In the field of target detection, YOLOv8n is the smallest network model among multiple versions, and its core advantage lies in its extremely fast inference speed. It can predict the bounding boxes and class probabilities of all targets in an image in a single forward propagation. The network adopts a hyperparameter adjustment mechanism to precisely control the depth and width of the network structure by adjusting the depth and width key parameters, making it very suitable for real-time or quasi-real-time bridge detection scenarios. For example, after the camera installed on the detection vehicle, unmanned aerial vehicle or robot collects images, YOLOv8n can quickly process the image stream and mark the crack position in near real time, greatly improving the detection efficiency and reducing the manual inspection time.
[0003] The small target detection capability of YOLOv8n is limited. Bridge cracks are usually very thin and narrow, reaching the pixel level, and may be submerged by the texture of the concrete surface background. As the network down-samples, the resolution of the deep feature map decreases, and the fine crack feature information is easily lost. Although YOLOv8n has improved feature fusion, its sensitivity to extremely small cracks (especially early micro-cracks) is still insufficient, which may lead to missed detection. SUMMARY
[0004] The present application aims to solve the outstanding contradiction between precision, efficiency and deployment cost of existing pier crack detection methods. Specifically, it aims to solve the problems of low efficiency, strong subjectivity and high safety risk of traditional manual inspection, as well as the key technical bottlenecks of high missed detection rate of fine cracks, high false detection rate in complex backgrounds, difficulty in supporting on-site real-time detection with model size and computing power requirements, and inability to provide crack quantification parameters meeting engineering precision requirements of existing deep learning models (such as original YOLOv8n).
[0005] The present application adopts the following technical solutions:
[0006] A pier crack detection method based on improved YOLOv8n, comprising the following steps:
[0007] S1, pre-processing the collected structure surface image, the pre-processing including color space conversion and contrast enhancement, and geometric correction of the image.
[0008] S2. Construct a crack target detection model. The model uses the YOLOv8n model as a baseline and embeds a MA-ECA (Multi-scale Adaptive Efficient Channel Attention) module into its backbone network. The MA-ECA module dynamically adjusts the channel weights through horizontal and vertical dual-path global pooling operations. At the same time, an asymptotic feature pyramid network replaces the path aggregation network in the original model. The asymptotic feature pyramid network optimizes multi-scale feature aggregation through hierarchical fusion and adaptive spatial weight allocation.
[0009] S3. Use the crack target detection model to predict the preprocessed image, and use the loss function based on the minimum point distance between the predicted box and the vertex of the ground truth box to perform bounding box regression.
[0010] S4. Perform pixel-level segmentation on the crack region detected in step S3, extract the sub-pixel-level edge contour of the crack, and calculate the physical width information of the crack based on the edge contour.
[0011] Preferably, the color space conversion and contrast enhancement in step S1 specifically include:
[0012] Convert the RGB color image to the YCbCr color space and separate the luminance channel.
[0013] The brightness channel is subjected to adaptive histogram equalization with limited contrast.
[0014] The histogram equalization includes:
[0015] 1) Divide the luminance channel image I into multiple image blocks of size G×G. For each image block, calculate its grayscale histogram. , where k is the gray level.
[0016] 2) Crop the grayscale histogram, setting a cropping limit β, to obtain the cropped histogram. Calculate the total number of pixels that were cropped. The histogram is then redistributed evenly across all gray levels to obtain the redistributed histogram. ,in, This represents the total number of gray levels.
[0017] 3) Based on the redistributed histogram, perform histogram equalization to obtain the grayscale mapping function for the image patch: Where j and k represent the gray levels, grayscale The number of pixels, This represents a grayscale histogram of a small region. This represents the histogram after overlaying and cropping this small area. The histogram clipping range. Here, G is the grayscale mapping function, and G represents the size of each image patch.
[0018] 4) The final grayscale value is obtained by performing bilinear interpolation on the mapping function of the adjacent image blocks of each pixel.
[0019] Preferably, the geometric correction includes:
[0020] 1) Detect the four corner points or marker points on the surface of the bridge pier in the original tilted image as the source point set. ,in, .
[0021] 2) Establish perspective transformation relationship: Define the target corner coordinates in the target correction coordinate system. Coordinate mapping is achieved through the homography matrix H, satisfying: Where H is a 3×3 perspective transformation matrix. These are points in the original image. It is the corrected point, and it is set. =1, expanded as: .
[0022] 3) Solving for transformation parameters using the least squares method: solving by 4 pairs of corresponding points. Given 8 unknown parameters, let the system of equations be: Write it as a matrix ,in Finally, the least squares solution is obtained as follows: ,in Let be the perspective transformation parameter vector to be solved.
[0023] Preferably, the MA-ECA module is embedded into a 3×3 standard convolutional layer in the YOLOv8n model.
[0024] Preferably, the dynamic adjustment of channel weights in the horizontal and vertical dual-path global pooling operation includes:
[0025] One-dimensional global average pooling is performed on the input feature map X∈C×H×W along both the horizontal and vertical dimensions to obtain feature encodings in two directions:
[0026] The horizontal one-dimensional global average pooling along the height direction is represented as: .
[0027] Vertical one-dimensional global average pooling along the width direction is represented as: .
[0028] wherein, C denotes the number of input channels, H and W denote the height and width of the input feature map, respectively, denotes the input feature of the c-th channel, denotes the width coordinate, denotes the height coordinate.
[0029] Preferably, the hierarchical fusion and adaptive spatial weight assignment include:
[0030] The initial stage fuses low-level features, and the subsequent gradually introduces high-level features, and the fusion process is represented as:
[0031]
[0032] wherein, denotes the feature after the n-th level fusion, n denotes the current fusion level index, and denote the feature maps of the previous level and the second previous level, respectively, is the dynamic weight coefficient assigned to the low-level feature during the n-th level fusion.
[0033] Further, the features of different levels are weighted and fused through adaptive spatial weight assignment, and the formula is represented as:
[0034]
[0035] wherein, is the spatial weight of the n-th level feature, denotes the n-th level, is the intermediate level index participating in the multi-scale feature fusion, 1≤ ≤n.
[0036] Preferably, the loss function used in the step S3 is an MPD-IoU loss function, and the MPD-IoU loss function is constructed based on the minimum point distance between the four vertices of the predicted frame and the real frame.
[0037] Preferably, a gradient continuity loss function is also introduced in the regression process, and the expression is:
[0038]
[0039] wherein, is the predicted crack segmentation map or the bounding box mask, is the real label, is the gradient operator, is the balance coefficient, is the edge gradient map of the predicted crack image, is the edge gradient map of the real crack image.
[0040] Preferably, the YOLOv8-Seg model is used in the step S4 to perform pixel-level segmentation on the crack area.
[0041] The sub-pixel level edge profile is extracted, specifically by calculating the gradient direction and quadratic surface fitting to solve the sub-pixel level offset of the edge point.
[0042] The physical width information of the crack is calculated based on the edge profile, specifically including:
[0043] The crack image is skeletonized and the center axis is extracted.
[0044] The width of each point of the crack is calculated by distance transformation or normal scanning.
[0045] The physical size conversion of the crack width is realized in combination with the camera calibration parameters.
[0046] Further, the sub-pixel level offset , ) is expressed as:
[0047] ,
[0048] wherein in the formula, is the gray value of the image, represents the first-order partial derivative of the image I in the x direction, represents the second-order partial derivative of the image I in the x direction, represents the first-order partial derivative of the image I in the y direction, represents the second-order partial derivative of the image I in the y direction.
[0049] The sub-pixel level edge point coordinates are calculated based on the offset:
[0050] .
[0051] Compared with the prior art, the present application has the following beneficial effects:
[0052] The bridge pier crack detection method based on the improved YOLOv8n can produce significant economic benefits. The core value lies in replacing traditional high-risk, low-efficiency and high-cost manual inspection with automation and intelligence.
[0053] Firstly, the method directly reduces the detection operation cost. The lightweight model can be deployed on mobile platforms such as unmanned aerial vehicles to realize unmanned aerial operation, save a large amount of scaffold erection, traffic control and manual labor costs, and the single detection cost is expected to be reduced by more than 60%, and the efficiency is improved by more than 80%.
[0054] Secondly, it has great preventive maintenance value. The millimeter-level precision quantization capability of 0.15mm can identify early micro-cracks that are easily overlooked by artificial, and realize "small treatment and large prevention". The maintenance mode is changed from expensive post-reinforcement to low-cost pre-repair, avoiding structure overhaul caused by crack expansion, and it is expected to save up to 60% of the later maintenance cost, greatly extending the service life of the bridge.
[0055] Finally, the method improves the safety and continuity of bridge operation. The rapid and efficient normalized detection reduces the bridge closure time, ensures smooth traffic, avoids huge indirect economic losses and social influence caused by sudden closure or accidents, and the long-term comprehensive economic benefits far exceed the technical investment itself, driving the upgrading of bridge operation and maintenance management mode. BRIEF DESCRIPTION OF DRAWINGS
[0056] Figure 1 is a bridge pier crack detection method process schematic diagram based on improved YOLOv8n. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all embodiments.
[0058] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.
[0059] The present application will be described in more detail below in conjunction with the drawings:
[0060] Reference Figure 1 A bridge pier crack detection method based on improved YOLOv8n, comprising the following steps:
[0061] S1, image preprocessing is completed for the photographed bridge pier surface picture: convert the RGB color image to YCbCr color space and separate the luminance channel and the color channel, apply limited contrast adaptive histogram equalization processing to the luminance channel to enhance the contrast and suppress noise, and perform geometric correction on the deformed image caused by the tilt of the shooting angle to convert to a front view.
[0062] Since the bridge piers images taken by UAV may be affected by uneven illumination, adaptive histogram equalization (CLAHE) is used to enhance the illumination and suppress the noise while enhancing the contrast of the image. For each small region (tile) in the image, its histogram is calculated and histogram equalization is performed.
[0063] Instead of simply performing histogram equalization on the whole RGB image, the RGB color image is converted to YCbCr color space in this embodiment. The Y channel represents the luminance information of the image, which accounts for most of the contrast and illumination effects. The Cb and Cr channels represent color information, which is relatively insensitive to changes in illumination. The Y channel representing the intensity of illumination is precisely processed, which fundamentally avoids the problem of color distortion. To avoid noise amplification, the histogram is clipped, and the part exceeding the clipping limit is redistributed to all gray levels.
[0064] The specific process is as follows:
[0065] Let the input image be I, and its size be The image is divided into small blocks with a size of
[0066] For each small block:
[0067] 1. Calculate the gray level histogram of the block , where (k represents the number of gray levels, and the total number of gray levels is 256 in this embodiment).
[0068] 2. Clip the histogram: set the clipping limit (this embodiment takes times the average histogram height), then the clipping process is:
[0069]
[0070] Then calculate the total number of pixels after clipping:
[0071]
[0072] And add to the histogram value of all gray levels:
[0073]
[0074] 3. Select the equalization of the clipped histogram to get the mapping function of the small block :
[0075]
[0076] where j, k represent the number of gray levels, The number of pixels of gray scale The gray histogram of a small region The histogram of the small region after clipping The clipping amplitude of the histogram The gray mapping function G represents the size of each image block.
[0077] 4. For each pixel, the final gray value is obtained by bilinear interpolation of the mapping functions of its four adjacent small blocks.
[0078] For the bridge pier image taken by the UAV, there may be a perspective tilt, which causes the deformation of the bridge pier surface. Therefore, we need to perform set correction to convert the image to a front view.
[0079] This embodiment establishes a perspective transformation relationship by detecting four corner points (or known marker points) on the surface of the bridge pier.
[0080] Let the four corner points detected in the original image be , and the four corner points after target correction be , which is usually defined as a matrix. The perspective transformation matrix is an matrix, which satisfies:
[0081]
[0082] wherein is a point in the original image, is the corrected point. Expanding it is:
[0083]
[0084] Through 4 pairs of corresponding points (the minimum requirement), the 8 unknown parameters of can be solved, which is usually set to 1.
[0085] Let the equation group be:
[0086]
[0087] Write it in matrix form , wherein .
[0088] The least square solution is . Wherein is the perspective transformation parameter vector to be solved.
[0089] Through light enhancement and geometric correction, high-quality input images are provided for subsequent crack detection and quantitative analysis.
[0090] S2. Optimize the YOLOv8n model to improve the performance of bridge pier crack detection: Introduce the MA-ECA attention mechanism module and embed it into the 3×3 standard convolutional layer in the original model to form an enhanced convolutional block. Dynamically adjust the channel weights through horizontal and vertical dual-path global pooling to enhance the sensitivity to crack features and suppress background interference. Replace the original PANet (PathAggregation Network) with AFPN (Asymptotic Feature Pyramid Network) structure. Optimize the multi-scale feature aggregation process by using hierarchical fusion and adaptive spatial weight allocation to improve the model's ability to perceive and detect cracks at different scales.
[0091] This step optimizes the YOLOv8n model to adapt to the characteristics of small targets, complex backgrounds, and varied shapes in bridge pier crack images.
[0092] The main improvement steps are as follows:
[0093] 1. By improving the attention mechanism, the model focuses more on the crack region and suppresses irrelevant background, thereby enhancing the ability to extract crack features. After adding the standard 3x3 convolutional layer from the original YOLOv8n using the MA-ECA (Multi-scale Adaptive Efficient Channel Attention) module, an enhanced basic convolutional block is formed, which adaptively adjusts the channel weights to enhance the sensitivity to crack features.
[0094] The MA-ECA module can first be seen as a method similar to the SE attention module. Let the original input tensor X∈C×H×W represent the intermediate feature map, where C represents the number of input channels, and H and W represent the height and width of the spatial dimension of the input feature, respectively.
[0095] Therefore, 1D global average pooling, which encodes global information along the horizontal dimension in the C dimension of height H, can be expressed as:
[0096]
[0097] in This represents the input feature of the c-th channel. Represents the width coordinate.
[0098] Through this encoding process, the MA-ECA module captures long-distance dependencies in the horizontal dimension and retains precise location information in the vertical dimension.
[0099] Similarly, another path is to directly perform one-dimensional global average pooling in the horizontal dimension, which can be expressed as:
[0100]
[0101] wherein represents the input feature of the c-th channel, represents the height coordinate.
[0102] Therefore, it can be regarded as a collection of position information in the vertical dimension. This path uses one-dimensional global average pooling in the vertical dimension to capture long-distance interactions in space while preserving accurate position information in the horizontal dimension, thereby enhancing attention to crack regions.
[0103] 2. Improve multi-scale crack detection capability by optimizing feature fusion structure. Due to the large variation in crack size, especially for fine cracks, improving the feature pyramid structure can enhance the model's perception of cracks of different sizes.
[0104] This embodiment replaces the original PANet (Path Aggregation Network) with AFPN (Asymptotic Feature Pyramid Network). The core idea is to optimize the feature fusion process through hierarchical fusion and adaptive spatial weight distribution to achieve more flexible multi-scale feature fusion and avoid loss of small target information in deep feature maps.
[0105] AFPN uses hierarchical fusion, only fusing low-level features in the initial stage, and gradually introducing high-level features in the subsequent stages, which can be expressed as:
[0106]
[0107] wherein, represents the feature after the n-th layer fusion, n represents the current fusion layer index, which limits the total number of intermediate levels participating in the final fusion, and the first level here represents the feature map level of different scales (respectively rates) in the feature pyramid, is the weight coefficient assigned to the low-level feature when the n-th layer fusion is performed, and the gradual fusion is realized by dynamically adjusting this coefficient. By dynamically adjusting the fusion weight of features at different levels through adaptive spatial weight distribution, the formula is:
[0108]
[0109] wherein, is the weight coefficient assigned to the low-level feature when the n-th layer fusion is performed, and the gradual fusion is realized by dynamically adjusting this coefficient.
[0110] The spatial weight of the layer feature is dynamically generated by calculating the semantic difference and position information of different layer features. representing the first layer, is an intermediate layer index participating in multi-scale feature fusion, 1≤ ≤n.
[0111] S3, the optimized YOLOv8n model adopts an MPD-IoU loss function for boundary box regression, and the MPD-IoU loss function is constructed based on the minimum point distance between the four vertices of the predicted box and the real box, and is used to optimize the boundary box regression accuracy of slender and curved cracks.
[0112] The original loss function is not friendly to the regression of slender and curved crack boxes, and is prone to inaccurate positioning. The improved loss function MPD-IoU (Minimum Point Distance-IoU) can better learn the geometric features of the crack, especially the boundary box regression of slender shape is more accurate. MPD-IoU considers the minimum point distance between the four vertices of the predicted box and the real box, and integrates it into the loss calculation, which can better handle irregularly shaped targets such as cracks.
[0113] In the segmentation and regression loss, the constraint of crack continuity and smoothness is added to complete the crack shape perception constraint, and the gradient continuity loss is as follows:
[0114]
[0115] wherein, is the predicted crack segmentation map or boundary box mask, is the (artificial) real label, is the gradient operator, is the edge gradient map of the predicted crack image, is the edge gradient map of the real crack image, is a balance coefficient, and the improved loss function reduces the missed detection of broken cracks, making the predicted crack contour smoother and more continuous.
[0116] It should be further pointed out that S2 and S3 interact and are related to each other, from feature extraction to final output, and the crack detection is optimized layer by layer:
[0117] 1. AFPN provides high-quality feature basis for MPD-IoU and gradient loss.
[0118] The multi-scale fusion strategy of AFPN ensures that the network feature maps contain rich spatial details and semantic information. For crack detection, low-level features preserve the fine structure and continuity of cracks, while high-level features provide the global context of cracks. This balanced feature representation is a prerequisite for accurate detection. Without the detailed features provided by AFPN, the MPD-IoU loss may lack sufficient local information to precisely locate the slender cracks when regressing the bounding box. Similarly, the gradient continuity loss also requires high-quality feature maps to generate smooth segmentation masks. The output of AFPN is directly used as input to the detection head for predicting bounding boxes and segmentation masks, so the quality of AFPN features directly affects the subsequent loss functions.
[0119] 2. MPD-IoU loss utilizes AFPN features for precise box regression.
[0120] In the detection network, based on the features extracted by AFPN, the detection head generates the bounding box prediction of the crack. The MPD-IoU loss function calculates the error between the predicted box and the true box through these features, but unlike the traditional IoU, it focuses on the vertex distance, which is more sensitive to the box regression of slender cracks. The features of AFPN enable the network to better perceive the endpoints and small-scale structures of the crack, and MPD-IoU utilizes this information to optimize the coordinate learning of the box. For example, the endpoints of the crack often correspond to the vertices of the bounding box, and the details preserved by AFPN help the network accurately identify these points, and MPD-IoU ensures that the distance between these points is minimized. In this way, the box regression is more consistent with the actual morphology of the crack, reducing missed detection or mispositioning.
[0121] 3. Gradient continuity loss optimizes the shape consistency together with MPD-IoU.
[0122] MPD-IoU mainly optimizes the global position of the bounding box, but pays insufficient attention to the continuity within the crack (such as the crack may be broken or blurred). The gradient continuity loss makes up for this deficiency, which directly acts on the segmentation output or box mask, forcing the prediction result to be continuous at the pixel level by punishing the gradient difference. During training, the gradient continuity loss is usually used together with the MPD-IoU loss as part of the total loss function. MPD-IoU ensures the overall shape of the box is accurate, while the gradient loss ensures that the crack prediction within the box is continuous and smooth.
[0123] S4, adopt YOLOv8-Seg model to extract sub-pixel level edge in the detected crack area, calculate the sub-pixel level offset of edge points through gradient direction and quadratic surface fitting, obtain edge positioning beyond pixel precision; further skeletonize the crack image and extract the center axis, calculate the width of each point of the crack through distance transform or normal scanning, combine with the camera calibration parameters to realize the physical size conversion of the crack width, complete the quantitative measurement.
[0124] YOLO is good at positioning, but to get accurate crack width, length, it needs to be combined with subsequent processing. The crack area detected in the above steps is subjected to sub-pixel level edge extraction using the YOLOv8-Seg model, and through the direction of the gradient and the fitting of the quadratic surface, the edge position beyond the pixel accuracy can be obtained, so as to realize the millimeter-level width measurement.
[0125] Sub-pixel level interpolation offset , ) is as follows:
[0126] ,
[0127] In the formula, I(x, y) is the gray value of the image, represents the first-order partial derivative of the image I in the x direction, represents the second-order partial derivative of the image I in the x direction, represents the first-order partial derivative of the image I in the y direction, represents the second-order partial derivative of the image I in the y direction. A pixel point in the corresponding image is usually an integer pixel coordinate located on the edge that is preliminarily detected, and the sub-pixel level position offset of the pixel point is estimated through the gradient and Hessian matrix
[0128] , ), and the first-order derivative and the second-order derivative can accurately locate the position of the feature point. The final sub-pixel level edge point coordinates are:
[0129]
[0130] The Zhang-Suen skeletonization algorithm is used on the segmented crack binary image to extract the single-pixel width crack centerline, and then the method based on Euclidean distance transformation (suitable for curved cracks) or normal scanning method (suitable for straight cracks) is used to calculate the width (unit: pixel) of each point of the crack. Finally, according to the camera calibration parameters (the scale factor is obtained in advance through the calibration board, such as 1 pixel = 0.1 mm), the pixel width is converted into physical size to obtain the actual width of the crack, and the width distribution chart or statistical report is output to complete the quantitative measurement of the crack.
[0131] By comparing the results output by the above steps with the previous results, the trend of the crack width can be known, and the alarm evaluation program is entered.
[0132] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited to the above embodiments, and any changes, modifications, substitutions, combinations, simplifications, etc. made without departing from the spirit and principles of the present application should be equivalent replacement manners and should be included in the protection scope of the present application.
Claims
1. A pier crack detection method based on improved YOLOv8n, characterized by, The method comprises the following steps: S1, preprocessing the collected structure surface image, the preprocessing comprising color space conversion and contrast enhancement, and geometric correction of the image; S2, constructing a crack target detection model, the model taking a YOLOv8n model as a baseline, and embedding a MA-ECA (Multi-scale Adaptive Efficient Channel Attention) module in the backbone network of the model, the MA-ECA module dynamically adjusting channel weights through horizontal and vertical dual-path global pooling operations; meanwhile, an asymptotic feature pyramid network is used to replace the path aggregation network in the original model, the asymptotic feature pyramid network optimizing multi-scale feature aggregation through hierarchical fusion and adaptive spatial weight distribution; The hierarchical fusion and adaptive spatial weight distribution comprise: In the initial stage, low-level features are fused, and high-level features are gradually introduced in the subsequent steps, and the fusion process is represented as: ; wherein, denotes the feature after fusion of the nth layer, n denotes the current fusion level index, and denote the feature maps of the previous level and the previous two levels, respectively, is a dynamic weight coefficient assigned to the low-level feature when the nth layer is fused. Further, the features at different levels are weighted and fused through adaptive spatial weight distribution, and the formula is represented as: ; wherein, is the first layer feature, is the spatial weight of the layer feature, is the first layer, is the intermediate layer index participating in the multi-scale feature fusion, 1≤ S3, predicting the preprocessed image using the crack target detection model, and performing boundary box regression using a loss function based on the minimum point distance between the vertices of the predicted box and the real box; S4, performing pixel-level segmentation on the crack region detected in step S3 to extract the sub-pixel level edge profile of the crack; and calculating the physical width information of the crack based on the edge profile.
2. The pier crack detection method based on improved YOLOv8n according to claim 1, characterized in that, The color space conversion and contrast enhancement in step S1 specifically comprises: Converting an RGB color image to a YCbCr color space and separating the luminance channel; Performing adaptive histogram equalization processing with limited contrast on the luminance channel; The histogram equalization comprises: 1) dividing the luminance channel image I into a plurality of image blocks of size G x G, for each image block, calculating its gray level histogram where k is the gray level; 2) clipping the histogram, setting a clipping limit β, to obtain a clipped histogram , calculating the total number of clipped pixels , and distributing them evenly to all gray levels to obtain a redistributed histogram , where is the total number of gray levels. 3) histogram equalization based on the re-distributed histogram to obtain the gray mapping function of the image block: wherein j, k represent the number of gray levels, is the number of pixels with gray level is the number of pixels with gray level represents the gray histogram in a small area, represents the histogram of the small area superimposed with the clipping, is the histogram clipping amplitude, is the gray mapping function, and G represents the size of each image block. 4) The final gray value is obtained by bilinear interpolation of the mapping function of each pixel point and its adjacent image block.
3. The pier crack detection method based on improved YOLOv8n according to claim 1, characterized in that, The geometric correction comprises: 1) Detect four corner points or marker points on the surface of the bridge pier in the original oblique image as the source point set wherein, ; 2) Establishing perspective transformation relationship: defining target corner coordinates in target correction coordinate system , realizing coordinate mapping through homography matrix H, satisfying: , wherein H is a 3*3 perspective transformation matrix, is a point in the original image, is a corrected point, and it is set that =1; it is expanded as: ; 3) Solving for transformation parameters using the least squares method: solving by 4 pairs of corresponding points. Given 8 unknown parameters, let the system of equations be: Write it as a matrix ,in Finally, the least squares solution is obtained as follows: ,in Let be the perspective transformation parameter vector to be solved.
4. The pier crack detection method based on improved YOLOv8n according to claim 1, characterized in that, The MA-ECA module is embedded into a 3x3 standard convolution layer in the YOLOv8n model.
5. The pier crack detection method based on improved YOLOv8n according to claim 4, characterized in that, The horizontal and vertical dual-path global pooling operation dynamically adjusts the channel weights, comprising: One-dimensional global average pooling is performed on the input feature map X∈C×H×W along the horizontal and vertical dimensions respectively to obtain feature encodings in two directions: The horizontal one-dimensional global average pooling in the height direction is represented as: ; The vertical one-dimensional global average pooling along the width direction is expressed as: ; wherein, wherein C denotes the number of input channels, H and W denote the height and width of the input feature map, respectively, denotes the input feature of the c-th channel, denotes the width coordinate, denotes the height coordinate.
6. The pier crack detection method based on improved YOLOv8n according to claim 1, characterized in that, The loss function used in step S3 is an MPD-IoU loss function; the MPD-IoU loss function is constructed based on the minimum point distance between the four vertices of the predicted box and the real box.
7. The pier crack detection method based on improved YOLOv8n according to claim 6, characterized in that, A gradient continuity loss function is also introduced in the regression process, and its expression is: ; wherein, is a predicted crack segmentation map or a bounding box mask, is a ground truth, is a gradient operator, is a balancing coefficient, is an edge gradient map of a predicted crack image, is an edge gradient map of a real crack image.
8. The pier crack detection method based on improved YOLOv8n according to claim 1, characterized in that, In step S4, a YOLOv8-Seg model is used for pixel-level segmentation of the crack region; The extraction of the sub-pixel level edge profile specifically comprises: calculating the sub-pixel level offset of the edge point by calculating the gradient direction and fitting a quadratic surface; Based on the edge profile, the physical width information of the crack is calculated, specifically comprising: Skeletonization processing is performed on the crack image to extract the center axis; The width of each point of the crack is calculated by distance transformation or normal scanning; The physical size conversion of the crack width is realized in combination with the camera calibration parameters.
9. The pier crack detection method based on improved YOLOv8n according to claim 8, characterized in that, the sub-pixel level offset , ) is represented as: , ; wherein the formulae is a grey value of the image, denotes a first order partial derivative of the image I in the x direction, denotes a second order partial derivative of the image I in the x direction, denotes a first order partial derivative of the image I in the y direction, denotes a second order partial derivative of the image I in the y direction; The sub-pixel level edge point coordinates are calculated based on the offset: 。
Citation Information
Patent Citations
Crack detection method and device based on image enhancement and texture extraction, and medium
CN115731172A
Video writing brush holding posture identification technology based on deep learning
CN118609218A