Intelligent identification method for crack trend of hydraulic concrete
By using bounding box annotation and an improved YOLOv8-OBB model, combined with multi-scale feature fusion and sliding window segmentation technology, the accuracy problem of identifying inclined and curved cracks in hydraulic concrete cracks was solved, achieving efficient and accurate crack detection.
Patent Information
- Application Number
- CN202510932821.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-11-07
AI Technical Summary
Existing deep learning-based target detection models struggle to accurately identify inclined and curved cracks in hydraulic concrete, resulting in large deviations between the detection box edge and the actual contour. Background noise also affects confidence levels, and the lack of directional information limits the ability to diagnose defects.
We employ directional bounding box annotation and an improved YOLOv8-OBB target detection network model, combined with transfer learning and multi-scale feature fusion. Through the Sobel operator and sliding window segmentation technique, we accurately annotate and analyze crack tilt angles, and optimize the loss function to improve recognition accuracy.
It enables precise location and orientation identification of cracks in hydraulic concrete, reduces false detection and missed detection rates, improves detection accuracy and efficiency, and reduces data acquisition and model optimization costs.
Smart Images

Figure CN120913142A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of underwater structure crack detection, and particularly relates to an intelligent identification method for the direction of cracks in hydraulic concrete. BACKGROUND
[0002] Under the long-term load and complex environmental action, the concrete structure of hydraulic structures such as dams, spillways and tunnels will age and produce cracks, and even further develop into diseases such as leakage, spalling and exposed reinforcement, which seriously affects the integrity and durability of the hydraulic concrete structure. Therefore, how to scientifically and effectively diagnose the safety of the hydraulic concrete cracks is a hot research topic at present.
[0003] Crack detection is an important means to ensure the safety of the hydraulic concrete structure, and the traditional manual inspection is time-consuming and laborious and has strong subjectivity. The machine learning method can realize a semi-automatic crack detection process, improve the efficiency and accuracy, but the method needs experts with certain experience to extract the crack features in the image, including the crack shape and direction. With the development of artificial intelligence technology, many studies use deep learning methods instead of manual inspection, automatically learn complex crack features from a large amount of image and video data, and understand, analyze and process, which can greatly improve the automation level of crack detection.
[0004] Although the current deep learning-based target detection model generally uses traditional horizontal frames for crack identification, its engineering applicability is fundamentally restricted: due to the influence of multi-view imaging conditions and the anisotropy of crack morphology, the crack images collected on site generally show multi-angle spatial distribution characteristics (0°, 180°). The axial constraint detection frame relied on by the existing method can only effectively locate the horizontal or vertical cracks, and it is difficult to accurately fit the cracks with inclined angles, curve shapes and bifurcations, resulting in a large deviation between the edge of the detection frame and the actual outline of the crack. Such deviation not only makes the prediction frame contain a large amount of background interference information, but more importantly, the direction feature of the frame cannot intelligently analyze the crack direction, which eventually leads to two key problems: first, the background noise will significantly reduce the detection confidence and affect the subsequent quantitative analysis; second, the lack of direction information seriously restricts the crack morphology evaluation and disease diagnosis capability. SUMMARY
[0005] The application aims to provide an intelligent identification method for the direction of cracks in hydraulic concrete, which solves the above technical problems.
[0006] To solve the above technical problems, the application realizes the following technical scheme:
[0007] An intelligent identification method for the direction of cracks in hydraulic concrete, comprising the following steps:
[0008] Step S1: Collecting images of cracks in concrete buildings through multiple channels;
[0009] Step S2: Using image labeling tools to label the cracks in the obtained images with directional boxes with inclination angles, and all the labeled images constitute a data set, and the data set is divided into a training set and a validation set according to a ratio of 7:3;
[0010] Step S3: Building a directional target detection network model YOLOv8-OBB and training the model by combining a transfer learning strategy;
[0011] Step S4: Collecting images of the surface of the concrete of the water conservancy building to be detected, inputting the images into the trained directional target detection network model for crack detection, and outputting the detection results containing the crack direction information.
[0012] Further optimization, in step S1, through network crawling, public traffic engineering concrete crack images and on-site shooting of water conservancy concrete structure images are obtained, the obtained images are preprocessed, and enhancement operations are performed through rotation and deformation, and then a multi-scene concrete crack image library is constructed. The preprocessing method is, for example, using a filtering algorithm to reduce noise, using an image enhancement algorithm to improve contrast, and the like, so as to highlight the crack features and provide a good data basis for subsequent gradient calculation and the like.
[0013] Further optimization, in step S2, the roLabelImg tool is used to label the cracks in the images obtained in step S1, and a rectangular directional box with five positioning parameters (c x , c y , w, h, θ) is generated, and the four vertices (x1, y1, x2, y2, x3, y3, x4, y4) of the directional box are calculated.
[0014] Wherein, (c x , c y ) represents the coordinates of the center point of the directional box; w represents the width of the directional box; h represents the height of the directional box; θ represents the inclination angle of the directional box relative to the horizontal line, i.e. the direction of the crack; (x1, y1), (x2, y2), (x3, y3) and (x4, y4) represent the coordinates of the four vertices of the directional box.
[0015] Further optimization, in step S2, for cracks that are curved or have bifurcations, the regions with relatively consistent inclination angles of the cracks in the image are first divided into independent segments, and then the roLabelImg tool is used to label each independent crack segment with five parameters with inclination angles.
[0016] Further optimization, for cracks that are curved or have bifurcations, the regions with relatively consistent inclination angles are divided into independent segments, which specifically include the following steps:
[0017] Step S2.1: Calculate the gradient direction of each pixel point in the crack region using Sobel operator; the Sobel operator includes horizontal direction convolution kernel S x and vertical direction convolution kernel S y , which are used to calculate horizontal direction gradient G x and vertical direction gradient G y , respectively.
[0018] Step S2.2: Calculate the gradient amplitude and direction: for each pixel point (x, y) in the crack region of the image, the horizontal direction gradient value G x (x, y) and the vertical direction gradient value G y (x, y) are obtained by convolving the Sobel operator with the neighborhood pixel values; then, the gradient amplitude G(x, y) is calculated according to the following formula:
[0019]
[0020] The gradient direction (x, y) is calculated by the formula: Through the above calculation, the gradient amplitude and direction of each pixel point in the crack region are obtained, which provides a basis for subsequent segmentation judgment.
[0021] Step S2.3: Segmentation judgment based on sliding window traversal, specifically including:
[0022] Step S2.3.1: Determine the sliding window parameters, including selecting a suitable size of the sliding window, such as a 5x5 pixel window, which can be adjusted according to the actual situation. At the same time, set the threshold of the standard deviation of the gradient direction, such as 15°, which is used to judge whether to segment.
[0023] Step S2.3.2: Sliding window traversal calculation: starting from the upper end of the crack region, using the sliding window to traverse the entire crack region along the crack extension direction according to the set step, such as moving 2 pixels each time, after each movement, the standard deviation of the gradient direction of all pixel points in the window is calculated; the specific calculation process is as follows:
[0024] First, record the gradient direction values φ i of the pixel points in the window, where i represents the index of the pixel points in the window;
[0025] Then, calculate the mean value of these gradient direction values, where n is the number of pixel points in the window;
[0026] Next, calculate the standard deviation σ:
[0027] Step S2.3.3: segmentation determination: when the standard deviation σ of the pixel gradient direction in the window exceeds a set threshold σ0, the position is considered as a segmentation boundary, and the position is marked to divide the crack into different segments; by continuously moving the sliding window and performing the above calculation and judgment, the segmentation of the crack region is realized.
[0028] Further optimization, in step S3, a directional target detection network model based on improved YOLOv8-OBB is built and trained, specifically including:
[0029] Step S3.1: building a directional target detection network model and optimization, specifically including:
[0030] Feature extraction module optimization: in the CSPDarknet backbone network, an angle perception mechanism is added to each convolutional layer, so that the dynamic convolution kernel can adaptively adjust the direction according to the angle information of the segmentation label; an attention mechanism is introduced in the PANet neck network to enhance the attention to the feature differences at the crack segmentation boundaries, so as to optimize the multi-scale feature fusion; YOLOv8 outputs three feature maps of 1 / 8, 1 / 16 and 1 / 32, when the input size is 640x640, the multi-scale feature extraction layer retains three feature maps of 80x80, 40x40 and 20x20, which are suitable for detecting small, medium and large cracks respectively.
[0031] Detection head design optimization: each detection head outputs a 5-degree-of-freedom parameter vector: center point coordinates (c x ,c y ), width and height (w, h), and rotation angle θ, where θ ∈ (-90°, 90°); a segmentation relationship prediction branch is added to output the connection probability and angle offset between crack segments; for crack segments with large curvature, a key point is added at the beginning and end of each segment, and the direction angle of the key point connecting line is predicted.
[0032] Step S3.2: training the built directional target detection network model:
[0033] The training set is input into the built model for training, and the improved loss function is used as the training objective function of the model, and the Adam optimizer is used to update the model parameters; after the end of each training period, the MSE of the validation set is calculated, until the loss of the validation set converges, and then the optimal parameters of the model are determined.
[0034] Further optimization, the improved loss function L total is:
[0035] L total =L cls +λ1·L box +λ2·L seg +λ3·L θ-seq ;
[0036] wherein, L cls represents a classification loss for determining whether a crack exists in an image, g k represents a true value of the kth crack category, represents a probability of the kth crack category predicted by the model, k = 1, 2, representing a crack and no crack, respectively.
[0037] L box represents a bounding box loss for evaluating the crack bounding box predicted by the model; L box = 1 - IoU + p 2 / c 2 + av;
[0038] Assuming that the predicted box is B p = (x p , y p , w p , h p ), the true box is B r = (x r , y r , w r , h r ), and IoU = intersection area of the predicted box and the true box / union area of the predicted box and the true box; (x p , y p ) represents the center coordinates of the predicted box, w p , h p represent the width and height of the predicted box; (x r , y r ) represents the center coordinates of the true box, w r , h r represent the width and height of the true box.
[0039] p 2 = (x p - x r ) 2 + (y p - y r ) 2 ;
[0040] w diag and h diag represent the width and height of the minimum circumscribed rectangle containing the predicted box and the true box;
[0041]
[0042] Lseg is a segmentation consistency loss for ensuring that the crack segmentation predicted by the model has consistency in position and direction, Lseg = λ 11• IoUseg + λ 22 • AngleDiffseg; where IoUseg measures the overlap degree between two crack segment prediction boxes and the true box intersection area divided by the union area; AngleDiffseg calculates the angle difference of adjacent segments, and λ 11 and λ 22 are weight coefficients for adjusting the relative importance of the overlap loss and the angle difference loss.
[0043] Lθ-seq; represents the segment angle sequence loss, which measures the difference between the predicted angle sequence and the true angle sequence by considering the continuity and sequence of the crack curve segment angles.
[0044] λ1, λ2, and λ3 are weight coefficients for adjusting the relative importance of different loss terms in the overall loss function.
[0045] Further optimization, in step S2, the public traffic engineering concrete crack images will be crawled through the network, and after labeling the cracks using the roLabelImg tool, a first training set is formed; the hydraulic concrete crack images collected on site are labeled using the roLabelImg tool, and a second training set is formed; in step S3, when training the directional target detection network model constructed, first pre-train the model based on the first training set to learn the general morphological features of cracks; then use the second training set to perform secondary training on the model, fine-tune the model parameters, and make the model accurately identify the five positioning parameters of the hydraulic concrete crack under the condition of a small amount of samples.
[0046] Since the pre-training stage uses public traffic engineering data, there is no need to invest a lot of manpower and resources to collect and label data, greatly reducing the data acquisition cost. At the same time, through two-stage training, the performance improvement of the model reduces the number of model optimization and retraining in the later stage, reducing the development cost. In terms of deployment, the efficiency and stability of the model reduce the requirements for hardware devices, further saving deployment costs and improving the performance-price ratio of the model in actual engineering applications.
[0047] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0048] 1. The present application uses directional boxes instead of traditional horizontal boxes, which can more accurately fit the crack edge and accurately represent the crack direction information, thereby more accurately positioning the crack position.
[0049] 2. The method of the present application does not require manual adjustment of the crack direction. As long as the crack appears in the image, the crack direction and position information can be intelligently identified.
[0050] 3. For complex cracks such as curved or branched cracks, the strike and morphology vary greatly. The present application can mark and analyze the characteristics of different parts of the crack through segmented marking, accurately capture the direction, length and other information of each segment, better fit the actual morphology of the crack, make the model learn the crack characteristics more accurately, thereby improving the prediction accuracy of the crack position and strike, and reducing the false detection and missed detection rate. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 The workflow diagram of the method of the present application is shown in the figure.
[0052] Figure 2 The definition diagram of the directional box used in the present application is shown in the figure.
[0053] Figure 3 The comparison diagram of the directional box and the horizontal box marking used in the present application is shown in the figure.
[0054] Figure 4 The recognition effect diagram of the method of the present application is shown in the figure. DETAILED DESCRIPTION
[0055] The specific embodiments of the present application will be described below with reference to the accompanying drawings, so that those skilled in the art can understand the present application. Obviously, the present application is not limited to the scope of the specific embodiments. For those skilled in the art, any changes within the spirit and scope of the present application defined and determined by the appended claims are non-creative labor, and all inventions utilizing the inventive concept of the present application are within the scope of protection.
[0056] As shown in the figure, an intelligent recognition method for the strike of hydraulic concrete cracks comprises the following steps: Figure 1
[0057] S1: Collect concrete crack images in multiple ways: collect public traffic engineering concrete crack images through network crawling, and shoot hydraulic concrete structure images on site, pretreat the obtained images, and perform enhancement operation through rotation and deformation, and then construct a multi-scene concrete crack image library.
[0058] S2: Use an image marking tool to mark the cracks in the obtained images with a directional box with an inclination angle, and all the marked images constitute a data set, and the data set is divided into a training set and a verification set according to a ratio of 7:3.
[0059] Specifically, the roLabelImg tool is used to mark the cracks in the images obtained in step S1, and five positioning parameters (c x , c y a rectangular oriented frame of (w, h, θ), and calculate the coordinates of the four vertices of the oriented frame (x1, y1, x2, y2, x3, y3, x4, y4) according to the rectangular oriented frame; wherein, (c x , c y ) represents the coordinates of the center point of the oriented frame; w represents the width of the oriented frame; h represents the height of the oriented frame; θ represents the inclination angle of the oriented frame relative to the horizontal line, that is, the direction of the crack; (x1, y1), (x2, y2), (x3, y3) and (x4, y4) represent the coordinates of the four vertices of the oriented frame, as shown in Figure 2 .
[0060] Wherein, the first training set and the first verification set are constructed after the public traffic engineering concrete crack images are crawled through the network and the cracks are labeled by using the roLabelImg tool; the second training set and the second verification set are constructed after the hydraulic concrete crack images are collected on site and the cracks are labeled by using the roLabelImg tool.
[0061] For the inclined crack with a certain angle, the existing technology adopts a horizontal frame for calibration, as shown in (a) of Figure 3 ; in the present application, an oriented frame with the same inclination angle as the crack is adopted for labeling, as shown in (b) of Figure 3 .
[0062] For the crack in a curve shape or with bifurcation, the region with relatively consistent crack inclination angle in the image is first divided into independent segments, and then the roLabelImg tool is used to perform five-parameter labeling with inclination angle on each independent crack segment. Wherein, the region with relatively consistent crack inclination angle in the image is divided into independent segments, which specifically includes the following steps:
[0063] Step S2.1: the gradient direction of each pixel point in the crack region is calculated by using the Sobel operator; the Sobel operator includes a horizontal direction convolution kernel S x and a vertical direction convolution kernel S y , which are respectively used to calculate the horizontal direction gradient G x and the vertical direction gradient G y .
[0064] Step S2.2: calculate the gradient amplitude and direction: for each pixel point (x, y) in the crack region of the image, the horizontal direction gradient value G x (x, y) and the vertical direction gradient value G y (x, y) are obtained by convolving the neighborhood pixel values of the pixel point with the Sobel operator; then, the gradient amplitude G(x, y) is calculated according to the following formula:
[0065]
[0066] The gradient direction (x, y) is calculated by the formula: Through the above calculation, the gradient amplitude and direction of each pixel point in the crack region are obtained, which provides a basis for subsequent segmentation judgment.
[0067] Step S2.3: segmentation judgment based on sliding window traversal, specifically including:
[0068] Step S2.3.1: determine the sliding window parameters, including selecting a suitable size of the sliding window and setting the threshold of the gradient direction standard deviation.
[0069] Step S2.3.2: sliding window traversal calculation: starting from the upper end of the crack region, using the sliding window to traverse the entire crack region along the crack extension direction according to the set step size, and calculating the standard deviation of the gradient direction of all pixel points in the window after each movement; the specific calculation process is:
[0070] First, record the gradient direction values φ i of the pixel points in the window, where i represents the index of the pixel points in the window.
[0071] Then, calculate the mean value of these gradient direction values, where n is the number of pixel points in the window.
[0072] Next, calculate the standard deviation σ:
[0073] Step S2.3.3: segmentation judgment: when the standard deviation σ of the pixel gradient direction in the window exceeds the set threshold σ0, consider that the position is a segmentation boundary, and mark this position to divide the crack into different segments; by continuously moving the sliding window and performing the above calculation and judgment, the segmentation of the crack region is realized.
[0074] S3: build the directional target detection network model YOLOv8-OBB and train the model combined with the transfer learning strategy, specifically including:
[0075] Step S3.1: build the directional target detection network model and optimize, specifically including:
[0076] Feature extraction module optimization: in the CSPDarknet backbone network, add an angle perception mechanism to each convolutional layer, so that the dynamic convolution kernel can adaptively adjust the direction according to the angle information of the segmentation label; introduce an attention mechanism in the PANet neck network to enhance the attention to the feature differences at the crack segmentation boundaries, in order to optimize the multi-scale feature fusion; keep three kinds of feature maps of 80x80, 40x40 and 20x20 in the multi-scale feature extraction layer, which are suitable for detecting small, medium and large cracks respectively.
[0077] Detection head design optimization: Each detection head outputs a 5-DOF parameter vector: center point coordinates (c x ,c y ), width and height (w, h), and rotation angle θ, where θ ∈ (-90°, 90°); a segmented relationship prediction branch is added to output the connection probability and angular offset between crack segments; for crack segments with large curvature, a key point is added at the beginning and end of each segment, and the direction angle of the key point connection line is predicted.
[0078] Step S3.2: Train the constructed directional target detection network model:
[0079] The training set is input into the constructed model for training, and the improved loss function is used as the model's training objective function. The Adam optimizer is used to update the model parameters. After each training cycle, the MSE of the validation set is calculated until the validation set loss converges, and then the optimal parameters of the model are determined.
[0080] During the training of the constructed directional target detection network model, first, pre-train the model based on the first training set to learn the general morphological features of cracks; then, fine-tune the model parameters using the second training set to enable the model to accurately identify the 5 positioning parameters of hydraulic concrete cracks under the condition of a small number of samples.
[0081] The improved loss function L total is:
[0082] L total =L cls +λ1·L box +λ2·L seg +λ3·L θ-seq ;
[0083] where L cls represents the classification loss, which is used to determine whether a crack exists in the image, g k represents the true value of the kth crack category, represents the probability of the kth crack category predicted by the model, k = 1, 2, representing cracks and non-cracks, respectively.
[0084] L box represents the bounding box loss, which is used to evaluate the crack bounding box predicted by the model; L box =1-IoU+ρ 2 / c 2 +αv;
[0085] Assuming the predicted box is B p =(x p ,y p ,w p ,hp ), the real box is B r = (x r , y r , w r , h r ), IoU = intersection area of prediction box and real box / union area of prediction box and real box; (x p , y p ) represents the center coordinates of the prediction box, w p , h p represent the width and height of the prediction box; (x r , y r ) represents the center coordinates of the real box, w r , h r represent the width and height of the real box.
[0086] p 2 = (x p - x r ) 2 + (y p - y r ) 2 ;
[0087] w diag and h diag represent the width and height of the minimum circumscribed rectangle containing the prediction box and the real box;
[0088]
[0089] Lseg is a segmentation consistency loss, used to ensure that the crack segmentation predicted by the model has consistency in position and direction, Lseg = λ 11 · IoUseg + λ 22 · AngleDiffseg; wherein, IoUseg measures the overlap degree, which is the area of the intersection of the two crack segmentation prediction boxes and the real box divided by the area of the union; AngleDiffseg calculates the angle difference of adjacent segments, λ 11 and λ 22 are weight coefficients, used to adjust the relative importance of the overlap loss and the angle difference loss.
[0090] Lθ-seq; represents the segmentation angle sequence loss, which is used to measure the difference between the predicted angle sequence and the real angle sequence by considering the continuity and sequence of the crack curve segmentation angles.
[0091] λ1, λ2, λ3 are weight coefficients, used to adjust the relative importance of different loss terms in the overall loss function.
[0092] S4: collect the image of the surface of the water conservancy building concrete to be detected, input to the trained directional target detection network model for crack detection, and output the detection result containing the crack direction information.
[0093] In the embodiment, the collected image of the surface of the water conservancy building concrete is detected by using the trained model, as shown in FIG. 5. Figure 4 Figure 4 (a) in FIG. 5 is a detected straight crack, the red inclined frame represents the calibration frame of the crack, 0.87 represents the probability of being judged as a crack, the upper left corner 28.3° represents the rotation angle θ of the calibration frame, and 61.7° represents the inclination angle θ' of the crack, that is, the crack direction; the rotation angle θ of the calibration frame and the crack direction θ' have a geometric relationship, that is, θ' = 90°-θ.
[0094] . Figure 4 The crack detected in (b) changes in direction at the corner of the water conservancy building, so it is identified that the crack includes two segments. Figure 4 The crack detected in (c) is in a curved shape and has a bifurcation, so it is identified that the crack includes three segments.
[0095] The above only describes the preferred embodiments of the present application and is not used to limit the present application, and any modification, equivalent replacement and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0096] The contents not described in detail in the specification of the present application belong to the prior art known to the person skilled in the art.
Claims
1. A method for intelligently identifying the direction of a hydraulic concrete crack, characterized in that, It comprises the following steps: Step S1: Collecting crack images of concrete buildings in multiple ways; Step S2: Using image labeling tools to label the cracks in the obtained images with directional boxes with inclination angles, and all the labeled images constitute a data set, and the data set is divided into a training set and a validation set according to 7:3; Step S3: Building a directional target detection network model YOLOv8-OBB and training the model combined with a transfer learning strategy; Step S4: Collecting the images of the surface of the water conservancy building concrete to be detected, inputting them into the trained directional target detection network model for crack detection, and outputting the detection results containing the crack direction information.
2. The method according to claim 1, characterized in that, In step S1, publicly available traffic engineering concrete crack images and on-site images of hydraulic concrete structures are crawled through a network, the obtained images are preprocessed, and then enhanced through rotation and deformation, and a multi-scene concrete crack image library is constructed.
3. The method according to claim 1, characterized in that, In the step S2, the crack in the image obtained in the step S1 is labeled by using the roLabelImg tool to generate a rectangular orientation frame with five positioning parameters (c x , c y , w, h, θ), and the four vertices (x1, y1, x2, y2, x3, y3, x4, y4) of the orientation frame are calculated accordingly. wherein (c x , c y ) represents the coordinate of the center point of the orientation box; w represents the width of the orientation box; h represents the height of the orientation box; θ represents the inclination angle of the orientation box relative to the horizontal line, i.e. the strike of the crack; (x1, y1), (x2, y2), (x3, y3) and (x4, y4) represent the coordinates of the four vertices of the orientation box.
4. The method according to claim 3, characterized in that, In step S2, for cracks that are curved or have bifurcations, the regions with relatively consistent inclination angles in the image are first divided into independent segments, and then the roLabelImg tool is used to label each independent crack segment with five parameters with inclination angles.
5. The method according to claim 4, characterized in that, For cracks that are curved or have bifurcations, the regions with relatively consistent inclination angles are divided into independent segments, which specifically includes the following steps: Step S2.1: calculate the gradient direction of each pixel point in the crack region by using Sobel operator; the Sobel operator includes horizontal direction convolution kernel S x and vertical direction convolution kernel S y , which are respectively used for calculating horizontal direction gradient G x and vertical direction gradient G y ; Step S2.2: Calculate the gradient magnitude and direction: for each pixel point (x, y) in the crack region of the image, the horizontal direction gradient value G x (x, y) and the vertical direction gradient value G y (x, y) are obtained by convoluting its neighborhood pixel values with the Sobel operator; then, the gradient magnitude G(x, y) is calculated according to the following formula: The gradient direction (x, y) is calculated by the formula: Through the above calculation, the gradient amplitude and direction of each pixel point in the crack region are obtained, which provides a basis for subsequent segmentation judgment; Step S2.3: Segmentation judgment based on sliding window traversal, specifically including: Step S2.3.1: Determine the sliding window parameters, including selecting an appropriate size of the sliding window and setting the threshold of the gradient direction standard deviation; Step S2.3.2: Sliding window traversal calculation: starting from the upper end of the crack region, using the sliding window to traverse the entire crack region along the crack extension direction at a set step size, and calculating the standard deviation of the gradient direction of all pixel points in the window after each movement; the specific calculation process is as follows: First, the gradient direction value φ of the pixel point in the window is recorded i recorded, and i represents the index of the pixel point in the window; Then, the mean value of these gradient direction values is calculated where n is the number of pixels in the window. Next, the standard deviation σ is calculated: Step S2.3.3: Segmentation judgment: when the standard deviation of the gradient direction of the pixels in the window exceeds the set threshold σ0, it is considered that the position is a segmentation boundary, and the position is marked, so as to divide the crack into different segments; by continuously moving the sliding window and performing the above calculation and judgment, the segmentation of the crack region is realized.
6. The method according to claim 5, wherein, In step S3, a directional target detection network model based on the improved YOLOv8-OBB is built and trained, specifically including: Step S3.1: Building a directional target detection network model and optimizing, specifically including: Feature extraction module optimization: In the CSPDarknet backbone network, an angle perception mechanism is added to each convolutional layer, so that the dynamic convolution kernel can adaptively adjust the direction according to the angle information marked by the segmentation; an attention mechanism is introduced in the PANet neck network to enhance the attention to the feature differences at the crack segmentation boundaries, so as to optimize the multi-scale feature fusion; three kinds of feature maps of 80x80, 40x40 and 20x20 are reserved in the multi-scale feature extraction layer, which are suitable for detecting small, medium and large cracks, respectively; Optimization of detection head design: each detection head outputs a 5-DOF parameter vector: center point coordinates (c x ,c y ), width and height (w, h), rotation angle θ, where θ ∈ (-90°, 90°); a segmented relationship prediction branch is added to output the connection probability and angular offset between fracture segments; for fracture segments with large curvature, a key point is added at the beginning and end of each segment, and the direction angle of the key point connecting line is predicted; Step S3.2: Training the built directional target detection network model: The training set is input into the constructed model for training, an improved loss function is used as a training target function of the model, and an Adam optimizer is used to update model parameters; after each training cycle ends, the MSE of the verification set is calculated until the loss of the verification set converges, and then the optimal parameters of the model are determined.
7. The method according to claim 6, characterized in that, The improved loss function L total is: L total = L cls + λ1 · L box + λ2 · L seg + λ3 · L θ-seq ; wherein L cls represents a classification loss for determining whether a crack exists in the image, g k represents a true value of the kth crack category, represents a probability of the kth crack category predicted by the model, k = 1, 2, respectively, representing a crack and no crack; L box represents a bounding box loss for evaluating the model-predicted crack bounding boxes; L box = 1 - IoU + p 2 / c 2 + av; Assume the predicted box is B p =(x p ,y p ,w p ,h p ), the real box is B r =(x r ,y r ,w r ,h r ), IoU = intersection area of the predicted box and the real box / union area of the predicted box and the real box;(x p ,y p ) represents the center coordinates of the predicted box, w p ,h p represents the width and height of the predicted box;(x r ,y r ) represents the center coordinates of the real box, w r ,h r represents the width and height of the real box; p 2 = (x p - x r ) 2 + (y p - y r ) 2 ; w diag and h diag denote the width and height of the smallest enclosing rectangle containing the prediction and ground truth boxes; Lseg is a segmentation consistency loss used to ensure the consistency of the predicted crack segmentation in position and direction, Lseg = λ 11 · IoUseg + λ 22 · AngleDiffseg; where IoUseg measures the overlap between segments, which is the area of intersection between the predicted and true boxes of two crack segments divided by the area of union; AngleDiffseg calculates the angle difference between adjacent segments, λ 11 and λ 22 are weight coefficients used to adjust the relative importance of the overlap loss and the angle difference loss. L theta-seq; represents the piecewise angle sequence loss, which is used to measure the difference between the predicted angle sequence and the real angle sequence by considering the continuity and sequence of the piecewise angle of the crack curve; L1, L2 and L3 are weight coefficients, which are used to adjust the relative importance of different loss terms in the overall loss function.
8. The method according to claim 7, characterized in that, In the step S2, the public traffic engineering concrete crack images are crawled through the network, the cracks are labeled by using the roLabelImg tool, and the first training set is constructed; the hydraulic concrete crack images collected on site are labeled by using the roLabelImg tool, and the second training set is constructed; In the step S3, when the directional target detection network model is trained, the model is pre-trained based on the first training set first, the general morphological features of the cracks are learned, then the second training set is used to fine-tune the model parameters, and the model can accurately identify the five positioning parameters of the hydraulic concrete crack under the condition of a small amount of samples.