Casting detection method and system based on machine vision
By integrating the three-dimensional dynamic shrinkage field and von Mises stress field of the casting, the defect risk weight map is generated, the polarization light source incident angle is adjusted, the defect edge characteristics of the casting are extracted, and the probability of crack germination is predicted, which solves the accuracy of casting detection in complex environments, improves the accuracy and reliability of the detection, and reduces the cost.
Patent Information
- Application Number
- CN202510478079.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-16
AI Technical Summary
The existing machine vision-based casting detection technology is inaccurate in complex environments, making it difficult to effectively integrate the relationship between the internal stress field and the external geometry, resulting in low accuracy in casting detection and increased repair and quality control costs.
The defect risk weight map is generated by obtaining the three-dimensional dynamic shrinkage field of the casting and the von Mises stress field, adjusting the incident angle of the polarized light source to obtain high-contrast images, and using the deformable convolution kernel to extract the defect edge feature map, and combining the material fatigue limit parameters to predict the crack germination probability.
It improves the accuracy and reliability of casting inspection, improves the applicability in complex working conditions, and reduces the cost of casting quality control.
Smart Images

Figure CN120404735A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field at the intersection of machine vision and materials science, and particularly to a casting detection method and system based on machine vision. Background Art
[0002] With the continuous progress of industrial manufacturing technology, castings, as basic components, play an indispensable role in many fields such as aerospace, automotive manufacturing, and mechanical engineering. However, various internal and surface defects are likely to occur during the production of castings, such as shrinkage cavities, cracks, bubbles, and inclusions. These defects will seriously affect the quality and service life of castings. Traditional casting detection methods mainly include radiographic testing, ultrasonic testing, and magnetic particle testing, etc. However, these methods have certain limitations. For example, they are complex to operate, costly, have strict environmental requirements, and it is difficult to achieve high-precision three-dimensional defect positioning. In recent years, with the development of machine vision technology, casting detection methods based on image processing have gradually emerged. Such methods can quickly obtain the surface information of castings in a non-contact manner and use algorithms to analyze and identify potential defect areas.
[0003] Nevertheless, there are still some deficiencies in the existing casting detection technologies based on machine vision. First of all, most of the existing technologies mainly rely on a single image feature for defect detection, which limits their application effects in complex environments (such as severe interference from the surface oxide layer). Secondly, traditional methods lack an effective fusion mechanism when dealing with the relationship between the internal stress field and the external geometry of castings, resulting in difficulty in accurately predicting the risk of crack initiation caused by uneven material shrinkage or stress concentration. These problems not only affect the accuracy of casting detection but also increase the costs of subsequent repair and quality control. Summary of the Invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a casting detection method based on machine vision to solve the problems of inaccurate defect detection in complex environments and difficulty in effectively fusing the relationship between the internal stress field and the external geometry in the prior art.
[0006] To solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a casting detection method based on machine vision, which includes obtaining a three-dimensional dynamic shrinkage field of a casting based on the pouring temperature, material melting point, and ambient temperature, and fusing it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map; extracting the boundary coordinates of the area where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame; adjusting the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame, and collecting local images to obtain a high-contrast image sequence with surface oxide layer interference eliminated; extracting a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel, and obtaining a defect candidate area mask; mapping the defect candidate area mask to the von Mises stress field, and predicting the crack initiation probability in combination with the material fatigue limit parameter.
[0008] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: the steps of obtaining a three-dimensional dynamic shrinkage field of a casting based on the pouring temperature, material melting point, and ambient temperature, and fusing it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map are as follows.
[0009] Combining the material shrinkage coefficient, a three-dimensional dynamic shrinkage field is constructed through the thermodynamic gradient field equation.
[0010] The three-dimensional dynamic shrinkage field and the von Mises stress field are normalized and fused in combination with an asymmetric interaction function to generate a defect risk weight map.
[0011] The defect risk weight map is normalized to generate a standard risk value, and a risk area judgment is performed.
[0012] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: the steps of extracting the boundary coordinates of the area where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame are as follows.
[0013] Obtain a high-risk area binary mask, and accurately extract the boundary coordinates through phase consistency edge detection.
[0014] Map the boundary coordinate set to scanning frame motion parameters, and the scanning frame motion parameters include a scanning center, a scanning radius, and a scanning angular velocity.
[0015] Based on the scanning frame motion parameters, construct a spatio-temporal trajectory equation of the scanning frame to generate a dynamic attention area scanning frame.
[0016] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: according to the trajectory of the dynamic attention area scanning frame, adjust the incident angle of the polarized light source, collect local images, and obtain a high-contrast image sequence with the interference of the surface oxide layer eliminated. The specific steps are as follows,
[0017] According to the trajectory of the dynamic attention area scanning frame, obtain the gradient amplitude of the three-dimensional dynamic contraction field and the von Mises stress field amplitude, and combine the arctangent function to obtain the basic polarization angle;
[0018] Superimpose a sine wave term on the basic polarization angle, and compensate for the random distribution characteristics of the oxide layer thickness and grain orientation through periodic angle fine-tuning to generate a command sequence for the incident angle of the polarized light source;
[0019] Adjust the incident angle of the polarized light source according to the command sequence, collect local images, and obtain a dual-angle image sequence;
[0020] Generate a high-contrast image sequence according to the dual-angle image sequence and the three-dimensional dynamic contraction field gradient amplitude, and obtain a high-contrast image sequence with the interference of the surface oxide layer eliminated.
[0021] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: the specific steps of extracting the defect edge feature map from the high-contrast image sequence through the deformable convolution kernel are as follows,
[0022] Perform multi-scale convolution feature extraction on the high-contrast image sequence and the defect risk weight map respectively, and splice them along the channel dimension to generate a multi-scale fusion feature map;
[0023] Generate an offset field according to the three-dimensional dynamic contraction field gradient, and apply a deformable convolution kernel in combination with the multi-scale fusion feature map to perform a deformable convolution operation;
[0024] Perform non-maximum suppression and Sobel edge detection on the result of the convolution operation to generate a defect edge feature map.
[0025] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: the specific steps of obtaining the defect candidate region mask are as follows,
[0026] Scale the defect risk weight map to the same resolution as the defect edge feature map through bilinear interpolation, and obtain a spatial attention weight map;
[0027] Based on the spatial attention weight map, apply attention weights to the defect edge feature map and perform feature map alignment to generate a spatially aligned fusion feature map
[0028] Perform adaptive threshold segmentation on the spatially aligned fusion feature map through the OTSU algorithm to generate a binary mask;
[0029] Perform an opening operation on the binary mask to generate a defect candidate region mask.
[0030] As a preferred solution of the casting detection method based on machine vision according to the present invention, wherein: mapping the defect candidate region mask to the von Mises stress field and combining the material fatigue limit parameters to predict the crack initiation probability, the specific steps are as follows.
[0031] Perform spatio-temporal alignment of the defect candidate region mask and the von Mises stress field.
[0032] Calculate the stress concentration factor according to the von Mises stress sub-graph sequence.
[0033] Combine the stress concentration factor with the material fatigue limit parameters to predict the crack initiation probability.
[0034] In a second aspect, the present invention provides a casting detection system based on machine vision, including a shrinkage stress fusion module for obtaining the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point, and environmental temperature, and fusing it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map; a dynamic scanning frame generation module for extracting the boundary coordinates of the region where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame; a polarized image acquisition module for adjusting the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame and acquiring local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer; a defect feature extraction module for extracting a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel and obtaining a defect candidate region mask; a crack prediction module for mapping the defect candidate region mask to the von Mises stress field and combining the material fatigue limit parameters to predict the crack initiation probability.
[0035] In a third aspect, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and wherein: when the computer program is executed by the processor, any step of the casting detection method based on machine vision as described in the first aspect of the present invention is implemented.
[0036] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and wherein: when the computer program is executed by the processor, any step of the casting detection method based on machine vision as described in the first aspect of the present invention is implemented.
[0037] The beneficial effects of the present invention are as follows: By calculating the three-dimensional dynamic shrinkage field of the casting and fusing it with the von Mises stress field to generate a defect risk weight map, high-risk areas can be accurately identified. At the same time, according to the dynamically monitored area, the incident angle of the polarized light source is adjusted to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer. These two key steps not only improve the accuracy and reliability of detection but also significantly enhance the applicability under complex working conditions, thereby effectively improving the quality control level of castings and reducing repair and quality control costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0039] Figure 1 It is a flowchart for generating the defect risk weight map in Embodiment 1.
[0040] Figure 2 It is a flowchart for generating the dynamic scanning frame in Embodiment 1.
[0041] Figure 3 It is a flowchart for collecting polarized images in Embodiment 1.
[0042] Figure 4 It is a flowchart for defect detection and prediction in Embodiment 1. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0043] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following will provide a detailed description of the specific embodiments of the present invention with reference to the accompanying drawings of the specification.
[0044] Many specific details are set forth in the following description to facilitate a thorough understanding of the present invention. However, the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.
[0045] Secondly, the so-called "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that can be included in at least one implementation manner of the present invention. The phrase "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that excludes other embodiments.
[0046] Embodiment 1, referring to Figures 1 to 4 , this embodiment provides a casting detection method based on machine vision, including the following steps:
[0047] S1: The three-dimensional dynamic shrinkage field of the casting is obtained based on the pouring temperature, material melting point and ambient temperature, and is integrated with the von Mises stress field obtained by finite element analysis to generate a defect risk weight map;
[0048] S1.1: Temperature parameter collection and preprocessing;
[0049] The pouring temperature is collected in real time by an infrared thermometer, the melting point is called from the material database, obtained using an ambient temperature and humidity sensor, and normalized.
[0050] S1.2: Obtain the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point, and ambient temperature;
[0051] Furthermore, the pouring temperature, material melting point and ambient temperature are input into the thermodynamic gradient field equation. Combined with the material shrinkage coefficient, the nonlinear effect of the second-order derivative of the temperature field on the shrinkage is calculated to obtain the initial shrinkage distribution of each point in the three-dimensional space.
[0052] Then, the casting geometry model was discretized using an adaptive meshing method. Local mesh refinement was performed in the gate, thin wall, and cooling channel areas. The finite difference method was used to obtain the numerical solution for shrinkage at discrete nodes.
[0053] Finally, the shrinkage of each node is mapped to the standard interval through maximum-minimum normalization to generate a three-dimensional dynamic shrinkage field that strictly matches the casting geometry.
[0054] S1.3: The three-dimensional dynamic shrinkage field and the von Mises stress field are normalized and fused with the asymmetric interaction function to generate a defect risk weight map, which is expressed as:
[0055]
[0056] Where R(x,y) is the defect risk weight map, ΔV is the normalized three-dimensional dynamic shrinkage field, and σ is the normalized von Mises stress field. is the stress field Laplace operator, ∈ is a minimum constant to prevent the denominator from being zero, It represents the rate of change of the three-dimensional dynamic contraction field along the z direction in the spatial rectangular coordinate system;
[0057] It should be noted that the specific steps for obtaining the von Mises stress field through finite element analysis are as follows:
[0058] According to the geometric dimensions and structural characteristics of the casting, a three-dimensional solid model including gates, risers and cooling channels is constructed using CAD software;
[0059] Call the elastic modulus, Poisson's ratio, and yield strength parameters from the material database, set the pouring temperature as the initial temperature condition, and the ambient temperature as the heat dissipation boundary condition;
[0060] Use tetrahedral elements to perform adaptive mesh division on the 3D model, and locally refine the high-curvature regions and thin-wall regions to ensure the calculation accuracy of the stress field;
[0061] Convert the thermal expansion effect during the pouring process into an equivalent temperature load, combine the displacement constraint conditions generated by cooling shrinkage, and generate the thermal stress distribution;
[0062] Based on the finite element solver, obtain the stress tensor of each node, extract the stress field distribution data, and generate the von Mises stress field.
[0063] Normalize the defect risk weight map, generate the standard risk value, and perform risk area judgment;
[0064] Furthermore, according to historical data, set the risk threshold. When the standard risk value is greater than the risk threshold, it is determined as a high-risk area. When the standard risk value is less than or equal to the risk threshold, it is determined as a safe area.
[0065] S2: Extract the boundary coordinates of the area where the risk value exceeds the risk threshold from the defect risk weight map to form a dynamic attention area scanning frame;
[0066] S2.1: Obtain the binary mask of the high-risk area, and accurately extract the boundary coordinates through phase congruency edge detection. The expression is:
[0067]
[0068] Among them, is the boundary coordinate set, O is the number of multi-scale directions, A o is the response amplitude of the Gabor filter in the o-th direction, φ o is the phase angle in the o-th direction, is the average phase, η is the phase congruency threshold, φ o (x, y) is the local phase angle in the o-th direction at the coordinate (x, y), is the weighted average of the phase angles at the coordinate (x, y), A o (x, y) is the response amplitude in the o-th direction at the coordinate (x, y);
[0069] It should be noted that perform threshold segmentation on the normalized defect risk weight map, set the risk threshold, mark the area higher than the threshold as foreground pixels, and generate the initial binary mask;
[0070] The initial binary mask is decomposed in the frequency domain using a multi-scale and multi-direction Gabor filter bank, the phase consistency metric value of each pixel point in the frequency domain is calculated, and local maximum points are retained in the phase consistency response map through the non-maximum suppression algorithm;
[0071] The adaptive threshold segmentation method is used to extract the edge pixel points whose phase consistency values exceed the set threshold, forming a candidate edge point set;
[0072] The morphological thinning algorithm is used to remove edge breakpoints and connect adjacent edge segments, and the edge tracking algorithm is combined to traverse the contour of the connected region, and an accurate set of closed boundary coordinates is output.
[0073] S2.2: Map the boundary coordinate set to the scanning frame motion parameters, where the scanning frame motion parameters include the scanning center, the scanning radius, and the scanning angular velocity;
[0074] It should be noted that the scanning center is calculated based on the minimum circumscribed rectangle of the boundary coordinate set, and the geometric center coordinates of the boundary point set are obtained as the scanning center in the scanning frame motion parameters;
[0075] Calculate the Euclidean distance from each point in the boundary point set to the scanning center, select the maximum distance value as the initial scanning radius, and superimpose the time decay factor in the scanning frame trajectory equation of the dynamic attention area to generate a scanning radius parameter that decreases with time;
[0076] According to the regional distribution density of the defect risk weight map, query the corresponding angular velocity reference value through the density-angular velocity mapping table, and adjust the final scanning angular velocity according to the shape complexity coefficient of the boundary coordinate set (calculated from the aspect ratio and the standard deviation of the contour curvature).
[0077] Based on the scanning frame motion parameters, construct the spatio-temporal trajectory equation of the scanning frame to generate a dynamic attention area scanning frame, and the expression is:
[0078] Ψ(t) = (x c + r(t)cos(ωt), y c + r(t)sin(ωt));
[0079] Among them, Ψ(t) is the spatio-temporal trajectory equation of the dynamic attention area scanning frame, r(t) is the scanning radius, ω is the scanning angular velocity, t is the time parameter, x c is the abscissa value of the scanning center in the Cartesian coordinate system, and y c is the ordinate value of the scanning center in the Cartesian coordinate system;
[0080] It should be noted that the scanning center coordinates are used as the origin of the polar coordinate system, and the scanning radius is jointly determined by the initial maximum value and the time decay factor, forming a polar radius function with an exponentially decaying radius over time;
[0081] Multiply the scanning angular velocity by the time parameter to obtain the polar angle, and generate a spatio-temporal trajectory equation through the polar coordinate-Cartesian coordinate conversion formula to describe the movement path of the center point of the scanning frame over time;
[0082] Connect the discrete trajectory points into a continuous motion trajectory through an interpolation algorithm, and generate a dynamic attention area scanning frame that covers the high-risk area and shrinks over time in combination with the preset scanning frame size parameters.
[0083] S3: Adjust the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame, and collect local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer;
[0084] S3.1: Calculate the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame;
[0085] At the coordinate of the trajectory point of the dynamic attention area scanning frame, obtain the gradient amplitude of the three-dimensional dynamic contraction field and the von Mises stress field amplitude;
[0086] It should be noted that based on the spatio-temporal trajectory equation of the dynamic attention area scanning frame, the corresponding spatial coordinates of the current trajectory point are analyzed; from the discretized grid data of the three-dimensional dynamic contraction field, the three-dimensional spatial gradient components of this coordinate point are extracted through bilinear interpolation, and its gradient amplitude is calculated; in the von Mises stress field, according to the node stress data set generated by finite element analysis, the von Mises stress value of the current coordinate point is obtained through nearest neighbor interpolation as the stress field amplitude.
[0087] Divide the gradient amplitude of the three-dimensional dynamic contraction field by the von Mises stress field amplitude plus a very small constant, and take the arctangent function of the quotient to obtain the basic polarization angle;
[0088] It should be noted that the gradient amplitude of each spatial coordinate point is extracted from the three-dimensional dynamic contraction field and obtained by calculating the square root of the sum of the squares of the components of the gradient vector in three orthogonal directions;
[0089] Obtain the normalized stress amplitude of the corresponding coordinate point from the von Mises stress field, and add a preset very small constant to avoid the denominator being zero;
[0090] Divide the result of adding the gradient amplitude and the stress amplitude plus a very small constant to obtain the quotient value representing the gradient-stress correlation strength;
[0091] Apply the arctangent function to the quotient value, map the linear proportional relationship to the [-π / 2, π / 2] angle interval, and generate a basic polarization angle that is positively correlated with the material contraction gradient and the stress concentration degree.
[0092] A sine wave term is superimposed on the base polarization angle, and a periodic angle fine-tuning is used to compensate for the random distribution characteristics of the oxide layer thickness and grain orientation, generating an incident angle command sequence for the polarized light source;
[0093] It should be noted that by analyzing the random characteristics of the oxide layer thickness distribution and grain orientation, a periodic angle adjustment component is generated;
[0094] The periodic angle adjustment component dynamically modulates the base polarization angle in the form of a sine function, and uses the continuous change characteristics of the fluctuation to cover the local differences in the oxide layer thickness and grain orientation;
[0095] The amplitude of the sine wave fluctuation is adaptively adjusted according to the change range of the oxide layer thickness. The greater the thickness difference, the stronger the amplitude. The frequency is set according to the spatial distribution density of the grain orientation. Higher frequency fluctuations are used in high-density regions to match the rapid change of the orientation;
[0096] Combined with a random initial phase offset, it is ensured that the modulation angle difference between adjacent scanning regions is maximized;
[0097] The modulated polarization angles are arranged in the time series of the scanning frame trajectory, forming an incident angle command sequence synchronized with the spatial distribution of the dynamic focus area, realizing point-by-point compensation for oxide layer interference.
[0098] S3.2: Adjust the incident angle of the polarized light source according to the command sequence and collect local images;
[0099] According to the command sequence, the polarized light source is adjusted from the current incident angle to the target incident angle, and the camera position is offset to the extension line of the dynamic focus area scanning frame trajectory point along the direction of the von Mises stress field gradient. According to the current scanning radius and polarization angle of the dynamic focus area scanning frame, the lens focal length is adjusted in real time: the focal length is extended when the scanning radius increases, and the focal length is shortened when the incident angle is large.
[0100] After the light source is stabilized at the target angle, local images are collected to obtain a dual-angle image sequence.
[0101] S3.3: Generate a high-contrast image sequence according to the dual-angle image sequence and the three-dimensional dynamic shrinkage field gradient amplitude;
[0102] The dual-angle image sequence is subjected to differential noise reduction and normalization processing to generate a differential image;
[0103] It should be noted that two polarized angle images collected at the same dynamic focus area scanning frame trajectory point are extracted from the dual-angle image sequence, and the original differential image is obtained through pixel-level differential operation;
[0104] The morphological filtering algorithm is used to suppress the noise of the original differential image, specifically including performing an opening operation with a circular structural element of a radius of 2 pixels to eliminate isolated noise points and retain the connected regions of the defect edges;
[0105] The filtered differential image is normalized. By calculating the difference between the maximum pixel value and the minimum pixel value in the image, the pixel values are linearly mapped to the interval [0, 1];
[0106] The local contrast of the normalized result is enhanced by combining with the gradient magnitude of the three-dimensional dynamic shrinking field. The specific method is as follows: in the regions where the gradient magnitude is higher than the set threshold, the hyperbolic tangent function is used to nonlinearly compress the pixel values, while in the low-gradient regions, linear stretching is used to generate a high-contrast differential image.
[0107] According to the gradient magnitude of the three-dimensional dynamic shrinking field, low weights are assigned to high-gradient regions and high weights are assigned to low-gradient regions to generate a weight map, and the weight map is multiplied by the normalized differential image to suppress background noise while retaining the defect signals;
[0108] And in the spatial order of the dynamic attention area scanning frame trajectory, the processed local images are stitched into a global image sequence, and a high-contrast image sequence with the interference of the surface oxide layer removed is obtained.
[0109] S4: Extract the defect edge feature map from the high-contrast image sequence through a deformable convolution kernel, and obtain the defect candidate region mask;
[0110] S4.1: Based on the high-contrast image sequence and the defect risk weight map, perform multi-scale feature fusion;
[0111] Furthermore, the high-contrast image sequence and the defect risk weight map are respectively subjected to multi-scale convolutional feature extraction and stitched along the channel dimension to generate a multi-scale fusion feature map.
[0112] It should be noted that the high-contrast image sequence is input into a multi-scale feature extraction branch composed of three parallel convolutional layers to extract multi-scale features including local details, medium structures, and global semantics;
[0113] The defect risk weight map is input into another independent multi-scale feature extraction branch, and multi-scale features of the spatial weight distribution are extracted through convolutional kernels with the same structure;
[0114] The convolutional output of the high-contrast image sequence and the convolutional output of the defect risk weight map are stitched along the channel dimension to form a basic feature layer, a medium feature layer, and a global feature layer;
[0115] The basic feature layer, the medium feature layer, and the global feature layer are stitched again along the channel dimension to generate a multi-scale fusion feature map containing the correlation between multi-scale spatial weight information and defect features.
[0116] S4.2: Extract the defect edge feature map from the multi-scale fusion feature map through a deformable convolution kernel;
[0117] Generate an offset field based on the three-dimensional dynamic contraction field gradient, apply a deformable convolution kernel in combination with the multi-scale fusion feature map, and perform a deformable convolution operation;
[0118] It should be noted that the gradient components of each spatial coordinate point are extracted from the discrete grid data of the three-dimensional dynamic contraction field, and a normalized gradient vector is generated through normalization processing;
[0119] Decompose the normalized gradient vector into two-dimensional offset components along the plane projection direction, and generate an offset field through a linear mapping function;
[0120] Align the offset field with the spatial dimension of the multi-scale fusion feature map. Through the deformation sampling mechanism of the deformable convolution kernel, dynamically adjust the sampling position of the convolution kernel at the feature map coordinates according to the offset;
[0121] Perform weighted summation on the resampled eigenvalues to generate a deformable convolution output feature map adapted to the three-dimensional dynamic contraction field gradient distribution.
[0122] Perform non-maximum suppression (NMS) and Sobel edge detection on the deformable convolution output feature map to generate a defect edge feature map.
[0123] S4.3: Align the defect edge feature map and the defect risk weight map spatially through a cross-layer attention mechanism;
[0124] Scale the defect risk weight map to the same resolution as the defect edge feature map through bilinear interpolation, and calculate the spatial attention weight map; Align the feature map by applying the attention weight to the defect edge feature map to generate a spatially aligned fused feature map.
[0125] It should be noted that based on the spatial resolution parameters of the defect edge feature map, determine the target interpolation grid size; Use the bilinear interpolation algorithm to resample each pixel point of the defect risk weight map, and calculate the interpolated pixel value through the weighted average of the adjacent four pixel points to obtain a scaled defect risk weight map with the same resolution as the defect edge feature map;
[0126] Input the scaled defect risk weight map into the attention generation branch composed of a convolutional layer and a Sigmoid activation function, and output a spatial attention weight map with a range between [0, 1];
[0127] Perform an element-wise multiplication operation on the spatial attention weight map and the defect edge feature map to strengthen the feature response corresponding to the high defect risk area in the defect edge feature map, and at the same time suppress the noise signal in the low risk area;
[0128] It should be noted that the weight value of each pixel in the spatial attention weight map represents the probability that the corresponding position belongs to the high defect risk area, and the value range is between 0 and 1, where the weight value close to 1 corresponds to the high risk area;
[0129] The feature response value of each pixel in the defect edge feature map reflects the possibility of the existence of a defect edge at that position, and the higher the value, the more significant the edge feature.
[0130] In the element-wise multiplication process, the high weight value in the high risk area is multiplied by the high response value of the defect edge feature to obtain an enhanced feature value, while the low weight value in the low risk area is multiplied by the low response value of the noise or background feature and further reduced, realizing the differential modulation of the feature response amplitude;
[0131] The modulated fusion feature map is complemented with the original defect edge feature map through channel concatenation, retaining the effective edge details not covered by the weight map.
[0132] The weighted defect edge feature map and the original defect edge feature map are feature fused through channel concatenation operation, and a convolutional kernel is used for cross-channel information integration to generate a spatially aligned fusion feature map;
[0133] It should be noted that the defect edge feature map modulated by the spatial attention weight map and the unmodulated original defect edge feature map are concatenated along the channel dimension to form an intermediate feature map with double the number of channels;
[0134] A convolutional kernel with a preset size is used to perform cross-channel information fusion on the concatenated feature map. Through the weight learning mechanism of the convolutional kernel, the complementary relationship between the weighted feature map and the original feature map is automatically captured, suppressing redundant information and strengthening the effective edge response;
[0135] An interpolation alignment operation in the spatial dimension is performed on the convolutional output feature map to eliminate the small position offsets introduced by weight modulation or convolutional operation, generating a fusion feature map that strictly matches the spatial resolution of the defect risk weight map.
[0136] S4.4: Generate a defect candidate region mask according to the spatially aligned fusion feature map;
[0137] The spatially aligned fusion feature map is adaptively threshold segmented by the OTSU algorithm to generate a binary mask;
[0138] It should be noted that the channel feature values of the spatially aligned fusion feature map are weighted and summed to generate a single-channel grayscale feature map;
[0139] Statistically calculate the histogram distribution of pixel values in the grayscale feature map, traverse the candidate thresholds, calculate the inter-class variance of the foreground area and the background area corresponding to each threshold, and select the threshold that maximizes the inter-class variance as the optimal segmentation threshold;
[0140] The area in the grayscale feature map where the pixel value is greater than the optimal segmentation threshold is marked as 1, and the area less than or equal to the threshold is marked as 0 to generate the initial binary mask;
[0141] A morphological closing operation is performed on the initial binary mask, and a rectangular structure element is used to eliminate holes inside the mask and smooth the edge contours to generate the final binary mask.
[0142] Perform an opening operation on the binary mask to generate a defect candidate area mask;
[0143] It should be noted that a rectangular structural element is used to perform a morphological erosion operation on the binary mask to eliminate isolated noise points with an area smaller than the structural element and to refine the edge contour;
[0144] A morphological dilation operation is performed on the eroded mask using a rectangular structure element of the same size to restore the size of the effective defect area reduced by the erosion operation while maintaining edge smoothness;
[0145] The independent regions in the expanded mask are marked by connected domain analysis, and the residual interference regions with an area smaller than a preset threshold are eliminated.
[0146] The processed mask is logically ANDed with the original binary mask, and the area that satisfies both the open operation morphological constraints and the original segmentation result is retained to generate the defect candidate area mask.
[0147] S5: Map the defect candidate area mask to the von Mises stress field and predict the crack initiation probability in combination with the material fatigue limit parameters.
[0148] S5.1: Temporally and spatially align the defect candidate mask with the von Mises stress field;
[0149] The pixel coordinates of the defect candidate area mask are mapped to the corresponding positions of the von Mises stress field. According to the spatial mapping relationship of the dynamic focus area scanning frame trajectory, the local coordinates of the mask are converted to the global stress field coordinate system.
[0150] It should be noted that the scanning center coordinates and scanning radius in the trajectory equation of the dynamic area of interest scanning frame are analyzed to establish the translation transformation relationship between the origin of the local coordinate system and the origin of the global coordinate system;
[0151] According to the scanning angular velocity time parameters at the trajectory points, the local coordinates of the defect candidate area mask are converted into global coordinates through polar coordinate transformation;
[0152] Based on the finite element mesh node distribution data of the von Mises stress field, calculate the stress field node index corresponding to the global coordinates through the bilinear interpolation algorithm;
[0153] Associate the transformed global coordinates with the finite element node index to generate a spatial mapping relationship table of the defect candidate area in the von Mises stress field.
[0154] For each defect candidate area, extract the von Mises stress field subgraph within its bounding box to generate a sequence of von Mises stress field subgraphs aligned with the defect area;
[0155] It should be noted that based on the connected component analysis result of the defect candidate area mask, extract the parameters of the minimum bounding rectangle of the mask, including the center coordinates, width, and height;
[0156] According to the global coordinate mapping relationship in the dynamic focus area scanning frame trajectory equation, convert the local center coordinates of the bounding box to the position in the global coordinate system corresponding to the von Mises stress field;
[0157] Intercept the stress field data centered on the global center coordinates and within the range of width and height from the finite element mesh node distribution data, and resample the discrete node stress values into a stress field subgraph with the same spatial resolution as the defect candidate area through the bilinear interpolation algorithm;
[0158] Verify the spatial alignment accuracy by calculating the Euclidean distance between the centroid coordinates of the stress field subgraph and the centroid of the defect candidate area. If the error exceeds the preset threshold, readjust the interpolation parameters to generate a sequence of von Mises stress field subgraphs precisely aligned with the defect area.
[0159] S5.2: Calculate the stress concentration factor according to the sequence of von Mises stress field subgraphs;
[0160] Extract the maximum stress value of each subgraph from the sequence of von Mises stress field subgraphs, and calculate the reference stress for the extension of the defect candidate area. The reference stress is obtained by taking the mean value after Gaussian smoothing of the stress field data in the area where the defect candidate area bounding box is expanded by 10%;
[0161] Based on the binary contour of the defect candidate area mask, obtain the major axis length and minor axis length of the defect by fitting the ellipse equation using the least squares method;
[0162] Calculate the local stress concentration factor according to the stress concentration factor theory; finally, perform the above calculations on the sequence of stress field subgraphs of the same defect candidate area at different moments in the dynamic focus area scanning frame trajectory, and take the sliding window mean value to generate the final stress concentration factor.
[0163] S5.3: Combine the stress concentration factor with the material fatigue limit parameters to predict the crack initiation probability;
[0164] Calculate the equivalent alternating stress amplitude according to the stress concentration factor and the fatigue limit of the material by the modified Goodman criterion;
[0165] Based on the material S-N curve parameters, calculate the fatigue damage degree by using the Miner linear cumulative damage theory;
[0166] Map the equivalent alternating stress amplitude to the crack initiation probability through the Weibull distribution function, and limit the probability value in the range of [0, 1] through normalization processing.
[0167] This embodiment also provides a casting detection system based on machine vision, including: a shrinkage stress fusion module, configured to obtain the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, the material melting point, and the ambient temperature, and fuse it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map; a dynamic scan box generation module, configured to extract the boundary coordinates of the area where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scan box; a polarized image acquisition module, configured to adjust the incident angle of the polarized light source according to the trajectory of the dynamic attention area scan box, and acquire local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer; a defect feature extraction module, configured to extract a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel, and obtain a defect candidate area mask; a crack prediction module, configured to map the defect candidate area mask to the von Mises stress field, and predict the crack initiation probability in combination with the material fatigue limit parameters.
[0168] This embodiment also provides a computer device, applicable to the case of the casting detection method based on machine vision, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the casting detection method based on machine vision as proposed in the above embodiment.
[0169] This computer device can be a terminal, and this computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected through a system bus. Among them, the processor of this computer device is used to provide computing and control capabilities. The memory of this computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of this computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a carrier network, NFC (Near Field Communication), or other technologies. The display screen of this computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of this computer device can be a touch layer covered on the display screen, or a button, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse, etc.
[0170] This embodiment also provides a storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the method for casting detection based on machine vision proposed in the above embodiment; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM for short), electrically erasable programmable read-only memory (EEPROM for short), erasable programmable read-only memory (EPROM for short), programmable read-only memory (PROM for short), read-only memory (ROM for short), magnetic memory, flash memory, magnetic disk or optical disc.
[0171] In summary, the present invention calculates the three-dimensional dynamic shrinkage field of the casting and fuses it with the von Mises stress field to generate a defect risk weight map, accurately identifying high-risk areas; at the same time, adjusts the incident angle of the polarized light source according to the dynamically concerned area to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer. These two key steps not only improve the accuracy and reliability of the detection, but also significantly enhance the applicability under complex working conditions, thereby effectively improving the level of casting quality control and reducing the repair and quality control costs.
[0172] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.
Claims
1. A casting detection method based on machine vision, characterized in that: including obtaining a three-dimensional dynamic shrinkage field of a casting based on the pouring temperature, material melting point, and ambient temperature, and fusing it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map; extracting the boundary coordinates of the region where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame; adjusting the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame, and collecting local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer; extracting a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel, and obtaining a defect candidate area mask; mapping the defect candidate area mask to the von Mises stress field, and predicting the crack initiation probability in combination with the material fatigue limit parameters.
2. The method for detecting castings based on machine vision according to claim 1, characterized in that: The steps of obtaining the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point, and ambient temperature, and fusing it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map are as follows: constructing a three-dimensional dynamic shrinkage field through the thermodynamic gradient field equation in combination with the material shrinkage coefficient; normalizing the three-dimensional dynamic shrinkage field and the von Mises stress field, and fusing them in combination with an asymmetric interaction function to generate a defect risk weight map; normalizing the defect risk weight map to generate a standard risk value, and performing risk area judgment.
3. The method for detecting castings based on machine vision according to claim 2, wherein: The steps of extracting the boundary coordinates of the region where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame are as follows: obtaining a binary mask of the high-risk area, and accurately extracting the boundary coordinates through phase consistency edge detection; mapping the boundary coordinate set to scanning frame motion parameters, where the scanning frame motion parameters include a scanning center, a scanning radius, and a scanning angular velocity; constructing a spatio-temporal trajectory equation of the scanning frame based on the scanning frame motion parameters to generate a dynamic attention area scanning frame.
4. The method for detecting castings based on machine vision according to claim 3, wherein: The steps of adjusting the incident angle of the polarized light source according to the trajectory of the dynamic attention area scanning frame, and collecting local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer are as follows: obtaining the gradient amplitude of the three-dimensional dynamic shrinkage field and the von Mises stress field amplitude according to the trajectory of the dynamic attention area scanning frame, and combining the arctangent function to obtain a basic polarization angle; superimposing a sine wave term on the basic polarization angle, and compensating for the random distribution characteristics of the oxide layer thickness and grain orientation through periodic angle fine-tuning to generate a polarized light source incident angle instruction sequence; adjusting the incident angle of the polarized light source according to the instruction sequence, and collecting local images to obtain a dual-angle image sequence; generating a high-contrast image sequence according to the dual-angle image sequence and the three-dimensional dynamic shrinkage field gradient amplitude, and obtaining a high-contrast image sequence that eliminates the interference of the surface oxide layer.
5. The method for detecting castings based on machine vision according to claim 4, wherein: The steps of extracting a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel are as follows: performing multi-scale convolution feature extraction on the high-contrast image sequence and the defect risk weight map respectively, and splicing them along the channel dimension to generate a multi-scale fusion feature map; generating an offset field according to the three-dimensional dynamic shrinkage field gradient, and applying a deformable convolution kernel in combination with the multi-scale fusion feature map to perform a deformable convolution operation; Perform non-maximum suppression and Sobel edge detection on the convolution operation result to generate a defect edge feature map.
6. The method for detecting castings based on machine vision according to claim 5, wherein: The steps for obtaining the defect candidate region mask are as follows: Scale the defect risk weight map to the same resolution as the defect edge feature map through bilinear interpolation, and obtain the spatial attention weight map; Based on the spatial attention weight map, apply the attention weight to the defect edge feature map and perform feature map alignment to generate a spatially aligned fused feature map. Perform adaptive threshold segmentation on the spatially aligned fused feature map through the OTSU algorithm to generate a binary mask; Perform an opening operation on the binary mask to generate a defect candidate region mask.
7. The method for detecting castings based on machine vision according to claim 6, wherein: The steps for mapping the defect candidate region mask to the von Mises stress field and predicting the crack initiation probability in combination with the material fatigue limit parameters are as follows: Perform spatio-temporal alignment between the defect candidate region mask and the von Mises stress field; Calculate the stress concentration factor according to the sequence of von Mises stress submaps; Predict the crack initiation probability by combining the stress concentration factor with the material fatigue limit parameters.
8. A casting detection system based on machine vision, based on the machine vision-based casting detection method according to any one of claims 1 to 7, characterized in that: Including: A shrinkage stress fusion module, a dynamic scanning frame generation module, a polarized image acquisition module, a defect feature extraction module, and a crack prediction module. The shrinkage stress fusion module is used to obtain the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point, and ambient temperature, and fuse it with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map; The dynamic scanning frame generation module is used to extract the boundary coordinates of the region where the risk value exceeds the risk threshold according to the defect risk weight map to form a dynamic attention region scanning frame; The polarized image acquisition module is used to adjust the incident angle of the polarized light source according to the trajectory of the dynamic attention region scanning frame and collect local images to obtain a high-contrast image sequence that eliminates the interference of the surface oxide layer; The defect feature extraction module is used to extract the defect edge feature map from the high-contrast image sequence through a deformable convolution kernel and obtain the defect candidate region mask; The crack prediction module is used to map the defect candidate region mask to the von Mises stress field and predict the crack initiation probability in combination with the material fatigue limit parameters.
9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the machine vision-based casting detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the machine vision-based casting detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Metal surface crack detection and real size measurement method and system based on machine vision
CN114719749A
Mechanical casting cold and hot crack self-adaptive distinguishing method based on computer vision
CN115063423A
Automobile casting surface defect detection method based on machine vision
CN116703907A
Method for automatically identifying internal defects of casting
CN117197146A
X-ray-based nondestructive testing method and system for internal defects of power supply equipment
CN118566266A
Cited By
Polar ultralow temperature detection method and system based on temperature sensor
CN120782426A
Inorganic mineral casting stress analysis method and system based on virtual simulation system
CN120805514A
Stress Analysis Method and System for Inorganic Mineral Castings Based on Virtual Simulation System
CN120805514B
Optimization design method and system for spheroidal graphite casting structure
CN120930440A
Copper bar conducting layer welding defect detection method based on machine vision
CN120976142A