Intelligent detection method and system for injection molding defects of plastic products
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NEW ZHIHAO TECHNOLOGY (NANTONG) CO LTD
- Filing Date
- 2026-04-15
- Publication Date
- 2026-07-21
Smart Images

Figure CN122434839A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of plastic product quality inspection technology, and in particular to an intelligent detection method and system for injection molding defects in plastic products. Background Technology
[0002] In the injection molding process of plastic products, efficient and accurate detection of surface and internal defects is a crucial step in ensuring product quality. Currently, the conventional approach in this field mainly relies on machine vision technology. Due to the material properties and injection molding process, plastic products often exhibit complex surface optical properties, such as significant differences in local transparency, and the simultaneous existence of transparent, semi-transparent, and opaque areas. This non-uniformity of optical properties leads to large fluctuations in the signal-to-noise ratio of the acquired images across different regions. Features extracted from such images are often not robust enough, easily resulting in missed or false detections of defects.
[0003] Existing methods often focus on single-modal information at the feature extraction level. However, plastic injection molding defects exhibit diverse morphologies, and their characterization may simultaneously involve surface optical properties, three-dimensional geometric deformation, and internal material structural anomalies. Judging from only a single information dimension makes it difficult to comprehensively and accurately characterize complex defect morphologies such as stress whitening associated with fine scratches or local refractive changes caused by internal bubbles. This incomplete feature representation limits the model's ability to distinguish certain ambiguous or complex defects, resulting in insufficient generalization performance and constituting another common drawback of existing technologies. Summary of the Invention
[0004] This invention provides an intelligent detection method and system for injection molding defects in plastic products, which can solve the problems in the prior art.
[0005] A first aspect of the present invention provides an intelligent detection method for injection molding defects in plastic products, comprising: A sequence of polarization images of the plastic product to be inspected is acquired, the polarization degree distribution is calculated, and the surface of the plastic product is divided into transparent, semi-transparent, and opaque regions based on the polarization degree distribution. A differentiated enhancement strategy is applied to regions with different transparency to generate adaptive enhanced images. A three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. A comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism, with the fusion weights adaptively predicted and generated based on the feature maps of each branch. Defect candidate regions are generated on the comprehensive feature map and the probability distribution of defect types is output. The defect types to be verified are determined. For bubble-type defects, the response consistency in the polarization image sequence is verified. For deformation-type defects, the curvature continuity is verified. For scratch-type defects, the aspect ratio and the consistency of the main direction are verified. Based on the verification results, the probability distribution is corrected and the defect detection results are output.
[0006] Calculate the polarization degree distribution and apply a differentiated enhancement strategy to regions with different transparency to generate adaptively enhanced images, including: Stokes parameter vectors are calculated based on the acquired polarization image sequence. The degree of polarization distribution is calculated based on each component of the Stokes parameter vector. Based on the numerical range of the degree of polarization distribution, the pixels on the surface of the plastic product are classified into transparent, semi-transparent, and opaque regions, respectively. A polarization difference enhancement strategy is used to extract polarization contrast features based on Stokes parameter components for the transparent region. An adaptive histogram equalization enhancement strategy is used to improve local contrast for the semi-transparent region. An intensity preservation strategy is used to preserve the original light intensity information for the opaque region. The enhanced images of each region are then spatially stitched together to generate an adaptive enhanced image.
[0007] A three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution, including: The surface texture branch configures the filter bank according to the division of the transparency region. The region with higher transparency adopts a higher directional sampling density and a smaller spatial scale range to generate material-adaptive directional gradient energy features. The geometric deformation branch assigns confidence weights based on the phase unwrapping process of the polarization degree distribution in the transparent, semi-transparent, and opaque regions. The confidence weight of the transparent region is less than that of the semi-transparent region, and the confidence weight of the semi-transparent region is less than that of the opaque region. The curvature feature is calculated based on the confidence-weighted height field. The optical anomaly branch constructs a multi-scale local analysis window. The statistical deviation calculated in the fine-scale window corresponds to the surface defect response characteristics, while the statistical deviation calculated in the coarse-scale window corresponds to the internal defect response characteristics. The multi-scale statistical deviation is then fused to generate the polarization anomaly index characteristics.
[0008] A comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism. The fusion weights are adaptively predicted and generated based on the feature maps of each branch, including: A spatial guiding mask is generated based on the division results of the transparent region, semi-transparent region and opaque region. The spatial guiding mask assigns a weight gain coefficient to the optical anomaly branch to the transparent region, a weight gain coefficient to the surface texture branch and geometric deformation branch to the semi-transparent region, and a weight gain coefficient to the geometric deformation branch to the opaque region. Calculate the feature correlation matrix between the feature maps of the three branches, and generate cross-branch modulation weights based on the feature correlation matrix. The cross-branch modulation weights are used to suppress the response intensity of feature conflict regions and enhance the response intensity of feature complementary regions. The final fusion weight is obtained by multiplying the weight gain coefficient of the spatial guiding mask element-wise with the cross-branch modulation weight. The feature maps of the three branches are then weighted and fused based on the final fusion weight to obtain the comprehensive feature map.
[0009] Generating candidate defect regions on the comprehensive feature map and outputting the probability distribution of defect types includes: Defect candidate regions are generated by performing response intensity threshold segmentation on the comprehensive feature map; Local response features of the candidate defect regions on the three branch feature maps are extracted, and preliminary type tendency scores for bubble, deformation, and scratch types are obtained through type tendency prediction. Based on the preliminary type tendency scores, the local response features of the three branches are dynamically weighted and fused with type awareness to obtain a discriminative enhancement feature vector. Specifically, the fusion weight of the optical anomaly branch feature is increased for the candidate region with the largest bubble defect tendency score, the fusion weight of the geometric deformation branch feature is increased for the candidate region with the largest deformation defect tendency score, and the fusion weight of the surface texture branch feature is increased for the candidate region with the largest scratch defect tendency score. The discriminative enhancement feature vector is input into the defect type prediction network, and the physical consistency constraint loss is introduced to optimize the defect type prediction network. The physical consistency constraint loss is calculated from the response consistency deviation of the candidate region predicted as a bubble, the curvature continuity deviation of the candidate region predicted as a deformation, and the aspect ratio and main direction consistency deviation of the candidate region predicted as a scratch. The probability distribution is output to determine the defect type to be verified.
[0010] The defect type prediction network is optimized by introducing a physical consistency constraint loss, including: For candidate regions predicted as bubbles, the standard deviation of the response intensity of the candidate region at different polarization angles in the polarization image sequence is calculated, and the difference between the standard deviation and the preset bubble response consistency threshold is taken as the response consistency deviation. For candidate regions predicted as deformable, the curvature feature distribution of the candidate region is extracted from the geometric deformation branch feature map, the gradient magnitude of the curvature values of adjacent pixels is calculated, and the difference between the average value of the gradient magnitude and the preset curvature smoothness threshold is taken as the curvature continuity deviation. For candidate regions predicted as scratches, the aspect ratio of the minimum bounding rectangle of the candidate region is calculated. The directional gradient energy distribution of the candidate region is extracted from the surface texture branch feature map, and the deviation angle of the main direction is calculated. The difference between the aspect ratio and the preset aspect ratio threshold, and the difference between the deviation angle of the main direction and the preset angle threshold are calculated. The weighted sum of the two differences is taken as the consistency deviation between the aspect ratio and the main direction.
[0011] For bubble-type defects, the consistency of their response in the polarization image sequence is verified; for deformation-type defects, the curvature continuity is verified; for scratch-type defects, the consistency of their aspect ratio and principal direction is verified. Based on the verification results, the probability distribution is corrected, including: For candidate regions of bubble-like defects, the variance of their response intensity sequence at different polarization angles in the polarization image sequence is calculated, and the polarization anomaly index in the optical anomaly branch feature map is used for joint determination to generate bubble verification confidence. For candidate regions of deformation-type defects, calculate the spatial gradient smoothness of the curvature feature distribution in the geometric deformation branch feature map to generate deformation verification confidence. For candidate regions of scratch-type defects, calculate the aspect ratio of their minimum bounding rectangle, combine the directional gradient energy features in the surface texture branch feature map to calculate the main direction consistency index and generate scratch verification confidence. The probability distribution is corrected by constructing a probability adjustment amount based on the bubble verification confidence, the deformation verification confidence, and the scratch verification confidence. For defect types with verification confidence greater than a first preset threshold, the probability value is increased, and for defect types with verification confidence less than the first preset threshold, the probability value is decreased. The corrected probability distribution is obtained, and the defect detection result is output based on the corrected probability distribution.
[0012] A second aspect of the present invention provides an intelligent detection system for injection molding defects in plastic products, comprising: The polarization image unit is used to acquire the polarization image sequence of the plastic product to be detected, calculate the polarization degree distribution, divide the surface of the plastic product into transparent, semi-transparent and opaque regions according to the polarization degree distribution, and apply a differentiated enhancement strategy to different transparency regions to generate adaptive enhanced images. The region partitioning unit is used to construct a three-branch feature extraction network, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. The feature extraction unit is used to dynamically weight and fuse the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism to obtain a comprehensive feature map. The fusion weights are adaptively predicted and generated based on the feature maps of each branch. The feature fusion unit is used to generate candidate defect regions on the comprehensive feature map and output the probability distribution of defect types, determine the defect types to be verified, verify the response consistency of bubble-type defects in the polarization image sequence, verify the curvature continuity of deformation-type defects, verify the aspect ratio and main direction consistency of scratch-type defects, correct the probability distribution based on the verification results, and output the defect detection results.
[0013] A third aspect of the present invention provides an electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0014] A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0015] This method divides the surface of plastic products into transparent, semi-transparent, and opaque areas based on differences in transparency, and implements a differentiated image enhancement strategy. This step effectively overcomes the problems of insufficient contrast or loss of detail in traditional single enhancement methods when dealing with materials with multiple levels of transparency, and significantly improves the visibility and distinguishability of various defects under complex optical conditions.
[0016] By constructing a three-branch feature extraction network, significant responses are made to changes in the internal optical properties of bubbles, impurities, etc. This multi-dimensional feature extraction mechanism ensures that highly discriminative feature representations can be obtained for different types of defects. Adaptive weighted fusion of the three-branch features can intelligently adjust the contribution ratio of different feature dimensions according to the characteristics of the current detection area. The resulting comprehensive feature map integrates the advantages of multi-source information, possessing both comprehensiveness and specificity, and significantly improving feature representation and defect discrimination capabilities.
[0017] In the defect identification stage, candidate defect regions are first generated and a preliminary probability distribution is output. Then, physical characteristic verification is performed for key defect types. For bubble-type defects, the consistency of their optical response in the polarization image sequence is verified; for deformation-type defects, the continuity of their curvature distribution is verified; and for scratch-type defects, the consistency of their aspect ratio and principal direction is verified. This verification step effectively filters out false detections caused by noise, artifacts, etc., significantly improving the accuracy and reliability of the final defect detection results and reducing the false alarm rate. Attached Figure Description
[0018] Figure 1 A flowchart illustrating an intelligent detection method for injection molding defects in plastic products; Figure 2 The flowchart is for a three-branch feature extraction network. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0021] Figure 1 This is a schematic flowchart of the intelligent detection method for injection molding defects in plastic products according to an embodiment of the present invention. Figure 1 As shown, the intelligent detection method for injection molding defects in plastic products includes: A sequence of polarization images of the plastic product to be inspected is acquired, the polarization degree distribution is calculated, and the surface of the plastic product is divided into transparent, semi-transparent, and opaque regions based on the polarization degree distribution. A differentiated enhancement strategy is applied to regions with different transparency to generate adaptive enhanced images. A three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. A comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism, with the fusion weights adaptively predicted and generated based on the feature maps of each branch. Defect candidate regions are generated on the comprehensive feature map and the probability distribution of defect types is output. The defect types to be verified are determined. For bubble-type defects, the response consistency in the polarization image sequence is verified. For deformation-type defects, the curvature continuity is verified. For scratch-type defects, the aspect ratio and the consistency of the main direction are verified. Based on the verification results, the probability distribution is corrected and the defect detection results are output.
[0022] In one optional implementation, the polarization degree distribution is calculated, and a differentiated enhancement strategy is applied to regions of different transparency to generate an adaptively enhanced image, including: Stokes parameter vectors are calculated based on the acquired polarization image sequence. The degree of polarization distribution is calculated based on each component of the Stokes parameter vector. Based on the numerical range of the degree of polarization distribution, the pixels on the surface of the plastic product are classified into transparent, semi-transparent, and opaque regions, respectively. A polarization difference enhancement strategy is used to extract polarization contrast features based on Stokes parameter components for the transparent region. An adaptive histogram equalization enhancement strategy is used to improve local contrast for the semi-transparent region. An intensity preservation strategy is used to preserve the original light intensity information for the opaque region. The enhanced images of each region are then spatially stitched together to generate an adaptive enhanced image.
[0023] For example, polarization imaging systems typically employ a rotating polarizer scheme or a polarization camera array scheme to acquire multi-angle polarization image sequences. Specifically, in the rotating polarizer scheme, a rotatable linear polarizer is placed in front of the image sensor, and four polarization images with polarization angles of 0°, 45°, 90°, and 135° are acquired sequentially, denoted as . , , , These four polarization images contain information about the polarization state of light waves and can be used to calculate the Stokes parameter vector.
[0024] The Stokes parameter vector consists of four components, denoted as: .in, This represents the total light intensity, calculated by summing the image intensities at four polarization angles, taking the average, and then multiplying by 2. . This represents the difference in polarization between the horizontal and vertical directions, through... Obtained through calculation. The formula representing the polarization difference between the 45° and 135° directions is as follows: In linear polarization measurements, The components are set to zero or obtained through additional circular polarization measurements. In this embodiment, the first three Stokes parameter components are mainly used for subsequent processing.
[0025] Based on the Stokes parameter vector, the degree of polarization distribution reflects the degree of polarization of light waves, and is calculated as follows: In practical applications, when ignoring When the components are used, the degree of polarization is simplified to The polarization degree ranges from 0 to 1. When the polarization degree is close to 1, it indicates that the light wave is nearly fully polarized, and when it is close to 0, it indicates that the light wave is close to natural light. For plastic products, transparent areas have low polarization of reflected light due to the material's light transmission characteristics, typically between 0 and 0.3; semi-transparent areas have some light scattering and reflection, with a polarization degree between 0.3 and 0.6; opaque areas are dominated by surface reflection, with a polarization degree typically greater than 0.6. Based on these polarization degree threshold ranges, each pixel on the surface of the plastic product is classified. Specifically, the coordinates of each pixel in the polarization degree distribution map are traversed. If the degree of polarization at that position If the pixel is in the transparent region set, then the pixel is classified into the transparent region set; if If it is, then it is classified into the semi-transparent region set; if If so, it is classified into the set of opaque regions.
[0026] For transparent regions, since conventional intensity images have low sensitivity to defects in these areas, a polarization difference enhancement strategy is employed to extract polarization contrast features. These polarization contrast features are achieved by constructing the differential response of the Stokes parameter components. The polarization contrast-enhanced image is defined as... ,in , , To enhance the weighting coefficients, optimal values of 0.4, 0.4, and 0.2 were determined through experimental statistics. This enhancement method can amplify polarization changes caused by local stress concentration and internal bubbles in transparent areas. For transparent plastic products, when bubble defects are present, the abrupt change in refractive index at the bubble boundary leads to abnormal changes in polarization state, which can be effectively highlighted through polarization difference.
[0027] For semi-transparent areas, which exhibit surface texture and scattering characteristics but suffer from insufficient overall contrast, an adaptive histogram equalization enhancement strategy is employed to improve local contrast. The semi-transparent image is divided into several non-overlapping sub-blocks, each with a size of 32×32 pixels. Histogram equalization is performed independently on each sub-block, calculating the cumulative distribution function of pixel grayscale values within that block and mapping it to the full grayscale range. To avoid boundary effects between adjacent sub-blocks, bilinear interpolation is used for smooth transitions at the sub-block boundaries. The advantage of adaptive histogram equalization lies in its ability to adaptively adjust the enhancement intensity based on local image characteristics, effectively highlighting surface defects such as scratches and blemishes in semi-transparent areas.
[0028] For opaque areas, due to their significant surface reflectivity, the original intensity image already contains rich texture and defect information; excessive enhancement may introduce noise or distortion. Therefore, an intensity preservation strategy is adopted, preserving the original intensity information without additional enhancement. Specifically, the enhanced image of the opaque area is directly set to a value equal to a certain percentage of the Stokes parameters. Components, i.e. To preserve the original intensity distribution characteristics of the region.
[0029] After completing the differentiated enhancement processing for each region, the enhanced images of each region need to be spatially stitched to generate an adaptive enhanced image. The stitching process follows the principle of pixel coordinate correspondence. Based on the previously established region classification results, for each pixel position in the image... Determine the category of the region it belongs to; if it belongs to a transparent region, assign a value to the corresponding position in the adaptively enhanced image. If it belongs to a semi-transparent area, assign the value as the result of adaptive histogram equalization; if it belongs to an opaque area, assign the value as... To eliminate abrupt changes at region boundaries, a 5-pixel wide transition band is set at the junction of different regions. A weighted average method is used within this transition band to achieve a smooth transition. Specifically, for pixels located near region boundaries, their final value is obtained by fusing the enhancement results of adjacent regions according to distance weights, with the weight coefficients varying linearly with distance. For example, for a pixel located at the junction of a transparent and a semi-transparent region, if it is 3 pixels from the center of the transparent region and 2 pixels from the center of the semi-transparent region, then the fusion weight of this pixel is... , The final value assigned is .
[0030] The generated adaptive enhanced image integrates polarization contrast features, local contrast enhancement features, and original intensity features, effectively adapting to the differences in transparency on the surface of plastic products and providing high-quality input data for subsequent feature extraction networks. This differentiated enhancement strategy effectively solves the problem that single enhancement methods cannot adequately address regions with varying transparency, significantly improving the robustness and accuracy of defect detection.
[0031] In one optional implementation, a three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution, including: The surface texture branch configures the filter bank according to the division of the transparency region. The region with higher transparency adopts a higher directional sampling density and a smaller spatial scale range to generate material-adaptive directional gradient energy features. The geometric deformation branch assigns confidence weights based on the phase unwrapping process of the polarization degree distribution in the transparent, semi-transparent, and opaque regions. The confidence weight of the transparent region is less than that of the semi-transparent region, and the confidence weight of the semi-transparent region is less than that of the opaque region. The curvature feature is calculated based on the confidence-weighted height field. The optical anomaly branch constructs a multi-scale local analysis window. The statistical deviation calculated in the fine-scale window corresponds to the surface defect response characteristics, while the statistical deviation calculated in the coarse-scale window corresponds to the internal defect response characteristics. The multi-scale statistical deviation is then fused to generate the polarization anomaly index characteristics.
[0032] Combination Figure 2 This paper describes a three-branch feature extraction network flowchart. During the injection molding process of plastic products, different material formulations, mold temperatures, and injection pressures can lead to varying transparency characteristics in the finished product. To address the impact of these transparency differences on defect detection, a feature extraction architecture capable of adapting to changes in the optical properties of the material is needed. This architecture employs a three-branch parallel processing strategy, extracting complementary defect features from three dimensions: surface texture, geometric deformation, and optical anomalies.
[0033] The core of the surface texture branch lies in dynamically adjusting the filter configuration parameters based on the material's transparency. For highly transparent areas, light undergoes significant refraction and scattering, causing surface texture information to be interfered with by deeper structures. In this case, it's necessary to increase the density of directional sampling, for example, reducing the directional sampling interval from the usual 30 degrees to 15 degrees or even 10 degrees, capturing subtle texture changes through denser directional sampling. Simultaneously, the spatial scale range is narrowed, adjusting the standard deviation of the Gaussian filter from the usual 3-5 pixels to 1-2 pixels, focusing on the texture features of the shallow surface. For semi-transparent areas, the partial light transmission characteristics of the material cause surface and subsurface information to mix. In this case, a medium-density directional sampling is used, with the directional interval set to approximately 20 degrees, and the spatial scale range selected as 2-4 pixels with a standard deviation. For opaque areas, since light cannot penetrate the material, the surface texture information is clearest, allowing for a larger spatial scale range, with a standard deviation set to 4-6 pixels, and the directional sampling interval can be appropriately widened to 25-30 degrees. In practical implementation, firstly, a region mask is generated based on the transparency region segmentation results, and then a corresponding Gabor filter group is configured for each transparency category. The filter bank for transparent regions contains 24 directions (spaced 15 degrees) and 3 scales (standard deviations of 1 pixel, 1.5 pixels, and 2 pixels, respectively). Semi-transparent regions have 18 directions (spaced 20 degrees) and 3 scales (standard deviations of 2 pixels, 3 pixels, and 4 pixels, respectively), while opaque regions have 12 directions (spaced 30 degrees) and 3 scales (standard deviations of 4 pixels, 5 pixels, and 6 pixels, respectively). After filtering the adaptively enhanced image, the gradient response energy of each pixel location in each direction is calculated. The energy responses in different directions are organized into an energy distribution vector, which characterizes the directionality and intensity features of the local texture. For regions with surface defects such as scratches and indentations, the directional gradient energy will show significant peaks in specific directions, while the energy distribution in normal texture regions is relatively uniform.
[0034] The geometric deformation branch utilizes phase measurement profilometry to acquire 3D topographic information of plastic products. This technique projects a periodic stripe pattern and acquires deformed stripes, calculating the height distribution of the object's surface from the phase information. However, materials with varying transparency significantly affect the imaging quality of the stripes. Highly transparent areas experience internal scattering, leading to blurred stripe edges and reduced reliability of phase calculations; opaque areas produce clear and stable stripe images with high reliability of phase information. To address this difference, a transparency-based confidence weighting mechanism is introduced during phase unwrapping. Transparent areas exhibit systematic errors in phase measurement due to internal scattering and refraction, and their confidence weight is set to 0.3-0.5; semi-transparent areas have moderate scattering effects, and their confidence weight is set to 0.5-0.7; phase measurement in opaque areas is the most reliable, and its confidence weight is set to 0.8-1.0. In practical calculations, the wrapped phase is first extracted from the acquired stripe image using Fourier transform or phase shift methods, and then a quality-oriented phase unwrapping algorithm is applied. This algorithm calculates the quality value of each pixel based on the phase gradient and modulation, combining it with the confidence weight corresponding to the transparency area to form a comprehensive quality map. The unwrapping process starts with high-quality points and expands towards low-quality points. The low confidence weight of transparent areas reduces their priority in path planning, preventing errors from accumulating in highly transparent areas and propagating to other areas. After unwrapping, a continuous phase distribution is obtained, and the surface height field is calculated based on the phase-height conversion relationship calibrated by the system. The phase-height conversion relationship is established through system calibration by fitting the phase values of standard samples with known heights to the actual heights at multiple points to obtain linear or polynomial conversion coefficients. Based on the height field, the curvature distribution at each point is calculated using a difference operator. For a two-dimensional surface, curvature includes principal curvature and mean curvature. Principal curvature reflects the curvature values of the surface in the directions of maximum and minimum bending, while mean curvature comprehensively characterizes the degree of surface bending. Regions with geometric deformation defects such as depressions and protrusions will have curvatures deviating from the design values; these deformed regions can be identified by setting a curvature threshold. To suppress noise, the height field is subjected to bilateral filtering before curvature calculation. This filtering method smooths noise while preserving geometric edge features.
[0035] The optical anomaly branch is analyzed directly based on the polarization degree distribution map. Polarization degree reflects the polarization characteristics of reflected light and is closely related to the surface state and internal structure of the material. The polarization degree distribution in normal areas exhibits stable statistical characteristics, while defective areas cause local anomalies in polarization degree. To distinguish between surface defects and internal defects, multi-scale local analysis windows are constructed. The size of the fine-scale window is set to 5×5 or 7×7 pixels, mainly capturing local abrupt changes in polarization degree, which usually correspond to surface defects such as scratches, indentations, and contamination. The size of the coarse-scale window is set to 15×15 or 21×21 pixels to analyze the statistical distribution of polarization degree over a larger range. This macroscopic statistical deviation often corresponds to internal structural defects such as bubbles and weld lines. Within each scale analysis window, the mean and standard deviation of the polarization degree in the neighborhood of the central pixel of the window are first calculated, and then the deviation of the central pixel's polarization degree from the neighborhood statistics is calculated. The deviation can be calculated in the form of standardized residuals, by subtracting the neighborhood mean from the central pixel's polarization degree and dividing by the neighborhood standard deviation to obtain the dimensionless statistical deviation. The larger the absolute value of this value, the more abnormal the polarization degree of that pixel. For surface defects, the statistical deviation of the fine-scale window will show a significant peak, while the statistical deviation of the coarse-scale window will be relatively small; for internal defects, the statistical deviation of the coarse-scale window will increase significantly, indicating the existence of a large-scale abnormal distribution of polarization degree. The statistical deviations of multiple scales are weighted and fused to form the final polarization anomaly index feature. The fusion weights are set according to prior knowledge of the defect type. For example, for detection scenarios mainly involving surface defects, the weight of the fine-scale window is increased; for scenarios that need to detect internal defects, the weight of the coarse-scale window is increased. In practical applications, three analysis windows can be set with sizes of 5×5, 11×11, and 21×21 pixels, respectively, with corresponding fusion weights of 0.5, 0.3, and 0.2. This configuration can ensure the sensitivity of surface defect detection while taking into account the ability to identify internal defects.
[0036] The feature maps output by the three branches after independent processing have the same spatial resolution, providing a foundation for subsequent feature fusion. This multi-dimensional, multi-modal feature extraction strategy can comprehensively capture various defect features that may exist on the surface and inside of plastic products, laying the foundation for accurate defect identification.
[0037] In one optional implementation, a comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism. The fusion weights are adaptively predicted and generated based on the feature maps of each branch, including: A spatial guiding mask is generated based on the division results of the transparent region, semi-transparent region and opaque region. The spatial guiding mask assigns a weight gain coefficient to the optical anomaly branch to the transparent region, a weight gain coefficient to the surface texture branch and geometric deformation branch to the semi-transparent region, and a weight gain coefficient to the geometric deformation branch to the opaque region. Calculate the feature correlation matrix between the feature maps of the three branches, and generate cross-branch modulation weights based on the feature correlation matrix. The cross-branch modulation weights are used to suppress the response intensity of feature conflict regions and enhance the response intensity of feature complementary regions. The final fusion weight is obtained by multiplying the weight gain coefficient of the spatial guiding mask element-wise with the cross-branch modulation weight. The feature maps of the three branches are then weighted and fused based on the final fusion weight to obtain the comprehensive feature map.
[0038] For example, after obtaining the feature maps of the three-branch feature extraction network, adaptive fusion is required based on the transparency characteristics of different regions on the surface of the plastic product and the feature relationships between the branches. The fusion process first generates a spatial guiding mask based on the transparency partitioning results. This mask is essentially a weight matrix with the same spatial size as the feature map, used to guide the contribution of different branch features at different spatial locations. The weight gain coefficient is a multiplicative coefficient used to adjust the contribution of each branch feature map to the final fusion result.
[0039] For mask generation in transparent regions, since the defects in these regions mainly manifest as optical anomalies, the spatial guiding mask for these regions needs to enhance the role of the optical anomaly branches. Specifically, the weight gain coefficient of the optical anomaly branch at the corresponding position in the transparent region is set to... Its numerical range is set to 1.5 to 2.5, and the surface texture branch weight gain coefficient for this region is set to... Its numerical range is 0.3 to 0.6, and the geometric deformation branch weight gain coefficient is set to... Its value ranges from 0.2 to 0.5. This weighting configuration reflects the physical fact that optical features dominate in the transparent region.
[0040] For semi-transparent regions, defects may manifest as either surface texture anomalies or geometric deformations; therefore, it is necessary to balance the contributions of the surface texture branch and the geometric deformation branch. In the spatial guiding mask for this region, the weight gain coefficient of the surface texture branch is set to... Its numerical range is 1.2 to 1.8, and the weight gain coefficient of the geometric deformation branch is set to... Its value ranges from 1.0 to 1.5, and the weighting gain coefficient of the optical anomaly branch is set to... Its value ranges from 0.5 to 0.9. This configuration allows surface features and deformation characteristics to be fully represented.
[0041] For opaque regions, the reliability of polarization and surface texture information decreases because light cannot penetrate them, and defect detection relies primarily on geometric deformation features. The spatial guiding mask for this region sets the weight gain coefficient of the geometric deformation branch to... Its value ranges from 2.0 to 3.0, and the weight gain coefficient of the surface texture branch is set to... Its value ranges from 0.4 to 0.7, and the weighting gain coefficient of the optical anomaly branch is set to... Its value ranges from 0.1 to 0.3.
[0042] After generating the spatial guiding mask, further analysis of the correlation between the three branch feature maps is needed. The feature correlation matrix is calculated by extracting the global statistical properties of each branch feature map in the spatial dimension. For a size of... Feature maps, where and These represent the height and width of the feature map, respectively. To represent the number of channels, first perform a global average pooling operation on the spatial dimension, and obtain... The eigenvectors of the three branches are denoted as follows: ,and Calculate the cosine similarity between each pair of them to construct a correlation matrix. .
[0043] Correlation matrix It is A symmetric matrix, where the elements Indicates the first The branch and the first The degree of correlation of features in each branch. When the value is large, it indicates that the features captured by the two branches in this region have high consistency, and there may be information redundancy; when When the value is small or even negative, it indicates that there is a conflict between the features of the two branches, which needs to be suppressed. Cross-branch modulation weights are generated based on the correlation matrix, the dominant mode in the feature space is extracted through diagonalization, and the response intensity of each branch is dynamically adjusted according to the degree of feature consistency.
[0044] The identification of feature conflict regions is achieved by calculating the response differences of the feature map within a local window. The feature map is then divided into several... A partial window, in which The typical value is 7 or 9. Within each local window, the mean response of the three branch feature maps is calculated and denoted as... , and When the difference between the mean responses of any two branches exceeds a preset threshold. At that time, the window is marked as a feature conflict region. Threshold The dynamic range of the feature map is adaptively determined, typically set to 0.5 to 1.0 times the global standard deviation of the feature map. The identification of complementary regions is achieved by analyzing the feature activation patterns of different branches at the same location. When a branch has a strong response at a specific location while other branches have weak responses, that location is considered a complementary region. Specifically, this is determined by calculating the normalized response values of the feature maps of each branch. When the normalized response value of a branch exceeds 0.7 and the normalized response values of other branches are below 0.4, that location is marked as a complementary region.
[0045] Cross-branch modulation weights The generation comprehensively considers the correlation matrix and the results of feature conflict complementarity analysis. For feature conflict regions, the modulation weights are adjusted using suppression factors. Attenuation is performed, with the suppression factor ranging from 0.2 to 0.5, and the degree of attenuation is proportional to the severity of feature conflict. For feature complementary regions, the modulation weights are adjusted using an enhancement factor. Amplification is applied, with enhancement factors ranging from 1.5 to 2.5, the degree of amplification being proportional to the significance of feature complementarity. For conventional regions that are neither conflicting nor complementary, the modulation weight remains at 1.0.
[0046] After obtaining the weight gain coefficients of the spatial guiding mask and the cross-branch modulation weights, an element-wise multiplication operation is performed to generate the final fused weights. This operation is performed at each spatial location and in each channel dimension of the feature map to ensure that the fused weights accurately reflect the importance of local features. The final fused weight matrix has the same dimension as the original feature map, i.e. Each feature response is given an independent weighting coefficient.
[0047] When weighting and fusing the feature maps of the three branches based on the final fusion weights, a channel-level weighted summation method is used. Let the feature map of the surface texture branch be... The feature map of the geometric deformation branch is The characteristic diagram of the optical anomaly branch is as follows The corresponding final fusion weights are respectively , and Comprehensive feature map The feature map is obtained by weighted summation, which involves multiplying the feature maps of the three branches element-wise with their corresponding weights and then summing the results. To prevent the fused feature values from being too large or too small, the combined feature map is normalized to adjust the range of feature values to between 0 and 1.
[0048] The weighted fusion of the integrated feature map retains the key information of each branch while suppressing redundant and conflicting features, significantly improving the accuracy and robustness of defect detection, and enabling the detection method to adapt to the diversity and complexity of the surface properties of plastic products.
[0049] In one optional implementation, generating candidate defect regions on the comprehensive feature map and outputting a probability distribution of defect types includes: Defect candidate regions are generated by performing response intensity threshold segmentation on the comprehensive feature map; Extract the local response features of the defect candidate region on the three branch feature maps, and obtain preliminary type tendency scores for bubble, deformation and scratch types through type tendency prediction; Based on the preliminary type tendency score, the local response features of the three branches are dynamically weighted and fused with type awareness to obtain a discriminative enhanced feature vector. Specifically, the fusion weight of the optical anomaly branch feature is increased for the candidate region with the largest tendency score of bubble-type defects, the fusion weight of the geometric deformation branch feature is increased for the candidate region with the largest tendency score of deformation-type defects, and the fusion weight of the surface texture branch feature is increased for the candidate region with the largest tendency score of scratch-type defects. The discriminative enhancement feature vector is input into the defect type prediction network, and the physical consistency constraint loss is introduced to optimize the defect type prediction network. The physical consistency constraint loss is calculated from the response consistency deviation of the candidate region predicted as a bubble, the curvature continuity deviation of the candidate region predicted as a deformation, and the aspect ratio and main direction consistency deviation of the candidate region predicted as a scratch. The probability distribution is output to determine the defect type to be verified.
[0050] For example, response intensity thresholding is performed on the composite feature map. This segmentation process is based on the statistical properties of the feature response values, calculating the mean response intensity of all pixels in the composite feature map. and standard deviation Set adaptive threshold , where the coefficient The value is typically set based on the material properties and manufacturing process of the plastic product, and usually ranges from 1.5 to 3.0. A response intensity greater than... Pixel regions are marked as potential defect response areas. To avoid noise interference, morphological filtering is performed on the marked regions to remove pixels with areas smaller than the minimum defect size threshold. The isolated response points. The connected regions obtained after these processes are the defect candidate regions, and each candidate region is located and described by the minimum bounding rectangle.
[0051] For each defect candidate region, local response features are extracted at the corresponding location on the three branch feature maps. On the surface texture branch feature map, the directional gradient energy distribution features within the candidate region are extracted. This feature vector contains statistical information about the gradient intensity of the region in multiple directions. Curvature response features of the candidate region are extracted from the geometric deformation branch feature map. This feature reflects the magnitude and distribution pattern of surface curvature variations within the region. Polarization anomaly response features of candidate regions are extracted from the optical anomaly branch feature map. This feature describes the degree of anomalous polarization characteristics within the region. These three local response features are concatenated to form a preliminary feature vector. To obtain preliminary type preference scores, a type preference prediction module is constructed. This module employs a lightweight fully connected network structure, consisting of an input layer, one hidden layer, and an output layer. The number of neurons in the input layer matches the dimension of the preliminary feature vector. The hidden layer contains 64 neurons using the ReLU activation function, and the output layer contains 3 neurons corresponding to the three defect types using the softmax activation function. The network is trained using labeled samples, with cross-entropy loss as the loss function, the Adam algorithm as the optimizer, and a learning rate of 0.001. The input is the preliminary feature vector. The output is a three-dimensional vector. , representing the tendency scores for the candidate region to belong to the bubble, deformation, and scratch defect categories, respectively. The tendency scores are normalized using the softmax function to ensure that the sum of the three scores is 1, i.e. The propensity score reflects a rough judgment of the defect type based on preliminary features, providing guidance for subsequent feature weighting and fusion.
[0052] A type-aware, dynamically weighted fusion strategy is implemented based on preliminary type preference scores. The core idea of this strategy is to dynamically adjust the fusion weights of the three branch features according to the most likely defect type of the candidate region, giving greater weight to the features of the most relevant branch in the fusion process. The fusion weight vector is then calculated. ( The weight coefficients (representing the three branch features) are assigned as follows: First, identify the category with the highest tendency score. Then according to The value of is set in the base weight vector. When When dealing with the bubble class, set the basic weight vector as follows: That is, increase the weight of the optical anomaly branch feature to 0.6; when When dealing with the corresponding transformation class, set That is, increase the weight of the geometric deformation branch feature to 0.6; when When dealing with scratches, set This means increasing the weight of surface texture branch features to 0.6. To make the weight adjustment smoother, further fine-tuning is performed by combining the confidence level of the propensity score, resulting in a final fused weight of... ,in The adjustment coefficient is typically set between 0.1 and 0.3. This dynamic weighting method is used to obtain the discriminatively enhanced feature vector. .
[0053] The discriminative enhancement feature vector is input into the defect type prediction network for accurate type discrimination. The defect type prediction network employs a multilayer perceptron structure, containing two hidden layers with 128 and 64 neurons respectively, and using the ReLU activation function. The network's output layer contains three neurons, corresponding to the predicted probabilities of bubble, deformed, and scratch defects, respectively. The output layer activation function is the softmax function, and the output probability distribution is expressed as follows: ,satisfy That is, the sum of the probabilities of the three types of defects is 1.
[0054] To improve prediction accuracy and incorporate prior physical knowledge, a physical consistency constraint loss is introduced when training the defect type prediction network. This loss function consists of three components, each constraining the physical characteristics of one of the three defect types. The first component is the response consistency deviation loss for bubble-type defects. For candidate regions predicted to be bubbles, the consistency of their response at different polarization angles in the polarization image sequence is calculated. The polarization characteristics inside the bubble should exhibit regular changes at various angles due to variations in material density. This is achieved by calculating the response value sequence of the candidate region in the images at each polarization angle. ( (The number of polarization angles) is used to calculate the coefficient of variation of the sequence. ,in and These are the standard deviation and mean of the response sequence, respectively. Response consistency deviation is defined as... ,in The first component is the reference coefficient of variation for standard bubble defects, obtained through statistical annotation of samples. The second component is the curvature continuity deviation loss for deformable defects. For candidate regions predicted as deformation-related, the continuity index of their surface curvature is calculated. Deformation defects typically exhibit a gradual transition in surface curvature rather than an abrupt change. The curvature distribution of the candidate regions is extracted. Calculate the maximum value of the curvature gradient along the region boundary. Curvature continuity deviation is defined as... ,in This is the curvature gradient threshold. Exceeding this threshold indicates that the curvature is discontinuous, which is inconsistent with the physical characteristics of the deformation defect.
[0055] The third component is the aspect ratio and main direction consistency deviation loss of scratch-type defects. For candidate regions predicted as scratches, verify whether their geometric features conform to the elongated characteristics of scratches. Calculate the minimum bounding rectangle of the candidate region and obtain its length. and width Calculate the aspect ratio The aspect ratio of a typical scratch should be greater than the threshold. (Typically set to 3.0). Simultaneously calculate the principal direction of the gradient within the region. This direction should be aligned with the major axis of the rectangle. Basically the same.
[0056] In one alternative implementation, a physical consistency constraint loss is introduced to optimize the defect type prediction network, including: For candidate regions predicted as bubbles, the standard deviation of the response intensity of the candidate region at different polarization angles in the polarization image sequence is calculated, and the difference between the standard deviation and the preset bubble response consistency threshold is taken as the response consistency deviation. For candidate regions predicted as deformable, the curvature feature distribution of the candidate region is extracted from the geometric deformation branch feature map, the gradient magnitude of the curvature values of adjacent pixels is calculated, and the difference between the average value of the gradient magnitude and the preset curvature smoothness threshold is taken as the curvature continuity deviation. For candidate regions predicted as scratches, calculate the aspect ratio of the minimum bounding rectangle of the candidate region, extract the directional gradient energy distribution of the candidate region from the surface texture branch feature map, and calculate the main direction deviation angle. Calculate the difference between the aspect ratio and the preset aspect ratio threshold, and the difference between the main direction deviation angle and the preset angle threshold. The weighted sum of the two differences is taken as the aspect ratio and main direction consistency deviation.
[0057] For example, during the training phase of the defect type prediction network, a physical consistency constraint loss function is introduced. This ensures that the feature representations learned by the network not only conform to data-driven statistical laws but also satisfy the physical characteristic constraints of defects in plastic products. This loss function designs constraint terms for the three main defect types, guiding the optimization direction of network parameters by quantifying the degree of deviation between the prediction results and prior physical knowledge.
[0058] To address the physical consistency constraints of bubble-like defects, this study leverages the stable optical response of bubbles under different polarization angles. When the network predicts that a candidate region belongs to the bubble-like defect, the response data of that candidate region in a polarization image sequence is extracted. The polarization image sequence contains polarization angles... Downloaded Image, usually Choose 4 to 6, with polarization angle intervals of 30° or 45°. For coordinates... The response intensities of the pixels at different polarization angles are denoted as follows: Calculate the standard deviation of the response intensity of all pixels within the candidate region at different polarization angles. Specifically, for the candidate region... Each pixel within Calculate the point at The average response intensity at each polarization angle
[0059] Then calculate the standard deviation.
[0060] The average standard deviation of all pixels within the candidate region is used as a measure of response consistency for that region. ,in This represents the total number of pixels in the candidate region. Real bubble defects, due to their uniform internal gas medium, should exhibit relatively small changes in response intensity at different polarization angles; therefore, the standard deviation... It should be lower than the preset bubble response consistency threshold. This threshold is determined by statistically analyzing the response characteristics of a large number of real bubble samples, typically ranging from 8 to 15 gray levels. The response consistency deviation is calculated as follows: The maximum value function is used to ensure that a penalty term is generated only when the actual standard deviation exceeds the threshold. The average value representing the standard deviation of the response intensity. This represents the preset bubble response consistency threshold. The larger this deviation value, the less the candidate region predicted as a bubble conforms to the physical characteristics of a real bubble in terms of polarization response, and the more the network needs to adjust its parameters to reduce such misjudgments.
[0061] To address the physical consistency constraints of deformation-type defects, the smooth and continuous curvature variation characteristic of plastic product surface deformation is utilized. In the geometric deformation branch feature map, the curvature feature distribution of candidate regions has been extracted using phase measurement profilometry. The curvature feature map is denoted as... , where each position The value represents the magnitude of the surface curvature at that point. For candidate regions predicted as deformation-type... Extract the curvature distribution submap within this region. Real deformation defects, such as depressions or protrusions, should exhibit a gradual change in curvature in space; the curvature values of adjacent pixels should not show abrupt changes. Calculate the gradient magnitude of the curvature values of adjacent pixels, using the Sobel operator or the central difference method to calculate the spatial gradient of the curvature map. In the horizontal direction, the curvature gradient is... In the vertical direction, the curvature gradient is The gradient magnitude is The average gradient magnitude of all pixels within the candidate region is used as a measure of curvature continuity. The average curvature gradient of a real deformation defect should be lower than a preset curvature smoothness threshold. This threshold is determined based on the properties of the plastic material and the molding process, with a typical range of 10% to 20% of the maximum curvature. The curvature continuity deviation is calculated as follows: When a region predicted as deformable experiences a sharp change in curvature, the bias value increases, and the constraint network corrects its prediction results or adjusts the feature extraction method.
[0062] To address the physical consistency constraint of scratch-type defects, the geometric characteristics of scratches—namely, their elongated, strip-like shape and extension along a specific direction—are utilized. For candidate regions predicted as scratch-type defects... First, calculate the minimum bounding rectangle of the region. Then, determine the minimum area rectangle that completely contains the candidate region using the rotating caliper algorithm or principal component analysis. The length of the longer side of this rectangle is denoted as... The length of the shorter side is denoted as Calculate the aspect ratio. Real scratch defects typically have a large aspect ratio, with a typical value between 3 and 10. A preset aspect ratio threshold should be set according to the specific application scenario. The aspect ratio deviation is calculated as follows: A penalty is applied when the aspect ratio of the region predicted as a scratch is too small. Simultaneously, the directional gradient energy distribution of the candidate region is extracted from the surface texture branch feature map. The feature map output by the surface texture branch contains multiple directional channels, each corresponding to a gradient direction; typically, 360° is divided into 8 or 12 directions. For each pixel within the candidate region, its directional gradient energy distribution is represented as a vector. ,in Let ϕ1, ϕ2, ..., ϕ be the number of directions. D For the first Each direction angle. Calculate the cumulative distribution of directional gradient energy for all pixels within the candidate region. The principal direction corresponds to the direction in which the maximum value of the energy accumulation distribution is located. Calculate the angle between the principal direction and the direction of the longest side of the smallest bounding rectangle as the principal direction deviation angle. The angle should be within the range of 0° to 90°, taking the minimum included angle value. The main direction of the actual scratch should be consistent with its extension direction, that is, the deviation angle of the main direction should be close to 0°. Set a preset angle threshold. Typical values range from 15° to 25°. The deviation in the principal direction is calculated as follows: The overall consistency deviation of scratch-type defects is obtained by weighted summation of aspect ratio deviation and principal direction deviation. ,in and The weighting coefficients are determined based on the importance of the two constraints, and are typically set to... , Alternatively, the optimal ratio can be obtained through validation set optimization.
[0063] Construct a physical consistency loss function that includes all constraints. For each sample in the training batch, identify candidate regions predicted as bubbles, deformations, or scratches based on the probability distribution of defect types predicted by the network. For multiple candidate regions, calculate the physical consistency deviation for each region separately, and then take the average or sum as the total deviation for that sample. The physical consistency loss function is used in conjunction with the standard classification cross-entropy loss, with the total loss being... ,in The balancing coefficient is set to 0.2. Stochastic gradient descent is used to optimize the network parameters, with a training period of 100 epochs. The convergence of the loss is monitored using a validation set.
[0064] In one optional implementation, the consistency of the response of bubble-type defects in the polarization image sequence is verified, the curvature continuity of deformation-type defects is verified, and the aspect ratio and main direction consistency of scratch-type defects are verified. The probability distribution is then corrected based on the verification results, including: For candidate regions of bubble-like defects, the variance of their response intensity sequence at different polarization angles in the polarization image sequence is calculated, and the polarization anomaly index in the optical anomaly branch feature map is used for joint determination to generate bubble verification confidence. For candidate regions of deformation defects, the spatial gradient smoothness of the curvature feature distribution in the geometric deformation branch feature map is calculated to generate the deformation verification confidence score; for candidate regions of scratch defects, the aspect ratio of the minimum bounding rectangle is calculated, and the main direction consistency index is calculated by combining the directional gradient energy feature in the surface texture branch feature map to generate the scratch verification confidence score. The probability distribution is corrected by constructing a probability adjustment amount based on the bubble verification confidence, the deformation verification confidence, and the scratch verification confidence. For defect types with verification confidence greater than a first preset threshold, the probability value is increased, and for defect types with verification confidence less than the first preset threshold, the probability value is decreased. The corrected probability distribution is obtained, and the defect detection result is output based on the corrected probability distribution.
[0065] For example, after obtaining candidate defect regions and their preliminary type determination, targeted verification is needed based on the physical characteristics of different defect types to improve detection accuracy and reduce false positive rates. Different types of injection molding defects exhibit significant differences in physical behavior. Bubble defects mainly manifest as localized optical translucency abnormalities, deformation defects show continuous changes in geometric curvature, and scratch defects exhibit obvious linear directional characteristics. Based on these differences in physical characteristics, establishing a classification verification mechanism can effectively filter out misjudgments generated in the preliminary detection stage.
[0066] For candidate regions of bubble-like defects, the verification process fully utilizes multi-angle information from the polarization image sequence. During the acquisition of the polarization image sequence, image data at four polarization angles—0°, 45°, 90°, and 135°—were obtained. Due to the difference in refractive index between air and plastic within the bubble defect, it produces a stable optical response pattern under illumination at different polarization angles. Specifically, the pixel grayscale values corresponding to the candidate region are first extracted from the image at each polarization angle, and the average response intensity of that region is calculated, forming a response intensity sequence containing four elements. This response intensity sequence is denoted as... The subscripts represent the polarization angles. The variance of this sequence is calculated as a measure of response stability; the variance calculation formula is as follows: ,in This represents the average of four response intensities. Due to the isotropic nature of their physical structure, real bubble defects should exhibit a small variance in response intensity at different polarization angles, typically ranging from 5 to 15. Simultaneously, the polarization anomaly index at the corresponding location of the candidate region is extracted from the optical anomaly branch feature map. This index has already been calculated in the previous feature extraction stage. When making joint decisions, a bubble check confidence level is defined. The calculation method is as follows ,in and For the weighting coefficients, satisfying , usually set , , This is the normalization parameter for the variance, with a value of 20. This confidence level comprehensively considers both response consistency and the degree of polarization anomaly. When the value is greater than 0.75, the candidate region is considered to have a high probability of being a real bubble defect.
[0067] For candidate regions of deformation-type defects, the verification focus is on confirming the spatial continuity of curvature features. Local deformation of plastic products is usually caused by uneven cooling or demolding stress during injection molding. Their geometric deformation exhibits a smooth transition in space, with continuous curvature changes. The curvature feature distribution of candidate regions and their neighborhoods is extracted from the geometric deformation branch feature map. Each pixel in this feature map corresponds to the surface curvature value at that location. The curvature feature is calculated using phase-measured profilometry. The candidate region is dilated, increasing its size by 5 to 8 pixels. The spatial gradient of the curvature is then calculated within the expanded region. The gradient along the horizontal direction is... The gradient along the vertical direction is Discretization is performed using the Sobel operator. The curvature gradient magnitude is defined as... Calculate the curvature gradient magnitude of all pixels within the candidate region and calculate their standard deviation. As a metric for spatial gradient smoothness, the curvature change of a genuine deformed defect should be smooth, with a gradient standard deviation typically less than 0.3. In contrast, candidate regions generated by spurious defects or noise interference often exhibit abrupt changes or random fluctuations in curvature distribution, with a gradient standard deviation typically greater than 0.6. Deformation verification confidence level. Defined as ,in The threshold parameter is set to 0.4. The function is used to map the standard deviation to a range of 0 to 1. When When the value is greater than 0.7, the candidate region is considered to have the curvature continuity characteristics of a real deformation defect.
[0068] For candidate regions of scratch defects, the verification process combines geometric morphological features and texture direction features. Scratch defects are morphologically characterized as elongated linear regions, with their length much greater than their width, and an aspect ratio typically between 5 and 30. First, the candidate regions are binarized, and their contour point sets are extracted. The minimum bounding rectangle that completely encompasses this contour is then calculated. The direction that minimizes the area of the bounding rectangle is determined using a rotating caliper algorithm or principal component analysis; this direction is the principal direction of the scratch, denoted as . The length of the longest side of the smallest bounding rectangle is denoted as... The length of the shorter side is denoted as Calculate the aspect ratio index Simultaneously, the directional gradient energy features corresponding to candidate regions are extracted from the surface texture branch feature map. This feature, calculated during the feature extraction stage, contains the energy distribution of multiple directional channels. A principal direction analysis is performed on the directional gradient energy features, and the direction with the highest energy is calculated as the principal texture direction. Define the main direction consistency index. This indicator ranges from -1 to 1, with a value close to 1 when the two principal directions are aligned and close to -1 when they are perpendicular. The geometric principal directions of a genuine scratch defect should be highly consistent with the texture principal directions. Typically greater than 0.8. Scratch test confidence level. Taking into account both aspect ratio and orientation consistency, the calculation formula is as follows: ,in , , The normalized function for aspect ratio is defined as follows: , For reference aspect ratio, set it to 10. When When the value is greater than 0.75, the candidate region is considered to have the morphological and directional characteristics of a real scratch defect.
[0069] After calculating the confidence scores for various defects, the initial probability distribution of defect types needs to be corrected based on these confidence scores. Assume the initial probability distribution is... The four elements represent the probabilities of bubbles, deformation, scratches, and normal conditions, respectively, satisfying the following condition: For each defect type, a probability adjustment factor is constructed based on its corresponding verification confidence level. A first preset threshold is set. The threshold is 0.7. When the verification confidence of a certain type of defect exceeds this threshold, it indicates that the judgment of this type is highly reliable, and its probability value needs to be increased. The probability increase adjustment is defined as follows: ,in For the corresponding verification confidence level, The gain coefficient is set to 0.3. When the verification confidence level is less than the first preset threshold, it indicates that there may be a misjudgment in this type of judgment, and its probability value needs to be reduced. The probability reduction adjustment amount is defined as follows: ,in The penalty coefficient is set to 0.4.
[0070] The initial probability distribution is corrected by applying adjustment amounts to each category. For the bubble category, if... The corrected probability is ;like ,but Perform the same operation on deformation and scratch classes. After correction, normalize the probability distribution to ensure... The category with the highest probability after correction is selected as the final defect type. If the highest probability is less than 0.5 and the normal class has the highest probability, it is determined to be defect-free; otherwise, the corresponding defect type, its location coordinates, and size parameters are output as the defect detection result.
[0071] A second aspect of the present invention provides an intelligent detection system for injection molding defects in plastic products, comprising: The polarization image unit is used to acquire the polarization image sequence of the plastic product to be detected, calculate the polarization degree distribution, divide the surface of the plastic product into transparent, semi-transparent and opaque regions according to the polarization degree distribution, and apply a differentiated enhancement strategy to different transparency regions to generate adaptive enhanced images. The region partitioning unit is used to construct a three-branch feature extraction network, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. The feature extraction unit is used to dynamically weight and fuse the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism to obtain a comprehensive feature map. The fusion weights are adaptively predicted and generated based on the feature maps of each branch. The feature fusion unit is used to generate candidate defect regions on the comprehensive feature map and output the probability distribution of defect types, determine the defect types to be verified, verify the response consistency of bubble-type defects in the polarization image sequence, verify the curvature continuity of deformation-type defects, verify the aspect ratio and main direction consistency of scratch-type defects, correct the probability distribution based on the verification results, and output the defect detection results.
[0072] A third aspect of the present invention provides an electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0073] A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0074] This invention can be a method, apparatus, system, and / or computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of the invention.
[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An intelligent detection method for injection molding defects in plastic products, characterized in that, include: A sequence of polarization images of the plastic product to be inspected is acquired, the polarization degree distribution is calculated, and the surface of the plastic product is divided into transparent, semi-transparent, and opaque regions based on the polarization degree distribution. A differentiated enhancement strategy is applied to regions with different transparency to generate adaptive enhanced images. A three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. A comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism, with the fusion weights adaptively predicted and generated based on the feature maps of each branch. Defect candidate regions are generated on the comprehensive feature map and the probability distribution of defect types is output. The defect types to be verified are determined. For bubble-type defects, the response consistency in the polarization image sequence is verified. For deformation-type defects, the curvature continuity is verified. For scratch-type defects, the aspect ratio and the consistency of the main direction are verified. Based on the verification results, the probability distribution is corrected and the defect detection results are output.
2. The method according to claim 1, characterized in that, Calculate the polarization degree distribution and apply a differentiated enhancement strategy to regions with different transparency to generate adaptively enhanced images, including: Stokes parameter vectors are calculated based on the acquired polarization image sequence. The degree of polarization distribution is calculated based on each component of the Stokes parameter vector. Based on the numerical range of the degree of polarization distribution, the pixels on the surface of the plastic product are classified into transparent, semi-transparent, and opaque regions, respectively. A polarization difference enhancement strategy is used to extract polarization contrast features based on Stokes parameter components for the transparent region. An adaptive histogram equalization enhancement strategy is used to improve local contrast for the semi-transparent region. An intensity preservation strategy is used to preserve the original light intensity information for the opaque region. The enhanced images of each region are then spatially stitched together to generate an adaptive enhanced image.
3. The method according to claim 1, characterized in that, A three-branch feature extraction network is constructed, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution, including: The surface texture branch configures the filter bank based on the division of the transparency region to generate material-adaptive directional gradient energy features; The geometric deformation branch assigns confidence weights based on the phase unwrapping process of the polarization degree distribution in the transparent, semi-transparent, and opaque regions. The confidence weight of the transparent region is less than that of the semi-transparent region, and the confidence weight of the semi-transparent region is less than that of the opaque region. The curvature feature is calculated based on the confidence-weighted height field. The optical anomaly branch constructs a multi-scale local analysis window. The statistical deviation calculated in the fine-scale window corresponds to the surface defect response characteristics, while the statistical deviation calculated in the coarse-scale window corresponds to the internal defect response characteristics. The multi-scale statistical deviation is then fused to generate the polarization anomaly index characteristics.
4. The method according to claim 1, characterized in that, A comprehensive feature map is obtained by dynamically weighting and fusing the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism. The fusion weights are adaptively predicted and generated based on the feature maps of each branch, including: A spatial guiding mask is generated based on the division results of the transparent region, semi-transparent region and opaque region. The spatial guiding mask assigns a weight gain coefficient to the optical anomaly branch to the transparent region, a weight gain coefficient to the surface texture branch and geometric deformation branch to the semi-transparent region, and a weight gain coefficient to the geometric deformation branch to the opaque region. Calculate the feature correlation matrix between the feature maps of the three branches, and generate cross-branch modulation weights based on the feature correlation matrix. The cross-branch modulation weights are used to suppress the response intensity of feature conflict regions and enhance the response intensity of feature complementary regions. The final fusion weight is obtained by multiplying the weight gain coefficient of the spatial guiding mask element-wise with the cross-branch modulation weight. The feature maps of the three branches are then weighted and fused based on the final fusion weight to obtain the comprehensive feature map.
5. The method according to claim 1, characterized in that, Generating candidate defect regions on the comprehensive feature map and outputting the probability distribution of defect types includes: Response intensity threshold segmentation is performed on the comprehensive feature map to generate defect candidate regions; Local response features of the candidate defect regions on the three branch feature maps are extracted, and preliminary type tendency scores for bubble, deformation, and scratch types are obtained through type tendency prediction. Based on the preliminary type tendency scores, the local response features of the three branches are dynamically weighted and fused with type awareness to obtain a discriminative enhancement feature vector. Specifically, the fusion weight of the optical anomaly branch feature is increased for the candidate region with the largest bubble defect tendency score, the fusion weight of the geometric deformation branch feature is increased for the candidate region with the largest deformation defect tendency score, and the fusion weight of the surface texture branch feature is increased for the candidate region with the largest scratch defect tendency score. The discriminative enhancement feature vector is input into the defect type prediction network, and the physical consistency constraint loss is introduced to optimize the defect type prediction network. The physical consistency constraint loss is calculated from the response consistency deviation of the candidate region predicted as a bubble, the curvature continuity deviation of the candidate region predicted as a deformation, and the aspect ratio and main direction consistency deviation of the candidate region predicted as a scratch. The output probability distribution is then used.
6. The method according to claim 5, characterized in that, The defect type prediction network is optimized by introducing a physical consistency constraint loss, including: For candidate regions predicted as bubbles, the standard deviation of the response intensity of the candidate region at different polarization angles in the polarization image sequence is calculated, and the difference between the standard deviation and the preset bubble response consistency threshold is taken as the response consistency deviation. For candidate regions predicted as deformable, the curvature feature distribution of the candidate region is extracted from the geometric deformation branch feature map, the gradient magnitude of the curvature values of adjacent pixels is calculated, and the difference between the average value of the gradient magnitude and the preset curvature smoothness threshold is taken as the curvature continuity deviation. For candidate regions predicted as scratches, the aspect ratio of the minimum bounding rectangle of the candidate region is calculated. The directional gradient energy distribution of the candidate region is extracted from the surface texture branch feature map, and the deviation angle of the main direction is calculated. The difference between the aspect ratio and the preset aspect ratio threshold, and the difference between the deviation angle of the main direction and the preset angle threshold are calculated. The weighted sum of the two differences is taken as the consistency deviation between the aspect ratio and the main direction.
7. The method according to claim 1, characterized in that, For bubble-type defects, the consistency of their response in the polarization image sequence is verified; for deformation-type defects, the curvature continuity is verified; for scratch-type defects, the consistency of their aspect ratio and principal direction is verified. Based on the verification results, the probability distribution is corrected, including: For candidate regions of bubble-like defects, the variance of their response intensity sequence at different polarization angles in the polarization image sequence is calculated, and the polarization anomaly index in the optical anomaly branch feature map is used for joint determination to generate bubble verification confidence. For candidate regions of deformation-type defects, calculate the spatial gradient smoothness of the curvature feature distribution in the geometric deformation branch feature map to generate deformation verification confidence. For candidate regions of scratch-type defects, calculate the aspect ratio of their minimum bounding rectangle, combine the directional gradient energy features in the surface texture branch feature map to calculate the main direction consistency index and generate scratch verification confidence. The probability distribution is corrected by constructing a probability adjustment amount based on the bubble verification confidence level, the deformation verification confidence level, and the scratch verification confidence level.
8. An intelligent detection system for injection molding defects in plastic products, used to implement the method as described in any one of claims 1-7, characterized in that, include: The polarization image unit is used to acquire the polarization image sequence of the plastic product to be detected, calculate the polarization degree distribution, divide the surface of the plastic product into transparent, semi-transparent and opaque regions according to the polarization degree distribution, and apply a differentiated enhancement strategy to different transparency regions to generate adaptive enhanced images. The region partitioning unit is used to construct a three-branch feature extraction network, wherein the surface texture branch extracts directional gradient energy features from the adaptively enhanced image, the geometric deformation branch extracts curvature features through phase measurement profilometry, and the optical anomaly branch calculates polarization anomaly index features based on the polarization degree distribution. The feature extraction unit is used to dynamically weight and fuse the feature maps output by the three-branch feature extraction network through an attention-weighted fusion mechanism to obtain a comprehensive feature map. The fusion weights are adaptively predicted and generated based on the feature maps of each branch. The feature fusion unit is used to generate candidate defect regions on the comprehensive feature map and output the probability distribution of defect types, determine the defect types to be verified, verify the response consistency of bubble-type defects in the polarization image sequence, verify the curvature continuity of deformation-type defects, verify the aspect ratio and main direction consistency of scratch-type defects, correct the probability distribution based on the verification results, and output the defect detection results.
9. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 7.