Crack recognition method and electronic device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2026-08-11
AI Technical Summary
然而,这类方法在处理钢结构表面存在锈蚀、油污、光照变化及背景干扰等多种复杂工程场景时,依然面临检测精度不高、误检漏检严重的瓶颈,难以满足实际工程对高鲁棒性和高精度的需求
[0060] This application provides a crack recognition method that acquires an inspection image, which includes a target object containing cracks; determines an initial segmentation mask based on the inspection image; and inputs the initial segmentation mask into a symmetric coding structure model based on an attention mechanism to obtain a crack recognition result. By using a symmetric coding structure model based on an attention mechanism, the accuracy of crack recognition can be improved.
Smart Images

Figure CN121032900B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of crack identification technology, and particularly relates to a crack identification method and electronic device. Background Technology
[0002] Large-span steel structures are widely used in important engineering projects such as large bridges, exhibition halls, and airport terminals. Surface cracks in these structures serve as early signs of service performance degradation and potential structural failure, making their efficient and accurate identification and quantitative assessment crucial. Traditional crack detection relies on manual inspection and image annotation, which is not only inefficient and subjective but also difficult to maintain stable operation over long periods in large-scale, complex environments. In recent years, with the rapid development of deep learning, crack recognition methods based on convolutional neural networks and image semantic segmentation have gradually become a research hotspot. However, these methods still face bottlenecks in handling complex engineering scenarios involving steel structure surfaces such as corrosion, oil stains, lighting variations, and background interference, resulting in low detection accuracy and significant false positives and false negatives, failing to meet the high robustness and high precision requirements of practical engineering projects. Summary of the Invention
[0003] In view of this, embodiments of this application provide a crack identification method and electronic device, which can improve the accuracy of crack identification.
[0004] In a first aspect, embodiments of this application provide a crack identification method, including:
[0005] Acquire inspection images, wherein the inspection images include target objects containing cracks;
[0006] Determine the initial segmentation mask based on the inspected images;
[0007] The initial segmentation mask is input into a symmetric coding structure model based on an attention mechanism to obtain crack recognition results.
[0008] In some embodiments, the attention-based crack recognition model includes an encoder module and a decoder module. The encoder module is used to extract features from the input initial segmentation mask, generate feature maps of different sizes, and input them into the decoder module. The decoder module is used to fuse the feature maps of different sizes based on the attention mechanism and output the crack recognition result based on the fused features.
[0009] In some embodiments, the decoder module is used to fuse feature maps of different sizes based on an attention mechanism, including:
[0010] Calculate the mean of all feature maps;
[0011] The variance of each feature map is calculated based on the mean.
[0012] The attention weight for each feature map is calculated based on the mean and the variance;
[0013] The attention weight of each feature map is multiplied by the corresponding element in the deconvolutioned feature map to fuse feature maps of different sizes.
[0014] In some embodiments, determining an initial segmentation mask based on the inspected image includes:
[0015] The inspection image is preprocessed to obtain a preprocessed image, wherein the preprocessed image satisfies the input of the extraction model;
[0016] The preprocessed image is input into the extraction model to determine the text description of the inspection image;
[0017] Extract the nouns from the text description and determine the semantic segmentation result image corresponding to each noun;
[0018] Each noun is input into a sentence embedding model to determine the semantic similarity between all nouns and preset nouns related to cracks;
[0019] The initial segmentation mask is determined based on the semantic segmentation result map corresponding to nouns with semantic similarity greater than the similarity threshold.
[0020] In some embodiments, the crack identification result includes: a crack image, and the method further includes:
[0021] Based on the crack image, determine the crack skeleton points and crack contour points;
[0022] Each crack skeleton point is divided into endpoints, effective bifurcation points, and ordinary points;
[0023] The path of the main crack is determined based on each endpoint, each effective bifurcation point, and each ordinary point.
[0024] The normal vector direction of the crack skeleton points of each main crack is determined based on the path of each main crack, and the width of each main crack is determined based on the normal vector direction and the crack contour points of each main crack.
[0025] In some embodiments, dividing each crack skeleton point into endpoints, effective bifurcation points, and ordinary points includes:
[0026] Determine the number of crack skeleton points within a first preset range from each crack skeleton point;
[0027] Endpoints, candidate bifurcation points, and ordinary points are determined based on the number of crack skeleton points. The number of crack skeleton points corresponding to an endpoint is 2, the number of crack skeleton points corresponding to a candidate bifurcation point is greater than 3, and the number of crack skeleton points corresponding to an ordinary point is 3.
[0028] Determine the number of ordinary points within a second preset range from each candidate bifurcation point;
[0029] If the number of ordinary points within a second preset range from the target candidate bifurcation point is greater than the number threshold, the target candidate bifurcation point is determined as a valid bifurcation point.
[0030] In some embodiments, determining the path of the main crack based on each endpoint, each effective bifurcation point, and each common point includes:
[0031] Identify all ordinary points within a third preset range from the effective bifurcation point, and use all ordinary points within a third preset range from the effective bifurcation point as candidate starting points for path construction;
[0032] Calculate the number of valid bifurcation points within a third preset range from each candidate starting point;
[0033] Based on the number of valid bifurcation points within a third preset range from each candidate starting point, the candidate starting points are divided into a first candidate starting point and a second candidate starting point, wherein the number of the first candidate starting point is not equal to 1, and the number of the second candidate starting point is equal to 1.
[0034] Based on the first candidate starting point, recursively search for crack skeleton points whose distance is less than a preset threshold until there are no more points to advance, and obtain the complete crack path.
[0035] Based on each complete crack path, the effective bifurcation points are deduplicated to obtain the deduplicated crack path.
[0036] Traverse the remaining endpoints and recursively search for crack skeleton points whose distance is less than a preset threshold to extract the remaining crack paths;
[0037] Based on each endpoint, each effective bifurcation point, and each extracted crack path, an undirected graph topology is constructed.
[0038] Calculate the shortest path length from the starting point to other nodes in the undirected graph topology, using the node with the smallest number as the starting point. Determine the node with the largest weight based on the shortest path length and the pre-set weight.
[0039] Starting from the node with the highest weight, calculate the shortest path length between the node with the highest weight and other nodes;
[0040] The sum of the weights of each crack path is determined based on the shortest path length between the node with the largest weight and other nodes.
[0041] The path of the main crack in the undirected graph topology is determined by the sum of the weights of each crack path.
[0042] In some embodiments, the method further includes:
[0043] Calculate the similarity between the path of the main crack and the preset prompt text;
[0044] The quality score of the main crack is determined based on the similarity.
[0045] If the quality score of the main crack is less than the set score threshold, the pre-set weight is adjusted.
[0046] In some embodiments, the step of removing duplicates from effective bifurcation points based on each complete crack path to obtain a deduplicated crack path includes:
[0047] Based on clustering algorithms, the effective branching points in each complete crack path are divided into different classes;
[0048] Determine the class to which the starting point of each crack path belongs;
[0049] If the starting points of multiple crack paths belong to the same category and the distance between their ending points is less than a threshold, then the multiple crack paths are determined to be duplicate paths.
[0050] Calculate the quality score for each duplicate path;
[0051] Crack paths with a mass fraction greater than the mass fraction threshold are retained to obtain deduplicated crack paths.
[0052] Secondly, embodiments of this application provide a crack identification device, comprising:
[0053] The acquisition module is used to acquire inspection images, which include target objects containing cracks;
[0054] The first determining module is used to determine an initial segmentation mask based on the inspection image;
[0055] The recognition module is used to input the initial segmentation mask into a symmetric coding structure model based on an attention mechanism to obtain crack recognition results.
[0056] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in any of the above-mentioned embodiments.
[0057] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any of the preceding claims.
[0058] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the electronic device to execute any of the methods described above.
[0059] The beneficial effects of the embodiments in this application compared with the prior art are:
[0060] This application provides a crack recognition method that acquires an inspection image, which includes a target object containing cracks; determines an initial segmentation mask based on the inspection image; and inputs the initial segmentation mask into a symmetric coding structure model based on an attention mechanism to obtain a crack recognition result. By using a symmetric coding structure model based on an attention mechanism, the accuracy of crack recognition can be improved. Attached Figure Description
[0061] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0062] Figure 1 A schematic diagram illustrating the implementation process of a crack identification method provided for the purposes of this application;
[0063] Figure 2 A schematic diagram of the structure of a crack recognition model based on an attention mechanism provided in an embodiment of this application;
[0064] Figure 3 An illustration of crack recognition provided in an embodiment of this application;
[0065] Figure 4 A schematic diagram illustrating the number of crack skeleton points provided in an embodiment of this application;
[0066] Figure 5 A flowchart illustrating a crack identification method provided in an embodiment of this application;
[0067] Figure 6 This is a schematic diagram of the structure of a crack identification device provided in an embodiment of this application;
[0068] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0069] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0070] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0071] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0072] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once detected," or "in response to detection."
[0073] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0074] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0075] Based on the problems in related technologies, this application provides a crack identification method that can be applied to electronic devices, including: mobile phones, tablets, wearable devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not limit the specific type of electronic device. Figure 1 A schematic diagram illustrating the implementation process of a crack identification method provided for the purposes of this application is shown below. Figure 1 As shown, the crack identification method includes:
[0076] Step S101: Obtain an inspection image, wherein the inspection image includes a target object containing cracks.
[0077] In this embodiment of the application, the inspection image refers to a two-dimensional image containing the target object (a structure with cracks) obtained by taking pictures of engineering structures such as large-span steel structures using specific inspection equipment (such as drones, inspection robots, etc.). The target object can be a large-span steel structure.
[0078] In this embodiment, appropriate inspection equipment can be selected based on the actual engineering scenario and requirements. For example, for large-span steel structures at high altitudes, a drone equipped with a high-definition camera can be used for imaging; for structures in complex environments, an inspection robot carrying a camera can be used for image acquisition. When capturing inspection images, it is necessary to set the camera parameters appropriately, such as resolution, focal length, and exposure time, to ensure that the acquired images are clear, complete, and accurately reflect the actual situation of the target object. After capturing the images, they are promptly stored in the device's storage medium and transmitted to subsequent electronic devices (such as computer servers) via wired or wireless means for further analysis and processing.
[0079] Step S102: Determine the initial segmentation mask based on the inspection image.
[0080] In this embodiment of the application, in image processing, a segmentation mask is a binary image used to identify different regions or objects in an image. The initial segmentation mask is obtained by performing preliminary segmentation on the inspection image using a specific segmentation model (such as the unsupervised zero-shot segmentation model DiffSeg). It can roughly distinguish between target object regions and background regions in the image that may contain cracks, providing preliminary location information for subsequent more accurate crack identification.
[0081] Step S103: Input the initial segmentation mask into the symmetric coding structure model based on the attention mechanism to obtain the crack recognition result.
[0082] In this embodiment, the attention-based symmetric encoding structure model is a specially designed deep learning model for crack recognition. It employs a symmetric encoder-decoder structure, focusing on the fusion of feature maps of different sizes. The model uses an attention-based mechanism to enhance feature fusion, thereby improving the accuracy of crack recognition. The encoding structure extracts feature information from the image, while the decoding structure performs image reconstruction or classification based on the encoded features to achieve accurate crack recognition.
[0083] In this embodiment, the initial segmentation mask obtained through the above steps (actually preliminary localization information of the cracked target object region in the inspection image) is used as input to a symmetric coding structure model based on an attention mechanism. In the model, the coding structure first extracts features from the input initial segmentation mask (which can be considered as image information of the target object region), obtaining feature maps of different sizes. Then, an attention mechanism is used to fuse the feature maps of different sizes. The attention mechanism calculates the mean and variance of each feature map, and then calculates the attention weights. These attention weights are multiplied by the corresponding elements of the deconvolutioned feature maps to improve the feature fusion effect, enabling the model to better focus on crack-related feature information. After feature fusion, the decoding structure performs image reconstruction or classification based on the fused feature information, ultimately outputting the crack recognition result. This result can accurately identify the specific location and shape of the cracked target object in the inspection image, achieving high-precision crack recognition.
[0084] This application provides a crack recognition method that acquires an inspection image, which includes a target object containing cracks; determines an initial segmentation mask based on the inspection image; and inputs the initial segmentation mask into a symmetric coding structure model based on an attention mechanism to obtain a crack recognition result. By using a symmetric coding structure model based on an attention mechanism, the accuracy of crack recognition can be improved.
[0085] In some embodiments, the attention-based crack recognition model includes an encoder module and a decoder module. The encoder module is used to extract features from the input initial segmentation mask, generate feature maps of different sizes, and input them into the decoder module. The decoder module is used to fuse the feature maps of different sizes based on the attention mechanism and output the crack recognition result based on the fused features.
[0086] Figure 2 A schematic diagram of the structure of an attention-based crack recognition model provided in an embodiment of this application is shown below. Figure 2As shown, the input shape is [B,3,512,512], where B represents the batch size, 3 represents the number of channels in the input image (usually an RGB image), and 512x512 is the spatial dimension of the image. The encoder module obtains image features of different spatial dimensions through downsampling and inputs these features into the decoder module. The decoder module restores the spatial resolution through upsampling and fuses the feature maps of different sizes based on an attention mechanism, outputting the crack recognition result based on the fused features.
[0087] The first arrow's processing steps include: a first convolutional layer, a second convolutional layer, and max pooling. The first convolutional layer uses a 3x3 kernel with padding of 1 and a stride of 1. Batch normalization is performed on the output after convolution to accelerate training and improve model stability. The Mish activation function is applied; Mish is a smooth, non-monotonic activation function that helps improve model performance. The second convolutional layer includes: convolution, batch normalization (BN), and the Mish activation function. The convolutional operation also uses a 3x3 kernel with padding of 1 and a stride of 1. This step further extracts features, keeping the spatial dimensions of the output feature map the same as the input. Batch normalization is performed again, and finally, the Mish activation function is applied again. Max pooling uses a 2x2 max pooling window with a stride of 2. Max pooling selects the largest value in each 2x2 window as the output, thereby reducing the spatial dimensions of the feature map (width and height are halved) while retaining important feature information. The second arrow represents the processing of the input to the improved attention-based module. The third arrow represents the processing of the input to the feature map. The transposed convolution (deconvolution) is used for upsampling, expanding the spatial size of the feature map. The transposed convolution has a 2×2 kernel size, and stride = 2 indicates that the output size is twice the input size. The output of the transposed convolution is then normalized, and the Mish activation function (Mish(x) = x*tanh(softplus(x))) is applied to provide a smooth non-linear transformation. The output feature map is then processed using the attention-based mechanism, followed by ordinary convolution. The fourth arrow represents the processing of the feature map through convolution and then processed using the Sigmoid activation function.
[0088] The processing of the first arrow can be represented by the following formulas: Conv 3×3(padding=1,stride=1)+BN+Mish(); Conv 3×3(padding=1,stride=1)+BN+Mish(); MaxPool 2×2(stride=2);
[0089] The processing of the second arrow can be represented as: Improved SimAM;
[0090] The processing of the third arrow can be represented as: ConvTranspose 2×2(stride=2)+BN+Mish();⊙;Conv3×3(padding=1)+BN+Mish();Conv 3×3(padding=1)+BN+Mish();
[0091] The processing of the fourth arrow can be represented as: Conv 1×1; Sigmoid(), where ⊙ represents feature fusion based on the attention mechanism.
[0092] In this embodiment of the application, the crack identification result includes a crack image. Figure 3 An example image of crack recognition provided in this application embodiment, such as... Figure 3 As shown, cracks can be accurately identified.
[0093] In some embodiments, the decoder module is used to fuse feature maps of different sizes based on an attention mechanism, including:
[0094] Step S1: Calculate the mean of all feature maps.
[0095] In this embodiment of the application, the feature map can be represented as X[B,C,H,W], where B is the number of feature maps in each batch, C is the number of feature map channels, H is the feature map height, and W is the feature map width. The average value can be expressed by the following formula:
[0096] μ = mean(X);
[0097] Where μ has dimensions [B,C,1,1].
[0098] Step S2: Calculate the variance of each feature map based on the mean.
[0099] In this embodiment of the application, the variance of each feature map can be calculated using the following formula:
[0100] σ 2 =sum(X-μ) / (H×W-1);
[0101] Where σ is [B,C,1,1].
[0102] Step S3: Calculate the attention weight for each feature map based on the mean and the variance.
[0103] In this embodiment, the attention weight Y can be represented by the following formula:
[0104] Y = sigmoid((X-μ)) 2 / λ(σ 2+β)+α); where α, β, and λ are learnable scalars, and the Y dimension is [B,C,H,W].
[0105] Step S4: Multiply the attention weight of each feature map with the corresponding element in the deconvolutioned feature map to fuse feature maps of different sizes.
[0106] The attention weight Y can be multiplied with the corresponding element of the deconvolutioned feature map to achieve the fusion of feature maps of different sizes.
[0107] In some embodiments, sample data can be acquired, image occlusion enhancement can be performed using the sample data, and the image occlusion-enhanced sample data can be used to train an attention-based symmetric coding structure model, thereby obtaining an attention-based symmetric coding structure model.
[0108] In some embodiments, step S102 can be implemented by the following steps:
[0109] Step S1021: Preprocess the inspection image to obtain a preprocessed image, wherein the preprocessed image satisfies the input of the extraction model.
[0110] In this embodiment, preprocessing refers to a series of processing operations performed on the inspection image to ensure that the image meets the input requirements of the subsequent extraction model. Preprocessing operations can improve image quality, adjust image size and format, etc., to ensure the model can correctly process the image. The extraction model is a model capable of analyzing images and generating text descriptions, typically a deep learning-based image description generation model. It can understand the content in the image and convert it into natural language text, providing a foundation for subsequent semantic analysis.
[0111] In this embodiment of the application, in order to reduce the computer's computational load and improve the accuracy of crack recognition in the model, it is necessary to preprocess the inspection images to make the inspection images into an input size that is easy for the extraction model to recognize, thus meeting the input image size requirements for the extraction model.
[0112] For example, the required input image size for the model is 512×512. Therefore, after preprocessing (image scaling and cropping), the image size is fixed at 512×512. In preprocessing, the image is first scaled based on the shortest side, directly scaling the shortest side to 512 proportionally, and the long side is scaled proportionally based on the shortest side. If the scaled long side size is less than or equal to 512n, then the image is cropped to obtain n images. Let the width and height of the original image be w and h, and the width and height of the scaled image be w' and h', then the scaling process can be expressed as: determine the scaling reference side short_side = min(w,h), and calculate the scaling ratio scale_ratio = short_side / 512 (scaled size). in This indicates rounding up to the nearest integer, ensuring that the scaled size is not smaller than the calculated value. For image cropping, assuming the longer side is w', i.e., w'≥h'=512, the 1st, 2nd…nth images are: Image[n-1:512(n-1),0:512].
[0113] Step S1022: Input the preprocessed image into the extraction model to determine the text description of the inspection image.
[0114] In this embodiment, the text description is the text information generated by the extraction model after analyzing the preprocessed inspection image, used to describe objects, scenes, and other content in the image. For example, "There is a steel structure in the image with a noticeable crack on it."
[0115] In this embodiment of the application, the extraction model can be the Bootstrapping Language-Image Pre-training (BLIP) model, which outputs a text description for each image by inputting the preprocessed image into BLIP.
[0116] Step S1023: Extract the nouns from the text description and determine the semantic segmentation result map corresponding to each noun.
[0117] In this embodiment, terms related to cracks, such as "crack" or "fissure," can be extracted from the text description. The semantic segmentation result image is a binary image used to identify regions of specific objects (represented by corresponding terms) in the image. In the semantic segmentation result image, pixels belonging to the object are marked with a specific value (e.g., 255), while background pixels are marked with another value (e.g., 0). For example, for the term "crack," the corresponding semantic segmentation result image will mark the pixels of the crack region in the image.
[0118] This application provides an embodiment that utilizes part-of-speech tagging (POS) technology from natural language processing to analyze text descriptions generated by an extraction model and identify nouns. The POS tagging algorithm determines the part of speech of each word based on its context and grammatical rules within the sentence. The extraction model then performs semantic segmentation on the preprocessed image based on each extracted noun. The model identifies and marks pixels in the image that belong to the object corresponding to that noun, generating a corresponding binary semantic segmentation result image.
[0119] Step S1024: Input each noun into the sentence embedding model to determine the semantic similarity between all nouns and preset nouns related to cracks.
[0120] In this embodiment, the sentence embedding model is a model capable of mapping words, phrases, or sentences to a high-dimensional vector space. Through this mapping, semantically similar words or sentences are closer in the vector space, thus allowing the calculation of their semantic similarity. Preset nouns are pre-defined nouns related to cracks, such as "crack" or "fissure." These nouns serve as reference standards for semantic similarity comparison with nouns extracted from the text description. Semantic similarity is an indicator that measures the degree of semantic similarity between two words or sentences. It is typically calculated using methods such as cosine similarity; a value closer to 1 indicates greater semantic similarity.
[0121] In this embodiment, the nouns extracted from the text description and pre-defined nouns related to cracks are input into a sentence embedding model. The sentence embedding model processes each input noun, mapping it to a high-dimensional vector space. Using vector calculation methods, such as cosine similarity, the similarity between the extracted noun vectors and the pre-defined noun vectors is calculated. Cosine similarity measures the degree of similarity between two vectors by calculating the cosine of the angle between them; a value closer to 1 indicates greater semantic similarity. Semantic similarity calculation can be implemented using the sentence-transformers library.
[0122] Step S1025: Determine the initial segmentation mask based on the semantic segmentation result map corresponding to the nouns whose semantic similarity is greater than the similarity threshold.
[0123] In this embodiment, the similarity threshold is a pre-set value used to determine whether the semantic similarity between two nouns is high enough. For example, the threshold is 0.45. If the calculated semantic similarity is greater than this threshold, the two nouns are considered to be semantically related.
[0124] In this embodiment, a similarity threshold can be set to filter out semantic segmentation result images corresponding to words with semantic similarity greater than the threshold. These filtered semantic segmentation result images are all related to cracks. The filtered semantic segmentation result images are merged or integrated to generate an initial segmentation mask. The merging method can be simple pixel overlay or logical operation, so that the initial segmentation mask can roughly identify the crack-related areas in the image.
[0125] In this embodiment of the application, since the above process can only roughly segment objects in actual engineering crack image segmentation experiments, it cannot perform pixel-level segmentation of cracks or fissures, and the accuracy cannot meet the detection requirements.
[0126] The method provided in this application embodiment can perform coarse segmentation of crack images, thereby enabling subsequent precise segmentation.
[0127] In some embodiments, after step S103, the method further includes:
[0128] Step S104: Determine the crack skeleton points and crack contour points based on the crack image.
[0129] In this embodiment, the crack image is an image containing crack information obtained after the preceding crack identification steps. It is typically a binarized image, where the crack region and background region are distinguished by different pixel values (e.g., 0 and 255). The crack skeleton is the centerline of the crack, and the crack skeleton points are the individual pixels that constitute this centerline. Crack skeleton points reflect the basic direction and shape of the crack and are an important basis for crack geometric feature analysis. Crack contour points are the pixels on the crack boundary; these points determine the specific range and shape of the crack in the image.
[0130] In this embodiment, an image processing skeleton extraction algorithm is used, such as the `skimage.morphology.medial_axis()` function in OpenCV (similar implementations exist in other environments). This algorithm analyzes the topological structure of the crack image to find the centerline of the crack, thereby determining the crack skeleton points and their shortest distances to the boundary. An image contour extraction algorithm is then used, such as the `cv2.findContours()` function in OpenCV. This function can detect the contours of objects in an image; for a crack image, it can extract the boundary contour points of the crack and record these points for subsequent width calculation.
[0131] Step S105: Divide each crack skeleton point into endpoints, effective bifurcation points, and ordinary points.
[0132] In this embodiment, an endpoint is a point in the crack skeleton that is connected to only one other skeleton point, typically located at the start or end of the crack. An effective bifurcation point is a point in the crack skeleton that is connected to multiple other skeleton points and is significant in crack analysis; it signifies crack branching and reflects the complexity of the crack morphology. Ordinary points are other skeleton points in the crack skeleton besides endpoints and effective bifurcation points; they constitute the main body of the crack skeleton.
[0133] In this embodiment, the number of skeleton points contained within a certain range of each skeleton point can be calculated based on topological principles. When the number of skeleton points contained within a certain range of a skeleton point is 2, the point is classified as an endpoint. Points containing more than 3 skeleton points within a certain range are initially marked as candidate fork points. Then, the candidate fork points are further filtered and merged. Within a certain range, the number of ordinary points existing at each candidate fork point is calculated, and points with valid branches are classified as valid fork points. All other skeleton points besides endpoints and valid fork points are classified as ordinary points.
[0134] Step S106: Determine the path of the main crack based on each endpoint, each effective bifurcation point, and each ordinary point.
[0135] In this embodiment, the main crack is the relatively primary and obvious crack portion in the crack system. Identifying the main crack helps to focus the analysis on the key parts of the crack, improving computational efficiency and accuracy. The path of the main crack is a route formed by connecting the various skeleton points of the main crack in a certain order, which describes the extension direction and trajectory of the main crack in the image.
[0136] In this embodiment, the NetworkX library is used to construct an undirected graph structure based on the connections between endpoints, valid branch points, and ordinary points as nodes. The path of the main crack is determined through this undirected graph structure.
[0137] Step S107: Determine the normal vector direction of the crack skeleton points of the main crack based on the path of each main crack, and determine the width of each main crack based on the normal vector direction and the crack contour points of each main crack.
[0138] In this embodiment, the normal vector direction is a direction vector perpendicular to the tangent direction of the crack at each skeleton point of the main crack. The normal vector direction is used to determine the direction perpendicular to the crack direction at each skeleton point, in order to measure the crack width. The width of the main crack is the distance between the two contour points on either side of the crack, measured along the normal vector direction at various locations along the main crack. It reflects the crack thickness at different locations.
[0139] In this embodiment, Principal Component Analysis (PCA) can be used to analyze the main crack skeleton points and calculate the normal vector direction at each skeleton point. PCA can identify the main direction of data change, thereby determining the normal vector perpendicular to the crack direction. Along the calculated normal vector direction, the corresponding two contour points on either side of each main crack skeleton point are found in the crack contour points. The Euclidean distance between these two contour points is calculated; this distance represents the width of each main crack at the corresponding skeleton point.
[0140] The method provided in this application embodiment can accurately calculate the width of each main crack.
[0141] In some embodiments, step S105 can be implemented by the following steps:
[0142] Step S1051: Determine the number of crack skeleton points within a first preset range from each crack skeleton point.
[0143] In this embodiment, the first preset range is a pre-defined specific region centered on each crack skeleton point. Other crack skeleton points within this range are included in the statistics to analyze the neighborhood features of the current skeleton point. Its specific size can be set according to factors such as image resolution and crack features.
[0144] In this embodiment, each crack skeleton point in the image can be traversed, and a first preset range can be determined with that point as the center (for example, a circular range can be determined by setting a radius value with that point as the center, or a rectangular area can be set, etc.). Then, the number of other crack skeleton points within this first preset range can be counted.
[0145] Step S1052: Determine endpoints, candidate bifurcation points, and ordinary points based on the number of crack skeleton points. The number of crack skeleton points corresponding to endpoints is 2, the number of crack skeleton points corresponding to candidate bifurcation points is greater than 3, and the number of crack skeleton points corresponding to ordinary points is 3.
[0146] Figure 4 A schematic diagram illustrating the number of crack skeleton points provided in an embodiment of this application, as shown below. Figure 4 As shown, if there are two neighboring skeleton points, the crack skeleton point is designated as an endpoint. If there are more than three neighboring skeleton points, the crack skeleton point is marked as a candidate bifurcation point. If there are three neighboring skeleton points, the crack skeleton point is classified as a regular point. This classification method is based on the topological characteristics of the crack skeleton, and different numbers of neighboring skeleton points reflect the different roles of the point in the crack structure.
[0147] Step S1053: Determine the number of ordinary points within a second preset range from each candidate bifurcation point.
[0148] In this embodiment, the second preset range is a pre-defined specific area centered on the candidate bifurcation point. This range is used to count the number of ordinary points around the candidate bifurcation point to determine whether the candidate bifurcation point is a valid bifurcation point.
[0149] In this embodiment of the application, for each crack skeleton point marked as a candidate bifurcation point, a second preset range is determined with that point as the center. Then, the number of ordinary points within this second preset range is counted.
[0150] Step S1054: If the number of ordinary points within the second preset range from the target candidate bifurcation point is greater than the number threshold, the target candidate bifurcation point is determined as a valid bifurcation point.
[0151] In this embodiment, the quantity threshold is a preset value used to determine whether a candidate bifurcation point is a valid bifurcation point. When the number of ordinary points within a second preset range from the target candidate bifurcation point is greater than the threshold, the target candidate bifurcation point is determined to be a valid bifurcation point. The quantity threshold can be adjusted according to factors such as the actual complexity of the crack and image quality.
[0152] In this embodiment, a quantity threshold is set, and the number of ordinary points within a second preset range of each candidate bifurcation point is compared with this threshold. If the number of ordinary points within the second preset range of a target candidate bifurcation point is greater than the quantity threshold, it indicates that there are enough ordinary points around the candidate bifurcation point, which conforms to the characteristics of actual crack bifurcation. Therefore, the target candidate bifurcation point is determined as a valid bifurcation point. In this way, some candidate bifurcation points caused by image noise or misjudgment can be filtered out, improving the accuracy of crack analysis.
[0153] The method provided in this application embodiment can effectively identify endpoints, valid bifurcation points, and ordinary points, thereby improving the accuracy of subsequent width calculation.
[0154] In some embodiments, step S107 can be implemented through the following steps:
[0155] Step S1071: Determine all ordinary points within a third preset range from the effective bifurcation point, and use all ordinary points within a third preset range from the effective bifurcation point as candidate starting points for path construction.
[0156] In this embodiment, the third preset range is a specific area range pre-defined with the effective bifurcation point or candidate starting point as the center. It is used to count the surrounding points or calculate relevant parameters. Its size can be set according to the actual situation such as the resolution of the crack image and crack features. All ordinary points within the third preset range of the candidate starting point from the effective bifurcation point are used as potential starting positions for constructing the crack path, providing a basis for subsequent path search.
[0157] In this embodiment of the application, a third preset range can be determined with each valid branch point as the center, and all ordinary points within this range can be used as candidate starting points for path construction.
[0158] Step S1072: Calculate the number of valid bifurcation points within a third preset range from each candidate starting point.
[0159] Step S1073: Based on the number of valid bifurcation points within a third preset range from each candidate starting point, the candidate starting points are divided into a first candidate starting point and a second candidate starting point, wherein the number of the first candidate starting point is not equal to 1, and the number of the second candidate starting point is equal to 1.
[0160] In this embodiment, the number of effective bifurcation points within a third preset range from each candidate starting point can be calculated. Based on the calculation results, the candidate starting points are divided into first candidate starting points and second candidate starting points. The candidate starting point with a number of effective bifurcation points not equal to 1 within its third preset range is the first candidate starting point, which is the starting point that needs to be further tracked; the candidate starting point with a number of effective bifurcation points equal to 1 within its third preset range is the second candidate starting point, which is the short crack path segment that has already formed a complete crack path.
[0161] Step S1074: Based on the first candidate starting point, recursively search for crack skeleton points whose distance is less than a preset threshold until there are no more points to advance, and obtain the complete crack path.
[0162] In this embodiment, starting from each first candidate starting point, the next skeleton point less than a certain distance from the current starting point is recursively searched in the crack skeleton point set, including ordinary points and endpoints. This search continues along the path until no more skeleton points can be reached, and a complete crack path is recorded. After traversing all starting points, most of the path can be obtained.
[0163] Step S1075: Based on each complete crack path, the effective bifurcation points are deduplicated to obtain the deduplicated crack path.
[0164] In this embodiment of the application, since there may be repeated detection of valid branching points during the path search process, the deduplication operation can avoid repeated analysis, improve analysis efficiency and accuracy, and obtain the deduplicated crack path.
[0165] Step S1076: Traverse the remaining endpoints and recursively search for crack skeleton points whose distance is less than a preset threshold to extract the remaining crack paths.
[0166] In this embodiment, the remaining endpoints can be traversed, and starting from each endpoint, the crack skeleton points with a distance less than a preset threshold can be recursively searched until there are no more crack skeleton points to advance to, and a complete crack path is recorded. This ensures that all possible crack paths are extracted.
[0167] In this embodiment, the remaining endpoints in the skeleton point set can be traversed. Starting from each endpoint, the adjacent skeleton points are recursively searched until there are no more skeleton points to advance, thus recording a complete crack path. After traversing all remaining endpoints, the remaining path can be obtained.
[0168] Step S1077: Construct an undirected graph topology based on each endpoint, each valid bifurcation point, and each extracted crack path.
[0169] In this embodiment, the undirected graph topology is constructed using the endpoints and effective bifurcation points of the crack as nodes and the crack path as edges to describe the connection relationships and topological features between different parts of the crack.
[0170] In this embodiment, an undirected graph topology can be constructed based on each endpoint, each valid branch point, and each extracted crack path. Endpoints and valid branch points are used as nodes, and crack paths are used as edges, clarifying the connection relationships between the parts and providing a foundation for subsequent path analysis.
[0171] In this embodiment, based on the NetworkX library, an undirected graph topology is constructed by combining endpoints, effective beginning points, and all extracted crack paths for subsequent path analysis and shortest path calculation.
[0172] Step S1078: Calculate the shortest path length from the starting point to other nodes in the undirected graph topology, using the node with the smallest number as the starting point. Determine the node with the largest weight based on the shortest path length and the pre-set weight.
[0173] In this embodiment, the node with the smallest number is the node with the smallest number in the undirected graph topology, serving as the starting point for calculating the shortest path and determining the shortest path relationship between all nodes in the entire undirected graph. The weight is an attribute value set when calculating the shortest path, used to measure certain characteristics of the path, such as path length and trunk priority. Reasonable weight settings can more accurately identify trunk cracks.
[0174] In this embodiment, the node with the smallest number can be the top left endpoint, and in some embodiments, it can also be any crack skeleton point.
[0175] In this embodiment, the shortest path length from the node with the smallest number to other nodes in the undirected graph topology can be calculated using Dijkstra's algorithm or similar methods. Then, by combining pre-defined weights (such as path length, trunk priority, etc.), the node with the largest weight is determined.
[0176] Step S1079: Starting from the node with the largest weight, calculate the shortest path length between the node with the largest weight and other nodes.
[0177] In this embodiment, the node with the highest weight is the most "important" node determined by combining the shortest path length calculated from the node with the lowest number with a pre-set weight. It is usually used as the key node for further analysis of crack paths.
[0178] In this embodiment, the shortest path length from the node with the highest weight to all other nodes can be calculated using the networkx.single_source_dijkstra_path() function.
[0179] Step S1010: Determine the sum of the weights of each crack path based on the shortest path length between the node with the largest weight and other nodes.
[0180] In this embodiment, the sum of the weights of each crack path can be determined based on these shortest path lengths and pre-defined weighting rules. The sum of the weights reflects the "importance" of the crack path in the overall structure.
[0181] Step S1011: Determine the path of the main crack in the undirected graph topology based on the sum of the weights of each crack path.
[0182] In this embodiment, the main crack is the relatively major and obvious crack part in the crack system. Through the above series of analyses and calculations, the main crack determined from many crack paths can reflect the core direction and key characteristics of the crack.
[0183] In this embodiment, the sum of path weights can be compared. Crack paths with a larger sum of weights are usually identified as main cracks, which represent the main direction and key parts of the crack, and help to focus on analyzing the core features of the crack.
[0184] The method provided in this application embodiment can accurately locate crack paths and accurately identify main cracks.
[0185] In some embodiments, after step S1011, the method further includes:
[0186] Step S1012: Calculate the similarity between the path of the main crack and the preset prompt text.
[0187] In this embodiment of the application, the preset prompt text is a pre-defined text description related to the characteristics of an ideal or standard crack, which may include expected information on crack morphology, orientation, continuity, etc., and is used for comparative analysis with the actual main crack path.
[0188] In this embodiment of the application, the cosine similarity between the main analysis crack image and the prompt ("a main crack, long and thick, not a small branch") is calculated based on Contrastive Language-Image Pretraining (CLIP).
[0189] Step S1013: Determine the quality score of the main crack based on the similarity.
[0190] In this embodiment, the quality score is an evaluation score determined based on the similarity between the path of the main crack and the preset prompt text. It is used to quantify the quality of the main crack. The higher the score, the more the main crack meets the preset standard or expectation.
[0191] In this embodiment, the quality score of the main crack can be determined based on the calculated similarity through a certain mapping relationship. For example, a linear relationship between similarity and quality score can be established, where higher similarity results in a higher quality score. Alternatively, a more complex nonlinear mapping method can be used to more accurately reflect the relationship between similarity and quality.
[0192] Step S1014: If the quality score of the main crack is less than the set score threshold, adjust the pre-set weight.
[0193] In this embodiment, a scoring threshold is set as a pre-defined scoring limit value to determine whether the quality of the main crack meets the requirements. When the quality score of the main crack is less than the threshold, it indicates that the quality of the main crack is poor and corresponding measures need to be taken.
[0194] In this embodiment, when the quality score of the main crack is less than a set score threshold, it indicates that the currently determined main crack does not meet the preset standard or expectation. At this time, it is necessary to adjust the preset weights. The reasons for the low quality score are analyzed to determine which factors cause the main crack path to mismatch with the preset prompt text. For example, the path length weight might be set unreasonably, causing shorter crack paths to be incorrectly identified as main cracks, while longer crack paths that better match the preset prompt text are ignored. Based on the analysis results, the weights are adjusted accordingly. If the path length factor is found to have a significant impact, the path length weight can be appropriately increased; if the problem lies in the connection relationship factor, the weight related to the connection relationship is adjusted. Through continuous adjustment and optimization of the weights, the subsequently determined main cracks better meet the preset standard and actual needs.
[0195] The method provided in this application adjusts the pre-set weights based on the comparison results between the quality score and the set score threshold. This can accurately identify the direction that needs to be optimized. After the weights are adjusted, the process of calculating similarity and determining the quality score can be repeated. Through multiple iterations of optimization, the quality score of the main crack can be gradually improved, making it more in line with the requirements of the preset prompt text.
[0196] In some embodiments, step S1075, which involves removing duplicates from effective bifurcation points based on each complete crack path to obtain a deduplicated crack path, can be achieved through the following steps:
[0197] Step S751: Based on the clustering algorithm, the effective branching points in each complete crack path are divided into different classes.
[0198] In this embodiment, the clustering algorithm is an unsupervised learning method that groups data objects into multiple classes or clusters, resulting in high similarity between objects within the same cluster and significant differences between objects in different clusters. The clustering algorithm can be a density-based noisy spatial clustering application algorithm.
[0199] Step S752: Determine the class to which the starting point of each crack path belongs.
[0200] In this embodiment of the application, after classifying the effective bifurcation points by clustering algorithm, the category to which the starting point of each crack path belongs is used to determine the correlation between crack paths.
[0201] In this embodiment, for each crack path, the coordinate information of its starting point is obtained. Based on the classification results of effective bifurcation points obtained by the clustering algorithm, the distance between the starting point and each cluster center is calculated, and the starting point is assigned to the nearest cluster, thereby determining the class to which the starting point of each crack path belongs.
[0202] Step S753: If the starting points of multiple crack paths belong to the same category and the distance between their ending points is less than a threshold, then the multiple crack paths are determined to be duplicate paths.
[0203] In this embodiment, the spatial distance between the endpoints of two crack paths is obtained by calculating the Euclidean distance between the endpoint coordinates, and is used to determine whether the two crack paths may be duplicate paths. Duplicate paths are multiple crack paths whose starting points belong to the same category and whose endpoint distance is less than a threshold. These paths are determined to be duplicate paths, meaning that they have a high degree of similarity and overlap in space.
[0204] In this embodiment of the application, if multiple paths originate from the same category, the Euclidean distance between their endpoints is calculated. If the distance is less than a certain value, the paths are considered duplicates. In this embodiment, the calculation requires pairing start points to start points and end points to end points.
[0205] Step S754: Calculate the quality score for each repeated path.
[0206] In this embodiment, the quality score is an indicator used to measure the quality of the crack path. It may be calculated based on various factors such as the length, continuity, integrity, and degree of conformity with the preset standard of the crack path. The higher the score, the better the path quality.
[0207] In this embodiment, for repeated paths, the number of valid coordinate points in each path is calculated to obtain the path length index. At the same time, the Euclidean straight-line distance between the start and end points of the path is calculated and the path length (path length is a variant of Chebyshev distance, which is obtained by traversing all skeleton points in each crack path, calculating the distance between adjacent skeleton points and accumulating them to obtain the length of each crack path) to obtain the geometric straightness index (the closer the ratio is to 1, the straighter the path). Finally, the two indices are combined into a comprehensive quality score by multiplying and weighting: quality score = path length × (1 + straightness coefficient).
[0208] Step S755: Retain crack paths with a mass fraction greater than the mass fraction threshold to obtain deduplicated crack paths.
[0209] In this embodiment, a pre-set threshold value for the quality score is used to determine whether the quality of the crack path meets the requirements. When the quality score of the crack path is greater than the threshold value, the path is retained; otherwise, it is discarded.
[0210] The method provided in this application can accurately identify duplicate paths, thereby reasonably retaining high-quality paths. By removing duplicate paths, the amount of subsequent computation can be reduced.
[0211] Based on the foregoing embodiments, this application further provides a crack identification method. Figure 5 This is a flowchart illustrating a crack identification method provided in an embodiment of this application, as shown below. Figure 5 As shown, it includes:
[0212] Step S501: Obtain a two-dimensional crack image.
[0213] Step S502: Preprocessing of inspection images.
[0214] Step S503: Extract images of cracked components based on Diffseg.
[0215] Step S504: Crack identification is performed based on the identification model.
[0216] Step S505: Calculate the crack width.
[0217] Step S505: Output the crack width.
[0218] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0219] According to the foregoing embodiments, this application provides a crack identification device. The various modules and units included in the device can be implemented by a processor in a computer device; of course, they can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0220] This application provides a crack identification device. Figure 6 This is a schematic diagram of the structure of a crack identification device provided in an embodiment of this application, as shown below. Figure 6 As shown, the crack detection device 600 includes:
[0221] Acquisition module 601 is used to acquire inspection images, wherein the inspection images include target objects containing cracks;
[0222] The first determining module 602 is used to determine an initial segmentation mask based on the inspection image;
[0223] The recognition module 603 is used to input the initial segmentation mask into a symmetric coding structure model based on an attention mechanism to obtain crack recognition results.
[0224] In some embodiments, the attention-based crack recognition model includes an encoder module and a decoder module. The encoder module is used to extract features from the input initial segmentation mask, generate feature maps of different sizes, and input them into the decoder module. The decoder module is used to fuse the feature maps of different sizes based on the attention mechanism and output the crack recognition result based on the fused features.
[0225] In some embodiments, the decoder module is used to fuse feature maps of different sizes based on an attention mechanism, including:
[0226] Calculate the mean of all feature maps;
[0227] The variance of each feature map is calculated based on the mean.
[0228] The attention weight for each feature map is calculated based on the mean and the variance;
[0229] The attention weight of each feature map is multiplied by the corresponding element in the deconvolutioned feature map to fuse feature maps of different sizes.
[0230] In some embodiments, the first determining module includes:
[0231] A preprocessing unit is used to preprocess the inspection image to obtain a preprocessed image, wherein the preprocessed image satisfies the input of the extraction model;
[0232] The first extraction unit is used to input the preprocessed image into the extraction model to determine the text description of the inspection image;
[0233] The second extraction unit is used to extract nouns from the text description and determine the semantic segmentation result image corresponding to each noun;
[0234] The first determining unit is used to input each noun into the sentence embedding model to determine the semantic similarity between all nouns and preset nouns related to cracks;
[0235] The second determining unit is used to determine the initial segmentation mask based on the semantic segmentation result map corresponding to nouns whose semantic similarity is greater than the similarity threshold.
[0236] In some embodiments, the crack identification result includes: a crack image, and the crack identification device 600 includes:
[0237] The second determining module is used to determine the crack skeleton points and crack contour points based on the crack image;
[0238] The classification module is used to divide each crack skeleton point into endpoints, effective bifurcation points, and ordinary points;
[0239] The third determination module is used to determine the path of the main crack based on each endpoint, each effective bifurcation point, and each ordinary point;
[0240] The fourth determining module is used to determine the normal vector direction of the crack skeleton points of the main crack based on the path of each main crack, and to determine the width of each main crack based on the normal vector direction and the crack contour points of each main crack.
[0241] In some embodiments, the classification module includes:
[0242] The third determining unit is used to determine the number of crack skeleton points within a first preset range from each crack skeleton point;
[0243] The fourth determining unit is used to determine endpoints, candidate bifurcation points, and ordinary points based on the number of crack skeleton points, wherein the number of crack skeleton points corresponding to the endpoints is 2, the number of crack skeleton points corresponding to the candidate bifurcation points is greater than 3, and the number of crack skeleton points corresponding to the ordinary points is 3.
[0244] The fifth determining unit is used to determine the number of ordinary points within a second preset range from each candidate bifurcation point;
[0245] The sixth determining unit is used to determine the target candidate bifurcation point as a valid bifurcation point when the number of ordinary points within a second preset range from the target candidate bifurcation point is greater than a number threshold.
[0246] In some embodiments, the third determining module includes:
[0247] The seventh determining unit is used to determine all ordinary points within a third preset range from the effective bifurcation point, and to use all ordinary points within a third preset range from the effective bifurcation point as candidate starting points for path construction.
[0248] The first calculation unit is used to calculate the number of valid bifurcation points within a third preset range from each candidate starting point;
[0249] The classification unit is used to divide the candidate starting point into a first candidate starting point and a second candidate starting point based on the number of valid bifurcation points within a third preset range from each candidate starting point, wherein the number of the first candidate starting point is not equal to 1, and the number of the second candidate starting point is equal to 1.
[0250] The first recursive unit is used to recursively search for crack skeleton points whose distance is less than a preset threshold based on the first candidate starting point, until there are no more points to advance, and obtain the complete crack path.
[0251] The deduplication unit is used to remove duplicates from effective bifurcation points based on each complete crack path, thus obtaining the deduplicated crack path.
[0252] The traversal unit is used to traverse the remaining endpoints and recursively search for crack skeleton points whose distance is less than a preset threshold in order to extract the remaining crack paths.
[0253] Component elements are used to construct an undirected graph topology based on each endpoint, each effective bifurcation point, and each extracted crack path;
[0254] The eighth determining unit is used to calculate the shortest path length from the starting point to other nodes in the undirected graph topology, starting from the node with the smallest number, and to determine the node with the largest weight based on the shortest path length and the pre-set weight.
[0255] The second calculation unit is used to calculate the shortest path length between the node with the largest weight and other nodes, starting from the node with the largest weight.
[0256] The ninth determining unit is used to determine the sum of the weights of each crack path based on the shortest path length between the node with the largest weight and other nodes;
[0257] The tenth determining unit is used to determine the path of the main crack in the undirected graph topology based on the sum of the weights of each crack path.
[0258] In some embodiments, the third determining module includes:
[0259] The third calculation unit is used to calculate the similarity between the path of the main crack and the preset prompt text;
[0260] A quality scoring determination unit is used to determine the quality score of the main crack based on the similarity.
[0261] An adjustment unit is used to adjust a pre-set weight when the quality score of the main crack is less than a set score threshold.
[0262] In some embodiments, the step of removing duplicates from effective bifurcation points based on each complete crack path to obtain a deduplicated crack path includes:
[0263] Based on clustering algorithms, the effective branching points in each complete crack path are divided into different classes;
[0264] Determine the class to which the starting point of each crack path belongs;
[0265] If the starting points of multiple crack paths belong to the same category and the distance between their ending points is less than a threshold, then the multiple crack paths are determined to be duplicate paths.
[0266] Calculate the quality score for each duplicate path;
[0267] Crack paths with a mass fraction greater than the mass fraction threshold are retained to obtain deduplicated crack paths.
[0268] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0269] In addition, the crack recognition device described above can be a software unit, a hardware unit, or a combination of both. It can also be integrated into electronic devices as an independent component or exist as an independent terminal device.
[0270] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0271] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 3 in this embodiment may include: at least one processor 30 ( Figure 7 Only one processor 30, memory 31, and computer program 32 stored in memory 31 and executable on at least one processor 30 are shown. When the processor 30 executes the computer program 32, it implements the steps in any of the above method embodiments, or the processor 30 executes the computer program 32 to implement the functions of each module / unit in the above device or system embodiments.
[0272] For example, computer program 32 may be divided into one or more modules / units, one or more of which are stored in memory 31 and executed by processor 30 to complete this application. One or more modules / units may be a series of computer program 32 instruction segments capable of performing a specific function, which describe the execution process of computer program 32 in electronic device 3.
[0273] This application also provides a computer-readable storage medium storing a computer program 32, which, when executed by a processor 30, implements the steps described in the above-described method embodiments.
[0274] This application provides a computer program product that, when run on an electronic device, enables the electronic device to perform the steps described in the various method embodiments above.
[0275] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program 32 instructing related hardware. The computer program 32 can be stored in a computer-readable storage medium, and when executed by the processor 30, it can implement the steps of the various method embodiments described above. The computer program 32 includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium can include at least: any entity or device capable of carrying computer program code to a terminal, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0276] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0277] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0278] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0279] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0280] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A crack identification method, characterized in that, include: Acquire inspection images, wherein the inspection images include target objects containing cracks; Determining an initial segmentation mask based on the inspection image includes: preprocessing the inspection image to obtain a preprocessed image, wherein the preprocessed image satisfies the input of an extraction model; inputting the preprocessed image into the extraction model to determine the text description of the inspection image; extracting nouns from the text description and determining the semantic segmentation result map corresponding to each noun; inputting each noun into a sentence embedding model to determine the semantic similarity between all nouns and preset nouns related to cracks; and determining the initial segmentation mask based on the semantic segmentation result maps corresponding to nouns with semantic similarity greater than a similarity threshold. The initial segmentation mask is input into a symmetric coding structure model based on an attention mechanism to obtain crack recognition results. The symmetric coding structure model based on an attention mechanism includes an encoder module and a decoder module. The encoder module extracts features from the input initial segmentation mask, generating feature maps of different sizes, which are then input into the decoder module. The decoder module fuses the feature maps of different sizes based on an attention mechanism and outputs crack recognition results based on the fused features. The fusing of feature maps of different sizes based on an attention mechanism includes: calculating the mean of all feature maps; calculating the variance of each feature map based on the mean; and calculating the attention of each feature map based on the mean and the variance. Weights; the attention weight of each feature map is multiplied by the corresponding element in the deconvolutioned feature map to fuse feature maps of different sizes. The crack recognition result includes a crack image. The method further includes: determining crack skeleton points and crack contour points based on the crack image; dividing each crack skeleton point into endpoints, effective bifurcation points, and ordinary points; determining the path of the main crack based on each endpoint, effective bifurcation point, and ordinary point; determining the normal vector direction of the crack skeleton points of the main crack based on the path of each main crack; determining the width of each main crack based on the normal vector direction and the crack contour points of each main crack. The path construction includes: determining all ordinary points within a third preset range from the effective bifurcation point, and using all ordinary points within the third preset range as candidate starting points for path construction; calculating the number of effective bifurcation points within the third preset range from each candidate starting point; dividing the candidate starting points into first candidate starting points and second candidate starting points based on the number of effective bifurcation points within the third preset range from each candidate starting point, wherein the number corresponding to the first candidate starting point is not equal to 1, and the number corresponding to the second candidate starting point is equal to 1; recursively searching for crack skeleton points with a distance less than a preset threshold based on the first candidate starting point until no further points can be reached, thus obtaining a complete crack path; and deduplicating effective bifurcation points based on each complete crack path. The process involves: obtaining deduplicated crack paths; traversing the remaining endpoints and recursively searching for crack skeleton points with distances less than a preset threshold to extract the remaining crack paths; constructing an undirected graph topology based on each endpoint, each valid branch point, and each extracted crack path; calculating the shortest path length from the starting point to other nodes in the undirected graph topology using the node with the smallest number as the starting point, and determining the node with the largest weight based on the shortest path length and a preset weight; calculating the shortest path length between the node with the largest weight and other nodes; determining the sum of the weights of each crack path based on the shortest path length between the node with the largest weight and other nodes; and determining the path of the main crack in the undirected graph topology based on the sum of the weights of each crack path.
2. The method according to claim 1, characterized in that, The process of dividing each crack skeleton point into endpoints, effective bifurcation points, and ordinary points includes: Determine the number of crack skeleton points within a first preset range from each crack skeleton point; Endpoints, candidate bifurcation points, and ordinary points are determined based on the number of crack skeleton points. The number of crack skeleton points corresponding to an endpoint is 2, the number of crack skeleton points corresponding to a candidate bifurcation point is greater than 3, and the number of crack skeleton points corresponding to an ordinary point is 3. Determine the number of ordinary points within a second preset range from each candidate bifurcation point; If the number of ordinary points within a second preset range from the target candidate bifurcation point is greater than the number threshold, the target candidate bifurcation point is determined as a valid bifurcation point.
3. The method according to claim 1, characterized in that, The method further includes: Calculate the similarity between the path of the main crack and the preset prompt text; The quality score of the main crack is determined based on the similarity. If the quality score of the main crack is less than the set score threshold, the pre-set weight is adjusted.
4. The method according to claim 1, characterized in that, The process of removing duplicates from effective bifurcation points based on each complete crack path to obtain the deduplicated crack path includes: Based on clustering algorithms, the effective branching points in each complete crack path are divided into different classes; Determine the class to which the starting point of each crack path belongs; If the starting points of multiple crack paths belong to the same category and the distance between their ending points is less than a threshold, then the multiple crack paths are determined to be duplicate paths. Calculate the quality score for each duplicate path; Crack paths with a mass fraction greater than the mass fraction threshold are retained to obtain deduplicated crack paths.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Sleeper crack identification method and device
CN118799245A
System and method for attention-based surface crack segmentation
US20220222914A1