A machine vision-based method and system for detecting defects in plastic particles

CN122820652APending Publication Date: 2026-09-25GUANGDONG GIANT NEW MATERIALS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611029818.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-10
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

人工目视检测作为行业内应用最广泛的方式,需要检测人员凭借经验对塑料颗粒的外观进行逐一甄别,但其存在诸多不可克服的弊端:一是检测效率极低,人工检测速度通常为200-300粒/分钟,无法匹配现代化塑料颗粒生产线的高速产出需求(通常为1000粒/分钟以上);二是检测精度不稳定,受检测人员视觉疲劳、情绪波动、经验差异等主观因素影响,对细微缺陷(如直径小于0.1mm的黑点、细微划痕)的识别率较低,错检率、漏检率通常高达5%-10%;三是人工成本高昂,大规模生产线需要配置大量检测人员,长期运营成本居高不下,且难以实现24小时连续检测;四是检测标准不统一,不同检测人员的判断标准存在差异,无法保证检测结果的一致性和客观性

Benefits of technology

1、本发明采用多视角图像采集结合小波变换融合算法,确保无视觉盲区,完整捕捉塑料颗粒的表面及内部缺陷;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122820652A_ABST
    Figure CN122820652A_ABST
Patent Text Reader

Abstract

The application provides a kind of based on machine vision's plastic particle defect detection method and system, the present application is fused into complete plastic particle image by wavelet transform fusion algorithm to the multi-view plastic particle image;Respectively extract the geometric feature, texture feature, color feature of plastic particle, to construct multidimensional defect feature vector;Utilize the defect identification model based on YOLOv8n realizes the identification and classification of plastic particle defect.The present application adopts multi-view image acquisition and wavelet transform fusion algorithm, ensures no visual blind area, complete capture plastic particle surface and internal defect;Through adaptive median filtering, CLAHE histogram equalization and other preprocessing algorithms, effectively eliminate noise, image distortion and illumination interference;Based on the defect identification model of improved YOLOv8n, introduce attention mechanism and micro defect detection layer, combined with multidimensional defect feature vector, the identification accuracy of subtle defect is ≥99%, recall rate is ≥98.5%.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and plastic defect detection technology, and in particular to a method and system for detecting defects in plastic particles based on machine vision. Background Technology

[0002] As a core raw material in the plastics processing industry, the quality of plastic granules directly determines the performance, appearance, and lifespan of end products. High-end plastic products such as automotive parts, food packaging, and electronic casings have extremely high requirements for the purity and integrity of plastic granules. During production, crushing, screening, and transportation, plastic granules are easily affected by factors such as raw material purity, equipment wear, and fluctuations in process parameters, resulting in various defects such as black spots, scratches, breakage, deformation, impurity contamination, and color differences. If defective plastic granules directly enter subsequent processing stages, it will not only lead to a significant increase in product scrap rates and production costs, but may also cause product safety hazards due to defects, affecting the company's market competitiveness.

[0003] Currently, defect detection in plastic granules mainly relies on two methods: manual visual inspection and traditional physical inspection. Manual visual inspection, the most widely used method in the industry, requires inspectors to rely on experience to individually examine the appearance of each plastic granule. However, it has several insurmountable drawbacks: First, the inspection efficiency is extremely low, with a manual inspection speed typically of 200-300 granules / minute, which cannot meet the high-speed output requirements of modern plastic granule production lines (usually over 1000 granules / minute). Second, the inspection accuracy is unstable, affected by subjective factors such as visual fatigue, emotional fluctuations, and differences in experience among inspectors, resulting in a low recognition rate for minor defects (such as black spots less than 0.1mm in diameter and minor scratches), with false positive and false negative rates typically as high as 5%-10%. Third, labor costs are high; large-scale production lines require a large number of inspectors, leading to persistently high operating costs and making 24-hour continuous inspection difficult. Fourth, inspection standards are inconsistent; different inspectors have different judgment criteria, making it impossible to guarantee the consistency and objectivity of the inspection results.

[0004] Traditional physical testing methods (such as sieving, density, and infrared spectroscopy) can detect some defects, but they have obvious limitations: sieving can only distinguish differences in particle size and cannot identify appearance defects and impurities with similar density; density is complex to operate and has a long testing cycle, making it unsuitable for real-time online testing; infrared spectroscopy has high equipment costs, strict requirements for the testing environment, and is difficult to detect subtle appearance defects (such as scratches and damage).

[0005] With the rapid development of machine vision technology, it has been gradually applied to the field of appearance defect detection for various products due to its advantages such as non-contact operation, high efficiency, high precision, and continuous operation. However, some existing machine vision-based particle detection solutions suffer from problems such as insufficient detection accuracy, poor adaptability, and weak anti-interference capabilities: First, image acquisition is not optimized for the characteristics of plastic particles (such as transparency / semi-transparency, surface reflectivity, and diverse colors), resulting in unclear defect feature extraction; second, defect recognition algorithms often employ traditional threshold segmentation and edge detection methods, which are ineffective at identifying subtle defects in complex backgrounds and are easily affected by factors such as lighting and particle posture; third, the linkage between the detection system and the production line is poor, making real-time sorting of defective particles impossible, resulting in a disconnect between detection and sorting; and fourth, there is a lack of statistical analysis functions for defect data, failing to provide data support for production process optimization.

[0006] Therefore, in view of the shortcomings of existing plastic particle defect detection technologies, there is an urgent need to provide a machine vision-based plastic particle defect detection method and system that has high detection accuracy, strong adaptability, strong anti-interference ability, can realize real-time online detection and sorting, and can provide data support for production process optimization. Summary of the Invention

[0007] To address the shortcomings of existing technologies, this invention provides a machine vision-based method and system for detecting defects in plastic particles, enabling real-time online high-precision detection of plastic particle defects, defect type identification, automatic sorting of defective particles, and statistical analysis of defect data.

[0008] In a first aspect, the present invention provides a method for detecting defects in plastic particles based on machine vision, comprising the following steps: S1) Acquire images of the plastic particles to be detected and perform preprocessing; S2) The wavelet transform fusion algorithm is used to fuse the preprocessed multi-view plastic particle images into a complete plastic particle image. S3) Extract the edge contours of plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculate the geometric features of the plastic particles based on the edge contours; S4) Use the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; S5) Extract the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles; S6) After normalizing the extracted geometric features, texture features, and color features of the plastic particles, a multi-dimensional defect feature vector is constructed. S7) Construct a defect recognition model based on YOLOv8n, and input the complete plastic particle image and multi-dimensional defect feature vector into the pre-trained defect recognition model to realize the recognition and classification of plastic particle defects.

[0009] Preferably, in step S1), the preprocessing includes: The plastic particle image is converted into a grayscale image, and then an adaptive median filtering algorithm is used to remove noise from the grayscale image; Next, the denoised image is corrected using a perspective transformation algorithm; Finally, the CLAHE histogram equalization algorithm is used to enhance image contrast and highlight the difference between defective and normal areas.

[0010] Preferably, step S2) is as follows: Wavelet decomposition was performed on the plastic particle images from various perspectives to obtain multiple low-frequency components and multiple high-frequency components. The low-frequency components and high-frequency components are fused separately to obtain the low-frequency fused amount and the high-frequency fused amount; Based on the low-frequency fusion amount and the high-frequency fusion amount, the fused complete plastic particle image is obtained by wavelet inverse transform.

[0011] Preferably, step S3) is as follows: S31) Perform Gaussian filtering noise reduction on the complete plastic particle image to obtain the Gaussian filtered plastic particle image; S32) Compare the Gaussian-filtered image of the plastic particles with... Perform convolution operations using the Sobel operator in the direction to obtain Oriented gradient image; S33), based on For oriented gradient images, calculate the gradient magnitude and gradient direction pixel by pixel; S34) Traverse each pixel in the gradient magnitude image, determine whether the gradient magnitude of the pixel is a local maximum in its gradient direction. If so, keep the pixel, determine it as a valid edge pixel, and continue traversing the next pixel. Otherwise, the pixel is removed and determined to be a non-edge pixel to avoid redundant pixels causing edge coarsening. Then, the process continues to traverse the next pixel. After the traversal is completed, the edge image after non-maximum suppression is obtained. S35) By setting two thresholds, high and low, the edge image after non-maximum suppression is binarized to distinguish edge pixels from background pixels. At the same time, the broken edges are connected to obtain a complete plastic particle edge contour image.

[0012] Preferably, in step S34), with the current pixel as the center, two adjacent pixels in the quantized gradient direction are selected, and the gradient magnitudes of the current pixel and the two adjacent pixels are compared: if the gradient magnitude of the current pixel is greater than the gradient magnitudes of the two adjacent pixels, it is determined to be a local maximum.

[0013] Preferably, in step S35), pixels with gradient magnitudes greater than the high threshold are identified as strong edge pixels and are directly retained; while pixels with gradient magnitudes less than the low threshold are identified as background pixels and are directly discarded. Pixels with gradient magnitudes between high and low thresholds are identified as weak edge pixels. It is then determined whether a weak edge pixel is adjacent to a strong edge pixel. If they are adjacent, they are identified as edge extensions and the weak edge pixel is retained. If they are not adjacent, they are identified as noise residues and the weak edge image is removed. The retained strong edge pixels are connected with the qualified weak edge pixels to form a complete and continuous edge contour of the plastic particles. Isolated edge pixels are then removed to obtain the final edge contour image of the plastic particles.

[0014] Preferably, in step S3), the geometric parameters of the plastic particles include particle diameter, roundness, aspect ratio, and contour flatness; wherein, roundness is used to determine whether the particles are deformed, aspect ratio is used to determine whether the particles are damaged, and contour flatness is used to identify protrusions and depressions on the particle surface.

[0015] Preferably, in step S4), the LBP value of the current pixel is calculated based on the gray value of the current pixel and the gray values ​​of the pixels in the current pixel's neighborhood. The distribution of LBP values ​​of all pixels within the plastic particle region is statistically analyzed, an LBP texture histogram is generated and normalized to obtain the normalized LBP texture histogram probability; the normalized LBP texture histogram is used as the LBP texture feature vector.

[0016] Preferably, in step S5), the color features include the RGB color mean, RGB color variance, and HSV saturation mean.

[0017] As a preferred embodiment, in step S7), the following improvements are made based on the YOLOv8n model: A small defect detection layer is added at the end of the pyramid of the neck network of the YOLOv8n model. At the same time, an SE-Net module is introduced, with one SE-Net module embedded in each detection layer to ensure that each detection layer can distinguish the features of the defect area from the background area. The CIoU loss function is used in the prediction head part. .

[0018] Preferably, in step S7), the trained defect recognition model is used to identify and classify defects in the plastic particles; specifically as follows: S71) Input the complete plastic particle image from step S2) and the multi-dimensional defect feature vector from step S6) into the pre-trained defect recognition model. First, extract multi-scale basic features from the complete plastic particle image through the backbone network; then fuse the multi-scale basic features with the multi-dimensional defect feature vector channel by channel to supplement the feature information of subtle defects and obtain the fused multi-scale features. S72) The fused multi-scale features are laterally connected through the neck network to achieve feature stitching, and then channel-weighted fusion is performed through the SE-Net module to deeply fuse high-level semantic features with low-level detail features, finally obtaining 4 scale feature maps. S73) The final four scale feature maps are fed into the four Anchor-Free detection branches of the prediction head for prediction, and finally the plastic particle defect classification results are output. If the confidence level of a predicted bounding box corresponding to a particle is greater than or equal to the preset confidence threshold, it is determined to be a defective particle; if the confidence level of all predicted bounding boxes is less than the preset confidence threshold, and the multi-dimensional feature vector has no obvious defective features, it is determined to be a normal particle. The Softmax activation function of the classification branch outputs the probability value of the defect belonging to black spot defect, scratch defect, breakage defect, deformation defect, impurity contamination defect, and color difference defect. The category with the highest probability is taken as the preliminary classification result. The localization parameters trained based on the CIoU loss function output the normalized coordinates of the defect bounding box, and also output the confidence level of the prediction result.

[0019] Secondly, the present invention provides a machine vision-based plastic particle defect detection system, comprising: The image acquisition module is used to acquire images of the plastic particles to be detected and to perform preprocessing. The image fusion module uses a wavelet transform fusion algorithm to fuse preprocessed multi-view plastic particle images into a complete plastic particle image. The geometric feature extraction module extracts the edge contours of plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculates the geometric features of the plastic particles based on the edge contours. The texture feature extraction module uses the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; The color feature extraction module extracts the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles. The feature fusion module normalizes the extracted geometric, texture, and color features of the plastic particles to construct a multi-dimensional defect feature vector. The defect prediction module calls a pre-trained YOLOv8n-based defect recognition model to perform prediction processing on the complete plastic particle image and multi-dimensional defect feature vectors, so as to output the defect classification results of the plastic particles.

[0020] Thirdly, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the plastic particle defect detection method.

[0021] The beneficial effects of this invention are as follows: 1. This invention uses multi-view image acquisition combined with wavelet transform fusion algorithm to ensure no visual blind spots and fully capture the surface and internal defects of plastic particles; 2. This invention effectively eliminates noise, image distortion, and illumination interference through preprocessing algorithms such as adaptive median filtering and CLAHE histogram equalization. 3. This invention is based on an improved YOLOv8n defect recognition model, introduces an attention mechanism and a micro-defect detection layer, and combines multi-dimensional defect feature vectors to achieve an accuracy of ≥99% and a recall rate of ≥98.5% for identifying micro-defects, which is significantly better than existing detection technologies. The false detection rate and false negative rate are reduced to below 0.5%. Attached Figure Description

[0022] Figure 1 This is a flowchart illustrating the method of Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the process for extracting the edge contour of plastic particles in Embodiment 1 of the present invention; Figure 3 This is a structural framework diagram of the system in Embodiment 2 of the present invention. Detailed Implementation

[0023] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings: Example 1 like Figure 1 As shown, this embodiment provides a machine vision-based method for detecting defects in plastic particles, including the following steps: S1) Acquire images of the plastic particles to be detected and perform preprocessing; In this embodiment, the plastic particles to be tested are vibrated onto the testing conveyor belt by a vibrating feeder, and images of the plastic particles are acquired in real time by industrial cameras set on both sides of the testing conveyor belt. The plastic particle image is converted into a grayscale image, and then an adaptive median filtering algorithm is used to remove noise from the grayscale image; In this embodiment, the following is adopted: The filter window, i.e.: ; In the formula, The filtered grayscale value; , These represent the minimum grayscale value, median grayscale value, and maximum grayscale value within the filtering window, respectively. For the current pixel grayscale value; Next, the denoised image is corrected using a perspective transformation algorithm to eliminate image distortion caused by industrial camera installation deviations and conveyor belt vibrations. This embodiment uses homogeneous coordinate transformation, and the calculation formula is: ; In the formula, These are the pixel coordinates of the original denoised image. For the pixel coordinates of the corrected image, These are the homogeneous coordinate coefficients; This is the perspective transformation matrix.

[0024] Finally, the CLAHE histogram equalization algorithm is used to enhance image contrast and highlight the difference between defective and normal areas; specifically: Calculate the histogram probability for each grayscale interval. ,Right now: in, For the first Number of pixels in each grayscale range This represents the total number of pixels in the image. Set the cropping threshold Then correct the histogram. for: ; The portion exceeding T is evenly distributed across all grayscale ranges, i.e., the supplementary amount. for: In the formula, This indicates the number of grayscale ranges, in this embodiment. ; Final corrected histogram Represented as: ; According to the final revised histogram Calculate the cumulative histogram ,Right now: and cumulative histogram Perform grayscale mapping to obtain the enhanced grayscale value. ,Right now: ; In the formula, This represents the rounding function; The current pixel after noise reduction The grayscale value.

[0025] S2) A wavelet transform fusion algorithm is used to fuse the preprocessed multi-view plastic particle images into a complete plastic particle image; specifically as follows: Wavelet decomposition was performed on the plastic particle images from various perspectives to obtain multiple low-frequency components and multiple high-frequency components. The low-frequency and high-frequency components are fused separately to obtain the low-frequency fused value and the high-frequency fused value; that is: ; In the formula, , These are low-frequency fusion quantity and high-frequency fusion quantity, respectively. , The first One low-frequency component and one high-frequency component; The number of viewpoints for the plastic particle image; It is a symbolic function; The high-frequency component with the largest absolute value; Based on the low-frequency and high-frequency fusion values, the fused complete image of plastic particles is obtained through inverse wavelet transform. ,Right now: .

[0026] S3) Extract the edge contours of the plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculate the geometric features of the plastic particles based on the edge contours; such as... Figure 2 As shown, the details are as follows: S31) Perform Gaussian filtering noise reduction on the complete plastic particle image to obtain the Gaussian-filtered plastic particle image; that is: ; In the formula, Represents the Gaussian filter function; This is an image of plastic particles after Gaussian filtering; S32) The Gaussian filtered image of plastic particles respectively with Sobel operators in direction , Perform convolution operation to obtain Orientation gradient image , ; S33), based on Orientation gradient image , Calculate gradient magnitude pixel by pixel and gradient direction ,Right now: ; ; Calculated The value range is [-π, π]. To facilitate subsequent non-maximum suppression operations, the gradient direction is quantized into four directions: 0° (horizontal direction), 45° (upper right to lower left direction), 90° (vertical direction), and 135° (upper left to lower right direction). The gradient direction of each pixel corresponds to the closest quantization direction.

[0027] S34), Traverse the gradient magnitude image For each pixel in the process, determine whether the gradient magnitude of the pixel is a local maximum in its gradient direction. If so, retain the pixel, determine it as a valid edge pixel, and continue to traverse the next pixel. Otherwise, the pixel is removed and determined to be a non-edge pixel to avoid redundant pixels causing edge coarsening. Then, the process continues to traverse the next pixel. After the traversal is completed, the edge image after non-maximum suppression is obtained. In this embodiment, taking the current pixel as the center, two adjacent pixels in that direction are selected according to the quantized gradient direction, and the gradient magnitudes of the current pixel and the two adjacent pixels are compared: if the gradient magnitude of the current pixel is greater than the gradient magnitudes of the two adjacent pixels, it is determined to be a local maximum.

[0028] S35) By setting two thresholds, high and low, the edge image after non-maximum suppression is binarized to distinguish edge pixels from background pixels. At the same time, the broken edges are connected to obtain a complete plastic particle edge contour image. In this embodiment, the gradient magnitude is greater than a high threshold. Pixels identified as having strong edges are retained directly; and pixels with gradient magnitudes less than a low threshold are also retained. Pixels that are identified as background pixels are directly removed. Pixels with gradient magnitudes between high and low thresholds are identified as weak edge pixels. It is then determined whether a weak edge pixel is adjacent to a strong edge pixel. If they are adjacent, they are identified as edge extensions and the weak edge pixel is retained. If they are not adjacent, they are identified as noise residues and the weak edge image is removed. The retained strong edge pixels are connected with the qualified weak edge pixels to form a complete and continuous edge contour of the plastic particles. Isolated edge pixels are then removed to obtain the final edge contour image of the plastic particles.

[0029] In this embodiment, the geometric parameters of the plastic granules include granule diameter, roundness, aspect ratio, and contour smoothness; wherein, roundness is used to determine whether the granules are deformed, aspect ratio is used to determine whether the granules are damaged, and contour smoothness is used to identify defects such as protrusions and depressions on the granule surface. The diameter of the particles ;in, The area enclosed by the outline; The sphericity of the particles ; The perimeter is the outline; if C ≥ 0.85, it is judged as a normal particle (without obvious deformation); if C < 0.85, it is judged as a deformed defect particle.

[0030] The aspect ratio of the particles ,in, , These are the longest and shortest axis lengths of the contour, calculated using the minimum bounding rectangle method based on the contour pixel coordinate set; Defect judgment: If ≤1.2, judged as normal particles (no obvious damage); if These particles were determined to be damaged or defective.

[0031] The smoothness of the particle outline ;like If it is determined to be normal particles (smooth surface); These particles are identified as surface protrusions or depressions.

[0032] S4) Use the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; In this embodiment, based on the current pixel grayscale value and the current pixel The LBP value of the current pixel is calculated from the grayscale values ​​of the neighboring pixels, that is: ; In the formula, It is a symbolic function; For the current pixel The number of pixels in the neighborhood; If the value is 1, then the corresponding binary code of the neighborhood is 1; otherwise, it is 0. The distribution of LBP values ​​of all pixels within the plastic particle region is statistically analyzed, an LBP texture histogram is generated and normalized to obtain the normalized LBP texture histogram probability; the normalized LBP texture histogram is used as the LBP texture feature vector.

[0033] S5) Extract the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles; In this embodiment, the RGB to HSV color space conversion calculation formula is as follows: ; ; ; In the formula, ; The value range is normalized to [0,1]. ; H, S, and V together constitute the HSV color space.

[0034] And calculate the RGB color mean, RGB color variance, and HSV saturation mean; that is: , , , ; , , ; In the formula, , , The average value of the RGB colors; The mean HSV saturation value; , , The variance of RGB colors; This represents the total number of pixels in the granular region. Finally, the color characteristics are obtained. .

[0035] S6) After normalizing the extracted geometric features, texture features, and color features of the plastic particles, a multi-dimensional defect feature vector is constructed. In this embodiment, min-max normalization is used to map each feature value to the [0,1] interval; then, the features are concatenated to obtain a multi-dimensional defect feature vector. .

[0036] S7) Construct a defect recognition model based on YOLOv8n, and input the complete plastic particle image and multi-dimensional defect feature vector into the pre-trained defect recognition model to realize the recognition and classification of plastic particle defects; In this embodiment, the following improvements are made based on the YOLOv8n model: A small defect detection layer is added at the end of the pyramid of the neck network of the YOLOv8n model. At the same time, an SE-Net module is introduced, with one SE-Net module embedded in each detection layer to ensure that each detection layer can distinguish the features of the defect area from the background area. The CIoU loss function is used in the prediction head part. ,Right now: ; ; In the formula, IoU is the intersection-union ratio of the predicted bounding box and the ground truth bounding box; A is the area of ​​the predicted bounding box; B is the area of ​​the ground truth bounding box. Center of the prediction box Centered at the true bounding box; Center of the prediction box Center of the real frame The Euclidean distance; The length of the diagonal of the smallest bounding rectangle of the two frames; This is the balance coefficient; This indicates the shape deviation between the predicted bounding box and the actual bounding box.

[0037] In this embodiment, a plastic particle defect sample library is constructed, including normal plastic particle samples and samples of various defects (black spots, scratches, damage, deformation, impurities, color difference), with no less than 10,000 samples of each defect type, covering plastic particles of different sizes, colors, and materials. The sample library is divided into a training set, a validation set, and a test set in an 8:1:1 ratio to train the improved YOLOv8n model. During training, a cosine annealing algorithm is used to avoid model overfitting. The model is validated using the validation set, and the model parameters are adjusted based on the validation results until the model's recognition accuracy and recall both reach preset thresholds (accuracy ≥ 99%, recall ≥ 98.5%). Finally, the model performance is tested using the test set to ensure that the model can stably recognize various defects.

[0038] The formula for cosine annealing is: ;in, For the first The learning rate of each training round; The initial learning rate; Minimum learning rate; This refers to the total number of training rounds.

[0039] In this embodiment, the trained defect recognition model is used to identify and classify defects in plastic particles; specifically as follows: S71) Input the complete plastic particle image from step S2) and the multi-dimensional defect feature vector from step S6) into the pre-trained defect recognition model. First, extract multi-scale basic features from the complete plastic particle image through the backbone network. Furthermore, the multi-scale basic features and multi-dimensional defect feature vectors are fused channel by channel to supplement the feature information of subtle defects, resulting in the fused multi-scale features. ;Right now: ; In the formula, Fusion weights; S72) Multi-scale features after fusion through the neck network Lateral connections are performed to concatenate features, and then channel-weighted fusion is performed through the SE-Net module to deeply fuse high-level semantic features with low-level detail features, ultimately resulting in four feature maps at different scales; that is: ; ; In the formula, This is a feature map of channel splicing; This is the final multi-scale feature map; Multi-scale features High-level semantic features and low-level detail features; Indicates feature concatenation operation; This is the activation function for the SE-Net module; This is a channel-by-channel multiplication operation; The SE-Net module adaptively adjusts the feature channel weights through a squeeze-excitation operation, strengthening the feature channels corresponding to defective regions (black spots, scratches, impurities, etc.) and suppressing invalid features in the background region to reduce the false detection rate. Through the four detection layers of the neck network, defects of different sizes are accurately captured: the 640×640 ultra-small target layer is specifically used to capture minute defects (black spots, fine scratches) of 0.05~0.15mm, and the 80×80, 40×40, and 20×20 detection layers capture large, medium, and small-sized defects, respectively.

[0040] S73) The final multi-scale feature map The four Anchor-Free detection branches of the prediction head are fed into the prediction head for prediction, and the final output is the plastic particle defect classification result; If the confidence score of the predicted bounding box corresponding to a certain particle is ≥0.7, it is judged as a defective particle; if the confidence scores of all predicted bounding boxes are <0.7 and the multi-dimensional feature vectors do not have obvious defective features, they are judged as normal particles. The Softmax activation function of the classification branch outputs the probability value of the defect belonging to 6 types of defects (black spot defect, scratch defect, breakage defect, deformation defect, impurity contamination defect, color difference defect). The category with the highest probability is used as the preliminary classification result. The localization parameters trained based on the CIoU loss function output the normalized coordinates of the defect bounding box, and also output the confidence level of the prediction result.

[0041] Example 2 like Figure 3 As shown, this embodiment provides a machine vision-based plastic particle defect detection system, including: The image acquisition module is used to acquire images of the plastic particles to be detected and to perform preprocessing. The image fusion module uses a wavelet transform fusion algorithm to fuse preprocessed multi-view plastic particle images into a complete plastic particle image. The geometric feature extraction module extracts the edge contours of plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculates the geometric features of the plastic particles based on the edge contours. The texture feature extraction module uses the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; The color feature extraction module extracts the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles. The feature fusion module normalizes the extracted geometric, texture, and color features of the plastic particles to construct a multi-dimensional defect feature vector. The defect prediction module calls a pre-trained YOLOv8n-based defect recognition model to perform prediction processing on the complete plastic particle image and multi-dimensional defect feature vectors, so as to output the defect classification results of the plastic particles.

[0042] Example 3 This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the plastic particle defect detection method described in Embodiment 1.

[0043] In this embodiment, the memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. A processor, coupled to the memory, is used to execute computer programs stored in the memory.

[0044] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or some intermediate form.

[0045] The embodiments and descriptions above are merely illustrative of the principles and preferred embodiments of the present invention. Various changes and modifications may be made to the present invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed.

Claims

1. A machine vision-based method for detecting defects in plastic particles, characterized in that, Includes the following steps: S1) Acquire images of the plastic particles to be detected and perform preprocessing; S2) The wavelet transform fusion algorithm is used to fuse the preprocessed multi-view plastic particle images into a complete plastic particle image. S3) Extract the edge contours of plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculate the geometric features of the plastic particles based on the edge contours; S4) Use the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; S5) Extract the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles; S6) After normalizing the extracted geometric features, texture features, and color features of the plastic particles, a multi-dimensional defect feature vector is constructed. S7) Construct a defect recognition model based on YOLOv8n, and input the complete plastic particle image and multi-dimensional defect feature vector into the pre-trained defect recognition model to realize the recognition and classification of plastic particle defects.

2. The method for detecting defects in plastic particles based on machine vision according to claim 1, characterized in that: In step S2), the specific details are as follows: Wavelet decomposition was performed on the plastic particle images from various perspectives to obtain multiple low-frequency components and multiple high-frequency components. The low-frequency components and high-frequency components are fused separately to obtain the low-frequency fused amount and the high-frequency fused amount; Based on the low-frequency fusion amount and the high-frequency fusion amount, the fused complete plastic particle image is obtained by wavelet inverse transform.

3. The method for detecting defects in plastic particles based on machine vision according to claim 2, characterized in that: In step S3), the specific details are as follows: S31) Perform Gaussian filtering noise reduction on the complete plastic particle image to obtain the Gaussian filtered plastic particle image; S32) Compare the Gaussian-filtered image of the plastic particles with... Perform convolution operations using the Sobel operator in the direction to obtain Oriented gradient image; S33), based on For oriented gradient images, calculate the gradient magnitude and gradient direction pixel by pixel; S34) Traverse each pixel in the gradient magnitude image, determine whether the gradient magnitude of the pixel is a local maximum in its gradient direction. If so, keep the pixel; otherwise, discard the pixel and continue traversing the next pixel. After traversal, the edge image after non-maximum suppression is obtained. S35) By setting two thresholds, high and low, the edge image after non-maximum suppression is binarized to distinguish edge pixels from background pixels. At the same time, the broken edges are connected to obtain a complete plastic particle edge contour image.

4. The method for detecting defects in plastic particles based on machine vision according to claim 3, characterized in that: In step S35), pixels with gradient magnitudes greater than the high threshold are identified as strong edge pixels and are directly retained. Pixels with gradient magnitudes less than a low threshold are identified as background pixels and directly removed. Pixels with gradient magnitudes between high and low thresholds are identified as weak edge pixels. It is then determined whether a weak edge pixel is adjacent to a strong edge pixel. If they are adjacent, they are identified as edge extensions and the weak edge pixel is retained. If they are not adjacent, they are identified as noise residues and the weak edge image is removed. The retained strong edge pixels are connected with the qualified weak edge pixels to form a complete and continuous edge contour of the plastic particles. Isolated edge pixels are then removed to obtain the final edge contour image of the plastic particles.

5. The method for detecting defects in plastic particles based on machine vision according to claim 1, characterized in that: In step S3), the geometric parameters of the plastic particles include particle diameter, roundness, aspect ratio, and contour flatness; wherein, roundness is used to determine whether the particles are deformed, aspect ratio is used to determine whether the particles are damaged, and contour flatness is used to identify protrusions and depressions on the particle surface.

6. The method for detecting defects in plastic particles based on machine vision according to claim 1, characterized in that: In step S4), the LBP value of the current pixel is calculated based on the gray value of the current pixel and the gray values ​​of the pixels in the current pixel's neighborhood; The distribution of LBP values ​​of all pixels within the plastic particle region is statistically analyzed, an LBP texture histogram is generated and normalized to obtain the normalized LBP texture histogram probability; the normalized LBP texture histogram is used as the LBP texture feature vector.

7. The method for detecting defects in plastic particles based on machine vision according to claim 1, characterized in that: In step S7), the following improvements are made based on the YOLOv8n model: A small defect detection layer is added at the end of the pyramid of the neck network of the YOLOv8n model. At the same time, an SE-Net module is introduced, with one SE-Net module embedded in each detection layer to ensure that each detection layer can distinguish the features of the defect area from the background area. The CIoU loss function is used in the prediction head part. .

8. The method for detecting defects in plastic particles based on machine vision according to claim 7, characterized in that: In step S7), the trained defect recognition model is used to identify and classify defects in plastic particles; specifically as follows: S71) Extract multi-scale basic features from complete plastic particle images through a backbone network; and fuse the multi-scale basic features with multi-dimensional defect feature vectors channel by channel to supplement the feature information of subtle defects and obtain the fused multi-scale features. S72) The fused multi-scale features are laterally connected through the neck network to achieve feature stitching, and then channel-weighted fusion is performed through the SE-Net module to deeply fuse high-level semantic features with low-level detail features, finally obtaining 4 scale feature maps. (S73) The final four scale feature maps are fed into the four Anchor-Free detection branches of the prediction head for prediction, and finally the plastic particle defect classification results are output.

9. A machine vision-based plastic particle defect detection system, characterized in that, include: The image acquisition module is used to acquire images of the plastic particles to be detected and to perform preprocessing. The image fusion module uses a wavelet transform fusion algorithm to fuse preprocessed multi-view plastic particle images into a complete plastic particle image. The geometric feature extraction module extracts the edge contours of plastic particles from the complete plastic particle image using the Canny edge detection algorithm; and calculates the geometric features of the plastic particles based on the edge contours. The texture feature extraction module uses the LBP algorithm to extract the texture features of the plastic particle surface from the complete plastic particle image; The color feature extraction module extracts the RGB color space features and HSV color space features of the plastic particles based on the complete plastic particle image to obtain the color features of the plastic particles. The feature fusion module normalizes the extracted geometric, texture, and color features of the plastic particles to construct a multi-dimensional defect feature vector. The defect prediction module calls a pre-trained YOLOv8n-based defect recognition model to perform prediction processing on the complete plastic particle image and multi-dimensional defect feature vectors, so as to output the defect classification results of the plastic particles.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the plastic particle defect detection method as described in any one of claims 1-8.