A method for inspecting the stamping quality of stamped parts

By introducing a spatial prior weight map of a 3D model and an improved feature extraction operator, combined with a weighted kernel function and a cost-sensitive learning support vector machine classifier, the problems of low accuracy and sample imbalance in stamping quality inspection are solved, and efficient defect identification is achieved.

CN120747056BActive Publication Date: 2025-10-31BAOJI YUNJIE METAL PROD CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511187648.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-25
Publication Date
2025-10-31
Estimated Expiration
2045-08-25

AI Technical Summary

Technical Problem

Existing stamping quality inspection methods have low accuracy, especially when there are class imbalance problems and insufficient defect feature extraction, making it difficult to effectively identify defects in complex industrial scenarios.

Method used

Feature extraction is performed using a spatial prior weight map based on a 3D model. Combined with elliptical neighborhood sampling and ternary encoding, cascaded feature vectors are generated. A support vector machine classification model with weighted combination of radial basis kernel function and chi-square kernel function is used to make judgments, along with a cost-sensitive learning strategy.

Benefits of technology

It improves the sensitivity to hidden or subtle defects, enhances the distinguishability and robustness of features, solves the sample imbalance problem, and improves the accuracy of detection and the detection rate of defective parts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120747056B_ABST
    Figure CN120747056B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image processing technology and discloses a method for inspecting the stamping quality of stamped parts. The method includes acquiring a digital image of the stamped part's surface, analyzing the surface curvature and material thickness gradient, and generating a spatial prior weight map; calculating the structural tensor of each pixel to determine the orientation and axial length ratio of the elliptical sampling neighborhood; sampling pixels along the elliptical sampling neighborhood to obtain an initial ternary pattern code; constructing a global feature histogram, accumulating contribution values ​​to statistical units, where the contribution value is the corresponding weight value of the pixel in the spatial prior weight map; concatenating the global feature histograms to generate a concatenated feature vector; and inputting the concatenated feature vector into a support vector machine classification model to determine whether the stamped part is qualified. This invention introduces a spatial prior weight map, integrating prior knowledge of the stamping process into the feature extraction process, allowing the detection focus to be on high-defect areas, making the extracted features more targeted and improving the accuracy of the detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically to a method for detecting the stamping quality of stamped parts. Background Technology

[0002] Stamping is a highly efficient and low-cost metal forming method in automobile manufacturing, aerospace, and home appliance production. However, during the stamping process, due to factors such as uneven material flow, unreasonable mold design, or improper process parameter settings, the surface of stamped parts is prone to forming defects such as wrinkling, cracking, tearing, denting, and springback. These defects not only affect the aesthetics of the product but can also reduce mechanical properties and service life in severe cases, and even pose safety hazards. Existing quality inspection methods include manual visual inspection and image processing-based automated inspection methods. Manual visual inspection is highly subjective, inefficient, and costly, and is prone to missed or false detections due to human fatigue, making it difficult to meet the needs of modern mass production. Image processing-based automated inspection methods extract features from the surface image of the stamped part that can effectively distinguish between qualified and defective products, and use a classifier for discrimination. Local Binary Pattern (LBP) is commonly used in image texture analysis and defect detection. However, existing Local Binary Pattern (LBP) techniques have the following limitations: LBP uses a fixed circular neighborhood for sampling, which makes it difficult to effectively represent the anisotropic texture structures commonly found in defective regions; LBP's binarization encoding method is sensitive to image noise; LBP treats all regions in the image equally, ignoring prior knowledge that different regions have different formation difficulties, resulting in insufficient feature discrimination of the extracted features.

[0003] In terms of classifier selection, Support Vector Machines (SVMs) are commonly used for defect classification tasks. Choosing the appropriate kernel function and SVM parameters is crucial to SVM performance. However, a single type of kernel function, such as the commonly used radial basis function, often fails to fully capture the diversity and nonlinear distribution of defect features in complex industrial scenarios, resulting in limited classification capabilities. Furthermore, in actual production, the number of defective samples is usually far less than the number of qualified samples. This severe class imbalance causes the trained classification model to tend to predict samples as belonging to the majority class (qualified samples), resulting in a low recognition rate for the minority class (defective samples). Moreover, SVMs apply the same penalty to all misclassified samples during training, failing to consider those more informative "hard-to-classify" samples near the classification boundary, thus affecting the optimization of the model's decision boundary. Improving the accuracy of stamping quality inspection for stamped parts is a pressing problem in this field. Summary of the Invention

[0004] This invention provides a method for inspecting the stamping quality of stamped parts to solve the problem of low accuracy in the inspection of stamping quality of stamped parts in the prior art.

[0005] The stamping quality inspection method for stamped parts of the present invention includes the following steps:

[0006] A digital image of the surface of the stamped part to be inspected is acquired. By analyzing the surface curvature and material thickness variation gradient of each region in the preset three-dimensional geometric model of the stamped part, a spatial prior weight map representing the forming difficulty of each region is generated. The spatial prior weight map is then registered with the surface digital image. The structure tensor of the pixels in the surface digital image is calculated, and the orientation and axis ratio of the elliptical sampling neighborhood are determined based on the feature vector of the structure tensor. Pixel sampling is performed at multiple preset scales along the contour of the elliptical sampling neighborhood. The pixel values ​​of the sampled points are compared with the pixel values ​​of the center pixel to obtain the initial ternary pattern encoding. At each scale, a global feature histogram is constructed, in which each pixel in the surface digital image... The statistical unit corresponding to the pixel in the global feature histogram is obtained by encoding the rotation-invariant ternary mode of the pixel. A contribution value is accumulated in the statistical unit, where the contribution value is the corresponding weight value of the pixel in the spatial prior weight map. Global feature histograms constructed at all scales are concatenated to generate a concatenated feature vector. This concatenated feature vector is input into a support vector machine (SVM) classification model. The kernel function of the SVM classification model is a weighted combination of a radial basis function (RBF) kernel and a chi-square kernel, where the weight coefficients of each kernel function are determined by a multi-kernel learning algorithm during model training. Based on the output of the SVM classification model, the stamped part to be inspected is determined to be either a qualified part or a defective part.

[0007] Preferably, the ternary comparison is as follows: when the absolute value of the difference between the sampled pixel value and the center pixel value is less than the threshold t1, it is encoded as 0; when the sampled pixel value is greater than the center pixel value and the absolute value of the difference is not less than t1, it is encoded as 1; when the sampled pixel value is less than the center pixel value and the absolute value of the difference is not less than t1, it is encoded as 2; the initial ternary pattern encoding is cyclically shifted, and the encoding with the smallest value is taken as the rotation-invariant ternary pattern encoding of the pixel.

[0008] Preferably, the step of generating a spatial prior weight map representing the forming difficulty of each region by analyzing the surface curvature and material thickness variation gradient of each region of the preset three-dimensional geometric model of the stamped part to be tested includes: dividing the three-dimensional geometric model into a surface mesh; calculating the average curvature K and material thickness variation gradient G at the center point of each surface element; and normalizing the K and G values ​​of all surface elements to the [0,1] interval to obtain... and The weight value W of any point in the spatial prior weight map is calculated using the following formula: , where α is a preset weighting coefficient, with a value range of (0,1).

[0009] Preferably, determining the orientation and axial length ratio of the elliptical sampling neighborhood based on the eigenvectors of the structure tensor includes: for each pixel in the surface digital image, calculating the image gradients in the x and y directions within a neighborhood of a preset scale. and The structure tensor is constructed by smoothing the product of gradient components using a Gaussian function. The structural tensor S is decomposed into eigenvalues ​​to obtain two eigenvalues. and the eigenvectors v1 and v2 corresponding to the two eigenvalues; the orientation of the major axis of the elliptic sampling neighborhood is consistent with the direction of the eigenvector v1; the ratio of the major axis to the minor axis of the elliptic sampling neighborhood is set to... Set the maximum axis length ratio threshold.

[0010] Preferably, the construction of the global feature histogram includes: dividing the rotation-invariant ternary mode encoding into uniform mode and non-uniform mode, wherein if the number of cyclic transitions in the encoded code value sequence is no more than 2, it is a uniform mode; and establishing statistical units for all uniform modes and one set of non-uniform modes to construct the global feature histogram.

[0011] Preferably, the step of sampling pixels at a preset plurality of scales includes: the preset plurality of scales being ellipse semi-radius radii of R1, R2, ..., R... n Pixels, where n is the total number of scales; P pixels are uniformly sampled along the contour of the elliptical sampling neighborhood of each scale; the threshold t1 is the standard deviation of the gray values ​​of all pixels in the elliptical sampling neighborhood of the center pixel.

[0012] Preferably, the kernel function of the support vector machine classification model is a weighted combination of the radial basis function kernel function and the chi-square kernel function, including:

[0013] The weighted combination kernel function of the support vector machine classification model The calculation formula is:

[0014] ;

[0015] ;

[0016] ;

[0017] in and X j Given two feature vectors, For radial basis kernel functions, For the chi-square kernel function, For feature vectors The One component; For the feature vector X j The Each component, weighting coefficient and kernel function parameters Both η and η are determined during the training phase.

[0018] Preferably, during the training phase, the support vector machine classification model employs a cost-sensitive learning strategy, setting differentiated penalty factors for different training samples and assigning high penalty weights to minority class samples.

[0019] Preferably, the cost-sensitive learning strategy, which sets differentiated penalty factors for different training samples, includes: for the i-th sample x in the training set... i Sample x i The penalty factor C i The calculation formula is:

[0020] ;

[0021] in Basic penalty factor; As a category weight, the value for defective parts is greater than 1, and the value for qualified parts is 1. The distance weights are related to the sample x. i The functional intervals to the classification hyperplane are negatively correlated.

[0022] Preferably, the multi-core learning algorithm is the SimpleMKL algorithm.

[0023] The beneficial effects of this invention are as follows: By introducing a spatial prior weight map based on a 3D model, prior knowledge of the stamping process is integrated into the feature extraction process, allowing the detection focus to concentrate on areas with high defect incidence. The extracted features are more targeted and discriminative, improving sensitivity to hidden or subtle defects. Furthermore, the improved feature extraction operator uses elliptical neighborhood sampling, which better matches the directional structures often exhibited by defects such as scratches and wrinkles, capturing more accurate texture information compared to circular neighborhoods. Additionally, ternary encoding enhances the robustness of features to image noise, while rotation-invariant properties ensure consistency in detection results for workpieces with different orientations. Moreover, in the classification stage, a classifier constructed by weighted combination of radial basis function and chi-square kernel functions can learn the distribution patterns of complex features, improving classification accuracy. Furthermore, the cost-sensitive learning strategy sets a higher misclassification cost for minority class defect samples, solving the common sample imbalance problem in real-world industrial scenarios, improving the detection rate of defective parts, and reducing the risk of missed detections. Attached Figure Description

[0024] Figure 1This is a flowchart illustrating the stamping quality inspection method for stamped parts provided in an embodiment of the present invention. Detailed Implementation

[0025] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0026] like Figure 1 As shown, the stamping quality inspection method for stamped parts provided in this embodiment of the invention specifically includes the following steps:

[0027] S1. Obtain a digital image of the surface of the stamping part to be inspected. By analyzing the surface curvature and material thickness variation gradient of each region of the preset three-dimensional geometric model of the stamping part to be inspected, generate a spatial prior weight map representing the forming difficulty of each region. Register the spatial prior weight map with the digital image of the surface.

[0028] The stamped part to be inspected is placed on a fixed fixture, and an industrial camera mounted directly above the workpiece is used to take vertical pictures. A shadowless dome light source is used to provide uniform illumination to the surface of the stamped part in order to acquire a high-contrast and non-reflective digital image of the surface.

[0029] Import the 3D CAD model of the stamping part to be tested into finite element analysis software such as AutoForm for stamping simulation. Extract the average curvature and material tensile thinning rate of each mesh element on the surface of the 3D CAD model; use a weighted summation function, for example, weight value = ,in is the weighting coefficient for curvature, b is the weighting coefficient for thinning rate, the forming difficulty value of each unit is calculated, and a two-dimensional spatial prior weight map is generated; by extracting geometric feature point pairs such as positioning holes and edge contours on the image and model projection map, an affine transformation matrix is ​​calculated to accurately map and align the two-dimensional spatial prior weight map to the surface digital image to be detected.

[0030] S2, calculate the structure tensor of the pixels in the surface digital image, determine the orientation and axis length ratio of the elliptical sampling neighborhood based on the feature vector of the structure tensor; sample pixels at multiple preset scales along the contour of the elliptical sampling neighborhood, compare the pixel values ​​of the sampled points with the pixel values ​​of the center pixel in ternary form, and obtain the initial ternary pattern code.

[0031] For each pixel in the image, at the image pixel Calculate the gradients in the x and y directions within the neighborhood and construct... The structure tensor matrix is ​​obtained by solving for its two eigenvalues ​​λ1 and λ2 and their corresponding eigenvectors e1 and e2. The direction of the eigenvector e1 corresponding to the larger eigenvalue λ1 is taken as the major axis direction of the elliptic sampling neighborhood. The ratio of the length of the major axis to the length of the minor axis is set as the ratio of the square roots of the two eigenvalues. .

[0032] S3. At each scale, a global feature histogram is constructed, wherein each pixel in the surface digital image is encoded according to the rotation-invariant ternary mode corresponding to the pixel to obtain the statistical unit corresponding to the pixel in the global feature histogram, and the contribution is accumulated to the statistical unit, wherein the contribution is the corresponding weight value of the pixel in the spatial prior weight map; the global feature histograms constructed at all scales are concatenated to generate a concatenated feature vector.

[0033] If the number of sampling points is 8, initialize a histogram vector of length 3 to the power of 8, i.e., 6561. Each statistical unit corresponds to a rotation-invariant ternary mode code. Traverse each pixel in the image, calculate the code corresponding to the pixel, query the corresponding weight value w in the registered spatial prior weight map, and accumulate the corresponding weight value w to the statistical unit corresponding to the rotation-invariant ternary mode code in the histogram, instead of simply adding 1.

[0034] The above encoding and histogram construction process was repeated at scales with radii of 2, 4, and 6, respectively, to obtain three feature histograms of length 6561. These three histograms were then concatenated to form a single vector of length 19683, which served as the final feature vector of the stamping part image.

[0035] S4, the cascaded feature vectors are input into a support vector machine (SVM) classification model. The kernel function of the SVM classification model is a weighted combination of a radial basis function (RBF) kernel and a chi-square kernel, wherein the weight coefficients of each kernel function are determined by a multi-kernel learning algorithm during the model training phase. During the training phase, the SVM classification model employs a cost-sensitive learning strategy, setting differentiated penalty factors for different training samples and assigning high penalty weights to minority class samples. Based on the output of the SVM classification model, the stamping part to be detected is determined to be either a qualified part or a defective part.

[0036] Specifically, the SimpleMKL algorithm is used to train the support vector machine. During the iterative training process, the SimpleMKL algorithm automatically optimizes the weight coefficients β1 and β2 of the radial basis function kernel and the chi-square kernel. For defective samples belonging to the minority class in the training set, the penalty factor C of the sample is set to N times that of the qualified samples, where N is the ratio of the number of qualified samples to defective samples. For samples that were misclassified or correctly classified in the previous iteration but are close to the classification boundary (i.e., within the margin), they are further multiplied by a distance weight greater than 1 to increase the penalty factor of the sample, thereby achieving cost-sensitive learning.

[0037] The cascaded feature vector of the stamping part to be tested is input into the trained support vector machine model, and the support vector machine model will output a decision function value. If the decision function value is greater than 0, the stamping part is determined to be a defective part; if the decision function value is less than or equal to 0, it is determined to be a qualified part.

[0038] In an optional embodiment, the ternary comparison is as follows: when the absolute value of the difference between the sampled pixel value and the center pixel value is less than a threshold t1, it is encoded as 0; when the sampled pixel value is greater than the center pixel value and the absolute value of the difference is not less than t1, it is encoded as 1; when the sampled pixel value is less than the center pixel value and the absolute value of the difference is not less than t1, it is encoded as 2; the initial ternary pattern encoding is cyclically shifted, and the encoding with the smallest value is taken as the rotation-invariant ternary pattern encoding of the pixel.

[0039] Taking a scale radius R equal to 2 and the number of sampling points P equal to 8 as an example, 8 sampling points are uniformly collected along the contour of the elliptical sampling neighborhood determined in the previous step; the pixel values ​​of these 8 sampling points are compared with the pixel value of the center point. If the threshold t1 is set to 5, an 8-bit initial ternary pattern code consisting of 0, 1, and 2 is obtained, for example, 12011021; this 8-bit code is cyclically shifted left 7 times to generate a total of 8 code sequences including the initial ternary pattern code. These 8 sequences are regarded as octal numbers and converted to decimal values. The code sequence with the smallest value is selected as the rotation-invariant ternary pattern code.

[0040] In an optional embodiment, by analyzing the surface curvature and material thickness variation gradient of each region of the preset three-dimensional geometric model of the stamped part to be tested, a spatial prior weight map representing the forming difficulty of each region is generated, including: dividing the three-dimensional geometric model into a surface mesh; calculating the average curvature K and material thickness variation gradient G at the center point of each surface element; and normalizing the K and G values ​​of all surface elements to the [0,1] interval to obtain... and The weight value W of any point in the spatial prior weight map is calculated using the following formula: , where α is a preset weighting coefficient, with a value range of (0,1).

[0041] Taking a car side panel as an example, the surface of the part includes large flat areas and abruptly changing corners and reinforcing rib structures. After meshing, a surface element located at a corner of the part may have a calculated average curvature K of 0.8 due to its greater curvature, and a calculated thickness gradient G of 0.6 due to material stretching during the stamping process. Conversely, a surface element located in a flat area of ​​the part may have a K value close to 0.05 and a G value close to 0.02.

[0042] After normalizing the K and G values ​​of all face elements, the face elements at the corners... It is 0.9. The value is 0.85 for the surface element of the flat region. It is 0.06. The weight is 0.03. If the weight coefficient α is set to 0.7, the weight W of the corner region is 0.885. The weight W of the flat region is 0.051. After generating the weight map in this way, the corner region, which is more difficult to form, has a much higher weight value than the flat region, indicating that the region is a priori more prone to defects such as cracking or wrinkling.

[0043] In an optional embodiment, determining the orientation and axial length ratio of the elliptic sampling neighborhood based on the feature vector of the structure tensor includes: for each pixel in the surface digital image, calculating the image gradients in the x and y directions within a neighborhood of a preset scale. and The structure tensor is constructed by smoothing the product of gradient components using a Gaussian function. The structural tensor S is decomposed into eigenvalues ​​to obtain two eigenvalues. and the eigenvectors v1 and v2 corresponding to the two eigenvalues; the orientation of the major axis of the elliptic sampling neighborhood is consistent with the direction of the eigenvector v1; the ratio of the major axis to the minor axis of the elliptic sampling neighborhood is set to... Set the maximum axis length ratio threshold.

[0044] Suppose there is a fine, approximately vertical scratch in the acquired image of the sheet metal. For a pixel located on the fine scratch, at pixel... The gradient is calculated within the neighborhood of the scratch. Since the scratch is vertical, the image grayscale changes drastically in the horizontal direction (x-direction) but gradually in the vertical direction (y-direction). Therefore, the calculated gradient... The value is very large. The value is very small. This leads to the structure tensor S having a very small value. The item is significantly larger than the others.

[0045] Eigenvalue decomposition of the structure tensor yields a large eigenvalue λ1 (e.g., 120), with the corresponding eigenvector v1 pointing in the x-direction, and a very small eigenvalue λ2 (e.g., 3), with the corresponding eigenvector v2 pointing in the y-direction. By definition, the major axis of the elliptic sampling neighborhood is along the x-direction, perpendicular to the scratch direction. The ratio of the major to minor axis of the elliptic sampling neighborhood is... The result is 6.32. This creates a flat, elongated sampling neighborhood that precisely fits the local scratch structure, enhancing the ability to extract linear defect features. Setting the maximum axis-to-length ratio threshold to 10 can prevent excessive stretching caused by noise.

[0046] In an optional embodiment, constructing a global feature histogram includes: dividing the rotation-invariant ternary mode encoding into uniform and non-uniform modes, wherein if the number of cyclic transitions in the encoded code value sequence is no greater than 2, it is a uniform mode; and establishing statistical units for all uniform modes and one set of non-uniform modes to construct the global feature histogram.

[0047] When using 8 sampling points for ternary pattern encoding, 3 to the power of 8, or 6561, possible patterns are generated. Creating a statistical unit for each pattern would result in a feature vector dimension of 6561, which is not only computationally intensive but also prone to overfitting in subsequent classification. Introducing the concept of uniform patterns can greatly simplify the problem. For example, in the encoded sequence 11100011, the cyclic transitions from 1 to 0 and from 0 to 1 occur twice, making it a uniform pattern representing a smooth edge or corner structure. In contrast, encoded sequences like 01201201 have far more than 2 transitions, belonging to non-uniform patterns, typically corresponding to noise or irregular complex textures in images. In 8-sampling-point ternary patterns, there are only about 200 uniform patterns. Therefore, a global feature histogram with over 200 terms can be constructed, where each term corresponds to a specific uniform pattern, plus an additional term to count the total number of occurrences of all non-uniform patterns. In this way, the dimension of the feature vector is reduced from 6561 dimensions to about 200 dimensions, which significantly improves the efficiency of feature calculation and subsequent model training while retaining most of the key texture information.

[0048] In an optional embodiment, pixel sampling is performed at multiple preset scales, including: the multiple preset scales are ellipse semi-axis radii of R1, R2, ..., R... n Pixels, where n is the total number of scales; P pixels are uniformly sampled along the contour of the elliptical sampling neighborhood of each scale; threshold t1 is the standard deviation of the gray values ​​of all pixels in the elliptical sampling neighborhood of the center pixel.

[0049] To simultaneously detect defects of varying sizes, such as tiny specks and larger pits, three scales (n) are defined, with the ellipse's major semi-axis radii set to R1 = 3 pixels, R2 = 6 pixels, and R3 = 12 pixels, respectively. At each scale, eight points are uniformly sampled along the ellipse contour. The small-scale sampling (R1 = 3 pixels) captures high-frequency details and textures, effectively identifying minute defects like specks. The large-scale sampling (R3 = 12 pixels) covers a wider area, aiding in the identification of larger-scale defects such as pits or ripples with slow grayscale changes.

[0050] The threshold t1 is set adaptively. For a center pixel located in a smooth area on the surface of a part, the center pixel... Neighboring pixel grayscale values ​​may be very close, for example, between 180 and 182, with a calculated standard deviation of only 0.8. This low threshold makes the encoding process very sensitive to slight grayscale variations. Conversely, if the center pixel is located in an area with a slightly rolled texture, the grayscale values ​​of the pixel's neighbors may fluctuate between 170 and 190, with a calculated standard deviation of 7.5. A higher threshold allows the encoding process to tolerate such normal texture fluctuations, avoiding misinterpretation as defects.

[0051] In an optional embodiment, the kernel function of the support vector machine classification model is a weighted combination of the radial basis function kernel function and the chi-square kernel function, including: a weighted combination kernel function of the support vector machine classification model. The calculation formula is:

[0052] ;

[0053] ;

[0054] ;

[0055] in and X j Given two feature vectors, For radial basis kernel functions, For the chi-square kernel function, For feature vectors The One component; For the feature vector X j The Each component, weighting coefficient and kernel function parameters Both η and η are determined during the training phase.

[0056] Radial basis kernel function It excels at measuring the overall distance between feature vectors in Euclidean space, effectively distinguishing samples with significantly different overall feature distributions, such as a defective part with large indentations and a perfectly good, acceptable part. The global feature histograms of acceptable parts can differ considerably on a macroscopic scale. It can effectively capture this difference. And the chi-square kernel function... It is highly sensitive to the differences in each statistical unit, or bin, of the global feature histogram, making it particularly suitable for comparing global feature histograms composed of texture features. For example, a tiny scratch may only cause a change in the values ​​of a few specific bins in the global feature histogram, and the chi-square kernel can accurately measure such local but critical changes.

[0057] During the training of a Support Vector Machine (SVM) classification model, grid search and cross-validation may determine the optimal parameters as β = 0.6, γ = 0.2, and η = 0.8. This means that the final classification decision depends 60% on the global feature similarity represented by the RBF kernel and 40% on the local texture detail differences represented by the chi-square kernel. This allows the classifier to identify both significant macroscopic defects and subtle defects indicated by minute texture anomalies, achieving higher overall detection performance than a single kernel function.

[0058] In an optional embodiment, a cost-sensitive learning strategy is employed to set differentiated penalty factors for different training samples, including: for the i-th sample x in the training set i Sample x i The penalty factor C i The calculation formula is:

[0059] ;

[0060] in, Basic penalty factor; As a category weight, the value for defective parts is greater than 1, and the value for qualified parts is 1. The distance weight is the value of the distance weight relative to the sample x. i The functional intervals to the classification hyperplane are negatively correlated.

[0061] In the training dataset for stamping parts quality inspection, there might be 2000 qualified part samples and only 100 defective part samples, a sample ratio of 20 to 1. To address this class imbalance, class weights can be assigned to the defective part samples. The number is 20, and the number of qualified samples is... The value is 1. This is equivalent to treating the error penalty for each defective part sample as 20 times that of a normal qualified part during model training, forcing the model to pay more attention to the correct classification of the minority class, i.e., defective parts, and preventing the model from simply predicting all samples as the majority class, i.e., qualified parts.

[0062] Furthermore, the difficulty of identifying different defective part samples varies. A defective sample that is severely misclassified by the model, i.e., far from the classification boundary, has a functional margin that is a negative number with a large absolute value, causing the distance weight of the sample to be affected. The value is very large, for example, 10.0. Meanwhile, another sample that was just misjudged and is very close to the boundary has a defective sample whose functional margin is a negative number with a very small absolute value. It could be 1.5. If the base penalty factor... If the value is 1, then the final penalty factor Ci for the previous sample is 200, and for the next sample it is 30. In this way, a huge cost will be incurred in subsequent iterations to correct the classification of the seriously misclassified difficult sample, optimize the classification boundary, and improve the detection rate of defects of various difficulty.

[0063] The implementation principle of the stamping quality inspection method for stamped parts in this invention is as follows: By introducing a spatial prior weight map based on a three-dimensional model, prior knowledge of the stamping process is integrated into the feature extraction process, allowing the detection focus to be on areas with high defect incidence. This makes the extracted features more targeted and discriminative, improving sensitivity to hidden or subtle defects. Furthermore, the improved feature extraction operator uses elliptical neighborhood sampling, which better matches the directional structures often present in defects such as scratches and wrinkles, capturing more accurate texture information compared to circular neighborhoods. Ternary encoding enhances the robustness of features to image noise, while rotation-invariant properties ensure consistency in detection results for workpieces with different orientations. Moreover, in the classification stage, a classifier constructed by weighted combination of radial basis function and chi-square kernel function can learn the distribution patterns of complex features, improving classification accuracy. Additionally, a cost-sensitive learning strategy is adopted, setting a higher misclassification cost for minority class defect samples, solving the common sample imbalance problem in real-world industrial scenarios, improving the detection rate of defective parts, and reducing the risk of missed detections.

[0064] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for inspecting the stamping quality of stamped parts, characterized in that, The steps include: acquiring a digital image of the surface of the stamping part to be inspected; analyzing the surface curvature and material thickness variation gradient of each region of the preset three-dimensional geometric model of the stamping part to be inspected to generate a spatial prior weight map representing the forming difficulty of each region; and registering the spatial prior weight map with the surface digital image. Calculate the structure tensor of the pixels in the surface digital image, and determine the orientation and axis ratio of the elliptical sampling neighborhood based on the feature vector of the structure tensor; sample the pixels at multiple preset scales along the contour of the elliptical sampling neighborhood, and compare the pixel values ​​of the sampled points with the pixel values ​​of the center pixel to obtain the initial ternary pattern code. At each scale, a global feature histogram is constructed, whereby each pixel in the surface digital image is encoded according to its rotation-invariant ternary mode to obtain the corresponding statistical unit in the global feature histogram. A contribution value is accumulated for each statistical unit, where the contribution value is the corresponding weight value of the pixel in the spatial prior weight map. The global feature histograms constructed at all scales are concatenated to generate a concatenated feature vector. This concatenated feature vector is input into a support vector machine (SVM) classification model, where the kernel function of the SVM classification model is a weighted combination of a radial basis function (RBF) kernel and a chi-square kernel, and the weight coefficients of each kernel function are determined by a multi-kernel learning algorithm during the model training phase. Based on the output of the SVM classification model, the stamping part to be inspected is determined to be either a qualified part or a defective part.

2. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The ternary comparison is as follows: The code is 0 when the absolute value of the difference between the sampled pixel value and the center pixel value is less than the threshold t1; the code is 1 when the sampled pixel value is greater than the center pixel value and the absolute value of the difference is not less than t1; and the code is 2 when the sampled pixel value is less than the center pixel value and the absolute value of the difference is not less than t1. The initial ternary mode code is cyclically shifted, and the code with the smallest value is taken as the rotation-invariant ternary mode code of the pixel.

3. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The process involves analyzing the surface curvature and material thickness variation gradients of each region in a pre-defined three-dimensional geometric model of the stamped part under test, generating a spatial prior weight map representing the forming difficulty of each region, including: The three-dimensional geometric model is divided into surface meshes; Calculate the average curvature K and material thickness gradient G at the center point of each surface element; Normalize the K and G values ​​of all face elements to the [0,1] interval to obtain and ; The weight value W of any point in the spatial prior weight map is calculated using the following formula: , where α is a preset weighting coefficient, with a value range of (0,1).

4. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The step of determining the orientation and axial length ratio of the elliptical sampling neighborhood based on the eigenvectors of the structure tensor includes: For each pixel in the surface digital image, calculate the image gradient in the x and y directions within a neighborhood of a preset scale. and ; The structure tensor is constructed by smoothing the product of gradient components using a Gaussian function. ; Eigenvalue decomposition is performed on the structure tensor S to obtain two eigenvalues. and the eigenvectors v1 and v2 corresponding to the two eigenvalues; The orientation of the major axis of the elliptical sampling neighborhood is consistent with the direction of the feature vector v1; The ratio of the major axis to the minor axis of the elliptical sampling neighborhood is set to... Set the maximum axis length ratio threshold.

5. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The construction of the global feature histogram includes: The rotation-invariant ternary mode encoding is divided into uniform mode and non-uniform mode. If the number of cyclic transitions in the encoded code value sequence is no more than 2, it is a uniform mode. Statistical units are established for all uniform patterns and one set of non-uniform patterns to construct the global feature histogram.

6. The method for detecting the stamping quality of stamped parts according to claim 2, characterized in that, The step of sampling pixels at multiple preset scales includes: The preset multiple scales are the radii of the major semi-axis of the ellipse, respectively taking the values ​​R1, R2, ..., R... n pixels, where n is the total number of scales; P pixels are uniformly sampled along the contour of the elliptical sampling neighborhood at each scale. The threshold t1 is the standard deviation of the gray values ​​of all pixels within the elliptical sampling neighborhood of the center pixel.

7. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The kernel function of the support vector machine classification model is a weighted combination of the radial basis function kernel function and the chi-square kernel function, including: The weighted combination kernel function of the support vector machine classification model The calculation formula is: ; ; ; in and X j Given two feature vectors, For radial basis kernel functions, For the chi-square kernel function, For feature vectors The One component; For the feature vector X j The Each component, weighting coefficient and kernel function parameters Both η and η are determined during the training phase.

8. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, During the training phase, the support vector machine classification model employs a cost-sensitive learning strategy, setting differentiated penalty factors for different training samples and assigning high penalty weights to minority class samples.

9. The method for detecting the stamping quality of stamped parts according to claim 8, characterized in that, The cost-sensitive learning strategy employs differentiated penalty factors for different training samples, including: For the i-th sample x in the training set i Sample x i The penalty factor C i The calculation formula is: ; in Basic penalty factor; As a category weight, the value for defective parts is greater than 1, and the value for qualified parts is 1. The distance weight is the value of the distance weight relative to the sample x. i The functional intervals to the classification hyperplane are negatively correlated.

10. The method for detecting the stamping quality of stamped parts according to claim 1, characterized in that, The multi-core learning algorithm is the SimpleMKL algorithm.

Citation Information

Patent Citations

  • Copper stamping part surface crack detection method based on quantum pigeon flock peak valley interval segmentation

    CN113916894A

  • SAR image change detection method based on global dynamic convolutional neural network

    CN115018773A