Plastic product surface defect intelligent detection method based on computer vision
By simultaneously acquiring three images of plastic products with different exposures and performing image fusion and graded detection, the problem of information loss in highlight areas caused by specular reflection was solved, achieving efficient and reliable defect identification and improving the input data quality and recognition capability of the detection algorithm.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- KUNSHAN PUSHITONG MECHANICAL & ELECTRICAL COMPLETE EQUIPMENT CO LTD
- Filing Date
- 2025-12-19
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies, when inspecting high-gloss curved plastic parts, suffer from pixel loss in the highlight areas due to specular reflection, making it impossible to effectively identify minute defects, leading to missed detections and posing safety hazards and brand reputation risks.
By simultaneously acquiring three images of plastic products with different exposures, the Gaussian distribution function is used to calculate the basic confidence weight of pixel values and a saturation penalty mechanism is introduced to generate an extended dynamic range image. Combining coarse growth and fine growth algorithms, the internal uniformity and boundary sharpness of the highlight area are analyzed to detect defects in a graded manner.
It effectively restored the texture details in both highlight and shadow areas, improved the quality of input data for the detection algorithm, achieved the globally optimal signal-to-noise ratio, enhanced the reliability and efficiency of defect identification, and saved processing time.
Smart Images

Figure CN121962009A_ABST
Abstract
Description
Intelligent Detection Method for Surface Defects in Plastic Products Based on Computer Vision Technical Field
[0001] This invention relates to the field of intelligent defect detection technology, specifically to an intelligent detection method for surface defects in plastic products based on computer vision. Background Technology
[0002] When inspecting high-gloss curved plastic parts (such as car logos and appliance buttons), specular highlights (commonly known as "overexposure" or "spots") are formed in specific areas of the curved surface due to the fixed illumination angle. These saturated highlight areas cause the image sensor to reach its dynamic range limit, resulting in the complete loss of pixel information in that area. Defects located within the highlight areas (such as micro-scratches and pitting) cannot be extracted because the signal is "submerged." Traditional vision systems rely on diffuse light for imaging, but specular light has a much higher intensity than diffuse light. The system design does not consider separating specular reflection components from surface texture features at the imaging level. Common methods include adjusting the lighting or using polarizing filters to "eliminate" reflections, but this is often incomplete for complex curved surfaces and reduces the overall signal-to-noise ratio. HDR imaging is not suitable for high-speed production lines due to its slow shooting speed. This leads to 100% missed detection of defects in the highlight coverage areas. These defects may become the origin of early product failures, posing serious safety hazards and brand reputation risks.
[0003] Therefore, the present invention provides an intelligent management system for prefabricated building components that applies BIM technology. Summary of the Invention
[0004] (I) Technical Problem Solved To address the shortcomings of existing technologies, this invention provides an intelligent detection method for surface defects in plastic products based on computer vision. This invention simultaneously acquires three images of plastic products with different exposures in the same scene, aligns the coordinates of the same physical point of the plastic product in the three images to maintain consistency, extracts the pixel values of the three images with different exposures, calculates the basic confidence weight of the pixel values using a Gaussian distribution function, and introduces a saturation penalty mechanism to correct and normalize the basic confidence weight of the pixel values, obtaining a second confidence weight for each pixel value. Based on the second confidence weight, the three images of plastic products are fused to generate an extended dynamic range image, effectively restoring the details of the highlight areas that are "completely white" due to overexposure and the textures of the dark areas that are "completely black" due to underexposure in a single image. This allows the image to simultaneously present visible information in both the brightest and darkest areas. This suppresses noise in the dark areas of long-exposure images and avoids the signal-to-noise ratio loss in non-highlight areas of short-exposure images, thus achieving the globally optimal signal-to-noise ratio across the entire image. The generated image is rich in detail and has natural transitions, fundamentally improving the input data quality of the detection algorithm. It transforms a problem of insufficient dynamic range into a standard problem with complete texture details that can be processed by standard or advanced algorithms, greatly improving the potential and reliability of the entire system for subsequent defect identification and analysis, thereby solving the technical problems described in the background art.
[0005] (II) Technical Solution To achieve the above objectives, this invention is implemented through the following technical solution: 1. A computer vision-based intelligent detection method for surface defects in plastic products, comprising the following steps: synchronously acquiring three plastic product images with different exposures in the same scene; aligning the coordinates of the same physical point of the plastic product in the three images to maintain consistency; extracting the pixel values of the three plastic product images with different exposures; normalizing them; calculating the basic confidence weight of the pixel values using a Gaussian distribution function; introducing a saturation penalty mechanism to correct the basic confidence weight of the pixel values; obtaining the second confidence weight of each pixel value after normalization; fusing the three plastic product images according to the second confidence weight to generate an extended dynamic range image; and from the extended dynamic range image... The process involves extracting brightness values, labeling candidate seeds based on these values, filtering each candidate seed according to certain conditions, and establishing a seed point queue in descending order of brightness value. Coarse growth and fine growth are then performed sequentially to identify highlight regions. The internal uniformity and boundary clarity of each highlight region are analyzed, along with two-dimensional scores. A confidence score for each highlight region is calculated based on these two-dimensional scores, and the highlight regions are categorized into three levels according to their confidence scores. Defect detection operations are then performed based on the highlight region levels to obtain the detection results for all highlight regions. Finally, the detection results for all highlight regions are fused to generate a complete defect annotation map and a structured detection report.
[0006] Furthermore, the normalization of the pixel values extracted from the three plastic product images with different exposures is specifically as follows: the original pixel values of the three plastic product images with different exposures are directly read from the image sensor, and the actual pixel value range of each image is recorded, including the minimum and maximum values. For each image, a linear transformation formula is used to map the pixel values to the [0,1] interval. The linear transformation formula is: normalized value = (original pixel value - minimum value) / (maximum value - minimum value). In cases where there may be abnormal noise, truncation processing is used, that is, the 99.5th percentile is used to replace the maximum value and the 0.5th percentile is used to replace the minimum value.
[0007] Furthermore, the calculation of the basic confidence weight of pixel values using the Gaussian distribution function specifically involves using a Gaussian distribution function centered at 0.5 to calculate the basic confidence weight of pixel values. That is, the closer the pixel value is to 0.5, the higher the weight; the further it deviates, the more exponentially the weight decreases.
[0008] Furthermore, the saturation penalty mechanism is as follows: for underexposed areas, i.e., areas where the pixel value is lower than the preset lower threshold, a quadratic function penalty factor is applied, and the weight is rapidly reduced as the pixel value approaches 0; for overexposed areas, i.e. areas where the pixel value is higher than the preset upper threshold, a quadratic function penalty factor is also applied, and the weight is rapidly reduced as the pixel value approaches 1; for ideal exposure areas, i.e. areas between the upper and lower thresholds, no penalty is applied, and the original Gaussian weight is maintained.
[0009] Further, after the normalization process, the second confidence weight for each pixel value is obtained as follows: For each spatial location (x, y) in the image, the confidence weight values of the three images at that location are obtained respectively: W_short(x, y) is the first confidence weight of the short exposure image, W_normal(x, y) is the first confidence weight of the normal exposure image, and W_long(x, y) is the first confidence weight of the long exposure image. The total weight at that location is calculated as W_total(x, y) = W_short(x, y) + W_normal(x, y) + W_long(x, y), where the normalization factor is 1 / W_total(x, y). It should be noted that if W_total(x, y) = If the value is 0, meaning all three images are completely unreliable at this position, then the normalization factor is set to 1 / 3 to distribute the weights of the three images evenly. If W_total(x,y) is less than a preset minimum threshold, such as 0.0001, it is considered a case of numerical instability, and the average weight distribution strategy is also adopted. The normalization factor is applied to the weights of each image at each position: the second confidence weight of the short exposure image W_short_norm(x,y) = W_short(x,y) × normalization factor; the second confidence weight of the normal exposure image W_normal_norm(x,y) = W_normal(x,y) × normalization factor; the second confidence weight of the long exposure image W_long_norm(x,y) = W_long(x,y) × normalization factor.
[0010] Furthermore, the step of fusing the three plastic product images to generate an extended dynamic range image based on the second confidence weight specifically involves: multiplying the pixel value of each spatial location in the three plastic product images by the corresponding second confidence weight to obtain a weighted pixel value; summing the weighted pixel values at each spatial location to obtain the fused pixel value; and traversing all pixel locations to generate an extended dynamic range image.
[0011] Furthermore, the sequential execution of coarse growth and fine growth to determine the highlight region specifically involves: starting from the first seed point in the seed point queue, checking its 4-neighbor or 8-neighbor pixels. If the brightness of a neighboring pixel is ≥235 and it is not occupied by other regions, it is included in the current region. The newly added pixel serves as a new growth front and continues to expand outward. When the growth regions of two different seeds meet, their average brightness is compared. If the brightness difference is <5, they are merged into the same region. If the brightness difference is ≥5, the region with higher brightness is retained, and the region with lower brightness stops growing in that direction until the region can no longer expand, thus obtaining the highlight region boundary of the coarse growth stage. For each region boundary in the coarse growth stage, a strict brightness threshold of ≥245 is applied to re-evaluate the boundary region. If the brightness of a boundary pixel is <245, it is removed from the current region. This process is repeated for the new boundary pixels formed after removal until all boundary pixels meet the strict threshold, thus obtaining the highlight region boundary after fine growth and determining the highlight region.
[0012] Furthermore, after conditional screening of each candidate seed, the seed is obtained by checking whether each candidate seed has at least 3 pixels with the same brightness ≥245 in its 8-neighborhood. If it meets the criteria, it is a seed.
[0013] Furthermore, the process of classifying the highlight region into three levels based on confidence level specifically involves: extracting the brightness values of all pixels within the highlight region, calculating the brightness standard deviation to determine the brightness uniformity score: a standard deviation < 3 scores 10 points (highly uniform), 3 ≤ standard deviation < 8 scores 6 points (moderately uniform), and a standard deviation ≥ 8 scores 3 points (non-uniform); calculating the Local Binary Pattern (LBP) features within the highlight region, and analyzing the entropy value of the LBP features to determine the texture uniformity score: an LBP entropy < 1.0 scores 10 points (no texture), 1.0 ≤ LBP entropy < 2.5 scores 5 points (weak texture), and LBP entropy ≥ 2.5 scores 0 points (obvious texture); and then assigning the brightness uniformity score to the appropriate level. The internal uniformity score is obtained by weighted fusion with the texture uniformity score. A brightness profile is extracted along the normal direction of the highlight region boundary. On the brightness profile, starting from the inside of the highlight region, a point with a brightness value of 245 is found, and then the point with a brightness value of 200 is found by moving outward. The pixel distance between these two points is the transition width in this normal direction. If the internal brightness is less than 245, it starts from the maximum internal brightness and decreases to 80% of the stable external brightness. An average transition width < 2 pixels scores 10 points (sharp), 2 ≤ transition width < 4 pixels scores 6 points (medium), and a transition width ≥ 4 pixels scores 3 points (blurred). The overall confidence score = 0.6 × uniformity + 0.4 × sharpness. A high confidence overall score ≥ 8.0 indicates a normal specular reflection area on the surface; a medium confidence overall score 6.0 ≤ overall score < 8.0 indicates a micro-defect warning area on the surface; and a low confidence overall score < 6.0 indicates a bright area with obvious defects.
[0014] Furthermore, the specific defect detection operation based on the highlight area level is as follows: For normal specular reflection areas, a verification-based detection method with the lowest computational cost is used. If no outliers exceed the threshold, the area is directly marked as normal. If there are sporadic outliers, they are considered noise and still classified as normal. For micro-defect warning areas, local adaptive threshold segmentation or texture analysis is used to enhance the contrast of subtle features. Smaller detection kernels or filters are used for spot detection or micro-edge extraction. Morphological operations are performed on the detected candidate defects to remove noise, and their basic features are calculated. If the features exceed the preset micro-defect threshold, they are marked as micro-defects; otherwise, they are downgraded to normal. For obvious defect highlight areas, a precise segmentation algorithm is used to outline the accurate contour of the defect. The detailed morphological and intensity features of the defect are calculated. According to the preset severity standard, the defect is classified as an acceptable defect or a rejected defect, and a preliminary judgment of the defect type is made.
[0015] (III) Beneficial Effects This invention provides an intelligent detection method for surface defects of plastic products based on computer vision, which has the following beneficial effects: 1. Simultaneously acquire three plastic product images with different exposures in the same scene, align the coordinates of the same physical point of the plastic product in the three plastic product images to maintain consistency, extract the pixel values of the three plastic product images with different exposures, calculate the basic confidence weight of the pixel value using a Gaussian distribution function, and introduce a saturation penalty mechanism to correct and normalize the basic confidence weight of the pixel value, and obtain the second confidence weight of each pixel value. Based on the second confidence weight, the three plastic product images are fused to generate an extended dynamic range image, which effectively restores the details of the highlight areas that are "completely white" due to overexposure and the dark textures that are "completely black" due to underexposure in a single image, so that the image can simultaneously present the visible information of the brightest and darkest areas. This not only suppresses the noise in the dark areas of long-exposure images, but also avoids the signal-to-noise ratio loss in non-highlight areas of short-exposure images, thereby achieving the globally optimal signal-to-noise ratio in the entire image. The generated image has rich details and natural transitions, fundamentally improving the input data quality of the detection algorithm. It transforms a problem of insufficient dynamic range into a standard problem with complete texture details that can be processed by standard or advanced algorithms, greatly improving the potential and reliability of the entire system for subsequent defect identification and analysis.
[0016] 2. Brightness values are extracted from the extended dynamic range image. Candidate seeds are labeled based on these brightness values. After conditional screening of each candidate seed, a seed point queue is established, arranged in descending order of brightness value. Coarse growth and fine growth are then performed sequentially to determine the highlight region. This elevates highlight region identification from a simple brightness segmentation problem to an intelligent reasoning process combining physical geometry and image features. It produces not only a region label but also a reliable, accurate, and semantically rich target localization result, laying the crucial foundation for the entire system to successfully "see through" highlights and achieve reliable detection.
[0017] 3. Analyze the internal uniformity and boundary clarity of each highlight area and the two-dimensional scores. Calculate the confidence score of each highlight area based on the two-dimensional scores, and classify the highlight areas into three levels according to the confidence score. Perform corresponding defect detection operations based on the highlight area level. Prioritize the allocation of limited computing resources and time to the areas with the highest risk and the most obvious problems, while using rapid screening for low-risk areas. This significantly improves the overall detection efficiency and prevents unnecessary complex reconstruction calculations for areas where there may not be any information loss (such as highlights caused by texture), saving up to 40-60% of processing time. Attached Figure Description
[0018] Figure 1 is a flowchart illustrating the intelligent detection method for surface defects in plastic products based on computer vision according to the present invention. Detailed Implementation
[0019] 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] Please refer to Figure 1. This invention provides an intelligent detection method for surface defects of plastic products based on computer vision, including the following steps: Step 1: Simultaneously acquire three plastic product images with different exposures in the same scene, align the coordinates of the same physical point of the plastic product in the three plastic product images to maintain consistency, extract the pixel values of the three plastic product images with different exposures, calculate the basic confidence weight of the pixel value using a Gaussian distribution function, and introduce a saturation penalty mechanism to correct and normalize the basic confidence weight of the pixel value to obtain the second confidence weight of each pixel value, and fuse the three plastic product images according to the second confidence weight to generate an extended dynamic range image.
[0021] Step 1 includes the following steps: Step 101: Control the high-speed strobe illumination unit integrated in the vision system to trigger three different light sources of different intensities at millisecond intervals during a single camera exposure time, thereby simultaneously acquiring three images of plastic products in the same scene, namely a short exposure image, a normal exposure image, and a long exposure image.
[0022] Among them, the short exposure image is used to capture unsaturated details in the highlight areas, the normal exposure image serves as the reference image to retain most of the surface information, and the long exposure image is used to enhance the signal-to-noise ratio and details in the dark areas.
[0023] Step 102: Perform multi-scale Harris response screening on three plastic product images with different exposures, use FAST to detect corner points, and calculate the principal direction based on the gray-scale centroid method to generate rotation-invariant descriptors, such as rBRIEF. Then, use FLANN for feature descriptor matching, and combine distance ratio thresholding to filter candidate matches. Apply RANSAC to estimate the fundamental matrix and eliminate false matches. Finally, use optical flow or descriptor-driven optimization for sub-pixel-level localization, and input the optimized matching point coordinates into the Bundle Adjustment algorithm to jointly optimize camera parameters and 3D point coordinates to ensure that the coordinates of the same physical point of the plastic product in the three plastic product images are consistent.
[0024] Since the three images of the plastic product with different exposures were acquired continuously in a very short time, the object may have slight displacement. Ensuring that the coordinates of the same physical point are consistent in all images eliminates image misalignment caused by object movement or vibration, guarantees the accuracy of subsequent pixel-level fusion, and avoids artifacts or blurring caused by registration errors. This is a prerequisite for high-quality image fusion.
[0025] Step 103: Use image processing software to extract the pixel values of three plastic product images with different exposures. Normalize the pixel values of the three plastic product images with different exposures to a continuous range of 0 to 1 to eliminate the differences between different exposure levels. Use a Gaussian distribution function centered at 0.5 to calculate the basic confidence weight of the pixel value. That is, the closer the pixel value is to 0.5, the higher the weight; the farther it deviates, the weight decays exponentially. Introduce a saturation penalty mechanism to correct the basic confidence weight of the pixel value, and obtain the first confidence weight of each pixel value of the three plastic product images with different exposures.
[0026] Normalizing the pixel values of three plastic product images with different exposures to a continuous range of 0 to 1 involves: directly reading the original pixel values of the three plastic product images with different exposures from the image sensor, recording the actual pixel value range of each image, including the minimum and maximum values, and mapping the pixel values to the [0,1] interval using a linear transformation formula. The linear transformation formula is: Normalized value = (Original pixel value - Minimum value) / (Maximum value - Minimum value). For cases where abnormal noise may exist, truncation is used, that is, the 99.5th percentile is used to replace the maximum value and the 0.5th percentile is used to replace the minimum value to avoid outliers affecting the normalization range.
[0027] The saturation penalty mechanism works as follows: For underexposed areas (where pixel values are below a preset lower threshold), a quadratic function penalty factor is applied, with the weight decreasing rapidly as the pixel value approaches 0. For overexposed areas (where pixel values are above a preset upper threshold), the same quadratic function penalty factor is applied, with the weight decreasing rapidly as the pixel value approaches 1. Ideally exposed areas (between the upper and lower thresholds) are not penalized and retain their original Gaussian weights.
[0028] Step 104: Normalize the first confidence weight of the pixel value at the same spatial location in the three plastic product images with different exposures to ensure that the sum of the weights of all images at that spatial location is 1, and obtain the second confidence weight of each pixel value.
[0029] For each spatial location (x,y) in the image, the confidence weight values of the three images at that location are obtained respectively: W_short(x,y) is the first confidence weight of the short-exposure image, W_normal(x,y) is the first confidence weight of the normal-exposure image, and W_long(x,y) is the first confidence weight of the long-exposure image. The total weight at that location is calculated as W_total(x,y) = W_short(x,y) + W_normal(x,y) + W_long(x,y). The normalization factor is 1 / W_total(x,y). It should be noted that if W_total(x,y) = 0, that is, all three images are completely unreliable at that location, the normalization factor is set to 1 / 3 to distribute the weights of the three images evenly. If W_total(x,y) is less than a preset minimum threshold, such as 0.0001, it is considered a case of numerical instability, and the average weight distribution strategy is also adopted.
[0030] Apply a normalization factor to the weights of each image at each location: Second confidence weight W_short_norm(x,y) = W_short(x,y) × normalization factor for short exposure images; Second confidence weight W_normal_norm(x,y) = W_normal(x,y) × normalization factor for normal exposure images; Second confidence weight W_long_norm(x,y) = W_long(x,y) × normalization factor for long exposure images. Step 105: Multiply the pixel value at each spatial location of the three plastic product images by the corresponding second confidence weight to obtain the weighted pixel value. Summate the weighted pixel values at each spatial location to obtain the fused pixel value. Iterate through all pixel locations to generate an extended dynamic range image.
[0031] In practice, combining steps 101 to 105, three images of plastic products with different exposures in the same scene are acquired simultaneously. The coordinates of the same physical point of the plastic product in the three images are aligned to maintain consistency. The pixel values of the three images with different exposures are extracted. The basic confidence weight of the pixel value is calculated using a Gaussian distribution function. After correcting and normalizing the basic confidence weight of the pixel value by introducing a saturation penalty mechanism, a second confidence weight for each pixel value is obtained. Based on the second confidence weight, the three images of plastic products are fused to generate an extended dynamic range image. This effectively restores the details of the highlight areas that are "completely white" due to overexposure and the textures of the dark areas that are "completely black" due to underexposure in a single image. This allows the image to simultaneously present the visible information of the brightest and darkest areas. This suppresses noise in the dark areas of long-exposure images and avoids the signal-to-noise ratio loss in non-highlight areas of short-exposure images. Thus, the globally optimal signal-to-noise ratio is achieved in the entire image. The generated image has rich details and natural transitions, fundamentally improving the input data quality of the detection algorithm. It transforms a problem of insufficient dynamic range into a standard problem with complete texture details that can be processed by standard or advanced algorithms, greatly improving the potential and reliability of the entire system for subsequent defect identification and analysis.
[0032] Step 2: Extract brightness values from the extended dynamic range image, label candidate seeds based on brightness values, filter each candidate seed according to conditions to obtain seeds, establish a seed point queue in descending order of brightness values, and perform coarse growth and fine growth in sequence to determine the highlight area.
[0033] Step 2 includes the following: Step 201: Extract brightness values from the extended dynamic range image, mark all pixels with brightness values ≥ 250 as candidate seeds, and obtain seeds after conditional filtering for each candidate seed. Conditional filtering means checking whether there are at least 3 pixels with the same brightness ≥ 245 in the 8-neighborhood of each candidate seed. If they meet the condition, they are seeds. Establish a seed point queue by arranging them in descending order of brightness value.
[0034] Step 202: Starting from the first seed point in the seed point queue, check its 4-neighbor or 8-neighbor pixels. If the brightness of the neighboring pixels is ≥235 and not occupied by other regions, include them in the current region. The newly added pixels serve as a new growth front and continue to expand outward. When the growth regions of two different seeds meet, compare their average brightness. If the brightness difference is <5, merge them into the same region. If the brightness difference is ≥5, retain the region with higher brightness and stop the region with lower brightness from growing in that direction until the region can no longer expand, thus obtaining the boundary of the highlight region in the coarse growth stage.
[0035] Step 203: Re-evaluate the boundary region for each region boundary in the coarse growth stage using a strict brightness threshold of ≥245. If the brightness of the boundary pixel is <245, remove it from the current region. Repeat this process for the new boundary pixels formed after removal until all boundary pixels meet the strict threshold, thus obtaining the boundary of the highlight region after fine growth and determining the highlight region.
[0036] In practice, combining steps 201 to 203: extracting brightness values from the extended dynamic range image, labeling candidate seeds based on brightness values, filtering each candidate seed to obtain the final seed, establishing a seed point queue in descending order of brightness value, and performing coarse growth and fine growth sequentially to determine the highlight region. This elevates highlight region identification from a simple brightness segmentation problem to an intelligent reasoning process combining physical geometry and image features. It produces not only a region label, but also a reliable, accurate, and semantically rich target localization result, laying the crucial foundation for the entire system to successfully "see through" highlights and achieve reliable detection.
[0037] Step 3: Analyze the internal uniformity and boundary clarity of each highlight area and the two-dimensional score. Calculate the confidence score of each highlight area based on the two-dimensional score, and divide the highlight areas into three levels according to the confidence score. Perform corresponding defect detection operations according to the highlight area level to obtain the detection results of all highlight areas. After fusing the detection results of all highlight areas, generate a complete defect annotation map and a structured detection report.
[0038] Step 3 includes the following steps: Step 301, analyze the internal uniformity and boundary sharpness of each highlight area and the two-dimensional score, calculate the confidence score of each highlight area based on the two-dimensional score, and divide the highlight areas into three levels based on the confidence score.
[0039] Extract the brightness values of all pixels within the highlight area, calculate the standard deviation of brightness to determine the brightness uniformity score. A standard deviation < 3 scores 10 points, indicating high uniformity; 3 ≤ standard deviation < 8 scores 6 points, indicating moderate uniformity; and a standard deviation ≥ 8 scores 3 points, indicating non-uniformity.
[0040] Calculate the Local Binary Pattern (LBP) features within the highlight region, analyze the entropy value of the LBP features to determine the texture uniformity score: LBP entropy < 1.0 scores 10 points (no texture), 1.0 ≤ LBP entropy < 2.5 scores 5 points (weak texture), and LBP entropy ≥ 2.5 scores 0 points (obvious texture).
[0041] The internal uniformity score is obtained by weighted fusion of the brightness uniformity score and the texture uniformity score.
[0042] Extract a luminance profile along the normal direction of the highlight region boundary. On the luminance profile, starting from the inside of the highlight region, find a point with a luminance value of 245, then move outward to find a point with a luminance value of 200. The pixel distance between these two points is the transition width along that normal direction. If the internal luminance is less than 245, start from the maximum internal luminance and decrease it to 80% of the stable external luminance.
[0043] Average transition width < 2 pixels: 10 points (sharp); 2 ≤ transition width < 4 pixels: 6 points (medium); Transition width ≥ 4 pixels: 3 points (blurred).
[0044] Overall confidence score = 0.6 × uniformity + 0.4 × sharpness. High confidence overall score ≥ 8.0 indicates a normal specular reflection area on the surface; medium confidence score ≤ 6.0 indicates a warning area for minor surface defects; low confidence score < 6.0 indicates a bright area with obvious defects.
[0045] Step 302: Perform corresponding defect detection operations based on the highlight area level: Normal specular reflection area. The surface condition of this area is good and the probability of defects is extremely low. Use the verification detection with the lowest computational cost. Apply a very lenient global threshold or perform simple uniformity statistics. If no outliers exceed the threshold, the area is directly marked as normal. If there are sporadic outliers, they are regarded as noise and still classified as normal.
[0046] The surface micro-defect warning area may contain minor defects, slight contamination, or material inhomogeneity, requiring more sensitive algorithms for careful identification. Local adaptive threshold segmentation (such as adaptive Gaussian thresholding) or texture analysis (such as calculating local contrast and entropy) is used to enhance the contrast of subtle features. Smaller detection kernels or filters are used for spot detection or micro-edge extraction. Morphological operations (such as opening operations) are performed on detected candidate defects to reduce noise, and their basic features (such as area and aspect ratio) are calculated. If the features exceed the preset micro-defect threshold, they are marked as micro-defects; otherwise, they are downgraded to normal.
[0047] Highlighted areas with obvious defects indicate areas with significant defects that require precise segmentation and feature extraction. Precise segmentation algorithms (such as edge-based active contour models, region growing, or more complex deep learning segmentation models) are used to delineate the accurate contours of the defects. Detailed morphological and intensity features of the defects are calculated, including precise area, perimeter, minimum bounding rectangle, average grayscale, and contrast. Based on preset severity criteria (such as area and length thresholds), defects are classified as "Acceptable" or "Rejected," providing a preliminary assessment of the defect type (e.g., scratches, dents, dirt).
[0048] Step 303: Merge the detection results of all highlight areas to generate a complete defect annotation map and a structured detection report. The report includes the status of each area, defect location, defect characteristics, detection confidence level, etc.
[0049] When using this method, combine steps 301 to 303: analyze the internal uniformity and boundary clarity of each highlight area and the two-dimensional scores, calculate the confidence score of each highlight area based on the two-dimensional scores, and divide the highlight areas into three levels according to the confidence scores. Perform corresponding defect detection operations according to the highlight area level, and prioritize the allocation of limited computing resources and time to the areas with the highest risk and the most obvious problems, while using rapid screening for low-risk areas. This significantly improves the overall detection efficiency, prevents unnecessary complex reconstruction calculations for areas where there may not be any information loss (such as highlights caused by texture), and saves up to 40-60% of processing time.
[0050] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0051] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0052] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A computer vision-based intelligent detection method for surface defects in plastic products, characterized in that: The process includes the following steps: Simultaneously acquire three images of plastic products with different exposures from the same scene; align the coordinates of the same physical point of the plastic product in the three images to maintain consistency; extract the pixel values from the three images with different exposures; after normalization, calculate the basic confidence weight of the pixel values using a Gaussian distribution function; introduce a saturation penalty mechanism to correct the basic confidence weight of the pixel values; after normalization, obtain the second confidence weight for each pixel value; fuse the three plastic product images based on the second confidence weight to generate an extended dynamic range image; extract the brightness value from the extended dynamic range image; and then... Candidate seeds are labeled with values, and each candidate seed is filtered according to conditions to obtain seeds. Seed points are arranged in descending order of brightness value to establish a seed point queue. Coarse growth and fine growth are performed sequentially to determine the highlight areas. The internal uniformity and boundary clarity of each highlight area are analyzed and scored in two dimensions. The confidence score of each highlight area is calculated based on the two-dimensional scores, and the highlight areas are divided into three levels according to the confidence scores. The corresponding defect detection operation is performed according to the highlight area level to obtain the detection results of all highlight areas. After fusing the detection results of all highlight areas, a complete defect annotation map and a structured detection report are generated.
2. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The extraction and normalization of pixel values from three plastic product images with different exposures involves: directly reading the original pixel values of the three plastic product images with different exposures from the image sensor, recording the actual pixel value range of each image, including the minimum and maximum values, and mapping the pixel values to the [0,1] interval using a linear transformation formula. The linear transformation formula is: Normalized value = (original pixel value - minimum value) / (maximum value - minimum value). For cases where abnormal noise may exist, truncation is performed, i.e., the 99.5th percentile is used to replace the maximum value and the 0.5th percentile is used to replace the minimum value.
3. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The method of using a Gaussian distribution function to calculate the basic confidence weight of pixel values is as follows: a Gaussian distribution function centered at 0.5 is used to calculate the basic confidence weight of pixel values. That is, the closer the pixel value is to 0.5, the higher the weight; the farther it deviates, the more exponentially the weight decreases.
4. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The saturation penalty mechanism is as follows: for underexposed areas, i.e., areas where the pixel value is lower than the preset lower threshold, a quadratic function penalty factor is applied, and the weight is rapidly reduced as the pixel value approaches 0. For overexposed areas, i.e. areas where the pixel value is higher than the preset upper threshold, a quadratic function penalty factor is also applied, and the weight is rapidly reduced as the pixel value approaches 1. For ideal exposure areas, i.e. areas between the upper and lower thresholds, no penalty is applied, and the original Gaussian weight is maintained.
5. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: After the normalization process, the second confidence weight for each pixel value is obtained as follows: For each spatial location (x, y) in the image, the confidence weight values of the three images at that location are obtained respectively: W_short(x, y) is the first confidence weight of the short exposure image, W_normal(x, y) is the first confidence weight of the normal exposure image, and W_long(x, y) is the first confidence weight of the long exposure image. The total weight at that location is calculated as W_total(x, y) = W_short(x, y) + W_normal(x, y) + W_long(x, y), where the normalization factor is 1 / W_total(x, y). It should be noted that if W_total(x, y) = If the value is 0, meaning all three images are completely unreliable at this position, then the normalization factor is set to 1 / 3 to distribute the weights of the three images evenly. If W_total(x,y) is less than a preset minimum threshold, such as 0.0001, it is considered a case of numerical instability, and the average weight distribution strategy is also adopted. The normalization factor is applied to the weights of each image at each position: the second confidence weight of the short exposure image W_short_norm(x,y) = W_short(x,y) × normalization factor; the second confidence weight of the normal exposure image W_normal_norm(x,y) = W_normal(x,y) × normalization factor; the second confidence weight of the long exposure image W_long_norm(x,y) = W_long(x,y) × normalization factor.
6. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The process of fusing three plastic product images to generate an extended dynamic range image based on the second confidence weight is as follows: multiply the pixel value of each spatial position of the three plastic product images by the corresponding second confidence weight to obtain a weighted pixel value, sum the weighted pixel values of each spatial position to obtain the fused pixel value, and traverse all pixel positions to generate an extended dynamic range image.
7. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The process of sequentially performing coarse growth and fine growth to determine the highlight region is as follows: Starting from the first seed point in the seed point queue, its 4-neighbor or 8-neighbor pixels are checked. If the brightness of a neighboring pixel is ≥235 and it is not occupied by other regions, it is included in the current region. The newly added pixel serves as a new growth front and continues to expand outward. When the growth regions of two different seeds meet, their average brightness is compared. If the brightness difference is <5, they are merged into the same region. If the brightness difference is ≥5, the region with higher brightness is retained, and the region with lower brightness stops growing in that direction until the region can no longer expand, thus obtaining the highlight region boundary of the coarse growth stage. For each region boundary in the coarse growth stage, a strict brightness threshold of ≥245 is applied to re-evaluate the boundary region. If the brightness of a boundary pixel is <245, it is removed from the current region. This process is repeated for the new boundary pixels formed after removal until all boundary pixels meet the strict threshold, thus obtaining the highlight region boundary after fine growth and determining the highlight region.
8. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The seed is obtained by filtering each candidate seed according to the following conditions: check whether each candidate seed has at least 3 pixels with the same brightness ≥245 in its 8-neighborhood. If it meets the condition, it is a seed.
9. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The method of classifying highlight regions into three levels based on confidence level is as follows: The brightness values of all pixels within the highlight region are extracted, and the brightness standard deviation is calculated to determine the brightness uniformity score: a standard deviation < 3 scores 10 points (highly uniform), 3 ≤ standard deviation < 8 scores 6 points (moderately uniform), and a standard deviation ≥ 8 scores 3 points (non-uniform). The local binary pattern (LBP) features within the highlight region are calculated, and the entropy value of the LBP features is analyzed to determine the texture uniformity score: an LBP entropy < 1.0 scores 10 points (no texture), and 1.0 ≤ LBP entropy < 1.0 scores 6.
0. 2.5 scores 5 points, weak texture; LBP entropy ≥ 2.5 scores 0 points, obvious texture; The internal uniformity score is obtained by weighted fusion of the brightness uniformity score and the texture uniformity score; A brightness profile is extracted along the normal direction of the highlight region boundary. Starting from the inside of the highlight region, a point with a brightness value of 245 is found on the brightness profile. Moving outwards, a point with a brightness value of 200 is found. The pixel distance between these two points is the transition width along this normal direction. If the internal brightness is less than 245, it decreases from the maximum internal brightness to 80% of the stable external brightness; Average transition width < 2 pixels scores 10 points, sharp; 2 ≤ transition width < 4 pixels scores 6 points, medium; transition width ≥ 4 pixels scores 3 points, blurry; Overall confidence score = 0.6 × uniformity + 0.4 × sharpness. High confidence overall score ≥ 8.0 indicates a normal specular reflection area; medium confidence; 6.0 ≤ overall score < 8.0 indicates a micro-defect warning area; low confidence; overall score < 6.0 indicates a clearly defective highlighted area.
10. The intelligent detection method for surface defects of plastic products based on computer vision according to claim 1, characterized in that: The specific defect detection operation based on the highlight area level is as follows: For normal specular reflection areas on the surface, a verification-based detection method with the lowest computational cost is used. If no outliers exceed the threshold, the area is directly marked as normal. If there are sporadic outliers, they are considered noise and still classified as normal. For micro-defect warning areas on the surface, local adaptive threshold segmentation or texture analysis is used to enhance the contrast of subtle features. Smaller detection kernels or filters are used for spot detection or micro-edge extraction. Morphological operations are performed on the detected candidate defects to remove noise, and their basic features are calculated. If a feature exceeds the preset micro-defect threshold, it is marked as a micro-defect; otherwise, it is downgraded to normal. For obvious defect highlighted areas, a precise segmentation algorithm is used to outline the accurate contour of the defect, calculate the detailed morphological and intensity characteristics of the defect, and classify the defect into an acceptable defect or a rejected defect according to the preset severity standard, so as to make a preliminary judgment on the defect type.