Self-adaptive enhanced detection method for surface defects of injection molded part

By combining multimodal data acquisition and adaptive illumination correction with LSTM model parameter optimization, dynamically allocating feature weights, and using a hybrid attention mechanism and an improved YOLOv8 model for defect identification, the problems of illumination variation and material adaptation in injection molded part surface defect detection are solved, achieving high-precision and stable defect detection.

CN122067005APending Publication Date: 2026-05-19SUZHOU XINYUDA INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SUZHOU XINYUDA INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2026-01-27
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing technologies cannot adapt to changes in lighting, resulting in overexposure of bright areas and concealment of defects in dark areas during the detection of surface defects in injection molded parts. Small-sized defects have a high rate of missed detection and lack adaptability to different materials and molding processes, making it difficult to distinguish between normal textures and defect features.

Method used

Multimodal data acquisition and adaptive illumination correction are employed, and the correction parameters are optimized by combining the LSTM illumination prediction model. Feature weights are dynamically allocated, and defect identification is performed through a hybrid attention mechanism and an improved YOLOv8 model, forming an adaptive detection closed loop.

Benefits of technology

It significantly improves the detection rate of small-sized defects such as microcracks, accurately identifies various defects and adapts to different materials and lighting scenarios, reduces process switching costs, and improves the intelligence and stability of quality control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122067005A_ABST
    Figure CN122067005A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive enhanced detection method for surface defects of an injection molded part, which belongs to the technical field of defect detection and comprises the following steps: step 1, surface data acquisition of the injection molded part, step 2, self-adaptive illumination correction, step 3, feature enhancement, step 4, defect identification and output, and step 5, feedback and optimization. Through the injection molding part surface defect adaptive enhancement detection method, the high-precision full-scene detection requirement of injection molding part production can be met, through visible light + three-dimensional depth + short wave infrared multi-mode collection and multi-scale feature extraction, the detection rate of small-size defects such as microcracks and pinholes which are prone to leak detection is greatly increased, and various common defects are accurately recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and more specifically, to an adaptive enhancement detection method for surface defects of injection molded parts. Background Technology

[0002] Injection molded parts are plastic products manufactured through injection molding. They are widely used in automobiles, electronics, home appliances, medical devices and other fields. Their surface quality directly affects the product's appearance, sealing performance, strength and service life. If there are defects such as scratches, dents, color differences, bubbles, etc., it may lead to assembly difficulties, functional failure or appearance defects, or even safety hazards. Therefore, it is necessary to inspect the surface defects of injection molded parts.

[0003] The prior art patent document with authorization announcement number CN115953409B discloses a "method for detecting surface defects of injection molded parts based on image processing", which includes: acquiring a grayscale image and a depth image of the injection molded part; obtaining the structural type of each pixel based on the depth difference between each pixel and each neighboring pixel; for each pixel with a planar structure, obtaining the defect probability of each pixel based on the depth value and grayscale value of each pixel's neighboring pixels, and then obtaining each defect region on the planar structure.

[0004] The patent document with authorization announcement number CN116542932A discloses "a method for detecting surface defects in injection molded parts based on improved YOLOv5s", which includes: obtaining a dataset of surface defects in injection molded parts; preprocessing and labeling the dataset, and then dividing it into a training set, a validation set, and a test set; building a YOLOv5s network structure model, and improving the model to obtain an improved YOLOv5s network structure model; training both the unimproved and improved YOLOv5s network models using the training set to obtain a model for detecting surface defects in injection molded parts; and testing the model and comparing the test results.

[0005] While existing technologies can detect defects in both planar and curved surfaces of injection molded parts, reducing interference from inherent curved surfaces, and improving detection accuracy, speed, and small target detection capabilities through improved target detection networks, adapting to multi-station inspection scenarios, they also suffer from several drawbacks. Existing technologies rely on manually set illumination parameters or fixed enhancement algorithms, failing to adapt to changes in illumination intensity and angle during injection molding production. This can lead to overexposure in bright areas, concealment of defects in dark areas, and a high rate of missed detection for small defects (microcracks, pinholes). Furthermore, the use of globally uniform enhancement strategies fails to distinguish between normal surface textures and defect features, easily amplifying background noise. Additionally, they lack adaptability for feature enhancement of different defect types (scratches, dents, color differences). Moreover, image preprocessing, feature extraction, and defect recognition are independent processes lacking adaptive feedback adjustment mechanisms, making them unsuitable for injection molded parts made of different materials and with different molding processes. Summary of the Invention

[0006] This invention provides an adaptive enhancement detection method for surface defects in injection molded parts, which can solve the problems mentioned in the background art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: an adaptive enhancement detection method for surface defects in injection molded parts, comprising: S1. Collect visible light images, 3D depth data, short-wave infrared images, grayscale mean, and texture density data of the injection molded part surface. Simultaneously perform multi-camera calibration and registration and data validity verification. After verification, transmit the data to subsequent steps. S2. Based on the collected data, the illumination correction parameters are dynamically adjusted, the image is segmented and the reflection components are extracted and the illumination unevenness is corrected. The polarization light adjustment is combined to suppress reflection, and the correction parameters are optimized through the LSTM illumination prediction model. S3. Extract multi-scale grayscale features, texture features, edge features, depth gradient features, and thermal gradient features from the corrected image. Dynamically allocate the weights of each feature and add a defect type adaptation penalty factor to fuse and enhance the features while simultaneously removing redundant features. S4. Input the enhanced feature image into the recognition model, focus the target region through a hybrid attention mechanism, and output defect type, location, confidence and severity classification information; S5. Feed back the recognition results and dynamically optimize the illumination correction parameters and feature weight allocation coefficients to form an adaptive detection closed loop.

[0008] Furthermore, in S1, a CCD camera, a TOF depth camera, and a short-wave infrared camera are used in conjunction with a ring-shaped adjustable light source and a polarizing filter to acquire multimodal data. The acquired images are first processed by median filtering for noise reduction, and then by adaptive bilateral filtering. The adaptive bilateral filtering parameters are adjusted based on the gray-scale mean and texture density. The internal and external parameters of the multiple cameras are calibrated using the Zhang Zhengyou calibration method. Alignment is achieved using the SIFT feature point matching algorithm. Data validity verification includes sharpness, point cloud density, and thermal contrast verification. If the verification fails, a second verification is performed.

[0009] Furthermore, in S2, the reflection component extraction is based on Retinex theory. The illumination correction intensity is dynamically adjusted by the gray-scale variance of the injection molded part surface. During the correction process, the original reflection characteristics of the defect area are preserved. Local block correction is performed using 16×16 pixel sub-blocks. The sub-block level gain coefficient is adjusted based on the difference between the local and global gray-scale mean values. After correction, boundary artifacts are eliminated by fusion of overlapping areas. An electronically controlled polarizer is added to the CCD camera lens, and the polarization angle is adjusted synchronously with the light source polarization filter. An LSTM illumination prediction model is introduced, and the predicted correction parameters are output based on historical data. The final correction parameters are obtained by fine-tuning the data in the current frame.

[0010] Furthermore, in S3, the extracted features include multi-scale grayscale features, LBP texture features, RI-LBP texture features, U-LBP texture features, Canny edge features, depth gradient features, and thermal gradient features. An improved entropy weighting method is used to dynamically allocate the weights of each feature. The weight allocation process is constrained by the gradient threshold of the defect region and the defect type adaptation penalty factor. Morphological gradient enhancement and non-maximum suppression are applied to the Canny edge features. Low-contribution redundant features are removed using the Relief-F algorithm.

[0011] Furthermore, in S4, the recognition model is an improved YOLOv8 model, the attention mechanism is a hybrid attention mechanism of CoAtNet and CBAM, the model neck adopts BiFPN feature pyramid network, and the head adds a defect severity classification branch. It is trained using a hybrid loss function of Focal Loss, Dice Loss and GIoU Loss. The model is quantized by INT8 and equipped with TensorRT inference engine to optimize inference speed. At the same time, it is adapted to different materials and processes through domain adaptive fine-tuning. Finally, it outputs defect type, location, confidence and slight / moderate / severe classification information.

[0012] Furthermore, in S5, the illumination correction parameters for feedback optimization include an adaptive gain coefficient and a baseline standard deviation, the feature weight allocation coefficients include an attenuation coefficient and a material coefficient, and the closed-loop optimization period is consistent with the image acquisition period.

[0013] Furthermore, the acquired image denoising adopts a two-stage filtering strategy of median filtering-adaptive bilateral filtering, with the median filtering window selected as 3×3 or 5×5 according to the texture density.

[0014] The beneficial effects of the adaptive enhancement detection method for surface defects of injection molded parts according to the present invention are as follows: The adaptive enhanced detection method for injection molded parts surface defects can meet the high-precision inspection requirements of injection molded parts production. By using multi-modal acquisition and multi-scale feature extraction of visible light, 3D depth, and short-wave infrared, it significantly improves the detection rate of easily missed small-sized defects such as microcracks and pinholes, and accurately identifies various common defects. At the same time, by combining block illumination correction, polarized light reflection suppression, and LSTM illumination prediction, it adapts to different materials and dynamic lighting scenarios, avoiding overexposure and defect concealment. In addition, through hybrid attention mechanism, BiFPN network, and hybrid loss function optimization, it achieves accurate defect localization and accurate type judgment. Combined with severity classification and model acceleration technology, it adapts to real-time production line control, and domain adaptive fine-tuning reduces process changeover costs. Finally, it performs full-process closed-loop feedback to continuously optimize parameters, clearly distinguish between normal textures and defects, quickly locate production problems, and significantly improve the intelligence and stability of quality control, providing reliable support for real-time control and quality traceability. Attached Figure Description

[0015] The present invention will now be described in further detail with reference to the accompanying drawings and specific implementation methods.

[0016] Figure 1 This is a schematic diagram of the process flow of an adaptive enhancement detection method for surface defects in injection molded parts according to the present invention. Detailed Implementation

[0017] To make the technical solution of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0018] Example 1 like Figure 1 As shown, a technical solution is provided: an adaptive enhancement detection method for surface defects of injection molded parts, comprising: Step 1: Data Acquisition of Injection Molded Part Surface Collect visible light images, 3D depth data, short-wave infrared images, grayscale mean, and texture density data of the injection molded part surface. Simultaneously perform multi-camera calibration and registration and data validity verification. After verification, the data is transmitted to subsequent steps. Specifically, a CCD camera, a TOF depth camera, and a short-wave infrared camera are used in conjunction with a ring-shaped adjustable light source and a polarizing filter for multimodal data acquisition. The acquired images are first processed by median filtering for noise reduction, and then adaptive bilateral filtering is performed. The adaptive bilateral filtering parameters are adjusted based on the gray-scale mean and texture density. The internal and external parameters of the multiple cameras are calibrated using the Zhang Zhengyou calibration method. The SIFT feature point matching algorithm is used to achieve alignment. Data validity verification includes sharpness, point cloud density, and thermal contrast verification. If the verification fails, a second verification is performed.

[0019] Image acquisition involves activating a CCD camera, a TOF depth camera, a short-wave infrared camera, and a ring-shaped adjustable light source. The ring-shaped adjustable light source, paired with a polarizing filter, is evenly positioned around the surface of the injection-molded part, ensuring comprehensive coverage. The three cameras are arranged in a triangular configuration, each directly facing the inspection area of ​​the injection-molded part. The imaging process is initiated synchronously. During imaging, a unified trigger signal controls the exposure time and light source brightness of the three cameras, ensuring consistent timestamps for visible light, 3D depth, and short-wave infrared data acquisition. Simultaneously, the camera angles are fine-tuned based on the placement of the injection-molded part. This allows the TOF depth camera to accurately capture the surface contours, the short-wave infrared camera to target key areas prone to micro-cracks, and the CCD camera to focus on the overall surface texture and obvious defects. The polarizing filter remains constantly... The polarization direction is coordinated with the electronically controlled polarizer of the camera lens. Excessive reflections are filtered by rotation adjustment (e.g., 0°-90°) to ensure that the acquired multimodal images can clearly present the defect-related details in the corresponding dimension. After acquisition, noise reduction processing is performed on the acquired images. The filtering window is dynamically selected according to the texture density result. For example, if the texture density is high (the surface texture is fine), a 3×3 filtering window is used to retain more details. If the texture density is low (the surface is relatively smooth), a 5×5 filtering window is used to improve the noise reduction effect. The gray value of the center pixel of the window is replaced by the median value of all pixel gray values ​​in the window. While effectively removing random noise, the original defect features and normal texture information of the injection molded part surface are preserved to the greatest extent. The grayscale mean is calculated based on the denoised image. It iterates through all pixels in the effective detection area of ​​the image (excluding image edges where there is no actual detection significance), extracts the grayscale value of each pixel row by row and column by column, sums all the extracted grayscale values, and then divides by the total number of pixels in the effective detection area. This calculation method yields the grayscale mean of the injection molded part surface, providing timely basic data support for illumination correction. During the calculation process, the pixel positions of TOF depth data and shortwave infrared data are simultaneously correlated, so that the calculation result of the grayscale mean can correspond to three-dimensional spatial coordinates and thermal radiation distribution area. At the same time, based on the distribution of the grayscale mean, it initially judges the areas in the image that may have uneven illumination, providing direction for subsequent adaptive bilateral filtering parameter adjustment (for example, in areas with large differences in grayscale mean, the grayscale domain adjustment range of the bilateral filter is appropriately increased), ensuring that the denoising effect and detail preservation in this area are balanced. This also includes texture density. In the denoised image, the effective detection area is uniformly divided into several fixed-size sub-regions (e.g., 16×16 pixel blocks). For each sub-region, the gray-level difference between adjacent pixels (horizontally and vertically) is calculated. The number of pixel pairs with gray-level differences greater than a preset threshold is counted; this number represents the local texture activity of the corresponding sub-region. Then, the average local texture activity of all sub-regions is calculated, and this average is used as the texture density of the entire injection-molded part surface. The calculation of texture density is performed in parallel with the calculation of the gray-level mean, sharing the pixel data of the same effective detection area. The result is not only used to select the median filter window size but also provides basic information on texture features for the weight allocation in subsequent feature enhancement stages. During the process, the calibration and registration of multiple cameras are completed simultaneously: First, the standard calibration plate is placed in the injection molded part inspection area, and images of the calibration plate are taken from different angles by three cameras. The intrinsic parameters (focal length, principal point coordinates, etc.) and extrinsic parameters (position, attitude, etc.) of each camera are calculated using the Zhang Zhengyou calibration method. Then, SIFT feature points are extracted from the acquired multimodal images. By matching the feature points of the same physical point in different images, the transformation matrix between images is calculated to achieve the alignment of visible light images, three-dimensional depth data, and short-wave infrared images. This ensures that the position of the same defect in different modal data corresponds in subsequent processing. The calculation results of texture density are also used to verify the alignment accuracy. If the texture density matching deviation in a certain area is too large, the feature point matching and alignment adjustment in that area are re-performed. Finally, the collected, denoised, clear images, grayscale mean, and texture density data are sent to subsequent processing stages. Before transmission, data validity is verified: for visible light images, clarity is judged by observing whether key details (such as known texture edges and micro-marks) are clearly distinguishable; if details are blurry, the image fails. For 3D depth data, the number of point clouds per unit area is counted; if it is lower than the preset minimum density standard, the image fails. For shortwave infrared images, the brightness difference between areas with defects and normal areas is compared; if the difference is not obvious, the image fails. For datasets that fail verification, the parameters of the corresponding cameras are adjusted (e.g., increasing the exposure of CCD cameras, increasing the sampling frequency of TOF cameras, and adjusting the gain of shortwave infrared cameras), and the acquisition process is restarted until the data passes verification, ensuring that the data transmitted to subsequent stages meets the detection accuracy requirements.

[0020] Step 2, Adaptive Illumination Correction The illumination correction parameters are dynamically adjusted based on the collected data. The image is segmented and the reflection components are extracted and the illumination unevenness is corrected. Polarization adjustment is combined to suppress reflection. At the same time, the correction parameters are optimized through the LSTM illumination prediction model. Specifically, the reflection component extraction is based on Retinex theory. The illumination correction intensity is dynamically adjusted by the gray-scale variance of the injection molded part surface. During the correction process, the original reflection characteristics of the defect area are preserved. Local block correction is performed using 16×16 pixel sub-blocks. The sub-block level gain coefficient is adjusted based on the difference between the local and global gray-scale mean values. After correction, boundary artifacts are eliminated by fusion of overlapping areas. An electronically controlled polarizer is added to the CCD camera lens, and the polarization angle is adjusted synchronously with the light source polarization filter. An LSTM illumination prediction model is introduced, and the predicted correction parameters are output based on historical data. The final correction parameters are obtained by fine-tuning the data in the current frame.

[0021] First, based on the gray values ​​of all pixels within the effective detection area obtained in step 1 and the calculated gray mean, the effective detection area is uniformly divided into several 16×16 pixel sub-blocks. Each sub-block is then iterated through, calculating the local gray mean and local gray variance within each sub-block. Simultaneously, the coordinates of each sub-block in the overall image are recorded, enabling subsequent correction to accurately locate local areas of uneven illumination. When dividing the sub-blocks, it is ensured that adjacent sub-blocks cover the entire effective detection area without gaps, avoiding correction blind spots. The gray variance is calculated using the following formula:

[0022] In the formula, To effectively detect location within the area The pixel grayscale value at that location, This represents the average grayscale value of the injection molded part surface. The total number of pixels in the effective detection area provides the core basis for adaptive correction; Then, the reflection component is extracted using Retinex theory, as shown in the following formula:

[0023] In the formula, The image after noise reduction. As a weighted average function, before extracting the reflection component, the degree of surface reflectivity of the injection molded part is first determined based on the global grayscale variance calculated in step 1. If the global grayscale variance is greater than a preset threshold, it indicates that there are many areas of high-gloss reflection. At this time, the electronically controlled polarizer of the CCD camera lens and the polarizing filter of the ring light source are rotated synchronously to gradually adjust the polarization angle. Each adjustment is followed by the acquisition of a local image and the calculation of the proportion of the reflective area until the proportion of the reflective area is lower than the set value. Finally, the optimal polarization angle is determined and fixed. Through the coordinated adjustment of the polarization direction, most of the specular reflection light is filtered to avoid the reflective area from covering the defect features. If the global grayscale variance is small, it indicates that there is less surface reflection. At the same time, an adaptive gain coefficient is constructed based on the grayscale variance obtained above. The specific formula is as follows:

[0024] In the formula, This is the gain coefficient. The gray-level variance is used to convert the gray-level variance into a gain coefficient between 0 and 1 using this formula, thereby establishing the correlation between gray-level distribution and correction intensity. Furthermore, the weighted average function is optimized using the constructed gain coefficient. First, the trained LSTM illumination prediction model is called, with the global grayscale mean, global grayscale variance, historical gain coefficient, and baseline standard deviation of the previous few frames as training features. The model learns from historical illumination changes and outputs the predicted gain coefficient and predicted baseline standard deviation for the current frame. Then, the predicted parameters are weighted and fused with the calculated gain coefficient and baseline standard deviation for the current frame. For example, the predicted parameters account for 70%, and the currently calculated parameters account for 30%, resulting in optimized gain coefficients and baseline standard deviations. This ensures that parameter adjustments both accurately reflect the current illumination situation and predict illumination trends, avoiding correction lag due to sudden illumination changes. The optimized weighted average function formula is as follows:

[0025] In the formula, Using the standard deviation as a baseline, during implementation, the calculated gain coefficient is substituted into the original weighted average function, and its standard deviation is dynamically adjusted: when the injection molded part has a matte surface, the grayscale variance is small, the corresponding gain coefficient is small, and the standard deviation of the weighted average function decreases accordingly, avoiding excessive enhancement of noise on the matte surface; when the injection molded part has a glossy surface, the grayscale variance is large, the gain coefficient is large, and the standard deviation of the weighted average function increases accordingly, effectively suppressing overexposure in the glossy area and achieving adaptive lighting adaptation for different surface materials; The final reflection component Gray-level normalization is performed. First, normalization is performed on each 16×16 pixel sub-block. Then, linear weighted fusion is performed on the overlapping areas of adjacent sub-blocks. During fusion, the distance between the center of the sub-block is used as the weight. The closer the pixel is to the center of the sub-block, the higher the weight, ensuring a natural transition between sub-blocks and eliminating boundary artifacts that may be generated by block correction. After normalization, the entire effective detection area is traversed, and the gray-level uniformity of the corrected image (the standard deviation of the local gray-level mean of all sub-blocks) is calculated. If the uniformity does not meet the preset standard, the sub-block level gain coefficient is finely adjusted based on the difference between the local gray-level mean of the current sub-block and the global gray-level mean. The reflection component is extracted and normalized again until the gray-level uniformity meets the requirements. The gray-level value is then mapped to the standard range of 0-255 to ensure that the image brightness is moderate and the details are clear, thus completing the correction of uneven illumination. After correction, the normalized reflection component image (i.e., the image after illumination correction) is transmitted in real time to the feature enhancement stage in step 3.

[0026] Step 3: Feature Enhancement Extract multi-scale grayscale features, texture features, edge features, depth gradient features, and thermal gradient features from the corrected image, dynamically allocate the weights of each feature and add a defect type adaptation penalty factor, fuse and enhance the features, and simultaneously remove redundant features. Specifically, the extracted features include multi-scale grayscale features, LBP texture features, RI-LBP texture features, U-LBP texture features, Canny edge features, depth gradient features, and thermal gradient features. An improved entropy weighting method is used to dynamically allocate the weights of each feature. The weight allocation process is constrained by the gradient threshold of the defect region and the defect type adaptation penalty factor. Morphological gradient enhancement and non-maximum suppression are applied to the Canny edge features. Low-contribution redundant features are removed using the Relief-F algorithm.

[0027] First, feature extraction is performed on the illumination-corrected image output from step 2: For grayscale features, the effective detection area of ​​the image is traversed, and histogram statistics such as the mean, variance, and skewness of grayscale values ​​are statistically analyzed to form a grayscale feature vector, which intuitively reflects the differences in the distribution of light and dark in the image. At the same time, the corrected image is subjected to multi-scale scaling processing to generate images at multiple scales, and grayscale feature vectors at each scale are extracted. Then, feature concatenation is used to form a multi-scale grayscale feature set to ensure that the grayscale differences of defects of different sizes (large-sized depressions, small-sized microcracks) can be captured. For LBP texture features, with each pixel as the center, a neighborhood window (e.g., 3×3) is used to compare the grayscale values ​​of pixels in the neighborhood with the grayscale value of the center pixel (e.g., greater than the center value is recorded as 1, less than as 0), generating an 8-bit binary number and converting it to a decimal LBP value. The LBP value distribution of the entire effective area is statistically analyzed to construct a texture feature matrix, capturing the coarseness and density characteristics of the surface texture, and simultaneously calculating the RI-LBP value. (The LBP value is rotated and normalized, and the smallest decimal number after rotation is taken) to solve the problem of texture feature offset caused by the change of the placement angle of the injection molded part. Then, the U-LBP value of the uniform mode is selected to reduce the redundancy of texture features and retain only the core texture information that is effective for defect identification. For Canny edge features, the corrected image is first smoothed by Gaussian filtering, and then the pixel gradient magnitude and direction are calculated. Edge pixels are filtered by a double threshold method (e.g., the high threshold is 150 and the low threshold is 50) to retain continuous and clear defect edges and remove false edges formed by noise interference. At the same time, the depth gradient features are extracted from the TOF three-dimensional depth data collected in step 1: the depth difference between adjacent pixels is calculated to form a depth gradient map to highlight the contours of three-dimensional defects such as depressions and protrusions. Thermal gradient features are extracted from short-wave infrared images, and the infrared gray value difference between the suspected defect area and the normal area is statistically analyzed to generate a thermal gradient vector to enhance the defect features with obvious differences in thermal conduction, such as microcracks. Then, the gradient threshold of the defect area is calculated and the gray-level variance is determined: the gray-level variance comes from the result calculated in step 2, based on the gray-level values ​​and gray-level mean of all pixels in the effective detection area, and is obtained by statistically analyzing the deviation of each pixel's gray-level value from the mean. It reflects the dispersion of the image's gray-level distribution and provides a basis for gradient threshold calculation. Then, the material coefficient of the injection molded part is introduced, and the gradient threshold of the defect area is calculated using the following formula:

[0028] In the formula, For the material coefficient of the injection molded part, To determine the gradient amplitude of the image after illumination correction, the material coefficient of the injection molded part can be adaptively adjusted according to the material hardness and surface smoothness of the injection molded part. At the same time, the gradient threshold is dynamically corrected by combining the distribution of depth gradient features and thermal gradient features: if the depth gradient amplitude is large (three-dimensional defects), the gradient threshold is appropriately reduced to ensure that the three-dimensional defect features are not filtered out; if the thermal gradient difference is significant (microcracks), the gradient threshold is kept stable to highlight the edge features of the subtle defects. In addition, feature sensitivity coefficients for different defect types are preset (e.g., scratches are sensitive to edge features, color difference is sensitive to grayscale features, and microcracks are sensitive to thermal gradient features), laying the foundation for the application of penalty factors in subsequent weight allocation. Next, the improved entropy weight method is used to dynamically allocate feature weights, specifically through the following formula for weight calculation:

[0029] In the formula, The weights of the i-th type of features are... Let i be the information entropy of the i-th type of feature. The number of feature categories is set, and then a gradient threshold constraint for weight allocation is applied: All dimensions of each feature category are traversed, and the gradient magnitude of the region corresponding to each feature dimension is calculated. This is then compared one by one with the gradient threshold of the defect region. If the gradient magnitude of a certain feature dimension is less than the threshold, it indicates that the region corresponding to that dimension has normal texture. The weight ratio of that dimension is reduced by a preset attenuation coefficient. Simultaneously, a defect type adaptation penalty factor is introduced: Based on a preset defect feature sensitivity coefficient, a positive penalty is applied to highly sensitive feature dimensions in the current scene, and a negative penalty is applied to low-sensitivity feature dimensions. For example, when detecting microcracks, the thermal gradient feature and the Canny edge feature are penalized accordingly. To increase the weight of grayscale features when detecting color differences, the Relief-F algorithm is then activated to remove redundant features: the correlation contribution of each feature class to the defect label is calculated, a contribution threshold is set, and feature dimensions below the threshold (such as some LBP redundant dimensions of smooth surfaces) are removed to reduce computation and improve feature discrimination, avoiding excessive enhancement of normal textures. If the gradient magnitude is greater than or equal to the threshold, it is determined that the dimension is likely to correspond to a defect feature, and its original weight is maintained or its weight ratio is appropriately increased. Through this targeted constraint, the weights allocated by the improved entropy weight method are more in line with the needs of defect recognition, and normal textures and defect features are accurately distinguished. Finally, based on dynamically assigned feature weights, the three types of features are fused and enhanced: grayscale features, texture features, and edge features are superimposed and fused according to their corresponding weights. During the fusion process, the defect feature dimension with higher weights is enhanced, while the background texture dimension with lower weights is suppressed. At the same time, morphological gradient enhancement is performed on the Canny edge features: a 3×3 rectangular structuring element is used to dilate the edge image, and then the image after erosion is subtracted to fill the breaks in discontinuous edges such as microcracks. Then, non-maximum suppression is performed: the edge pixels are traversed, and only the local maximum pixels in the gradient direction are retained to remove false edges and redundant edge points, making the defect edges clearer and more continuous, achieving the differentiated effect of "precise enhancement of defect areas and noise reduction and suppression of background areas". The fused comprehensive feature map is normalized to map the feature values ​​to a uniform numerical range to ensure the stability and consistency of the features. Then, the enhanced feature image is transmitted in real time to the defect recognition stage in step 4 to provide accurate and clear feature input for the attention mechanism to focus on the defect area.

[0030] Step 4: Defect Identification and Output The enhanced feature image is input into the recognition model, which focuses on the target region through a hybrid attention mechanism and outputs information on defect type, location, confidence level, and severity rating. Specifically, the identification model is an improved YOLOv8 model, the attention mechanism is a hybrid attention mechanism of CoAtNet and CBAM, the model neck adopts BiFPN feature pyramid network, and the head adds a defect severity classification branch. It is trained using a hybrid loss function of FocalLoss, DiceLoss and GIoU Loss. The model is quantized by INT8 and equipped with TensorRT inference engine to optimize inference speed. At the same time, it is adapted to different materials and processes through domain adaptive fine-tuning. Finally, it outputs defect type, location, confidence and mild / moderate / severe classification information.

[0031] First, the enhanced feature image output from step 3 is preprocessed using standardization, scaling the image pixel values ​​to the input range suitable for the model, ensuring that the image size perfectly matches the number of input channels. Based on common defect types on injection molded parts (e.g., scratches, dents, microcracks, color difference, bubbles), defect area, depth, and impact range (e.g., minor impact corresponds to small defect area and no functional impact; moderate impact corresponds to obvious but repairable defects; severe impact corresponds to defects affecting product safety), a labeled sample dataset is constructed. A hybrid loss function of Focal Loss, Dice Loss, and GIoU Loss is used, weighting and summing the three types of losses in a reasonable proportion. Focal Loss focuses on small, difficult-to-classify defects by reducing the weight of easily classified samples. Dice Loss improves the recognition accuracy of blurry edge defects by calculating the overlap between the predicted and real regions. GIoU Loss... Loss improves the accuracy of locating irregular defects by optimizing the bounding box regression error. At the same time, it reserves a domain adaptive fine-tuning interface. If the injection molding material or production process is changed in the future, only multiple new material samples need to be input. There is no need to retrain the entire model. Only the parameters of the feature extraction layer need to be fine-tuned to quickly adapt to the new scenario. The preprocessed enhanced feature image is then input into the trained improved YOLOv8 model. During the model's feature extraction process, a CoAtNet attention mechanism is embedded. By fusing global and local features in the feature map, key information related to defects is captured: First, attention weights are assigned to the channel and spatial dimensions of the feature map to strengthen the feature response corresponding to the defect region and weaken irrelevant feature interference from normal texture regions. Then, the features are further optimized through the CBAM attention mechanism: the channel attention branch calculates the importance weight for each channel of the feature map, strengthening channel features crucial for defect identification such as depth gradient and thermal gradient, and suppressing redundant channel interference; the spatial attention branch… Focusing on the spatial location of defects, pooling and convolution operations are used to highlight the features of the target region. When the features are passed to the neck of the model, the BiFPN feature pyramid network is used to achieve bidirectional cross-scale connection of multi-scale features. Features at different levels are weighted and fused, and the edge features of high-resolution shallow layers are combined with the semantic features of low-resolution deep layers. This effectively improves the feature representation ability of small target defects such as microcracks and pinholes, and avoids information attenuation during feature transmission. Then, through multi-scale feature fusion, the defect features at different levels (such as the fine component features of microcracks and the contour features of depressions) are integrated, so that the model can accurately locate the target defect region and avoid missed detection due to the defect size being too small or the features being indistinct. Finally, the detection results are output synchronously through classification and regression branches: the classification branch, based on the fused defect features, matches various defect feature templates learned during training to determine the defect type (e.g., scratches, microcracks, etc.) of each target area; the regression branch, through the bounding box coordinates optimized by GIoU Loss, accurately marks the specific location of the defect in the image, ensuring that the localization error is controlled within a preset range. Before output, the model is quantized by INT8 and inferred by the TensorRT inference engine. The computational efficiency is improved through optimization methods such as layer fusion and tensor rearrangement to meet the real-time detection needs of the production line. Finally, the defect type, location coordinates, confidence score, and severity classification information are output synchronously. Results with a confidence score higher than the set threshold are directly used for production control, while results with a confidence score lower than the threshold are marked as suspected defects and prompt for manual review.

[0032] Step 5: Feedback and Optimization The recognition results are fed back to dynamically optimize the illumination correction parameters and feature weight allocation coefficients, forming an adaptive detection closed loop. Specifically, the illumination correction parameters for feedback optimization include adaptive gain coefficient and baseline standard deviation, and the feature weight allocation coefficients include attenuation coefficient and material coefficient. The closed-loop optimization period is consistent with the image acquisition period.

[0033] First, the recognition results output from step 4 are received, and the results are analyzed in layers: For defects with confidence scores below the set threshold, it is determined whether the unclear features are caused by uneven illumination. If the defects are lost due to overexposure in bright areas, the gain coefficient is appropriately reduced, and the reference standard deviation is finely adjusted to make the illumination correction more gentle and avoid excessive suppression of the defect reflection features. If the defects are hidden in dark areas, the adaptive gain coefficient is increased, the adjustment range of the reference standard deviation is expanded, and the extraction of the reflection components of dark area defects is strengthened to ensure that the defect features can be effectively highlighted after correction. Then, based on the distinction between normal textures and defects in the recognition results, the feature weight allocation coefficient is optimized: if a normal texture is misjudged as a defect, it means that the feature dimension weight corresponding to this type of texture is too high. By increasing the attenuation coefficient, its weight ratio is reduced to avoid the normal texture being over-enhanced. If the recognition confidence of a certain type of defect (such as microcracks) is consistently low, the material coefficient is adjusted in combination with its corresponding feature type (such as Canny edge features) to optimize the gradient threshold of the defect area. This makes the improved entropy weight method more inclined to the feature dimension of this type of defect when allocating weights, enhance the weight ratio of the target feature, and ensure that different types of defects can obtain appropriate feature enhancement effects. Finally, the optimized gain coefficient, reference standard deviation, and other illumination correction parameters, as well as the attenuation coefficient, material coefficient, and other feature weight allocation coefficients, are synchronized in real time to the corresponding processing stages in steps 2 and 3 to complete a closed-loop optimization. Since the closed-loop optimization cycle is consistent with the image acquisition cycle, when the next injection molded part surface data acquisition is started, the optimized parameters will be directly used for illumination correction and feature enhancement, realizing dynamic linkage of the entire process of "acquisition-correction-enhancement-recognition-optimization". This continuously adapts to the detection needs of illumination changes, material differences, and different defect types during the injection molded part production process, gradually improving detection accuracy and stability, and solving the problem of independent links and lack of adaptive feedback in existing technologies.

[0034] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.

Claims

1. An adaptive enhancement detection method for surface defects in injection molded parts, characterized in that: S1. Collect visible light images, 3D depth data, short-wave infrared images, grayscale mean, and texture density data of the injection molded part surface. Simultaneously perform multi-camera calibration and registration and data validity verification. After verification, transmit the data to subsequent steps. S2. Based on the collected data, the illumination correction parameters are dynamically adjusted, the image is segmented and the reflection components are extracted and the illumination unevenness is corrected. The polarization light adjustment is combined to suppress reflection, and the correction parameters are optimized through the LSTM illumination prediction model. S3. Extract multi-scale grayscale features, texture features, edge features, depth gradient features, and thermal gradient features from the corrected image. Dynamically allocate the weights of each feature and add a defect type adaptation penalty factor to fuse and enhance the features while simultaneously removing redundant features. S4. Input the enhanced feature image into the recognition model, focus the target region through a hybrid attention mechanism, and output defect type, location, confidence and severity classification information; S5. Feed back the recognition results and dynamically optimize the illumination correction parameters and feature weight allocation coefficients to form an adaptive detection closed loop.

2. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 1, characterized in that: In step S1, a CCD camera, a TOF depth camera, and a short-wave infrared camera are used in conjunction with a ring-shaped adjustable light source and a polarizing filter to acquire multimodal data. The acquired images are first processed by median filtering for noise reduction, and then adaptive bilateral filtering is performed. The adaptive bilateral filtering parameters are adjusted based on the gray-scale mean and texture density. The internal and external parameters of the multiple cameras are calibrated using the Zhang Zhengyou calibration method. Alignment is achieved using the SIFT feature point matching algorithm. Data validity verification includes sharpness, point cloud density, and thermal contrast verification. If the verification fails, a second verification is performed.

3. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 1, characterized in that: In S2, the reflection component extraction is based on Retinex theory. The illumination correction intensity is dynamically adjusted by the gray-scale variance of the injection molded part surface. During the correction process, the original reflection characteristics of the defect area are preserved. Local block correction is performed using 16×16 pixel sub-blocks. The sub-block level gain coefficient is adjusted based on the difference between the local and global gray-scale mean values. After correction, boundary artifacts are eliminated by fusion of overlapping areas. An electronically controlled polarizer is added to the CCD camera lens, and the polarization angle is adjusted synchronously with the light source polarization filter. An LSTM illumination prediction model is introduced, and the predicted correction parameters are output based on historical data. The final correction parameters are obtained by fine-tuning the data in the current frame.

4. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 1, characterized in that: In S3, the extracted features include multi-scale grayscale features, LBP texture features, RI-LBP texture features, U-LBP texture features, Canny edge features, depth gradient features, and thermal gradient features. An improved entropy weighting method is used to dynamically allocate the weights of each feature. The weight allocation process is constrained by the gradient threshold of the defect region and the defect type adaptation penalty factor. Morphological gradient enhancement and non-maximum suppression are applied to the Canny edge features. Low-contribution redundant features are removed using the Relief-F algorithm.

5. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 1, characterized in that: In S4, the identification model is an improved YOLOv8 model, the attention mechanism is a hybrid attention mechanism of CoAtNet and CBAM, the model neck adopts BiFPN feature pyramid network, and the head adds a defect severity classification branch. It is trained using a hybrid loss function of Focal Loss, Dice Loss and GIoU Loss. The model is quantized by INT8 and equipped with TensorRT inference engine to optimize inference speed. At the same time, it is adapted to different materials and processes through domain adaptive fine-tuning. Finally, it outputs defect type, location, confidence and slight / moderate / severe classification information.

6. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 1, characterized in that: In S5, the illumination correction parameters for feedback optimization include adaptive gain coefficient and baseline standard deviation, and the feature weight allocation coefficients include attenuation coefficient and material coefficient. The closed-loop optimization period is consistent with the image acquisition period.

7. The adaptive enhancement detection method for surface defects of injection molded parts according to claim 2, characterized in that: The acquired image noise reduction adopts a two-stage filtering strategy of median filtering-adaptive bilateral filtering. The median filtering window is selected as 3×3 or 5×5 according to the texture density.