A method for intelligent classification and identification of three-dimensional hole defects of die castings based on machine learning

By using machine learning methods to automatically classify and quantify the internal pores of die castings, the problem of low efficiency in identifying and statistically analyzing pore defects in die castings in existing technologies has been solved, thereby improving casting performance and optimizing the process.

CN122391713APending Publication Date: 2026-07-14BEIJING JIAOTONG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING JIAOTONG UNIV
Filing Date
2026-04-16
Publication Date
2026-07-14

Smart Images

  • Figure CN122391713A_ABST
    Figure CN122391713A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on machine learning's die casting three-dimensional hole defect intelligent classification identification statistics method, it is related to casting internal defect nondestructive testing and machine learning technical field.For prior art can only statistics die casting total porosity, cannot distinguish pore, shrinkage cavity, gas shrinkage cavity and reconstruction noise point, artificial classification efficiency is low, strong subjectivity, the problem of insufficient simple geometric parameter classification accuracy, the application is separated from the STL model of industrial CT three-dimensional reconstruction by the connected domain algorithm based on KD tree space index and adjacency relation analysis, extracts four key three-dimensional geometric features of spherical degree, convexity, volume surface area ratio and surface normal vector variance, realizes the high-precision classification of four types of defects using the pre-trained random forest classification model, finally statistics output the number, volume, volume fraction and three-dimensional space distribution of each type of defect, which can provide reliable classification quantitative data support for the precise optimization of die casting process parameters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of internal defect detection in castings and machine learning, specifically to a machine learning-based intelligent classification and statistical method for identifying three-dimensional hole defects in die castings. Background Technology

[0002] Die casting, as a highly efficient metal forming process, is widely used in the automotive, aerospace, and electronics industries. During die casting, due to the rapid filling speed and short solidification time of the molten metal, defects such as porosity, shrinkage cavities, and gas shrinkage cavities are easily generated inside the casting, reducing its mechanical properties and reliability. Therefore, it is necessary to optimize the die casting process to reduce the content of these defects. However, because the formation mechanisms of porosity, shrinkage cavities, and gas shrinkage cavities are fundamentally different, process optimization cannot simultaneously reduce the content of all three types of defects. Optimizing a single defect can exacerbate other defects. To address this irreconcilable process conflict, it is necessary to find a "process balance point" that places the content of each type of defect within a suitable range, maximizing the overall performance of the casting. Finding the correct "process balance point" requires clarifying the quantitative relationship between the content of each type of defect and process parameters, which necessitates knowing the specific content of each type of defect in the casting. Therefore, accurately identifying the specific content of each type of defect in the casting is crucial for precise optimization of the die casting process and further improvement of casting performance.

[0003] Currently, industrial CT scanning is the most widely used non-destructive testing technology for internal defects in castings. Through multi-angle projection reconstruction, industrial CT scanning can obtain the three-dimensional spatial distribution and geometric morphology of internal defects in castings. Using 3D reconstruction software, CT data can be reconstructed to generate 3D models of pore defects. However, most existing technologies only provide overall porosity statistics, without individually analyzing each type of pore defect. Classifying and statistically analyzing the thousands or even tens of thousands of reconstructed 3D pore models manually is extremely inefficient, unable to achieve large-scale, standardized quantitative statistics, and difficult to support quantitative research on the relationship between pore defect content and process parameters.

[0004] In recent years, machine learning-based methods for detecting casting defects have developed rapidly. For example, deep learning has enabled the automatic identification of defects such as porosity, bubbles, inclusions, and looseness in two-dimensional DR images. However, these methods, based on two-dimensional projection images, can only obtain the planar contour information of defects and cannot obtain the three-dimensional geometric shape and spatial distribution characteristics of defects. They are difficult to distinguish between gas shrinkage cavities and shrinkage cavities with similar shapes in die castings, and cannot accurately calculate the volume and volume fraction of defects, thus failing to provide effective quantitative data support for die casting process optimization.

[0005] In addition, some studies have attempted to classify pores using simple three-dimensional geometric parameters such as volume and sphericity. However, these single parameters are difficult to effectively characterize the morphological differences of different types of pores, especially in distinguishing between small pores and reconstructed noise, and between air-contraction pores and shrinkage pores, resulting in low classification accuracy. Summary of the Invention

[0006] To address the shortcomings of existing technologies, the present invention aims to provide a machine learning-based method for identifying and classifying three-dimensional pore defects in die castings. This method can automatically identify and separate independent pores inside die castings, extract their three-dimensional geometric features, and use a pre-trained random forest classification model to achieve high-precision classification of porosity, shrinkage cavities, gas shrinkage cavities, and noise. It also outputs quantitative information such as the number, volume, volume fraction, and spatial distribution of various types of pores, providing data support for the precise optimization of the die casting process.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: A machine learning-based intelligent classification and identification statistical method for three-dimensional void defects in die castings includes the following steps: Step S1: Data acquisition, acquire a three-dimensional reconstruction model of the internal hole defects of the die casting, the three-dimensional reconstruction model is in STL format and only contains the surface geometry information of the hole; Step S2: Connectivity analysis, perform connectivity analysis on the STL format 3D reconstruction model to identify and separate each independent hole; Step S3: Feature extraction. For each independent hole identified in step S2, calculate its three-dimensional geometric features. The three-dimensional geometric features include at least sphericity, convexity, volume-to-surface area ratio, and surface normal variance. Step S4: Model classification. The sphericity, convexity, volume-to-surface-area ratio, and surface normal variance calculated in step S3 are input into a pre-trained random forest classification model. The random forest classification model outputs the category of the hole, which includes vents, constriction pores, air-constriction pores, and noise. Step S5: Output the results. Statistically analyze and output the classification results of all independent holes in the 3D reconstruction model. The classification results include the number of holes in each category, the volume of holes in each category, the porosity, the volume fraction of holes in each category, and the spatial distribution information of holes in each category.

[0008] Furthermore, the connected component analysis in step S2 further includes: Sub-step S2.1: Vertex deduplication. Use the KD tree to perform spatial clustering on the vertices in the STL model, merge vertices with a spatial distance less than a preset threshold into the same vertex, and establish a unique vertex index. Sub-step S2.2: Construct adjacency relationships. Based on the unique vertex index, standardize the identification of each edge of each triangular facet, establish the adjacency relationship from edge to face, and then construct the adjacency graph between triangular faces. Sub-step S2.3: Identify connected components, and use a breadth-first search strategy to traverse the adjacency graph to group interconnected triangular faces into the same connected component. Each connected component represents an independent hole.

[0009] Furthermore, in step S3, the formula for calculating sphericity is:

[0010] Where S is the sphericity of the hole, and A S Let A be the surface area of ​​a standard sphere with the same volume as the hole, and let A be the actual surface area of ​​the hole. The formula for calculating the convexity is:

[0011] Where C is the convexity of the hole, and V is the volume of the hole. h Let be the volume of the convex hull of the hole; The volume-to-surface-area ratio is the ratio of the pore volume to its surface area; The variance of the surface normal vector is calculated as follows: obtain the normal vectors of all triangular facets on the surface of the hole, calculate the overall variance of the components of all normal vectors in the three coordinate axes, and calculate the Euclidean norm of the overall variance vector.

[0012] Furthermore, the hyperparameters of the random forest classification model in step S4 are set as follows: the number of decision trees is 200, the maximum depth of the decision trees is 20, the minimum number of samples required for node splitting is 2, and the minimum number of samples for leaf nodes is 1.

[0013] Furthermore, the random forest classification model in step S4 is pre-trained using the following method: Step T1: Construct a training dataset and obtain multiple STL models of holes with pre-labeled categories, including pores, constrictions, air-contraction pores, and noise. Step T2: Training feature extraction. For each hole in the training dataset, calculate its sphericity, convexity, volume-to-surface area ratio, and surface normal vector variance to form a training feature set. Step T3: Model training. The training feature set is used as input, and the corresponding hole category is used as label to train the random forest model to obtain the random forest classification model.

[0014] Furthermore, in step S5, the porosity is obtained by calculating the ratio of the total volume of all pores to the total volume of the die casting; the volume fraction of a certain type of pore is obtained by calculating the ratio of the total volume of a certain type of pore to the total volume of the die casting.

[0015] Furthermore, step S5 also includes: generating a three-dimensional visualization image based on the spatial coordinates of each hole and its category, and marking pores, shrinkage pores, and air shrinkage pores in the three-dimensional visualization image using different colors.

[0016] In summary, the technical solutions conceived by this invention have the following beneficial effects compared with the prior art: This invention enables automated identification and classification of internal hole defects in die-cast parts, replacing the traditional manual visual judgment method and significantly improving detection efficiency and the objectivity and consistency of results.

[0017] This invention separates independent cavities from the 3D reconstruction model of casting cavities through connected component analysis, extracts four geometric features: sphericity, convexity, volume-to-surface-area ratio, and normal vector variance, and uses a random forest model to classify cavities into porosity, shrinkage cavities, gas shrinkage cavities, and noise points, and outputs the number, volume fraction, and 3D visualization distribution of each type of cavity, providing quantitative data support for die casting process optimization. Attached Figure Description

[0018] Figure 1 This is an overall flowchart of a machine learning-based intelligent classification and identification statistical method for three-dimensional hole defects in die castings provided in an embodiment of the present invention; Figure 2 This is a flowchart of the hole connectivity identification process provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of the random forest classification model provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the CART decision tree structure provided in an embodiment of the present invention; Figure 5 These are typical three-dimensional morphological diagrams of various types of holes provided in embodiments of the present invention, wherein (a) is a pore, (b) is a shrinkage cavity, (c) is a shrinkage cavity, and (d) is a noise point; Figure 6 This is a three-dimensional visualization diagram of the hole classification results provided in an embodiment of the present invention. Detailed Implementation To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the described embodiments are merely some embodiments of this invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0019] This invention provides a machine learning-based intelligent classification and statistical method for identifying three-dimensional void defects in die-cast parts, as shown in Figure 1, including the following steps: Step S1: Data acquisition, acquire a three-dimensional reconstruction model of the internal hole defects of the die casting, the three-dimensional reconstruction model is in STL format and only contains the surface geometry information of the hole; Specifically, firstly, three-dimensional data of the internal pores of the die-cast sample are obtained through industrial CT scanning. Then, three-dimensional reconstruction software is used to reconstruct a three-dimensional model of the internal pore defects of the casting sample. Finally, the three-dimensional reconstruction model is converted into STL format and exported and saved for subsequent identification and classification of pores.

[0020] Step S2: Connectivity analysis, perform connectivity analysis on the STL format 3D reconstruction model to identify and separate each independent hole; like Figure 2 As shown, connected component analysis further includes the following sub-steps: Sub-step S2.1: Vertex deduplication. Using a KD tree, spatial clustering is performed on all vertices in the STL model, grouping vertices whose spatial distance is less than a preset threshold ε (set to 1×10⁻⁶). -6 The vertices of a vertex are merged into a single vertex, and a unique vertex index is established. Specifically, due to the inherent precision limitations of computer floating-point numbers, the shared vertices of adjacent triangular faces may have slight coordinate deviations, resulting in vertices at the same spatial location being stored with multiple different coordinate values. A KD-tree is an indexing structure for high-dimensional spatial data that efficiently finds vertices with a spatial distance less than ε and groups these vertices into the same group, retaining the vertex with the smallest index value as the representative of that group. This step maps the original vertices to deduplicated vertex indices, allowing adjacent triangular faces in space to share common vertices and creating topological relationships. Sub-step S2.2: Constructing adjacency relationships. Based on the unique vertex index, each edge of each triangular facet is standardized and identified to establish the adjacency relationship between the edges and the face, thereby constructing the adjacency graph between the triangular faces. Specifically, firstly, each edge of each triangular facet is standardized: each edge is defined using its two corresponding vertices after deduplication. To avoid ambiguity caused by different vertex orders for the same physical edge, the ascending-ordered vertex pairs are used as the unique spatial identifiers for that edge, ensuring that each physical edge in the model corresponds to a unique standardized identifier. Then, the adjacency relationship between edges and faces is established: using the standardized edge identifiers as indexes, all edges of all triangular faces are traversed, recording each triangular plane to which each edge belongs. For the closed hole model, each edge is shared by two triangular faces. Finally, the adjacency relationship between faces is established: for each triangular plane, all faces to which its three edges belong are extracted from the above edge-face adjacency relationship. After removing the face itself, the set of all faces adjacent to that face is obtained. After traversing all the faces, all adjacent faces of each triangular facet are found, clarifying the spatial connection relationships of all faces. Sub-step S2.3: Identify connected components. Use a breadth-first search strategy to traverse the adjacency graph and group interconnected triangular faces into the same connected component. Each connected component represents an independent hole. Specifically, all faces in the model are first initialized to an unvisited state, and then all faces are traversed sequentially. When an unvisited face is encountered, it is determined to be the starting face of an independent connected component. The process then proceeds to collect the faces for that component: a queue following a first-in, first-out (FIFO) principle is created, the starting face is added to the queue, and its state is updated to visited. The face at the head of the queue is retrieved, and the visit status of all its adjacent faces is checked from the face adjacency graph constructed above. All unvisited adjacent faces are then inserted into the tail of the queue, and their status is updated to visited. This process is repeated until there are no faces to be processed in the queue. At this point, all the visited triangular faces collected through this process form an independent and complete connected component, and a unique identification number is assigned to this component. By traversing all triangular faces according to the above process until all states are marked, the connected component corresponding to each hole in the model is obtained.

[0021] Step S3: Feature extraction. For each independent hole identified in step S2, calculate its three-dimensional geometric features. The three-dimensional geometric features include at least sphericity, convexity, volume-to-surface area ratio, and surface normal variance. Specifically, sphericity is a characteristic describing whether a hole is close to a standard sphere, and it is a key parameter for distinguishing holes. Air pores are closer to a sphere and have higher sphericity, while constriction pores have irregular shapes and lower sphericity. The sphericity of constriction pores generally falls between the two. The formula for calculating sphericity is:

[0022] Where S is the sphericity of the hole, and A S Let A be the surface area of ​​a standard sphere with the same volume as the hole, and let A be the actual surface area of ​​the hole. The convexity is a characteristic describing the degree of unevenness of the surface of a hole. A more full pore with no depressions has a higher convexity, while a constricted hole has an uneven surface and a lower convexity. The formula for calculating the convexity is:

[0023] Where C is the convexity of the hole, and V is the volume of the hole. h Let be the volume of the convex hull of the hole; The volume-to-surface-area ratio is the ratio of the pore volume to the surface area, which can describe the degree of pore fullness or flatness. Fuller pores correspond to a larger volume-to-surface-area ratio, while flat pores or shrinkage pores correspond to a smaller volume-to-surface-area ratio. The surface normal vector variance reflects the surface roughness. For sheet-like and polyhedral noise points, the surface smoothness and flatness correspond to a smaller normal vector variance value, while the surface roughness and unevenness of the shrinkage hole correspond to a larger normal vector variance value. The surface normal vector variance is calculated as follows: obtain the normal vectors of all triangular facets on the hole surface, calculate the overall variance of the components of all normal vectors in the three coordinate axis directions, and calculate the Euclidean norm of the overall variance vector.

[0024] Step S4: Model classification. The sphericity, convexity, volume-to-surface-area ratio, and surface normal variance calculated in step S3 are input into a pre-trained random forest classification model. The random forest classification model outputs the category of the hole, which includes vents, constriction pores, air-constriction pores, and noise. Specifically, this invention provides a random forest model comprising 200 CART decision trees, a maximum tree depth of 20, a minimum number of samples required for node splitting of 2, and a minimum number of samples required for leaf nodes of 1. By training 200 independent decision trees, the model outputs classification results using a majority voting rule. The random forest model is as follows: Figure 3 As shown, the CART decision tree is as follows: Figure 4 As shown.

[0025] The random forest classification model is pre-trained using the following method: Step T1: Construct a training dataset and obtain multiple STL models of holes with pre-labeled categories, including pores, constrictions, air-contraction pores, and noise. Specifically, a three-dimensional visualization of a single hole is performed, and its morphological characteristics are observed and labeled. The hole type is determined using the following methods: pores are relatively full, spherical or nearly spherical; constriction pores are irregularly dendritic or meandering tubular; cavitation pores are formed by the interlocking of constriction pores and pores, and a distinct spherical pore structure can be observed in a certain part of the constriction pore; noise points are thin-film, needle-like, or polyhedral fragments. Typical three-dimensional morphologies of various hole types are shown below. Figure 5 As shown, the training dataset of this invention contains 600 each of pores, constrictions, air-constriction pores, and noise points, for a total of 2400 hole training data.

[0026] Step T2: Training Feature Extraction. For each hole in the training dataset, calculate its sphericity, convexity, volume-to-surface-area ratio, and surface normal vector variance to form a training feature set. Preprocess the collected data: remove data with erroneous sphericity or convexity values ​​greater than 1; encode the labels, converting the category labels (pore, constriction, air-contraction pore, noise) into their corresponding numerical forms; and use Z-score standardization to scale each feature to a standard normal distribution with a mean of 0 and a standard deviation of 1, addressing the issue of dimensional differences between different features.

[0027] Step T3: Model Training. The training feature set is used as input, and the corresponding hole category is used as label to train the random forest model to obtain the random forest classification model. Specifically, a random forest classification model is initialized with 200 decision trees, a maximum tree depth of 20, a minimum number of samples for node splits of 2, and a minimum number of samples for leaf nodes of 1. 2400 samples are randomly selected with replacement from the training feature set to generate a subset, and this process is repeated 200 times to generate an independent subset for each decision tree. 200 CART decision trees are constructed in parallel. Before splitting at each node, two candidate features are randomly selected. The optimal splitting feature and threshold are selected by calculating the weighted Gini impurity. The model is recursively grown until the stopping conditions of a maximum tree depth of 20, a minimum number of samples for node splits of 2, and a minimum number of samples for leaf nodes of 1 are met. The class with the most occurrences in a leaf node is then used as the predicted output for that node. Figure 3 , Figure 4 As shown, after training is completed, the random forest model, label encoder, feature normalizer and feature column information are saved as a binary file for subsequent hole defect classification tasks.

[0028] Step S5: Output the results. Statistically analyze and output the classification results of all independent holes in the 3D reconstruction model. The classification results include the number of holes in each category, the volume of holes in each category, the porosity, the volume fraction of holes in each category, and the spatial distribution information of holes in each category.

[0029] Specifically, porosity is obtained by calculating the ratio of the total volume of all pores to the total volume of the die casting; the volume fraction of a certain type of pore is obtained by calculating the ratio of the total volume of a certain type of pore to the total volume of the die casting; a three-dimensional visualization image is generated based on the spatial coordinates of each pore and its category, and in the three-dimensional visualization image, pores are marked in red, shrinkage cavities in blue, and gas shrinkage cavities in yellow, as shown below. Figure 6 As shown.

[0030] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A machine learning-based intelligent classification and statistical method for identifying three-dimensional void defects in die-cast parts, characterized in that, The identification and classification process includes the following steps: Step S1: Data acquisition, acquire a three-dimensional reconstruction model of the internal hole defects of the die casting, the three-dimensional reconstruction model is in STL format and only contains the surface geometry information of the hole; Step S2: Connectivity analysis, perform connectivity analysis on the STL format 3D reconstruction model to identify and separate each independent hole; Step S3: Feature extraction. For each independent hole identified in step S2, calculate its three-dimensional geometric features. The three-dimensional geometric features include at least sphericity, convexity, volume-to-surface-area ratio, and surface normal variance. Step S4: Model classification. The sphericity, convexity, volume-to-surface-area ratio, and surface normal variance calculated in step S3 are input into a pre-trained random forest classification model. The random forest classification model outputs the category of the hole, which includes vents, constriction pores, air-constriction pores, and noise. Step S5: Output the results. Statistically analyze and output the classification results of all independent holes in the 3D reconstruction model. The classification results include the number of holes in each category, the volume of holes in each category, the porosity, the volume fraction of holes in each category, and the spatial distribution information of holes in each category.

2. The intelligent classification and statistical method for three-dimensional hole defects in die-castings based on machine learning according to claim 1, characterized in that, The connected component analysis in step S2 further includes: Sub-step S2.1: Vertex deduplication. Use the KD tree to perform spatial clustering on the vertices in the STL model, merge vertices with a spatial distance less than a preset threshold into the same vertex, and establish a unique vertex index. Sub-step S2.2: Construct adjacency relationships. Based on the unique vertex index, standardize the identification of each edge of each triangular facet, establish the adjacency relationship from edge to face, and then construct the adjacency graph between triangular faces. Sub-step S2.3: Identify connected components, and use a breadth-first search strategy to traverse the adjacency graph to group interconnected triangular faces into the same connected component. Each connected component represents an independent hole.

3. The intelligent classification and statistical method for three-dimensional hole defects in die-castings based on machine learning according to claim 1, characterized in that, In step S3, the formula for calculating sphericity is: Where S is the sphericity of the hole, AS is the surface area of ​​a standard sphere with the same volume as the hole, and A is the actual surface area of ​​the hole. The formula for calculating the convexity is: Where C is the convexity of the hole, V is the volume of the hole, and Vh is the convex hull volume of the hole; The volume-to-surface-area ratio is the ratio of the pore volume to its surface area; The variance of the surface normal vector is calculated as follows: obtain the normal vectors of all triangular facets on the surface of the hole, calculate the overall variance of the components of all normal vectors in the three coordinate axes, and calculate the Euclidean norm of the overall variance vector.

4. The intelligent classification and statistical method for three-dimensional hole defects in die-castings based on machine learning according to claim 1, characterized in that, The hyperparameters of the random forest classification model in step S4 are set as follows: the number of decision trees is 200, the maximum depth of the decision trees is 20, the minimum number of samples required for node splitting is 2, and the minimum number of samples for leaf nodes is 1.

5. The machine learning-based method for identifying and classifying three-dimensional void defects in die-castings according to claim 1, characterized in that, The random forest classification model in step S4 is pre-trained using the following method: Step T1: Construct a training dataset and obtain multiple STL models of holes with pre-labeled categories, including pores, constrictions, air-contraction pores, and noise. Step T2: Training feature extraction. For each hole in the training dataset, calculate its sphericity, convexity, volume-to-surface area ratio, and surface normal vector variance to form a training feature set. Step T3: Model training. The training feature set is used as input, and the corresponding hole category is used as label to train the random forest model to obtain the random forest classification model.

6. The intelligent classification and statistical method for three-dimensional hole defects in die-castings based on machine learning according to claim 1, characterized in that, In step S5, the porosity is obtained by calculating the ratio of the total volume of all holes to the total volume of the die casting; the volume fraction of a certain type of hole is obtained by calculating the ratio of the total volume of a certain type of hole to the total volume of the die casting.

7. The intelligent classification and statistical method for three-dimensional hole defects in die-castings based on machine learning according to claim 1, characterized in that, Step S5 further includes: generating a three-dimensional visualization image based on the spatial coordinates of each hole and its category, and marking pores, shrinkage holes and air shrinkage holes in the three-dimensional visualization image using different colors respectively.