A method for detecting surface defects of injection electroplated parts based on machine vision
Patent Information
- Application Number
- CN202610275075.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-09
- Publication Date
- 2026-06-26
Smart Images

Figure CN122290098A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision technology, specifically relating to a machine vision-based method for detecting surface defects in injection-molded electroplated parts. Background Technology
[0002] Photometric Stereo (PS), a 3D reconstruction technology based on physical optical models, plays an irreplaceable role in industrial inspection. Compared to traditional 2D imaging, which is susceptible to defects being masked by highlights and false alarms caused by shadows, photometric stereo technology can physically eliminate illumination interference and recover micron-level surface morphology, thus becoming a key means to solve the problem of detecting defects on highly reflective surfaces. However, existing surface defect detection technologies based on photometric stereo still have certain shortcomings:
[0003] First, at the level of photometric stereo imaging and feature representation, existing technologies lack further physical feature decoupling mechanisms after obtaining the normal vector. Although photometric stereo technology can reconstruct the normal vector field of the workpiece surface through basic models such as the least squares method, the original reconstruction result inevitably contains nonlinear specular artifacts due to the high reflectivity of injection-molded and electroplated parts. Directly using the original normal vector map or albedo map containing artifacts as the final feature input to the detection system, or simply using general image filtering for smoothing, may lead to a high false negative rate.
[0004] Secondly, at the level of detection algorithms and network architecture, traditional pixel statistical methods (CN119722642A) or simple image processing techniques often only focus on the grayscale values of pixels, ignoring the texture and shape of the image. For injection-molded parts with logos or slightly curved surfaces, these traditional algorithms cannot distinguish between the normal edges of the logo and the abnormal edges of defects, or they may erase shallow scratches when removing the background. Moreover, in pursuit of speed, general detection networks often use deep downsampling to extract features. For micron-level defects with a width of only a few pixels, this crude downsampling will cause the features of tiny defects to disappear completely in the deep network, leading to missed detections. In addition, while some semantic segmentation-based solutions are sophisticated, they are computationally too slow to meet the high-speed inspection requirements of industrial production lines. Summary of the Invention
[0005] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and to propose a method for detecting surface defects in injection-molded electroplated parts based on machine vision.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] A machine vision-based method for detecting surface defects in injection-molded electroplated parts includes the following steps:
[0008] S1. Construct a photometric stereo imaging system and acquire the original image sequence;
[0009] S2. Preprocess the original image and extract the region of interest. Use photometric stereo technology to reconstruct the surface of the part in three dimensions and calculate the geometric feature map.
[0010] S3. Establish a weight optimization objective function based on SNR, find the optimal weight, and perform multi-channel feature weighted fusion based on the optimal weight;
[0011] S4. Construct the SAE-YOLO convolutional neural network. In the feature extraction stage of its backbone network, construct the C3k2_EEM module to replace the original C3k2 module. In the feature pyramid structure of its neck network, design a small target feature enhancement pyramid to obtain the improved SAE-YOLO detection network.
[0012] S5. Train the improved SAE-YOLO detection network and use the trained SAE-YOLO detection network to detect surface defects in injection-molded electroplated parts.
[0013] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0014] 1. This invention solves the problem of missed detection of defects with insignificant depth changes, such as shallow scratches and micro-pits, by constructing a three-dimensional reconstruction algorithm based on photometric stereo and deriving geometric feature maps and multi-channel fusion. It reconstructs the normal vector field of the workpiece surface using a least-squares photometric stereo model and derives geometric feature maps such as average curvature and normal difference using differential geometry principles. At the same time, it proposes an adaptive weighted fusion algorithm based on maximizing signal-to-noise ratio, which can dynamically calculate the optimal weight combination of each feature map according to the imaging quality, thereby significantly improving the detection sensitivity and robustness of the system in complex industrial environments.
[0015] 2. To address the issue that existing deep learning models easily lose high-frequency edge details during backbone network feature extraction, leading to inaccurate defect contour localization, this invention constructs an SAE-YOLO network. This is achieved by designing a hierarchically nested C3k2_EEM module within the SAE-YOLO network backbone. Furthermore, by employing a heterogeneous dual-stream architecture and embedding a parameter-freezing Sobel operator branch within the backbone network, the network can explicitly preserve the physical gradient information of the image while extracting high-level semantic features. Residual connections are then used to losslessly transfer edge features to the deep network, effectively solving the problem of deep feature blurring and improving the ability to capture minute defects.
[0016] 3. To address the issues of pixel loss and background noise interference in small targets caused by existing feature pyramid structures during downsampling, this invention constructs a small target feature enhancement pyramid in SAE-YOLO, achieving lossless feature transfer and precise focusing. Utilizing SPDConv, a pixel rearrangement mechanism is employed to expand the channel dimension in exchange for lossless downsampling of spatial geometric information, fully preserving the texture details of small targets. Simultaneously, PST is combined to guide shallow features with deep semantics for sparse focusing, automatically suppressing background noise at the feature level, thereby achieving efficient detection of minute defects. Attached Figure Description
[0017] Figure 1 This is a flowchart of the method of the present invention.
[0018] Figure 2 This is a flowchart of the multi-channel fused image generation process.
[0019] Figure 3 This is a schematic diagram of the improved SAE-YOLO detection network.
[0020] Figure 4 This is a schematic diagram of the C3k2_EEM module.
[0021] Figure 5 This is a schematic diagram of the Small Target Feature Enhancement Pyramid (SOFEP). Detailed Implementation
[0022] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.
[0023] Explanation of relevant terms:
[0024] PS: Photometric Stereo.
[0025] DoN: Difference of Normals.
[0026] FGS: Fast Global Smoother.
[0027] SNR: Signal-to-Noise Ratio.
[0028] SOFEP: Small Object Feature Enhancement Pyramid.
[0029] EEM: Edge Enhancement Module.
[0030] CSP: Cross Stage Partial.
[0031] SPPF: Spatial Pyramid Pooling - Fast.
[0032] C2PSA: Cross-Stage Local Spatial Attention Module.
[0033] SAE-YOLO: Small-object And Edge-enhanced YOLO, a YOLO detection network for small objects and edge enhancement.
[0034] SPDConv: Space-to-Depth Convolution. See the paper: No MoreStrided Convolutions or Pooling: A New CNN Building Block for Low-Resolution Images and Small Objects (Sunkara et al., 2022).
[0035] PST: Pyramid Sparse Transformer. See the paper: Enhancing Multi-Scale Feature Fusion with Dynamic Token Selection.
[0036] Examples; such as Figure 1 As shown, a machine vision-based method for detecting surface defects in injection-molded electroplated parts includes the following steps:
[0037] S1. Construct a photometric stereo imaging system and acquire the original image sequence; in this embodiment, specifically:
[0038] Construct and utilize a photometric stereo imaging acquisition device that includes an industrial camera and a partitioned coaxial light source;
[0039] Based on the principle of photometric stereo imaging, the light source is divided into four independent illumination directions with 90-degree intervals. During the data acquisition process, the light sources in each direction are turned on independently in sequence, and the camera is used to acquire the original grayscale images of the workpiece under different incident light angles. The relative positions of the camera and the workpiece are kept fixed during the acquisition process, thereby obtaining a set of original image sequences with pixel-level spatial correspondence.
[0040] S2. Preprocess the original image and extract the region of interest. Use photometric stereo technology to reconstruct the three-dimensional surface of the part and calculate the geometric feature map; in this embodiment, such as Figure 2 As shown, it includes:
[0041] S21. Read the original image sequence and the background image without the workpiece; use the background subtraction method to calculate the gray-level difference between the image to be tested and the background image to obtain the preliminary contour region of the workpiece; for the difference image, use binarization thresholding segmentation to convert the gray-level difference image into a binary mask, and use morphological closing operation to fill the holes inside the contour and smooth the edges to connect the broken connected components; finally, use the contour search algorithm to locate the largest connected component of the workpiece, calculate its minimum bounding rectangle, and crop the region of interest image sequence containing the workpiece body from the original high-resolution image.
[0042] S22. Edge-preserving filtering based on FGS, specifically:
[0043] A Fast Global Smoothing Filter (FGS) based on a weighted least squares model is used to preprocess the region of interest image. The FGS algorithm constructs a gradient-based weight matrix to minimize the global gradient of the image while constraining the similarity between pixel values and the original image, thereby filtering out high-frequency random noise while strictly preserving the texture and scratch edge details of the workpiece surface. To address the slight differences in luminous intensity that may exist from the four-directional light sources, global brightness normalization is performed on the filtered image sequence. The global mean of each image is calculated, and the gain coefficient is calculated based on the global average brightness to perform linear correction on each image pixel.
[0044] S23. A photometric stereo 3D reconstruction algorithm based on the least squares method is adopted to solve the global optimal solution of the surface normal vector using multi-angle illumination information;
[0045] First, a set of illumination imaging equations is constructed based on the Lambert reflection model. The grayscale observations of the same pixel in four images are combined to form a brightness vector. Subsequently, an overdetermined system of linear equations was constructed. , The pseudo-normal vector is to be determined, containing information about the normal and albedo. Since the equation is an overdetermined system, the least squares method is applied to solve it, yielding the pseudo-normal vector of the surface. :
[0046]
[0047] Based on this, by calculating the pseudo-normal vector Solving for surface reflectivity map using modulus The formula is:
[0048]
[0049] At the same time, for pseudo normal vectors Normalization is performed to obtain the unit normal vector. ;
[0050] in pseudo normal vector The three components; the albedo map This characterizes the material reflection properties of the object's surface, removing the influence of lighting and geometry, and labels it as... It serves as one of the input components for subsequent multi-channel fusion.
[0051] S24. Computational geometric feature map, including:
[0052] S241. Generate the Mean Curvature feature map, specifically:
[0053] To calculate the divergence of the normal vector field and obtain the mean curvature, first, calculate the partial derivatives of the surface gradient based on the normal vector components:
[0054]
[0055] Using the Sobel operator with a 3×3 convolution kernel, we solve for the first-order partial derivatives of p and q with respect to the image coordinates x and y; finally, we substitute these into the mean curvature formula:
[0056]
[0057] Calculated mean curvature diagram Reflecting the microscopic unevenness of the workpiece surface, it is marked as , as the input component for subsequent multi-channel fusion;
[0058] S242. Generate the normal difference feature map, specifically:
[0059] Setting large-scale Gaussian kernel parameters ,according to The kernel size is adaptively determined, and the original normal map is smoothed by Gaussian convolution to obtain a smoothed unit normal map. Subsequently, the Euclidean norm of the vector difference between the original unit normal and the smoothed unit normal is calculated to obtain the normal difference feature map.
[0060]
[0061] This feature map highlights the high-frequency normal variation region, which is labeled as , which serves as the input component for subsequent multi-channel fusion.
[0062] S3. Establish a weight optimization objective function based on SNR, find the optimal weights, and perform multi-channel feature weighted fusion based on the optimal weights; in this embodiment, as... Figure 2 As shown, it includes:
[0063] S31. Establish a weight optimization objective function based on SNR, specifically as follows:
[0064] The geometric feature maps in step S2 are weighted and fused, and the signal-to-noise ratio (SNR) is introduced as an evaluation metric during multi-view fusion; a temporary fusion map is defined for weight evaluation. The weighted sum of the three basic feature maps:
[0065]
[0066] in , , Let be the fusion weight coefficients to be solved, and satisfy the normalization constraint. Construct an optimization function with the objective of maximizing the SNR of the fused image:
[0067]
[0068] in, To merge the grayscale average of the defective areas in the image, The average gray level of the background area. The standard deviation of the background region;
[0069] A grid search is used to iteratively search in the weight space for... The optimal weight combination that achieves the global maximum value;
[0070] S32. Multi-channel feature weighted fusion based on optimal weights, specifically:
[0071] The globally optimal weight combination obtained in step S31 is used to perform batch weighted fusion processing on the geometric feature map sequences of all the workpieces to be tested. The three channels are respectively , , ;
[0072] The three weighted components are combined into a three-channel pseudo-color feature fusion map to construct a pseudo-color image dataset.
[0073] S4. Construct the SAE-YOLO convolutional neural network. In the feature extraction stage of its backbone network, construct the C3k2_EEM module to replace the original C3k2 module. In the feature pyramid structure of its neck network, design a small target feature enhancement pyramid to obtain the improved SAE-YOLO detection network, such as... Figure 3The diagram shown is a schematic of the improved SAE-YOLO detection network.
[0074] In this embodiment, the SAE-YOLO convolutional neural network consists of three parts: a backbone network, a neck network, and a detection head.
[0075] S41. In the feature extraction stage of the SAE-YOLO convolutional neural network backbone, a C3k2_EEM module is constructed to replace the original C3k2 module to improve the network's ability to capture weak defect edges; for example... Figure 4 The diagram shown is a structural schematic of the C3k2_EEM module. The C3k2_EEM module is structurally divided into three nested levels, specifically:
[0076] The first layer: The outermost layer of the C3k2_EEM module adopts a CSP dual-stream architecture to enrich the gradient path; the input feature tensor is first divided into two branches through a splitting mechanism: the cross-layer branch retains the original feature information and is directly connected to the end; the main branch feeds the feature map into a sequence composed of n stacked C3k_EEM modules for deep feature extraction, then concatenates the output of the main branch with the cross-layer branch in the channel dimension, and finally fuses the output through a 1×1 convolution.
[0077] The second level: Within the main branch, a C3k_EEM submodule was designed to deepen the network and enhance its nonlinear expressive power. This level consists of n EEM units from the third level stacked in series. The output of the previous EEM unit is directly used as the input of the next unit. This structure extracts high-order combined features from shallow textures to deep edges by repeatedly stacking core operators, thus acting as a feature amplifier.
[0078] The third level: An EEM module was designed inside C3k_EEM to replace the original Bottleneck module. The EEM unit adopts a dual-path parallel structure, specifically:
[0079] One channel uses a Sobel operator convolutional layer with frozen parameters to calculate the horizontal gradient separately. with vertical gradient The two are linearly superimposed. One channel uses a 3×3 convolution to extract semantic features. After concatenating the physical edge features and semantic features in the channel dimension, they are first fused by a 1×1 convolution for dimensionality reduction. Then, residual connections are introduced to add the fused features to the unit input. Finally, the output is adjusted by convolution again.
[0080] S42. In the feature pyramid structure of the neck network of the SAE-YOLO convolutional neural network, a Small Target Feature Enhancement Pyramid (SOFEP) is designed for the small target detection layer, which is prone to losing information; for example... Figure 5The diagram shown is a schematic representation of the small target feature enhancement pyramid.
[0081] like Figure 5 As shown, the small target feature enhancement pyramid consists of three parts: a lossless downsampling branch based on SPDConv (Space-to-DepthConvolution), a three-stream feature aggregation layer, and a semantically guided filter based on PST. Specifically:
[0082] The lossless downsampling branch based on SPDConv: A cross-layer branch is established from the output of layer P2 (the second layer of the backbone network), and an SPDConv module is introduced into this branch to replace the traditional strided convolution; the SPDConv module is used to downsample the original feature map according to... The grid is used for spatial segmentation, and adjacent pixels in space are transferred to the channel dimension through pixel rearrangement; the dimension of the input feature map X is... Where H and W are even numbers; the SPDConv operation splits it into 4 subgraphs according to the following indexing rules:
[0083]
[0084]
[0085]
[0086]
[0087] Subsequently, the four sub-images are concatenated along the channel dimension (dim=1) to obtain the intermediate feature map. Dimension becomes Then, a standard 3×3 convolutional layer outputs. ;
[0088] Three-stream feature aggregation layer: The output features of the SPDConv module are concatenated with the output features of the P3 layer (the fourth layer of the backbone network) and the fourteenth layer of the neck network to construct a hybrid feature tensor. The hybrid feature tensor receives the upsampled deep semantic features from the fourteenth layer of the neck network, the original features from the P3 layer (the fourth layer of the backbone network), and the high-frequency detail feature map processed by the SPDConv module. The three features are concatenated in the channel dimension to form a coarse-grained fusion feature tensor containing rich details and semantics.
[0089] A PST-based semantic-guided filter is introduced to accurately locate minute defects from aggregated features containing a large amount of background noise. The generated coarse-grained fusion feature tensor is used as the query. The 40×40 resolution deep semantic features of the P4 layer (the sixth layer of the backbone network) are used as the key. Cross-scale attention calculation is performed on the fusion features of the fifteenth layer of the neck network using the deep semantic features of the P4 layer (the sixth layer of the backbone network), generating a global similarity heatmap. Based on the similarity score, the k regions with the highest response values are dynamically selected. High-resolution feature interaction and enhancement are performed only on the fusion features of the fifteenth layer of the neck network corresponding to these k selected regions, outputting the final enhanced small target feature map. This feature map is then fed into the detection head for prediction.
[0090] S43. Multi-scale decoupling detection and post-processing, specifically:
[0091] After feature extraction by the backbone network and enhancement by SOFEP in the neck network, three feature maps of different scales are output. In order to transform these enhanced features into the final detection results, the detection head part of the SAE-YOLO detection network adopts the decoupled detection head structure of the YOLOv11 standard.
[0092] like Figure 3 The diagram shown is a schematic of the improved SAE-YOLO detection network.
[0093] S5. Train the improved SAE-YOLO detection network and use the trained SAE-YOLO detection network to detect surface defects in injection-molded electroplated parts. In this embodiment, when detecting surface defects in injection-molded electroplated parts, the fused image processed in step S3 is input into the SAE-YOLO detection network. The network performs edge feature extraction from the backbone network, downsampling and semantic focusing from the neck network, and outputs the prediction result from the detection head. Finally, the predicted bounding box is drawn on the original high-resolution image, and the defect category and confidence score are labeled, and the final detection report is output.
[0094] In the data construction process, this invention utilizes least-squares photometric stereo technology to reconstruct the normal vector and albedo of the workpiece surface. Furthermore, it employs differential geometry and frequency domain analysis principles to derive geometric feature maps such as the average curvature map and the normal difference map. An adaptive weighting mechanism based on signal-to-noise ratio is introduced to fuse the reflectance map, curvature map, and normal difference map into a high-contrast multi-channel input tensor. Secondly, in the SAE-YOLO detection network, a C3k2_EEM module is designed, employing a heterogeneous dual-stream architecture. It explicitly extracts edge gradients using the parameter-frozen Sobel operator and performs residual fusion with convolutional features. Finally, an SOFEP architecture is constructed in the neck network, utilizing SPDConv to achieve lossless physical downsampling of feature maps. Combined with the PST pyramid sparse Transformer, it uses deep semantics to guide shallow features for sparse focusing, ultimately outputting the detection results and achieving accurate detection of minute defects in injection-molded electroplated parts.
[0095] It should also be noted that, in this specification, terms such as "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0096] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting surface defects in injection-molded electroplated parts based on machine vision, characterized in that, Includes the following steps: S1. Construct a photometric stereo imaging system and acquire the original image sequence; S2. Preprocess the original image and extract the region of interest. Use photometric stereo technology to reconstruct the surface of the part in three dimensions and calculate the geometric feature map. S3. Establish a weight optimization objective function based on SNR, find the optimal weight, and perform multi-channel feature weighted fusion based on the optimal weight; S4. Construct the SAE-YOLO convolutional neural network. In the feature extraction stage of its backbone network, construct the C3k2_EEM module to replace the original C3k2 module. In the feature pyramid structure of its neck network, design a small target feature enhancement pyramid to obtain the improved SAE-YOLO detection network. S5. Train the improved SAE-YOLO detection network and use the trained SAE-YOLO detection network to detect surface defects in injection-molded electroplated parts.
2. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 1, characterized in that, Step S1 is as follows: Construct and utilize a photometric stereo imaging acquisition device that includes an industrial camera and a partitioned coaxial light source; Based on the principle of photometric stereo imaging, the light source is divided into four independent illumination directions with 90-degree intervals. During the data acquisition process, the light sources in each direction are turned on independently in sequence, and the camera is used to acquire the original grayscale images of the workpiece under different incident light angles. The relative positions of the camera and the workpiece are kept fixed during the acquisition process, thereby obtaining a set of original image sequences with pixel-level spatial correspondence.
3. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 1, characterized in that, In step S2, the original image is preprocessed and the region of interest is extracted, specifically including: The process involves reading the original image sequence and a background image without the workpiece; calculating the gray-level difference between the image to be tested and the background image using background subtraction to obtain the preliminary contour region of the workpiece; converting the gray-level difference image into a binary mask using binarization thresholding segmentation, and filling the internal holes of the contour and smoothing the edges using morphological closing operations to connect broken connected components; finally, locating the largest connected component of the workpiece using a contour search algorithm, calculating its minimum bounding rectangle, and cropping the region of interest image containing the workpiece body from the original high-resolution image. The edge-preserving filtering process based on FGS is as follows: A Fast Global Smoothing Filter (FGS) based on a weighted least squares model is used to preprocess the region of interest image. The FGS algorithm constructs a gradient-based weight matrix to minimize the global gradient of the image while constraining the similarity between pixel values and the original image, thus filtering out high-frequency random noise while preserving the texture and scratch edge details of the workpiece surface. To address the slight differences in luminous intensity that may exist from the four-directional light sources, global brightness normalization is performed on the filtered image sequence. The global mean of the images from each direction is calculated, and the gain coefficient is calculated based on the global average brightness to perform linear correction on each image pixel.
4. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 3, characterized in that, In step S2, photometric stereoscopic technology is used to perform three-dimensional reconstruction of the part surface, specifically as follows: A photometric stereo 3D reconstruction algorithm based on the least squares method is adopted to solve for the global optimal solution of the surface normal vector using multi-angle illumination information. First, an illumination imaging equation system is constructed based on the Lambertian reflection model. The grayscale observations of the same pixel in four images are combined to form a brightness vector. ; Subsequently, an overdetermined system of linear equations was constructed. , The pseudo-normal vector is to be determined, containing information about the normal and albedo. Since the equation is an overdetermined system, the least squares method is applied to solve it, yielding the pseudo-normal vector of the surface. : Calculate the pseudo normal vector Solving for surface reflectivity map using modulus The formula is: At the same time, for pseudo normal vectors Normalization is performed to obtain the unit normal vector. ; in, pseudo normal vector The three components; albedo map This characterizes the material reflection properties of the object's surface, removing the influence of lighting and geometry, and labels it as... It serves as one of the input components for subsequent multi-channel fusion.
5. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 4, characterized in that, Computational geometric feature maps specifically include: Generate the average curvature feature map, specifically as follows: The divergence of the normal vector field is calculated to obtain the mean curvature; first, the partial derivatives of the surface gradient are calculated based on the normal vector components: The first-order partial derivatives of p and q with respect to image coordinates x and y are solved using the Sobel operator with a 3×3 convolution kernel; finally, they are substituted into the mean curvature formula: Calculated mean curvature diagram Reflecting the microscopic unevenness of the workpiece surface, it is marked as , as the input component for subsequent multi-channel fusion; The generation of the normal difference feature map is as follows: Setting large-scale Gaussian kernel parameters ,according to The kernel size is adaptively determined, and the original normal map is smoothed by Gaussian convolution to obtain a smoothed unit normal map. Subsequently, the Euclidean norm of the vector difference between the original unit normal and the smoothed unit normal is calculated to obtain the normal difference feature map. This feature map highlights the high-frequency normal variation region, which is labeled as , which serves as the input component for subsequent multi-channel fusion.
6. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 5, characterized in that, Step S3 specifically includes: S31. Establish a weight optimization objective function based on SNR, specifically as follows: The geometric feature maps in step S2 are weighted and fused, and the signal-to-noise ratio (SNR) is introduced as an evaluation metric during multi-view fusion; a temporary fusion map is defined for weight evaluation. The weighted sum of the three basic feature maps: in, , , Let be the fusion weight coefficients to be solved, and satisfy the normalization constraint. ; Construct an optimization function that aims to maximize the SNR of the fused image: in, To merge the grayscale average of the defective areas in the image, The average gray level of the background area. The standard deviation of the background region; A grid search is used to iteratively search in the weight space for... The optimal weight combination that achieves the global maximum value; S32. Multi-channel feature weighted fusion based on optimal weights, specifically: The globally optimal weight combination is used to perform batch weighted fusion processing on the geometric feature map sequences of all the workpieces to be tested, with the three channels being... , , ; The three weighted components are combined into a three-channel pseudo-color feature fusion map to construct a pseudo-color image dataset.
7. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 1, characterized in that, In step S4, the SAE-YOLO convolutional neural network consists of three parts: the backbone network, the neck network, and the detection head. In the feature extraction stage of its backbone network, the C3k2_EEM module is constructed to replace the original C3k2 module. The C3k2_EEM module is structurally divided into three nested levels, specifically: First level: The outermost layer of the C3k2_EEM module adopts the CSP dual-stream architecture; The input feature tensor is first divided into two branches through a splitting mechanism: the cross-layer branch retains the original feature information and is directly connected to the end; the main branch feeds the feature map into a sequence composed of n stacked C3k_EEM modules for deep feature extraction, and then concatenates the output of the main branch with the cross-layer branch in the channel dimension, and finally fuses them through 1×1 convolution. Second level: Within the main branch, design the C3k_EEM submodule; this level is composed of n third-level EEM units stacked in series; the output of the previous EEM unit is directly used as the input of the next unit; The third level: An EEM module is designed inside C3k_EEM to replace the original Bottleneck module. The EEM unit adopts a dual-path parallel structure, specifically: One channel uses a Sobel operator convolutional layer with frozen parameters to calculate the horizontal gradient separately. with vertical gradient The two are linearly superimposed. One channel uses 3×3 convolution to extract semantic features. After concatenating the physical edge features and semantic features in the channel dimension, they are first fused by 1×1 convolution for dimensionality reduction. Then, residual connections are introduced to add the fused features to the unit input. Finally, the output is adjusted by convolution again.
8. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 7, characterized in that, In step S4, the Small Target Feature Enhancement Pyramid (SOFEP) consists of three parts: a lossless downsampling branch based on SPDConv, a three-stream feature aggregation layer, and a semantically guided filter based on PST. Specifically: Lossless downsampling branch based on SPDConv: A cross-layer branch is established from the output of the C3k2_EEM module in the second layer of the backbone network, and the SPDConv module is introduced into this branch to replace the traditional strided convolution; the SPDConv module is used to downsample the original feature map according to... The grid is used for spatial segmentation, and adjacent pixels in space are transferred to the channel dimension through pixel rearrangement; the dimension of the input feature map X is... Where H and W are even numbers; the SPDConv operation splits it into 4 subgraphs according to the following indexing rules: Subsequently, the four sub-images are concatenated along the channel dimension dim=1 to obtain the intermediate feature map. Dimension becomes Then, a standard 3×3 convolutional layer outputs. ; Three-stream feature aggregation layer: The output features of the SPDConv module are concatenated with the output features of the C3k2_EEM module in the fourth layer of the backbone network and the fourteenth layer of the neck network to construct a hybrid feature tensor. The hybrid feature tensor receives the upsampled deep semantic features from the fourteenth layer of the neck network, the original features from the fourth layer of the backbone network, and the high-frequency detail feature map processed by the SPDConv module. The three features are concatenated in the channel dimension to form a coarse-grained fusion feature tensor containing rich details and semantics. A PST-based semantic guided filter: To accurately locate minute defects from aggregated features containing a large amount of background noise, a PST module is introduced for semantic guided filtering; the generated coarse-grained fused feature tensor is used as the query; the resolution of the sixth layer C3k2_EEM module of the backbone network is... The deep semantic features are used as keys; Cross-scale attention calculation is performed on the fusion features of the 15th layer of the neck network using the deep semantic features of the sixth layer of the backbone network to generate a global similarity heatmap. Based on the similarity score, the k regions with the highest response values are dynamically selected, and high-resolution feature interaction and enhancement are performed only on the fusion features of the 15th layer of the neck network corresponding to these k selected regions to output the final enhanced small target feature map. This feature map is then fed into the detection head for prediction.
9. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 8, characterized in that, After feature extraction by the backbone network and enhancement by SOFEP in the neck network, three feature maps of different scales are output. In order to transform the enhanced features into the final detection results, the detection head part of the SAE-YOLO detection network adopts the decoupled detection head structure of the YOLOv11 standard.
10. The method for detecting surface defects of injection-molded electroplated parts based on machine vision according to claim 1, characterized in that, In step S5, when detecting surface defects of injection-molded electroplated parts, the fused image processed in step S3 is input into the SAE-YOLO detection network. The network undergoes edge feature extraction of the backbone network, downsampling and semantic focusing of the neck network, and finally the detection head outputs the prediction result.
Citation Information
Patent Citations
Metal electroplating surface defect detection method and system
CN119722642A
