Plastic particle quality detection method and device based on machine vision
By using high-resolution image processing and depth feature extraction based on machine vision, the problem of accuracy in identifying agglomeration in plastic particle quality inspection was solved, realizing automated and precise inspection and report generation, and improving production efficiency and inspection consistency.
Patent Information
- Application Number
- CN202511123258.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-11-21
Smart Images

Figure CN120997182A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of particle quality detection technology, and in particular to a method and apparatus for detecting the quality of plastic particles based on machine vision. Background Technology
[0002] In the manufacturing sector, plastic granules are an important basic raw material, and their quality directly affects product performance and production efficiency. In particular, the shape, size, and aggregation state of the granules are of great significance to subsequent processes.
[0003] Currently, the industry commonly uses manual visual inspection or simple visual inspection techniques to inspect the quality of plastic granules. These methods typically rely on human experience, using the naked eye or with the aid of magnifying glasses or industrial cameras to perform preliminary identification of granule images to determine whether their shape, size, and agglomeration meet quality requirements. In one implementation, although basic visual inspection techniques are introduced, most only implement shallow functions such as edge detection and grayscale thresholding, and the processing methods are limited, such as judging the presence of agglomeration solely based on area or aspect ratio thresholds.
[0004] However, these methods are difficult to effectively deal with the complex and varied adhesion morphology between particles, and cannot accurately identify and classify different types of agglomeration. Therefore, they cannot accurately determine whether agglomeration meets size standards, resulting in poor consistency and reliability of quality inspection results, which seriously restricts the accuracy and automation level of quality control. Summary of the Invention
[0005] This invention provides a machine vision-based method and apparatus for detecting the quality of plastic particles, thereby achieving automated and precise visual detection of the quality of plastic particles.
[0006] In a first aspect, to solve the above-mentioned technical problems, the present invention provides a machine vision-based method for detecting the quality of plastic particles, comprising: High-resolution image data of plastic particles are acquired, and the distribution state of the particles in the high-resolution image data is digitally processed to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions. Based on the preliminary particle distribution feature map, the adhesion region is separated to obtain agglomeration units, and contour feature data containing size parameters is extracted from the agglomeration units; The shape factor and initial feature vector are calculated based on the contour feature data, and the corresponding preliminary adhesion type is found in the preset morphological feature library. If the initial adhesion type is a complex morphological type, then the contour feature data is subjected to depth feature extraction to obtain a refined morphological vector; The possible adhesion types are obtained by matching the refined morphological vector with the preset refined morphological feature library, and a second calibration is performed based on the possible adhesion types, the refined morphological vector and the preset shape threshold database to determine the final adhesion type. Based on the final adhesion type, the size standard threshold is obtained by querying the preset size threshold library; If the size parameter exceeds the size standard threshold, the size parameter is calibrated according to the agglomeration unit, and a distribution record of abnormal particles is generated. Based on the distribution records of the abnormal particles and the preliminary particle distribution feature map, a comprehensive analysis report for quality inspection is generated.
[0007] Preferably, the step of digitally processing the distribution state of particles in the high-resolution image data to obtain a preliminary particle distribution feature map including particle outlines and adhesion regions includes: The high-resolution image data is used as input to a grayscale conversion algorithm to obtain an intermediate output, and the intermediate output is used as input to an adaptive threshold segmentation method to obtain a binary image. The binary image is used as input to the Canny edge detection algorithm to obtain a first image containing particle outlines; The first image is used as input to the watershed algorithm. It is initially segmented according to a preset spacing threshold, and the adhesion region is identified to obtain the second image. Based on the second image, particle distribution features are extracted to obtain a preliminary particle distribution feature map.
[0008] Preferably, the step of separating the agglomerated region based on the preliminary particle distribution feature map to obtain agglomerated units, and extracting contour feature data containing size parameters from the agglomerated units, includes: Based on the preliminary particle distribution feature map and the adhesion region, a binary map of the region and a gradient map of the region are obtained. Using the region binary map and the region gradient map as inputs to the watershed algorithm, clustering units are obtained; The clustered units are used as input to the Canny edge detection algorithm to generate an edge map; Based on the edge map, a contour tracking algorithm is used to perform calculations to obtain contour feature data containing size parameters.
[0009] Preferably, the step of calculating the shape factor and initial feature vector based on the contour feature data, and searching for the corresponding preliminary adhesion type in a preset morphological feature library, includes: The contour feature data is smoothed to obtain clear boundary description information; Calculate the shape factor and initial feature vector based on the boundary description information; Based on the shape factor and the initial feature vector, a preset morphological feature library is matched to obtain the corresponding preliminary adhesion type.
[0010] Preferably, the step of extracting depth features from the contour feature data to obtain a refined shape vector includes: The contour feature data is used as input to a pre-trained ResNet-50 deep learning model to obtain the first feature vector; Principal component analysis is performed on the first eigenvector to reduce dimensionality, resulting in the second eigenvector. Based on the shape factor and the second feature vector, a preset morphological feature library is matched to obtain the three most similar adhesion types; Based on the specific data of the three adhesion types and the contour feature data, a construction operation is performed to obtain a refined morphological vector.
[0011] Preferably, the step of performing secondary calibration based on the possible adhesion types, the refined morphological vector, and a preset shape threshold database to determine the final adhesion type includes: According to the possible adhesion type, the corresponding shape data threshold is obtained from the preset shape threshold database; If the refined shape vector exceeds the shape data threshold, then a similar adhesion type and similar shape data threshold similar to the possible adhesion type are searched according to the preset shape threshold database. If the refined shape vector does not exceed the similar shape data threshold, then the similar adhesion type is determined as the final adhesion type.
[0012] Preferably, the step of calibrating the size parameters based on the agglomeration units and generating a distribution record of anomalous particles includes: Based on the preliminary particle distribution feature map, spatial analysis and calculation are performed on the aggregated units to obtain a particle distribution dataset. Based on the particle distribution dataset, the size parameters are calibrated to obtain calibrated size data; If the calibrated size data exceeds the size standard threshold, then the distribution record of abnormal particles is obtained based on the particle distribution dataset.
[0013] Preferably, the step of generating a comprehensive analysis report for quality inspection based on the distribution record of the abnormal particles and the preliminary particle distribution feature map includes: The number of abnormal particles is obtained from the distribution record of the abnormal particles; The total number of particles is obtained based on the preliminary particle distribution characteristic map; The density of abnormal particles is calculated based on the number of abnormal particles and the total number of particles. If the density of the abnormal particles exceeds the preset normal density threshold, the current product quality is determined to be abnormal, and preliminary test report data is generated. The abnormal particles are obtained by comparing the distribution records of the abnormal particles with the high-resolution image data of the plastic particles, and the shape parameters are obtained based on the particle outlines. The color parameters and shape parameters are used as inputs to a preset classification neural network to obtain the abnormal particle type; Based on the preliminary test report data and the types of abnormal particles, a comprehensive analysis report for quality testing is obtained.
[0014] Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention requires no manual intervention throughout the entire process from image acquisition to report generation, which significantly reduces the labor costs and operational errors required for visual inspection or semi-automatic detection. Through the preset morphological feature library, refined feature library and threshold database, "one-click" batch detection and analysis can be achieved, improving the detection efficiency and capacity of the production line.
[0015] (2) This invention utilizes high-resolution images and distribution feature maps to accurately separate various complex adhesion morphologies, avoiding misjudgments caused by single area or aspect ratio threshold judgments. By combining shape factor, initial and depth feature vector multi-stage matching and secondary calibration, it can make fine distinctions between slight adhesion, heavy aggregation and small irregular particles, greatly improving the recognition accuracy.
[0016] (3) The present invention enables the system to adapt to particle samples of different batches, different particle size distributions and different shooting conditions by extracting "second-order" deep features and performing multi-level threshold calibration for complex morphological types. Through continuous updating of feature and threshold libraries, the detection capability can be rapidly expanded according to new materials or new processes, and the detection performance can be maintained in a long-term stable manner.
[0017] (4) The calibration and distribution records of abnormal particles are archived in the report, so that every batch and every test is traceable, meeting the needs of production quality traceability and statistical analysis. The comprehensive analysis report can provide multi-dimensional indicators such as particle size distribution, proportion of adhesion types, and reasons for exceeding the standard, which facilitates in-depth analysis and improvement. Attached Figure Description
[0018] Figure 1 This is a schematic flowchart of the machine vision-based plastic particle quality detection method provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a machine vision-based plastic particle quality detection device provided in the second embodiment of 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] Reference Figure 1 The first embodiment of the present invention provides a method for detecting the quality of plastic particles based on machine vision, including the following steps: S101, acquire high-resolution image data of plastic particles, and digitally process the distribution state of particles in the high-resolution image data to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions. S102, the adhesion region is separated according to the preliminary particle distribution feature map to obtain agglomeration units, and contour feature data containing size parameters is extracted from the agglomeration units; S103, calculate the shape factor and initial feature vector based on the contour feature data, and find the corresponding preliminary adhesion type in the preset morphological feature library; S104, If the initial adhesion type is a complex morphological type, then the contour feature data is subjected to depth feature extraction to obtain a refined morphological vector; S105, Match the refined morphological vector with the preset refined morphological feature library to obtain possible adhesion types, and perform secondary calibration based on the possible adhesion types, the refined morphological vector and the preset shape threshold database to determine the final adhesion type; S106, Based on the final adhesion type, query the preset size threshold library to obtain the size standard threshold; S107, If the size parameter exceeds the size standard threshold, the size parameter is calibrated according to the agglomeration unit, and a distribution record of abnormal particles is generated; S108, Based on the distribution record of the abnormal particles and the preliminary particle distribution feature map, generate a comprehensive analysis report for quality detection.
[0021] In step S101, high-resolution image data of the plastic particles needs to be acquired.
[0022] It should be noted that the high-resolution image data of the plastic particles is the input to this method and is acquired by a high-resolution camera. In this embodiment, an industrial camera with a resolution of 1920x1080 pixels is used to capture the particle distribution scene at a speed of 30 frames per second, and the acquired image data is stored in lossless PNG format as high-resolution image data of the plastic particles.
[0023] In one implementation, the distribution state of particles in the high-resolution image data is digitally processed to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions, including: S201, the high-resolution image data is used as input to the grayscale conversion algorithm to obtain an intermediate output, and the intermediate output is used as input to the adaptive threshold segmentation method to obtain a binary image; S202, The binary image is used as input to the Canny edge detection algorithm to obtain a first image containing particle outlines; S203, the first image is used as the input of the watershed algorithm, and preliminary segmentation is performed according to the preset spacing threshold, and the adhesion region is identified to obtain the second image; S204, Extract particle distribution features from the second image to obtain a preliminary particle distribution feature map.
[0024] It should be noted that step S201 uses a grayscale conversion algorithm to output high-resolution color image data, extracts the RGB values of each pixel in the high-resolution image data, and calculates the grayscale value of each pixel using the formula Gray = 0.299R + 0.587G + 0.114B, where Gray is the grayscale value, and R, G, and B are the three parameters of the RGB values. Finally, all grayscale pixels are converted into a grayscale image, which is the intermediate output. This intermediate output is used as the input of an adaptive threshold segmentation method, setting the threshold range between 0 and 255, automatically calculating the optimal threshold to distinguish between granular and non-granular regions, and obtaining the binary image, where granular regions are white and the background is black. For example, if the optimal threshold automatically calculated by the adaptive threshold segmentation method is 125, then pixels with Gray values greater than 125 are set to Gray values of 255 (white), and pixels with Gray values less than or equal to 125 are set to Gray values of 0 (black), resulting in a binary image with Gray values of only 0 or 255.
[0025] It should be noted that step S202, which processes the binary image as input to the Canny edge detection algorithm, specifically includes: performing Gaussian filtering on the binary image to reduce noise; calculating the gradient magnitude and gradient direction of each pixel in the x and y directions to obtain a gradient map; traversing pixels along the gradient direction, retaining only pixels with locally maximum gradient magnitudes as possible edges. For example, if the gradient direction of a pixel is 0° (horizontal), then the tangent direction of the edge containing that pixel is vertical. Then, examine the left and right adjacent pixels; if their gradient directions are also 0° and the pixel with the largest gradient magnitude is retained as a possible edge; traversing all possible edges... The pixels at the edge are processed using a dual threshold method. In this embodiment, the low threshold is set to 50 and the high threshold is set to 150. If the pixel amplitude is greater than 150, the pixel is set as a strong edge. If the pixel amplitude is between 50 and 150, the pixel is set as a weak edge. If the pixel amplitude is less than 50, it is no longer considered an edge. All weak edges are traversed. If a weak edge is connected to a strong edge, it is considered an edge. Otherwise, it is discarded. Finally, the pixels of the strong edges and the weak edges that are considered edges are marked with edges to obtain the first image. The pixels marked with edges are the particle contours. The first image includes a binary image, a particle contour, and a gradient image.
[0026] It should be noted that in step S203, pixels that are white in the binary image and within the range of the particle outline are taken as foreground, and pixels that are black in the binary image and outside the particle outline are taken as background. A distance transformation is performed on the foreground, and the Euclidean distance from each foreground pixel to the nearest background is calculated. Each particle outline is traversed, and if the maximum Euclidean distance of its internal pixels is greater than a preset spacing threshold, the corresponding pixel is set as a seed. All seeds are assigned unique labels, such as 1, 2, 3, 4, forming a marker map. Based on the gradient map and the marker map, the algorithm simulates water flowing out from the seeds, with different flow directions and speeds according to different gradients. When encountering other water sources, a boundary line is generated based on the meeting point. According to the boundary line, in the divided region of the first image, if there are multiple particle outlines in the same region, the region is marked as an adhesion region. Finally, the marked adhesion regions and the first image are merged into a second image.
[0027] It should be noted that in this embodiment, the method of marking the region as an adhesion region is to use a mask image, that is, to copy the binary image as a mask image, set the pixel value corresponding to the adhesion region to 1, and set the other pixel values to 0.
[0028] It should be noted that in step S204, the particle distribution features include the center coordinates of the particles, the center coordinates of the adhesion region, the area of the particles, and the area of the adhesion region. The area of the adhesion region is obtained by counting the number of pixels with a pixel value of 1 in the corresponding area of the mask image, and the area of the particle is obtained by counting the number of pixels within the particle outline. The center coordinates of the particles are... , The calculation formula is shown in Formula 1: in, Let X be the X coordinate of each pixel within the particle outline. Let Y be the Y coordinate of each pixel within the particle outline. This represents the number of pixels within the grain outline. Replace with the X coordinate of each pixel in the adhered area, Replace with the Y coordinate of each pixel in the adhered region, and calculate. , The coordinates of the center of the adhesion region are used. An index table is constructed in the second image, containing the center coordinates and area of each particle and adhesion region, and merged into the second image to obtain a preliminary particle distribution feature map. For example, the particles and adhesion regions in the second image are labeled, and the index table contains the center coordinates and area of particles or adhesion regions with different labels. By merging this index table into the second image, the center coordinates and area of particles or adhesion regions can be obtained by querying the index table based on the labels in the second image.
[0029] In step S102, the agglomerated region is separated according to the preliminary particle distribution feature map to obtain agglomerated units, and contour feature data containing size parameters is extracted from the agglomerated units, including: S301, based on the preliminary particle distribution feature map and the adhesion region, a region binary map and a region gradient map are obtained by segmentation; S302, the region binary map and region gradient map are used as inputs to the watershed algorithm to obtain clustering units; S303, The clustering unit is used as input to the Canny edge detection algorithm to generate an edge map; S304, Based on the edge map, a contour tracking algorithm is used to perform calculations to obtain contour feature data containing size parameters.
[0030] It should be noted that the preliminary particle distribution feature map includes various images and feature data, such as gradient maps, binary maps, distribution data, and particle contours. In step S301, the binary map and gradient map in the preliminary particle distribution feature map are segmented according to the adhesion region to obtain a region binary map and a region gradient map within the adhesion region. For example, the bounding box of the region is obtained based on the adhesion region contour, denoted as [x_min, y_min, x_max, y_max]. The binary map is cropped, retaining only pixels within the range [x_min:x_max, y_min:y_max] to generate a region binary map; similarly, the gradient map is cropped within the same range to generate a region gradient map.
[0031] It should be noted that in step S302, the region binary map and region gradient map need to be used as inputs to the watershed algorithm. The specific algorithm process is similar to that in step S203. The difference is that when setting the seed, each particle contour within the range is traversed to obtain the maximum Euclidean distance among all particle contours, and 0.8 times this maximum value is set as the new distance threshold. For each particle contour, if the maximum Euclidean distance of its internal pixels is greater than the new distance threshold, then the corresponding pixel is set as the seed. After the watershed algorithm divides the region, each region is a clustering unit. If the boundary lines of the clustering units overlap or break, then the boundary lines are smoothed or connected.
[0032] It should be noted that the complete boundary information obtained after step S302 is relatively vague and requires refinement in step S303. The clustering unit is used as the input to the Canny edge detection algorithm, and the specific algorithm calculation process is the same as that of the Canny edge detection algorithm in step S202, and the output is an edge map.
[0033] It should be noted that in step S303, the contour tracking algorithm starts from a pixel on the boundary of the edge map, marks the current boundary pixel, finds the next boundary point, and repeats the above process until it returns to the starting pixel, thus obtaining a closed boundary. The coordinates of the closed boundary points are extracted from the closed boundary, and the perimeter of the contour is estimated by accumulating the distance between adjacent boundary points, as shown in Formula 2: (2) Where C is the perimeter of the profile, ∆X i Let ∆Y be the difference in x-coordinate between the i-th pixel and its next counterclockwise adjacent pixel. i It represents the difference in ordinate between the i-th pixel and its next adjacent pixel counterclockwise.
[0034] Calculate the area of the outline using the polygon area calculation formula, see Formula 3: (3) Where A is the area of the contour range, X i+1 Y is the x-coordinate of the next adjacent pixel in the counter-clockwise direction. i+1 It represents the ordinate of the next adjacent pixel.
[0035] The minimum bounding rectangle of the clustering unit is calculated using the `minAreaRect` function in OpenCV. The contour feature data is obtained by integrating the contour perimeter, the contour area, the coordinates of the closed boundary points, and the minimum bounding rectangle. The size parameters of the contour feature data include the contour perimeter, the contour area, and the length and width of the minimum bounding rectangle.
[0036] In step S103, the shape factor and initial feature vector are calculated based on the contour feature data, and the corresponding preliminary adhesion type is found in a preset morphological feature library, including: S401, Smoothing is performed on the contour feature data to obtain clear boundary description information; S402, Calculate the shape factor and initial feature vector based on the boundary description information; S403, Based on the shape factor and the initial feature vector, a preset morphological feature library is matched to obtain the corresponding preliminary adhesion type.
[0037] It should be noted that step S401 requires smoothing the contour feature data. The sequence of closed boundary point coordinates in the contour feature data is treated as a signal, and a one-dimensional Gaussian kernel convolution is applied to the x and y coordinates respectively to obtain a smoother boundary and smoothed boundary point coordinates. The closed boundary point coordinates in the contour feature data are then updated to the smoothed boundary point coordinates to obtain boundary description information. This boundary description information includes the smoothed boundary point coordinates, the contour perimeter, the contour area, and the minimum bounding rectangle.
[0038] It should be noted that in step S402, the shape factor is calculated based on the perimeter and area of the contour in the boundary description information. The calculation formula is SF = 4π × S / C. 2 Where SF is the shape factor, S is the area of the contour range, and C is the perimeter of the contour; it is also necessary to calculate the initial feature vector based on the coordinates of the smooth boundary points, and convert these smooth boundary point coordinates into complex numbers, as shown in Formula 5. Where, ( , () are the coordinates of the smooth boundary point. It is a complex number. The imaginary unit. The complex sequence is then converted into frequency components using the discrete Fourier transform, as shown in Formula 6; where, For frequency components, It is a complex number. The imaginary unit, To smooth out the number of boundary point coordinates, It is a constant. Calculate. The magnitudes of the frequency components from 0 to 10 are used to obtain a 10-dimensional initial eigenvector.
[0039] (5) (6) It should be noted that step S403 requires combining the shape factor and the initial feature vector into an 11-dimensional query vector, calculating the cosine similarity between the query vector and each item in the preset morphological feature library, and recording the maximum cosine similarity and the corresponding adhesion type. If the maximum cosine similarity is less than 0.4, the initial adhesion type of the clustering unit is set to complex adhesion; if the maximum cosine similarity is greater than or equal to 0.4, the initial adhesion type of the clustering unit is set to the corresponding adhesion type.
[0040] It should be noted that each item in the preset morphological feature library includes the shape factor value range, feature vector, and specific data for the corresponding adhesion type for different adhesion types. The morphological feature database only contains five adhesion types: single entity, point contact, line contact, surface contact, and encapsulation. If a high degree of similarity cannot be matched with any of these five types, the initial adhesion type will be set as complex adhesion, requiring further refinement and reclassification.
[0041] In one implementation, if the initial adhesion type is complex adhesion, then depth feature extraction needs to be performed on the contour feature data to obtain a refined morphological vector, including: S501, The contour feature data is used as input to the pre-trained ResNet-50 deep learning model to obtain the first feature vector; S502, perform principal component analysis to reduce the dimensionality based on the first eigenvector to obtain the second eigenvector; S503, Based on the shape factor and the second feature vector, a preset morphological feature library is matched to obtain the three most similar adhesion types; S504, a construction operation is performed based on the specific data of the three adhesion types and the contour feature data to obtain a refined morphological vector.
[0042] It should be noted that the ResNet-50 in step S501 is a classic deep convolutional neural network, mainly used for visual tasks such as image classification. The coordinates of closed boundary points in the contour feature data are extracted to generate a 224×224 binary boundary map with boundary point pixel values of 0 and other pixel values of 255. This binary map is then subjected to multiple convolution and pooling operations to extract a 2048-dimensional first feature vector.
[0043] It should be noted that step S502 requires dimensionality reduction of the 2048-dimensional first eigenvector. Principal component analysis (PCA) is used to reduce the dimensionality of the first eigenvector to a 10-dimensional second eigenvector. PCA is a commonly used dimensionality reduction method, widely applied in data preprocessing, visualization, noise removal, and other scenarios. It maps high-dimensional data to a low-dimensional space, preserving as much variance information as possible from the original data.
[0044] It should be noted that in step S503, the shape factor and the second feature vector need to be integrated into an 11-dimensional query vector, and the cosine similarity between the query vector and each item in the morphological feature library is calculated to obtain the three adhesion types with the highest cosine similarity.
[0045] It should be noted that in step S504, specific data for the three adhesion types are extracted from the morphological feature library, including morphological complexity and edge smoothness. The average morphological complexity and average edge smoothness are calculated from the specific data for the three adhesion types. The average morphological complexity, average edge smoothness, shape factor, and the ratio of contour perimeter to contour area in the contour feature data are combined into a 4-dimensional refined morphological vector.
[0046] In another implementation, if the initial adhesion type is not a complex adhesion type, then steps S104 and S105 are skipped, and the initial adhesion type is taken as the final adhesion type.
[0047] In step S105, it is necessary to match the refined morphology vector with the preset refined morphology feature library to obtain possible adhesion types.
[0048] It should be noted that the preset refined morphological feature library includes morphological complexity, edge smoothness, the ratio of contour perimeter to contour area, and shape factor for different adhesion types. The possible adhesion types are obtained by matching the refined morphological vector with the item in the refined morphological feature library that has the highest similarity.
[0049] In one implementation, a secondary calibration is performed based on the possible adhesion types, the refined morphological vector, and a preset shape threshold database to determine the final adhesion type, including: S601, Obtain the corresponding shape data threshold from the preset shape threshold database according to the possible adhesion type; S602, if the refined shape vector exceeds the shape data threshold, then search for similar adhesion types and similar shape data thresholds that are similar to the possible adhesion types according to the preset shape threshold database. S603, if the refined shape vector does not exceed the similar shape data threshold, then the similar adhesion type is determined as the final adhesion type.
[0050] It should be noted that in step S601, the preset shape threshold library records shape data thresholds corresponding to different adhesion shapes, including thresholds for morphological complexity, edge smoothness, the ratio of contour perimeter to contour area, and shape factor. The shape data thresholds for the possible adhesion types can be searched from the preset shape threshold library.
[0051] It should be noted that step S602 requires determining whether the refined shape vector exceeds the shape data threshold.
[0052] In one implementation, if the refined morphological vector exceeds the shape data threshold, a similar adhesion type and similar shape data threshold are searched according to a preset shape threshold database. For example, if the possible adhesion type of the agglomeration unit is line contact, the morphological complexity of the unit is 0.7, and the corresponding morphological complexity threshold is 0.65, the adhesion type in the shape threshold database with a high cosine similarity between the shape data threshold and the shape data threshold of line contact and a morphological complexity threshold greater than 0.7 is searched, resulting in a similar adhesion type of surface contact and a corresponding similar shape data threshold. If no similar adhesion type that meets the requirements can be found, the particles in the agglomeration unit are marked as abnormal particles and added to the distribution record of abnormal particles.
[0053] In another implementation, if the refined shape vector does not exceed the shape data threshold, the final adhesion type is set to a possible adhesion type, and step S603 is skipped.
[0054] It should be noted that, in step S603, after obtaining the similar shape data threshold, it is necessary to determine whether the refined shape vector exceeds the similar shape data threshold.
[0055] In one implementation, if the refined shape vector does not exceed the similar shape data threshold, the final adhesion type is set to the similar adhesion type.
[0056] In another implementation, if the refined morphological vector exceeds the similar shape data threshold, then the particles within the agglomeration unit are marked as anomalous particles and added to the distribution record of anomalous particles.
[0057] In step S106, based on the final adhesion type, a preset size threshold is obtained by querying a preset size threshold library. This preset size threshold library stores size standard thresholds for different adhesion types, including thresholds for the length and width of the minimum bounding rectangle, the perimeter of the outline, and the area of the outline range.
[0058] For example, if the final adhesion type is line contact, the threshold data of line contact aggregation units in the preset size threshold library are queried to obtain the minimum bounding rectangle length threshold of 100px, width threshold of 50px, outline perimeter threshold of 325px, and outline area threshold of 4350px.
[0059] In step S107, it is necessary to compare whether the size parameter exceeds the size standard threshold, and compare the size parameter with the size standard threshold one by one.
[0060] In one implementation, if the size parameter exceeds the size standard threshold, the size parameter is calibrated based on the agglomeration unit, and a distribution record of abnormal particles is generated, including: S701, Spatial analysis and calculation are performed on the agglomeration unit based on the preliminary particle distribution feature map to obtain a particle distribution dataset; S702, Based on the particle distribution dataset, calibrate the size parameters to obtain calibrated size data; S703, if the calibrated size data exceeds the size standard threshold, then the distribution record of abnormal particles is obtained based on the particle distribution dataset.
[0061] It should be noted that in step S701, the particle outline center coordinates in the preliminary particle distribution feature map are traversed. If the particle outline center coordinates are within the range of the clustering unit, it indicates that the particle is a component of the clustering unit. All particle outlines, particle center coordinates, and particle areas within the clustering unit range are then added to the particle data distribution set. The particle distribution dataset records the particle outlines, particle center coordinates, and particle areas of different clustering units.
[0062] It should be noted that in step S702, the size parameters need to be calibrated based on the particle distribution dataset. For example, there are gaps between particles in the particle distribution data. The number of pixels in these gaps is accumulated to obtain the number of calibrated pixels. The area of the contour range in the size parameters is then subtracted from the number of calibrated pixels to obtain the calibrated size data.
[0063] It should be noted that in step S703, it is necessary to determine whether the calibrated size data exceeds the size standard threshold. If the calibrated size data does not exceed the size standard threshold, it indicates that the agglomeration unit conforms to the size standard; if the calibrated size still exceeds the size standard threshold, it indicates that the agglomeration unit does not conform to the size standard, and the particle distribution data is added to the distribution record of abnormal particles. The distribution record of abnormal particles includes the center position of the abnormal particle, the particle outline, and the agglomeration unit to which it belongs.
[0064] For example, the minimum bounding rectangle of a line-contact type agglomeration unit has a length threshold of 100px, a width threshold of 50px, a perimeter threshold of 325px, and a surface area threshold of 4350px. In this case, the agglomeration unit type is line-contact, and its calibrated minimum bounding rectangle has a length of 99px, a width of 49px, a perimeter of 320px, and a surface area of 4400px. Although the length, width, and perimeter of the minimum bounding rectangle are all within the threshold range, the surface area exceeds the threshold, so the agglomeration unit does not meet the size standard.
[0065] In another implementation, if the size parameter does not exceed the size standard threshold, it indicates that the current agglomeration unit meets the size standard, and no further anomaly processing or anomaly reporting is performed.
[0066] In step S108, based on the distribution record of the abnormal particles and the preliminary particle distribution feature map, a comprehensive analysis report for quality inspection is generated, including: S801, the number of abnormal particles is obtained based on the distribution record of the abnormal particles; S802, The total number of particles is obtained based on the preliminary particle distribution characteristic map; S803, calculate the abnormal particle density based on the number of abnormal particles and the total number of particles; S804, If the density of the abnormal particles exceeds the preset normal density threshold, the current product quality is determined to be abnormal, and preliminary test report data is generated. S805, Based on the distribution record of the abnormal particles, the high-resolution image data of the plastic particles are compared to obtain the color parameters of the abnormal particles, and the shape parameters are calculated based on the particle outline. S806, The color parameter and the shape parameter are used as inputs to a preset classification neural network to obtain the abnormal particle type; S807, Based on the preliminary test report data and abnormal particle types, a comprehensive analysis report for quality testing is obtained.
[0067] It should be noted that in step S801, the distribution record of abnormal particles records the center position, particle outline and the agglomeration unit to which the abnormal particles belong. The number of abnormal particles is obtained by counting the number of items in the distribution record of abnormal particles.
[0068] It should be noted that in step S802, the preliminary particle distribution feature map includes the labels of all particles, and the total number of particles is obtained by counting the number of particle labels.
[0069] It should be noted that in step S803, the density of abnormal particles needs to be calculated. The calculation formula is: Density=N / A, where Density is the density of abnormal particles, N is the number of abnormal particles, and A is the total number of particles.
[0070] It should be noted that in step S804, the preset normal density threshold is 1.5%. If the abnormal particle density is less than 1.5%, the current product meets the quality requirements; if the abnormal particle density is greater than 1.5%, the current product is unqualified. Based on the above judgment, preliminary test report data is generated, which includes product quality and abnormal particle density.
[0071] It should be noted that in step S805, the location information of the abnormal particles is obtained based on the distribution record of the abnormal particles. The high-resolution image data of the plastic particles is then retrieved based on this location information to obtain the RGB values (color parameters) of the corresponding pixels of the abnormal particles. The radius of curvature of each pixel is calculated using the pixel coordinates of the particle outline to obtain the shape parameters.
[0072] It should be noted that the preset classification neural network in step S806 is trained from a number of training data. The training data includes shape parameters, color parameters, and corresponding abnormal particle type labels, which can determine the abnormal particle type based on the shape and color parameters of the abnormal particles. The abnormal particle types include those with off-color and non-circular shape, those with normal color but non-circular shape, those with off-color and circular shape, and those with normal color and circular shape.
[0073] It should be noted that the comprehensive analysis report for quality inspection in step S807 includes product quality, abnormal particle density, and abnormal particle type. Based on the comprehensive analysis report, one can understand the current product quality and analyze the specific causes of the abnormalities based on the abnormal particle density and abnormal particle type, and address them in a timely manner.
[0074] In summary, this invention discloses a machine vision-based method for detecting the quality of plastic particles, comprising: acquiring high-resolution image data of plastic particles, and digitally processing the distribution state of the particles in the high-resolution image data to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions; separating the adhesion regions according to the preliminary particle distribution feature map to obtain agglomeration units, and extracting outline feature data containing size parameters from the agglomeration units; calculating a shape factor and an initial feature vector according to the outline feature data, and searching for the corresponding preliminary adhesion type in a preset morphological feature library; if the preliminary adhesion type is a complex morphological type, then... The contour feature data is subjected to depth feature extraction to obtain a refined morphological vector. The refined morphological vector is matched with a preset refined morphological feature library to obtain possible adhesion types. A secondary calibration is performed based on the possible adhesion types, the refined morphological vector, and a preset shape threshold database to determine the final adhesion type. Based on the final adhesion type, a preset size threshold library is queried to obtain a size standard threshold. If the size parameter exceeds the size standard threshold, the size parameter is calibrated based on the agglomeration unit, and a distribution record of abnormal particles is generated. Based on the distribution record of abnormal particles and the preliminary particle distribution feature map, a comprehensive analysis report for quality inspection is generated. This invention achieves efficient, accurate, and traceable fully automated plastic particle quality inspection through multi-level feature extraction, automatic calibration, and automatic verification comparison.
[0075] Reference Figure 2 The second facility of the present invention provides a machine vision-based plastic particle quality inspection device, which can implement all processes of the energy-saving control method of the above-mentioned electricity meter, including: M01, digital processing module, acquires high-resolution image data of plastic particles, and performs digital processing on the distribution state of the particles in the high-resolution image data to obtain a preliminary particle distribution feature map containing particle outlines and adhesion areas. M02, Unit Separation Module, separates the adhesion region according to the preliminary particle distribution feature map to obtain agglomeration units, and extracts contour feature data containing size parameters from the agglomeration units; M03, the type lookup module, calculates the shape factor and initial feature vector based on the contour feature data, and searches for the corresponding preliminary adhesion type in the preset morphological feature library; M04, Feature Extraction Module: If the initial adhesion type is a complex morphological type, then perform depth feature extraction on the contour feature data to obtain a refined morphological vector. M05, the type determination module, matches the refined morphological vector with the preset refined morphological feature library to obtain possible adhesion types, and performs secondary calibration based on the possible adhesion types, the refined morphological vector and the preset shape threshold database to determine the final adhesion type; M06, Threshold lookup module, according to the final adhesion type, queries a preset size threshold library to obtain the size standard threshold; M07, Record Generation Module: If the size parameter exceeds the size standard threshold, the size parameter is calibrated according to the agglomeration unit, and a distribution record of abnormal particles is generated. M08, the report generation module, generates a comprehensive analysis report for quality inspection based on the distribution record of the abnormal particles and the preliminary particle distribution feature map.
[0076] It should be noted that all the process steps of the machine vision-based plastic particle quality detection method provided in the embodiments of the present invention correspond one-to-one in terms of working principle and beneficial effect, and therefore will not be repeated.
[0077] This invention also provides an electronic device. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a difference calculation program. When the processor executes the computer program, it implements the steps in the various embodiments of the machine vision-based plastic particle quality detection method described above, for example... Figure 1 The step S11 shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, such as a unit separation module.
[0078] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0079] The electronic device may be a desktop computer, laptop, handheld computer, or smart tablet, etc. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0080] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting all parts of the electronic device via various interfaces and lines.
[0081] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0082] Wherein, if the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0083] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0084] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A machine vision-based method for detecting the quality of plastic granules, characterized in that, include: High-resolution image data of plastic particles are acquired, and the distribution state of the particles in the high-resolution image data is digitally processed to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions. Based on the preliminary particle distribution feature map, the adhesion region is separated to obtain agglomeration units, and contour feature data containing size parameters is extracted from the agglomeration units; The shape factor and initial feature vector are calculated based on the contour feature data, and the corresponding preliminary adhesion type is found in the preset morphological feature library. If the initial adhesion type is a complex morphological type, then the contour feature data is subjected to depth feature extraction to obtain a refined morphological vector; The possible adhesion types are obtained by matching the refined morphological vector with the preset refined morphological feature library, and a second calibration is performed based on the possible adhesion types, the refined morphological vector and the preset shape threshold database to determine the final adhesion type. Based on the final adhesion type, the size standard threshold is obtained by querying the preset size threshold library; If the size parameter exceeds the size standard threshold, the size parameter is calibrated according to the agglomeration unit, and a distribution record of abnormal particles is generated. Based on the distribution records of the abnormal particles and the preliminary particle distribution feature map, a comprehensive analysis report for quality inspection is generated.
2. The method for detecting the quality of plastic particles based on machine vision according to claim 1, characterized in that, The step of digitizing the distribution of particles in the high-resolution image data to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions includes: The high-resolution image data is used as input to a grayscale conversion algorithm to obtain an intermediate output, and the intermediate output is used as input to an adaptive threshold segmentation method to obtain a binary image. The binary image is used as input to the Canny edge detection algorithm to obtain a first image containing particle outlines; The first image is used as input to the watershed algorithm. It is initially segmented according to a preset spacing threshold, and the adhesion region is identified to obtain the second image. Based on the second image, particle distribution features are extracted to obtain a preliminary particle distribution feature map.
3. The machine vision-based plastic particle quality detection method according to claim 2, characterized in that, The step of separating the agglomerated region based on the preliminary particle distribution feature map to obtain agglomerated units, and extracting contour feature data containing size parameters from the agglomerated units, includes: Based on the preliminary particle distribution feature map and the adhesion region, a binary region map and a gradient region map are obtained by segmentation. Using the region binary map and the region gradient map as inputs to the watershed algorithm, clustering units are obtained; The clustered units are used as input to the Canny edge detection algorithm to generate an edge map; Based on the edge map, a contour tracking algorithm is used to perform calculations to obtain contour feature data containing size parameters.
4. The machine vision-based plastic particle quality detection method according to claim 1, characterized in that, The step of calculating the shape factor and initial feature vector based on the contour feature data, and searching for the corresponding preliminary adhesion type in a preset morphological feature library, includes: The contour feature data is smoothed to obtain clear boundary description information; Calculate the shape factor and initial feature vector based on the boundary description information; Based on the shape factor and the initial feature vector, a preset morphological feature library is matched to obtain the corresponding preliminary adhesion type.
5. The machine vision-based plastic particle quality detection method according to claim 4, characterized in that, The step of extracting depth features from the contour feature data to obtain a refined shape vector includes: The contour feature data is used as input to a pre-trained ResNet-50 deep learning model to obtain the first feature vector; Principal component analysis is performed on the first eigenvector to reduce dimensionality, resulting in the second eigenvector. Based on the shape factor and the second feature vector, a preset morphological feature library is matched to obtain the three most similar adhesion types; Based on the specific data of the three adhesion types and the contour feature data, a construction operation is performed to obtain a refined morphological vector.
6. The method for detecting the quality of plastic particles based on machine vision according to claim 1, characterized in that, The step of performing secondary calibration based on the possible adhesion types, the refined morphological vector, and a preset shape threshold database to determine the final adhesion type includes: According to the possible adhesion type, the corresponding shape data threshold is obtained from the preset shape threshold database; If the refined shape vector exceeds the shape data threshold, then a similar adhesion type and similar shape data threshold similar to the possible adhesion type are searched according to the preset shape threshold database. If the refined shape vector does not exceed the similar shape data threshold, then the similar adhesion type is determined as the final adhesion type.
7. The method for detecting the quality of plastic particles based on machine vision according to claim 1, characterized in that, The step of calibrating the size parameters based on the agglomeration units and generating a distribution record of abnormal particles includes: Based on the preliminary particle distribution feature map, spatial analysis and calculation are performed on the aggregated units to obtain a particle distribution dataset. Based on the particle distribution dataset, the size parameters are calibrated to obtain calibrated size data; If the calibrated size data exceeds the size standard threshold, then the distribution record of abnormal particles is obtained based on the particle distribution dataset.
8. The method for detecting the quality of plastic particles based on machine vision according to claim 1, characterized in that, The process of generating a comprehensive analysis report for quality inspection based on the distribution records of the abnormal particles and the preliminary particle distribution feature map includes: The number of abnormal particles is obtained from the distribution record of the abnormal particles; The total number of particles is obtained based on the preliminary particle distribution characteristic map; The density of abnormal particles is calculated based on the number of abnormal particles and the total number of particles. If the density of the abnormal particles exceeds the preset normal density threshold, the current product quality is determined to be abnormal, and preliminary test report data is generated. By comparing the distribution records of the abnormal particles with the high-resolution image data of the plastic particles, the color parameters of the abnormal particles are obtained, and the shape parameters are calculated based on the particle outline. The color parameters and shape parameters are used as inputs to a preset classification neural network to obtain the abnormal particle type; Based on the preliminary test report data and the types of abnormal particles, a comprehensive analysis report for quality testing is obtained.
9. A machine vision-based plastic particle quality inspection device, characterized in that, include: The digital processing module acquires high-resolution image data of plastic particles and performs digital processing on the distribution state of the particles in the high-resolution image data to obtain a preliminary particle distribution feature map containing particle outlines and adhesion regions. The unit separation module separates the adhesion region according to the preliminary particle distribution feature map to obtain agglomeration units, and extracts contour feature data containing size parameters from the agglomeration units; The type lookup module calculates the shape factor and initial feature vector based on the contour feature data, and searches for the corresponding preliminary adhesion type in the preset morphological feature library; The feature extraction module performs deep feature extraction on the contour feature data if the initial adhesion type is a complex morphology type, to obtain a refined morphology vector. The type determination module matches the refined morphological vector with a preset refined morphological feature library to obtain possible adhesion types, and performs secondary calibration based on the possible adhesion types, the refined morphological vector, and a preset shape threshold database to determine the final adhesion type. The threshold lookup module queries a preset size threshold library to obtain a standard size threshold based on the final adhesion type. The record generation module calibrates the size parameter according to the agglomeration unit if the size parameter exceeds the size standard threshold, and generates a distribution record of abnormal particles. The report generation module generates a comprehensive analysis report for quality inspection based on the distribution record of the abnormal particles and the preliminary particle distribution feature map.
10. A computer-readable storage medium storing a computer program, characterized in that, When executed by a processor, the program implements the steps of the method according to any one of claims 1 to 8.