Method and system for casting detection based on machine vision
By fusing the three-dimensional dynamic shrinkage field and the von Mises stress field of the casting to generate a defect risk weight map, adjusting the incident angle of the polarized light source, and using deformable convolution kernels to extract defect edge feature maps, the accuracy problem of casting inspection in complex environments is solved, and the inspection effect and quality control level are improved.
Patent Information
- Application Number
- CN202510478079.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-04-16
AI Technical Summary
Existing machine vision-based casting inspection technologies are inaccurate in detecting defects in complex environments and struggle to effectively integrate the relationship between internal stress fields and external geometry, leading to increased accuracy in casting inspection and higher quality control costs.
By fusing the three-dimensional dynamic shrinkage field of the casting with the von Mises stress field, a defect risk weight map is generated. The incident angle of the polarized light source is adjusted to obtain a high-contrast image. The defect edge feature map is extracted using deformable convolution kernels, and the probability of crack initiation is predicted by combining the material fatigue limit parameters.
It improves the accuracy and reliability of casting inspection, enhances applicability under complex working conditions, and reduces repair and quality control costs.
Smart Images

Figure CN120404735B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine vision and material science, in particular to a casting detection method and system based on machine vision. BACKGROUND
[0002] With the continuous progress of industrial manufacturing technology, castings as basic components play an indispensable role in many fields such as aerospace, automobile manufacturing, mechanical engineering, etc. However, various internal and surface defects such as shrinkage, cracks, bubbles and inclusions may easily occur in the production process of castings, which will seriously affect the quality and service life of castings. Traditional casting detection methods mainly include X-ray detection, ultrasonic detection and magnetic powder detection, etc., but these methods have certain limitations, such as complex operation, high cost, strict environmental requirements and difficulty in realizing high-precision three-dimensional defect positioning. In recent years, with the development of machine vision technology, image processing-based casting detection methods have gradually emerged. This kind of method can quickly obtain the surface information of the casting by non-contact means, and use algorithm analysis to identify potential defect areas.
[0003] However, the existing machine vision-based casting detection technology still has some shortcomings. First, most of the existing technologies mainly rely on single image features for defect detection, which limits their application effect in complex environments (such as severe surface oxidation layer interference). Second, traditional methods lack effective fusion mechanisms in dealing with the relationship between internal stress field and external geometry of castings, making it difficult to accurately predict 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 cost of subsequent repair and quality control. SUMMARY
[0004] In view of the above existing problems, the present application is proposed.
[0005] Therefore, the present application provides a casting detection method based on machine vision to solve the problem of inaccurate defect detection in complex environments and difficulty in effectively fusing the relationship between internal stress field and external geometry of the existing technology.
[0006] To solve the above technical problems, the present application provides the following technical solutions:
[0007] In a first aspect, the present application provides a machine vision-based casting detection method, which comprises: obtaining a three-dimensional dynamic shrinkage field of a casting based on pouring temperature, material melting point and environmental temperature, and fusing a von Mises stress field obtained through finite element analysis to generate a defect risk weight map; extracting region boundary coordinates of a region with a risk value exceeding a risk threshold according to the defect risk weight map to form a dynamic attention region scanning frame; adjusting an incident angle of a polarized light source according to a trajectory of the dynamic attention region scanning frame, and collecting a local image to obtain a high-contrast image sequence eliminating interference of a surface oxidation layer; extracting a defect edge feature map from the high-contrast image sequence through a deformable convolution kernel, and obtaining a defect candidate region mask; and mapping the defect candidate region mask to the von Mises stress field, and combining a material fatigue limit parameter to predict a crack initiation probability.
[0008] As a preferred scheme of the machine vision-based casting detection method, the method comprises the following steps:
[0009] A three-dimensional dynamic shrinkage field is constructed through a thermodynamic gradient field equation in combination with a material shrinkage coefficient.
[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 the defect risk weight map.
[0011] The defect risk weight map is normalized to generate a standard risk value, and a risk region is judged.
[0012] As a preferred scheme of the machine vision-based casting detection method, the method comprises the following steps:
[0013] A high-risk region binary mask is obtained, and boundary coordinates are accurately extracted through phase consistency edge detection.
[0014] The boundary coordinates are mapped to scanning frame motion parameters, and the scanning frame motion parameters include a scanning center, a scanning radius and a scanning angular velocity.
[0015] A time-space trajectory equation of the scanning frame is constructed based on the scanning frame motion parameters to generate the dynamic attention region scanning frame.
[0016] As a preferred scheme of the casting detection method based on machine vision, wherein: according to the track of the dynamic focus area scanning frame, the incident angle of the polarized light source is adjusted, and the local image is collected to obtain a high-contrast image sequence eliminating the interference of the surface oxide layer, the specific steps are as follows,
[0017] According to the track of the dynamic focus area scanning frame, the gradient amplitude of the three-dimensional dynamic shrinkage field and the von Mises stress field amplitude are obtained, and the basis polarization angle is obtained by combining the arctangent function;
[0018] The sine wave term is superimposed on the basis polarization angle, the random distribution characteristics of the oxide layer thickness and the grain orientation are compensated by periodic angle fine adjustment, and the incident angle instruction sequence of the polarized light source is generated;
[0019] According to the instruction sequence, the incident angle of the polarized light source is adjusted, and the local image is collected to obtain a double-angle image sequence;
[0020] According to the double-angle image sequence and the three-dimensional dynamic shrinkage field gradient amplitude, a high-contrast image sequence is generated, and a high-contrast image sequence eliminating the interference of the surface oxide layer is obtained.
[0021] As a preferred scheme of the casting detection method based on machine vision, wherein: the defect edge feature map is extracted from the high-contrast image sequence by a deformable convolution kernel, and the specific steps are as follows,
[0022] The high-contrast image sequence and the defect risk weight map are respectively subjected to multi-scale convolution feature extraction, and are spliced along the channel dimension to generate a multi-scale fusion feature map;
[0023] According to the three-dimensional dynamic shrinkage field gradient, an offset field is generated, and a deformable convolution kernel is applied to the multi-scale fusion feature map to perform deformable convolution operation;
[0024] The convolution operation result is subjected to non-maximum suppression and Sobel edge detection to generate a defect edge feature map.
[0025] As a preferred scheme of the casting detection method based on machine vision, wherein: the defect candidate region mask is obtained, and the specific steps are as follows,
[0026] The defect risk weight map is scaled to the same resolution as the defect edge feature map by bilinear interpolation, and a spatial attention weight map is obtained;
[0027] Based on the spatial attention weight map, the attention weight is applied to the defect edge feature map, and the feature map is aligned to generate a spatially aligned fusion feature map
[0028] The spatially aligned fusion feature map is subjected to adaptive threshold segmentation by OTSU algorithm to generate a binary mask;
[0029] performing an open operation on the binary mask to generate a defect candidate region mask.
[0030] As a preferred scheme of the casting detection method based on machine vision, the method comprises the following steps of:
[0031] spatiotemporally aligning the defect candidate region mask with the von Mises stress field;
[0032] calculating a stress concentration factor according to the von Mises stress field subgraph sequence;
[0033] predicting a crack initiation probability by combining the stress concentration factor with a material fatigue limit parameter.
[0034] In a second aspect, the application provides a casting detection system based on machine vision, comprising 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.
[0035] In a third aspect, the application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to implement any step of the casting detection method based on machine vision according to the first aspect of the application.
[0036] In a fourth aspect, the application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement any step of the casting detection method based on machine vision according to the first aspect of the application.
[0037] The application has the beneficial effects that: the three-dimensional dynamic shrinkage field of the casting is calculated and fused with the Von Mises stress field to generate a defect risk weight map, and the high-risk area is accurately identified; at the same time, the incident angle of the polarized light source is adjusted according to the dynamic attention area, and a high-contrast image sequence eliminating the interference of the surface oxide layer is obtained. The two key steps not only improve the accuracy and reliability of the detection, but also significantly improve the applicability under complex working conditions, thereby effectively improving the casting quality control level and reducing the repair and quality control cost. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0039] Fig. 1 Flow chart for generating the defect risk weight map in Example 1.
[0040] Fig. 2 Flow chart for generating the dynamic scanning frame in Example 1.
[0041] Fig. 3 Flow chart for polarized image acquisition in Example 1.
[0042] Fig. 4 Flow chart for defect detection and prediction in Example 1. DETAILED DESCRIPTION
[0043] In order to make the above-mentioned purposes, features and advantages of the present application more apparent and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings.
[0044] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application, but the present application can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of the present application, therefore the present application is not limited to the specific embodiments disclosed below.
[0045] Secondly, the "one embodiment" or "embodiment" referred to herein means that the specific features, structures or characteristics can be included in at least one implementation of the present application. "In one embodiment" appearing in different places in the specification does not mean the same embodiment, nor is it an independent or alternative embodiment that excludes other embodiments.
[0046] Example 1, with reference to Figs. 1-4 The embodiment provides a casting detection method based on machine vision, comprising the following steps:
[0047] S1: Obtain the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point and environmental temperature, and fuse the von Mises stress field obtained by finite element analysis to generate a defect risk weight map;
[0048] S1.1: Temperature parameter acquisition and preprocessing;
[0049] The pouring temperature is collected in real time by an infrared thermometer, the melting point is called from a material database, the environmental temperature and humidity are obtained using an environmental temperature and humidity sensor, and normalization processing is performed.
[0050] S1.2: Obtain the three-dimensional dynamic shrinkage field of the casting based on the pouring temperature, material melting point and environmental temperature;
[0051] Further, the pouring temperature, material melting point and environmental temperature are input into a thermodynamic gradient field equation, combined with the material shrinkage coefficient, and the nonlinear influence of the second derivative term of the temperature field on the shrinkage amount is calculated to obtain the initial shrinkage amount distribution of each point in the three-dimensional space;
[0052] Subsequently, an adaptive meshing method is used to discretize the casting geometry model, local mesh is encrypted in the sprue, thin wall and cooling channel area, and the finite difference method is used to solve the numerical solution of the shrinkage amount at the discrete nodes;
[0053] Finally, the maximum-minimum normalization is used to map the shrinkage amount of each node to the standard interval to generate a three-dimensional dynamic shrinkage field strictly matched with the geometry of the casting.
[0054] S1.3: Normalize the three-dimensional dynamic shrinkage field and the von Mises stress field, and fuse them combined with the asymmetric interaction function to generate a defect risk weight map, the expression is:
[0055]
[0056] Wherein, R(x,y) is the defect risk weight map, ΔV is the normalized three-dimensional dynamic shrinkage field, σ is the normalized von Mises stress field, is the stress field Laplace operator, ∈ is a very small constant to prevent the denominator from being zero, represents the rate of change of the three-dimensional dynamic shrinkage field along the z direction in the space rectangular coordinate system;
[0057] It should be noted that the specific steps of the von Mises stress field obtained by finite element analysis are as follows,
[0058] According to the geometric size and structural characteristics of the casting, a three-dimensional solid model including the sprue, riser and cooling channel is constructed by CAD software;
[0059] The elastic modulus, Poisson's ratio, yield strength parameters are called from the material database, the pouring temperature is set as the initial temperature condition, and the environmental temperature is set as the heat dissipation boundary condition.
[0060] The tetrahedral elements are used to adaptively mesh the three-dimensional model, and the local encryption is performed on the high-curvature area and thin-wall area to ensure the stress field calculation accuracy.
[0061] The thermal expansion effect of the pouring process is converted into an equivalent temperature load, and the displacement constraint condition generated by the cooling shrinkage is combined to generate the thermal stress distribution.
[0062] The stress tensor of each node is obtained based on the finite element solver, and the stress field distribution data is extracted to generate the von Mises stress field.
[0063] The defect risk weight map is normalized to generate a standard risk value, and a risk area is judged.
[0064] Further according to the historical data, the risk threshold is set, when the standard risk value is greater than the risk threshold, it is judged as a high-risk area, when the standard risk value is less than or equal to the risk threshold, it is judged as a safe area.
[0065] S2: According to the defect risk weight map, the region boundary coordinates of the risk value exceeding the risk threshold are extracted to form a dynamic attention area scanning frame;
[0066] S2.1: Obtain the high-risk area binary mask, and accurately extract the boundary coordinates through phase consistency edge detection, the expression is:
[0067]
[0068] wherein, is the boundary coordinate set, O is the multi-scale direction number, A o is the response amplitude of the Gabor filter of the oth direction, φ o is the phase angle of the oth direction, is the average phase, η is the phase consistency threshold, φ o (x,y) is the local phase angle of the oth direction at coordinates (x,y), is the weighted average value of the phase angle at coordinates (x,y), A o (x,y) is the response amplitude of the oth direction at coordinates (x,y);
[0069] It should be noted that the normalized defect risk weight map is threshold segmented, the risk threshold is set to mark the area higher than the threshold as a foreground pixel to generate an initial binary mask.
[0070] The initial binary mask is decomposed in frequency domain by using a multi-scale and multi-direction Gabor filter bank, and a phase consistency measurement value of each pixel point in the frequency domain is calculated. Local maximum points are reserved in the phase consistency response map by using a non-maximum suppression algorithm;
[0071] An adaptive threshold segmentation method is used to extract edge pixel points with a phase consistency value exceeding a set threshold, forming a candidate edge point set;
[0072] A morphological thinning algorithm is used to remove edge breakpoints and connect adjacent edge segments. An edge tracking algorithm is used to traverse the connected region contour, and an accurate closed boundary coordinate set is output.
[0073] S2.2: Map the boundary coordinate set to the scanning frame motion parameters, including 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] The Euclidean distance of each point in the boundary point set to the scanning center is calculated, the maximum distance value is selected as the initial scanning radius, and the time decay factor in the trajectory equation of the dynamic attention area scanning frame is superimposed to generate a scanning radius parameter that decreases with time;
[0076] According to the regional distribution density of the defect risk weight map, the corresponding angular velocity reference value is queried through a density-angular velocity mapping table, and the final scanning angular velocity is adjusted according to the shape complexity coefficient of the boundary coordinate set (calculated by the aspect ratio and the standard deviation of the contour curvature).
[0077] Based on the scanning frame motion parameters, a spatio-temporal trajectory equation of the scanning frame is constructed 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] Wherein, Ψ(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 horizontal coordinate value of the scanning center in the Cartesian coordinate system, and y c is the vertical coordinate value of the scanning center in the Cartesian coordinate system;
[0080] It should be noted that the scanning center coordinates are taken as the origin of the polar coordinate system, and the scanning radius is determined by the initial maximum value and the time decay factor, forming a polar radius function with exponential decay of the radius with time;
[0081] The polar angle is obtained by multiplying the scanning angular velocity with the time parameter, and the space-time trajectory equation is generated by a polar coordinate-Cartesian coordinate conversion formula to describe the movement path of the scanning frame center point over time;
[0082] The discrete trajectory points are connected into a continuous motion trajectory by an interpolation algorithm, and a dynamic attention area scanning frame covering the high-risk area and shrinking over time is generated in combination with the preset scanning frame size parameter.
[0083] S3: According to the trajectory of the dynamic attention area scanning frame, the incident angle of the polarized light source is adjusted, and a local image is collected to obtain a high-contrast image sequence eliminating the interference of the surface oxidation 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 coordinates of the trajectory points of the dynamic attention area scanning frame, the gradient amplitude of the three-dimensional dynamic shrinkage field and the von Mises stress field amplitude are obtained;
[0086] It should be noted that based on the space-time trajectory equation of the dynamic attention area scanning frame, the spatial coordinates corresponding to the current trajectory point are analyzed; from the discretized grid data of the three-dimensional dynamic shrinkage field, the three-dimensional spatial gradient components of the coordinate point are extracted by bilinear interpolation, and the 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 by nearest neighbor interpolation as the stress field amplitude.
[0087] Divide the gradient amplitude of the three-dimensional dynamic shrinkage field by the von Mises stress field amplitude plus a small constant, take the inverse tangent function of the quotient value, and 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 shrinkage field, and the square root of the sum of the squares of the components of the gradient vector in three orthogonal directions is obtained by calculation;
[0089] The normalized stress amplitude of the corresponding coordinate point is obtained from the von Mises stress field, and a preset small constant is added to avoid a zero denominator;
[0090] Divide the result of the gradient amplitude and the stress amplitude plus a small constant to obtain the quotient value representing the gradient-stress correlation strength;
[0091] Apply the inverse tangent function to the quotient value to map the linear proportional relationship to the [-π / 2, π / 2] angle interval to generate a basic polarization angle positively correlated with the material shrinkage gradient and stress concentration degree.
[0092] Superimpose a sinusoidal fluctuation term on the base polarization angle to compensate for the random distribution characteristics of the oxide layer thickness and grain orientation by periodic angle fine-tuning, and generate the incident angle instruction sequence of the polarized light source;
[0093] It should be noted that the periodic angle adjustment component is generated by analyzing the randomness of the oxide layer thickness distribution and grain orientation;
[0094] The periodic angle adjustment component dynamically modulates the base polarization angle in the form of a sinusoidal function, and covers the local differences in oxide layer thickness and grain orientation using the continuous change characteristics of the fluctuation;
[0095] The amplitude of the sinusoidal fluctuation is adaptively adjusted according to the thickness variation range of the oxide layer, and the greater the thickness difference, the stronger the amplitude. The frequency is set according to the spatial distribution density of the grain orientation, and a higher frequency fluctuation is used in high-density areas to match the rapid change in orientation;
[0096] Combined with random initial phase offset, the modulation angle difference between adjacent scanning areas is maximized;
[0097] Arrange the modulated polarization angle according to the time sequence of the scanning frame trajectory to form an incident angle instruction sequence synchronized with the spatial distribution of the dynamic attention area, and realize point-by-point compensation of the oxide layer interference.
[0098] S3.2: Adjust the incident angle of the polarized light source according to the instruction sequence, and collect local images;
[0099] Adjust the incident angle of the polarized light source from the current incident angle to the target incident angle according to the instruction sequence, and offset the camera position to the extension line of the dynamic attention area scanning frame trajectory point along the von Mises stress field gradient direction. According to the current scanning radius of the dynamic attention area scanning frame and the polarization angle, the lens focal length is adjusted in real time: the focal length is lengthened when the scanning radius increases, and the focal length is shortened when the incident angle is large.
[0100] After the light source is stabilized to the target angle, local image acquisition is performed to obtain a double-angle image sequence.
[0101] S3.3: Generate a high-contrast image sequence according to the double-angle image sequence and the three-dimensional dynamic shrinkage field gradient amplitude;
[0102] Difference denoising and normalization processing is performed on the double-angle image sequence to generate a difference image;
[0103] It should be noted that two polarized angle images collected at the same dynamic attention area scanning frame trajectory point are extracted from the double-angle image sequence, and the original difference image is obtained through pixel-level difference operation;
[0104] The morphological filtering algorithm is used for noise suppression of the original difference image, specifically including performing an open operation of a circular structural element with a radius of 2 pixels to eliminate isolated noise points and retain the connected region of the defect edge;
[0105] The filtered difference image is normalized, and the pixel value is linearly mapped to the interval [0, 1] by calculating the difference between the maximum pixel value and the minimum pixel value in the image;
[0106] The normalized result is locally contrast enhanced in combination with the gradient amplitude of the three-dimensional dynamic shrinkage field, specifically: in the region where the gradient amplitude is higher than the set threshold, the pixel value is nonlinearly compressed by using the hyperbolic tangent function, while in the low gradient region, linear stretching is used to generate a high-contrast difference image.
[0107] According to the gradient amplitude of the three-dimensional dynamic shrinkage field, the high gradient region is given a low weight, and the low gradient region is given a high weight, a weight map is generated, and the weight map is multiplied by the normalized difference image, to retain the defect signal while suppressing the background noise;
[0108] And according to the spatial order of the dynamic attention area scanning frame trajectory, the processed local images are spliced into a global image sequence, and a high-contrast image sequence that eliminates the interference of the surface oxidation layer is obtained.
[0109] S4: Extracting defect edge feature map from high-contrast image sequence through deformable convolution kernel, and obtaining defect candidate region mask;
[0110] S4.1: Based on the high-contrast image sequence and the defect risk weight map, multi-scale feature fusion is performed;
[0111] Further, the high-contrast image sequence and the defect risk weight map are respectively subjected to multi-scale convolution feature extraction, and are spliced 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 convolution layers to extract multi-scale features containing local details, medium structures and global semantics;
[0113] The defect risk weight map is input into another independent multi-scale feature extraction branch to extract multi-scale features of spatial weight distribution through the same structure of convolution kernel;
[0114] The convolution output of the high-contrast image sequence and the convolution output of the defect risk weight map are spliced 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 spliced again along the channel dimension to generate a multi-scale fusion feature map containing multi-scale spatial weight information and defect feature correlation.
[0116] S4.2: Extracting defect edge feature map from multi-scale fusion feature map through deformable convolution kernel;
[0117] Generating offset field according to three-dimensional dynamic shrinkage field gradient, applying deformable convolution kernel to multi-scale fusion feature map, and performing 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 shrinkage field, and the normalized gradient vector is generated through normalization processing;
[0119] The normalized gradient vector is decomposed into two-dimensional offset components along the projection direction of the plane, and the offset field is generated through a linear mapping function;
[0120] Aligning the spatial dimensions of the offset field and the multi-scale fusion feature map, and dynamically adjusting the sampling position of the convolution kernel according to the offset at the feature map coordinate through the deformation sampling mechanism of the deformable convolution kernel;
[0121] Performing weighted summation on the resampled feature values to generate a deformable convolution output feature map that adapts to the gradient distribution of the three-dimensional dynamic shrinkage field.
[0122] Performing 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: Spatial alignment of defect edge feature map and defect risk weight map through cross-layer attention mechanism;
[0124] Scaling the defect risk weight map to the same resolution as the defect edge feature map through bilinear interpolation, and calculating the spatial attention weight map; performing feature map alignment by applying attention weight to the defect edge feature map, and generating a spatially aligned fusion feature map.
[0125] It should be noted that the target interpolation grid size is determined based on the spatial resolution parameters of the defect edge feature map; the bilinear interpolation algorithm is used to resample each pixel point of the defect risk weight map, and the interpolated pixel value is calculated by weighted average of adjacent four pixel points, obtaining the 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 convolution layer and Sigmoid activation function, and output the spatial attention weight map with a range of [0, 1];
[0127] Performing element-wise multiplication operation between the spatial attention weight map and the defect edge feature map, strengthening the feature response corresponding to the high defect risk area in the defect edge feature map, and suppressing the noise signal in the low risk area.
[0128] It should be noted that the weight value of each pixel point in the spatial attention weight map represents the probability that the corresponding position belongs to a high defect risk area, and the numerical range is between 0 and 1, wherein the weight value close to 1 corresponds to a high risk area;
[0129] The feature response value of each pixel point in the defect edge feature map reflects the possibility of the existence of the defect edge at this position, and the higher the value, the more significant the edge feature.
[0130] In the element-by-element multiplication process, the high weight value of 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 of the low risk area is multiplied by the low response value of the noise or background feature to further reduce it, realizing the differentiated modulation of the feature response amplitude;
[0131] The modulated fusion feature map is complementary to the original defect edge feature map through channel splicing, and the effective edge details not covered by the weight map are retained.
[0132] The weighted defect edge feature map and the original defect edge feature map are fused through a channel splicing operation, and a convolution 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 original defect edge feature map without modulation are spliced along the channel dimension to form an intermediate feature map with double the number of channels.
[0134] A convolution kernel of a preset size is used to fuse the cross-channel information of the spliced feature map, and the weight learning mechanism of the convolution kernel automatically captures the complementary relationship between the weighted feature map and the original feature map, suppresses redundant information, and strengthens the effective edge response;
[0135] An interpolation alignment operation is performed on the convolution output feature map in the spatial dimension to eliminate the slight positional offset introduced by weight modulation or convolution operation, and a fusion feature map strictly matched with the spatial resolution of the defect risk weight map is generated.
[0136] S4.4: generating 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 gray feature map;
[0139] The histogram distribution of pixel values in the grayscale feature map is statistically analyzed. By traversing the candidate thresholds, the inter-class variance between the foreground and background regions corresponding to each threshold is calculated. The threshold that maximizes the inter-class variance is selected as the optimal segmentation threshold.
[0140] Regions in the grayscale feature map with pixel values greater than the optimal segmentation threshold are marked as 1, and regions with pixel values less than or equal to the threshold are marked as 0, thus generating an initial binary mask;
[0141] A morphological closing operation is performed on the initial binarized mask, and rectangular structuring elements are used to eliminate holes inside the mask and smooth the edge contours to generate the final binarized mask.
[0142] Perform an opening operation on the binarized mask to generate a defect candidate region mask;
[0143] It should be noted that a rectangular structuring element is used to perform morphological erosion on the binarized mask to eliminate isolated noise points with an area smaller than the structuring element and to refine the edge contour.
[0144] The morphological dilation operation is performed on the etched mask using rectangular structuring elements of the same size to restore the effective defect area size that was reduced due to the etch operation, while maintaining edge smoothness.
[0145] By analyzing connected components, the independent regions in the expanded mask are marked, and residual interference regions with an area smaller than a preset threshold are removed.
[0146] The processed mask is logically ANDed with the original binary mask, and the regions that simultaneously satisfy the opening operation morphological constraints and the original segmentation result are retained to generate defect candidate region masks.
[0147] S5: The defect candidate region is masked and mapped to the von Mises stress field, and the crack initiation probability is predicted by combining the material fatigue limit parameters.
[0148] S5.1: Spatiotemporally align the defect candidate region mask with the von Mises stress field;
[0149] The pixel coordinates of the defect candidate region mask are mapped to the corresponding positions of the von Mises stress field. Based on the spatial mapping relationship of the dynamic interest region scan box trajectory, the local coordinates of the mask are transformed 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 scanning box of the dynamic interest region 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] Based on the scanning angular velocity time parameters at the trajectory points, the local coordinates of the defect candidate region mask are transformed into global coordinates through polar coordinate transformation;
[0152] Based on the finite element grid node distribution data of the von Mises stress field, the stress field node index corresponding to the global coordinates is calculated through a bilinear interpolation algorithm;
[0153] The converted global coordinates are associated with the finite element node index to generate a spatial mapping relationship table of the defect candidate region in the von Mises stress field.
[0154] For each defect candidate region, the von Mises stress field subgraph within its bounding box is extracted to generate a von Mises stress field subgraph sequence aligned with the defect region;
[0155] It should be noted that based on the connected domain analysis result of the defect candidate region mask, the minimum circumscribed rectangular boundary box parameters of the mask are extracted, including the center coordinates, width and height;
[0156] According to the global coordinate mapping relationship in the dynamic attention region scanning frame trajectory equation, the local center coordinates of the bounding box are converted to the global coordinate system position corresponding to the von Mises stress field;
[0157] From the finite element grid node distribution data, the stress field data centered on the global center coordinates and within the range of width and height are intercepted, and the discrete node stress values are resampled into a stress field subgraph with the same spatial resolution as the defect candidate region through a bilinear interpolation algorithm;
[0158] The spatial alignment accuracy is verified by calculating the Euclidean distance between the stress field subgraph centroid coordinates and the defect candidate region centroid. If the error exceeds the preset threshold, the interpolation parameters are adjusted to generate a von Mises stress field subgraph sequence that is accurately aligned with the defect region.
[0159] S5.2: Calculate the stress concentration factor according to the von Mises stress field subgraph sequence;
[0160] The maximum stress value of each subgraph is extracted from the von Mises stress field subgraph sequence, and the extension reference stress of the defect candidate region is calculated. The reference stress is obtained by taking the mean value after Gaussian smoothing of the stress field data of the 10% area outside the defect candidate region boundary box;
[0161] Based on the binary profile of the defect candidate region mask, the major axis length and the minor axis length are obtained by fitting an elliptical equation through the least squares method;
[0162] According to the stress concentration factor theory, the local stress concentration factor is calculated. Finally, the stress field subgraph sequence of the same defect candidate region at different times of the dynamic attention region scanning frame trajectory is calculated, and the sliding window mean value is taken to generate the final stress concentration factor.
[0163] S5.3: Combine the stress concentration factor with the material fatigue limit parameter to predict the crack initiation probability;
[0164] According to the stress concentration factor and the material fatigue limit, the equivalent alternating stress amplitude is calculated by the modified Goodman criterion;
[0165] Based on the material S-N curve parameters, the fatigue damage degree is calculated by the Miner linear cumulative damage theory.
[0166] The equivalent alternating stress amplitude is mapped to the crack initiation probability by the Weibull distribution function, and the probability value is limited in the interval [0, 1] by normalization processing.
[0167] The embodiment also provides a cast detection system based on machine vision, comprising: a shrinkage stress fusion module, configured to obtain a three-dimensional dynamic shrinkage field of a cast based on pouring temperature, material melting point and environmental temperature, and fuse a von Mises stress field obtained through finite element analysis to generate a defect risk weight map; a dynamic scanning frame generation module, configured to extract boundary coordinates of a region with a risk value exceeding a risk threshold according to the defect risk weight map to form a dynamic attention area scanning frame; a polarized image acquisition module, configured to adjust an incident angle of a polarized light source according to a track of the dynamic attention area scanning frame, and acquire a local image to obtain a high-contrast image sequence eliminating interference of a 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 region mask; and a crack prediction module, configured to map the defect candidate region mask to the von Mises stress field, and predict a crack initiation probability in combination with a material fatigue limit parameter.
[0168] The embodiment also provides a computer device suitable for the cast detection method based on machine vision, comprising: a memory and a processor; the memory is configured to store computer executable instructions, and the processor is configured to execute the computer executable instructions to implement the cast detection method based on machine vision proposed in the above embodiment.
[0169] The computer device can be a terminal, and the computer device comprises a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises 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 running the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is configured to perform wired or wireless communication with external terminals. The wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or can be a key, trackball or touchpad arranged on the shell of the computer device, or can be an external keyboard, touchpad or mouse, etc.
[0170] The embodiment also provides a storage medium on which a computer program is stored, the program being executed by a processor to implement the method for detecting a casting based on machine vision as 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 a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.
[0171] To sum up, the application achieves the following: a three-dimensional dynamic shrinkage field of a casting is calculated and fused with a von Mises stress field to generate a defect risk weight map, and a high-risk area is accurately identified; at the same time, the incident angle of a polarized light source is adjusted according to a dynamic attention area, and a high-contrast image sequence that eliminates the interference of a surface oxide layer is obtained. The two key steps not only improve the accuracy and reliability of detection, but also significantly improve the applicability under complex working conditions, thereby effectively improving the casting quality control level and reducing repair and quality control costs.
[0172] It should be noted that the above embodiments are only used to illustrate the technical solutions of the application rather than limit the application. Although the application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the application, and all should be covered in the scope of the claims of the application.
Claims
1. A machine vision-based method for inspecting castings, characterized in that: include, The three-dimensional dynamic shrinkage field of the casting is obtained based on the pouring temperature, material melting point and ambient temperature, and then fused with the von Mises stress field obtained by finite element analysis to generate a defect risk weight map. Based on the defect risk weight map, extract the boundary coordinates of the regions where the risk value exceeds the risk threshold to form a dynamic scan box of the region of interest. Based on the trajectory of the scanning box of the dynamic region of interest, the incident angle of the polarized light source is adjusted, and local images are acquired to obtain a high-contrast image sequence that eliminates interference from the surface oxide layer. Defect edge feature maps are extracted from high-contrast image sequences using deformable convolution kernels, and defect candidate region masks are obtained. The candidate defect region is masked onto the von Mises stress field, and the crack initiation probability is predicted by combining the material fatigue limit parameter.
2. The machine vision-based casting inspection method as described in claim 1, characterized in that: The three-dimensional dynamic shrinkage field of the casting is obtained based on the pouring temperature, material melting point, and ambient temperature, and then fused with the von Mises stress field obtained through finite element analysis to generate a defect risk weight map. The specific steps are as follows: By combining the material shrinkage coefficient, a three-dimensional dynamic shrinkage field is constructed using the thermodynamic gradient field equation; The three-dimensional dynamic contraction field and the von Mises stress field are normalized and fused with an asymmetric interaction function to generate a defect risk weight map. The defect risk weight map is normalized to generate standard risk values, and risk areas are identified.
3. The machine vision-based casting inspection method as described in claim 2, characterized in that: The specific steps for extracting the boundary coordinates of regions with risk values exceeding the risk threshold based on the defect risk weight map to form a dynamic region of interest scanning box are as follows. Obtain a binary mask for high-risk areas and accurately extract boundary coordinates through phase-consistent edge detection; The boundary coordinate set is mapped to scan frame motion parameters, which include scan center, scan radius and scan angular velocity; Based on the motion parameters of the scan box, the spatiotemporal trajectory equation of the scan box is constructed to generate a dynamic scan box of the region of interest.
4. The machine vision-based casting inspection method as described in claim 3, characterized in that: The steps for adjusting the incident angle of the polarized light source based on the trajectory of the scanning box of the dynamic region of interest, acquiring local images, and obtaining a high-contrast image sequence with the surface oxide layer interference eliminated are as follows: Based on the trajectory of the scanning box of the dynamic region of interest, the gradient magnitude of the three-dimensional dynamic contraction field and the magnitude of the von Mises stress field are obtained, and the basic polarization angle is obtained by combining the arctangent function. By superimposing a sinusoidal wave term on the basic polarization angle, and by periodically fine-tuning the angle to compensate for the random distribution characteristics of oxide layer thickness and grain orientation, a sequence of polarization light source incident angle command is generated. Adjust the incident angle of the polarized light source according to the instruction sequence, and acquire local images to obtain a dual-angle image sequence; Based on the dual-angle image sequence and the three-dimensional dynamic contraction field gradient magnitude, a high-contrast image sequence is generated, and a high-contrast image sequence with the surface oxide layer interference eliminated is obtained.
5. The machine vision-based casting inspection method as described in claim 4, characterized in that: The specific steps for extracting defect edge feature maps from high-contrast image sequences using deformable convolution kernels are as follows. High-contrast image sequences and defect risk weight maps are subjected to multi-scale convolutional feature extraction, and then stitched together along the channel dimension to generate a multi-scale fused feature map. An offset field is generated based on the gradient of the three-dimensional dynamic shrinking field, and deformable convolution kernels are applied to the multi-scale fused feature map to perform deformable convolution operations. Non-maximum suppression and Sobel edge detection are applied to the convolution operation results to generate defect edge feature maps.
6. The machine vision-based casting inspection method as described in claim 5, characterized in that: The specific steps for obtaining the defect candidate region mask are as follows: The defect risk weight map is scaled to the same resolution as the defect edge feature map using bilinear interpolation, and a spatial attention weight map is obtained. Based on the spatial attention weight map, attention weights are applied to the defect edge feature map, and feature map alignment is performed to generate a spatially aligned fused feature map. The spatially aligned fused feature map is adaptively thresholded using the OTSU algorithm to generate a binary mask. Perform an opening operation on the binarized mask to generate a defect candidate region mask.
7. The machine vision-based casting inspection method as described in claim 6, characterized in that: The specific steps for mapping the defect candidate region mask to the von Mises stress field and predicting the crack initiation probability by combining it with the material fatigue limit parameters are as follows. The defect candidate region mask is spatiotemporally aligned with the von Mises stress field; Calculate the stress concentration factor based on the von Mises stress field subplot sequence; The stress concentration factor is combined with the material fatigue limit parameter to predict the probability of crack initiation.
8. A machine vision-based casting inspection system, based on the machine vision-based casting inspection method according to any one of claims 1 to 7, characterized in that: include, The module includes a shrinkage stress fusion module, a dynamic scanning frame generation module, a polarization 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 by finite element analysis to generate a defect risk weight map. The dynamic scan box generation module is used to extract the boundary coordinates of areas where the risk value exceeds the risk threshold based on the defect risk weight map, and form a dynamic scan box of the area of interest. The polarization image acquisition module is used to adjust the incident angle of the polarization light source according to the trajectory of the scanning box of the dynamic region of interest, and to acquire local images to obtain a high-contrast image sequence that eliminates interference from the surface oxide layer. The defect feature extraction module is used to extract defect edge feature maps from high-contrast image sequences using deformable convolution kernels and obtain defect candidate region masks. The crack prediction module is used to map the defect candidate region mask to the von Mises stress field and combine it with the material fatigue limit parameters to predict the crack initiation probability.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the machine vision-based casting inspection 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 inspection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Automobile casting surface defect detection method based on machine vision
CN116703907A
Method for automatically identifying internal defects of casting
CN117197146A