Real-time detection method and system for visual defects of plastic valve based on deep learning
Patent Information
- Application Number
- CN202610923239.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-25
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2046-06-25
AI Technical Summary
[0007]为解决现有技术中存在的由塑料阀门结构产生的漫反射伪影容易导致缺陷误判的问题,本发明提出基于深度学习的塑料阀门视觉缺陷实时检测方法及系统
本发明通过极坐标降维空间滤波与引入绝对物理半径的双输入轻量化网络相融合,剥离了由阀门内部通孔拔模斜度引起的漫反射伪影干扰,提高了塑料阀门视觉缺陷实时检测的准确性与鲁棒性。
Smart Images

Figure CN122454302B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision and image processing technology, specifically to a method and system for real-time detection of visual defects in plastic valves based on deep learning. Background Technology
[0002] In automated continuous production lines for IBCs (medium-sized bulk containers) or large liquid bags, multi-layer co-extruded PE films are typically conveyed continuously forward at a linear speed of 24 m / min. In this core process, rigid plastic valves need to be heat-sealed onto the flexible PE film. To ensure product quality, the production line is usually equipped with an 8K high-speed line scan camera and a bottom ultra-bright LED transmission light source to continuously acquire images of the wide film surface, thereby intercepting abnormalities caused by the production process, such as pores, crystal points, and misalignment of the heat-sealing line and poor plasticization in the valve area.
[0003] Existing conventional visual detection methods involve: triggering a camera to acquire an image using a servo encoder; then using morphological methods to select the rectangular region containing the plastic valve; finally, directly feeding the image into a traditional edge extraction operator or shrinking the entire image before feeding it into a deep learning object detection network, such as the YOLO series networks. Figure 1 Complete end-to-end classification and location of good and defective products in one go.
[0004] However, in continuous production, the inherent three-dimensional structural characteristics of plastic valves can cause optical artifacts, thus interfering with the accuracy of visual inspection. Specifically, the center of the IBC plastic valve is a main through-hole structure. To meet the requirements of the injection molding process, the inner wall of the through-hole has a certain draft angle. Under the illumination of the bottom transmitted light source, the light undergoes complex diffuse reflection on the smooth and inclined inner wall. Affected by the valve's posture fluctuation caused by the slight vibration of the production line, this diffuse reflection will form an asymmetrical, cloud-like bright area with continuously varying gray levels on the two-dimensional focal plane of the camera, i.e., diffuse reflection artifact.
[0005] In conventional visual inspection processes, this asymmetrical, cloud-like diffuse reflection artifact has a high brightness characteristic. The diffuse reflection artifact is located in the transition zone of the inner edge of the plastic valve. In terms of spatial distribution, it is easy to be confused with the features of real micro scratches and burrs. Directly inputting the original image into the existing deep learning model for defect identification is prone to misjudgment because the existing deep learning model cannot distinguish the difference between this diffuse reflection artifact and real defects, resulting in inaccurate defect detection results.
[0006] Therefore, there is an urgent need for a real-time visual defect detection method and system for plastic valves that can accurately identify diffuse reflection artifact interference and accurately locate minute defects. Summary of the Invention
[0007] To address the problem in existing technologies where diffuse reflection artifacts generated by the structure of plastic valves can easily lead to misjudgments of defects, this invention proposes a real-time visual defect detection method and system for plastic valves based on deep learning.
[0008] On the one hand, the real-time visual defect detection method for plastic valves based on deep learning provided by the present invention includes: S1: Obtain a grayscale image containing the plastic valve and the surrounding heat-sealed wire; lock the main body region of the plastic valve in the grayscale image; extract the geometric moments of the main body region of the plastic valve; and use the geometric moments to locate the centroid of the main body region of the plastic valve. S2: Based on the centroid of the main body region of the plastic valve, map each pixel in the grayscale image from the Cartesian coordinate system to the polar coordinate system to obtain the panoramic unfolded image corresponding to the grayscale image; S3: Apply a one-dimensional high-pass filter to the panoramic unfolded image row by row along the polar angle direction of the polar coordinate system to obtain a high-pass filtered image. Extract the average value and standard deviation of the gray values of each row of pixels in the high-pass filtered image as gray-level statistical features. Based on the gray-level statistical features, perform adaptive threshold segmentation to extract abnormal gray-level pixels. After inversely mapping the abnormal gray-level pixels to the rectangular coordinate system, perform spatial density clustering to generate multiple suspected defect areas. S4: Obtain the Euclidean distance between the centroid of each suspected defect region and the centroid of the main body region of the plastic valve. Input each suspected defect region and the corresponding Euclidean distance into a dual-input lightweight convolutional network for feature fusion and classification processing to obtain the defect detection result.
[0009] This technical solution analyzes the optical imaging characteristics of the three-dimensional structure of plastic valves. First, it utilizes the global balance characteristics of geometric moment integrals to dilute the asymmetric weighting caused by diffuse reflection with localized cloud-like features, accurately locating the geometric centroid for interference resistance. Then, through polar coordinate mapping, the complex cloud-like artifacts distributed along the edge of the through-hole are flattened into a continuous gray-scale gradient band along the polar angle in the panoramic image. Based on the optical gradient difference between diffuse reflection artifacts and real defects, a one-dimensional high-pass filter is applied along the polar angle to filter out the low-frequency cloud-like background in the signal domain, preserving the real defect abrupt change region. Finally, by calculating the centroid spacing as a spatial prior and feeding it into a dual-input network, the model is forced to consider the target's location during decision-making, effectively distinguishing diffuse reflection afterimages from real material damage and improving the accuracy of visual defect detection results for plastic valves.
[0010] Further, locking the main body region of the plastic valve in the grayscale image includes: using Otsu's method to perform adaptive binarization segmentation processing on the grayscale image to obtain all initial connected components; introducing the prior area of the plastic valve as a constraint condition to filter all initial connected components, and using the initial connected components retained after filtering as the main body region of the plastic valve.
[0011] Furthermore, the panoramic unfolded image corresponding to the grayscale image is generated based on the following method: taking the centroid of the main body area of the plastic valve as the pole and the horizontal center line of the grayscale image as the reference direction; obtaining the polar radius of each pixel in the grayscale image relative to the pole and the polar angle relative to the reference direction through the polar coordinate transformation formula; mapping the polar angle of each pixel to the horizontal direction of the panoramic unfolded image and mapping the polar radius to the vertical direction of the panoramic unfolded image to generate a panoramic unfolded image composed of all pixels.
[0012] This technical solution transforms complex two-dimensional spatial topology into easily processed one-dimensional signal arrangement. By setting the centroid as the pole, the image is mapped from the Cartesian coordinate system to polar coordinates. The originally ring-shaped heat-sealed line edges and the asymmetrical cloud-like diffuse reflection artifacts distributed along the inner wall of the main hole are flattened into a horizontal broadband structure in the panoramic image. This reconstruction of mathematical dimensions removes the computational obstacle of inconsistent gradient changes in various directions of the ring structure in the Cartesian coordinate system.
[0013] Further, the average and standard deviation of the gray values of each row of pixels in the high-pass filtered image are extracted as gray-level statistical features. Based on the gray-level statistical features, adaptive threshold segmentation is performed to extract abnormal gray-level pixels, including: calculating the average and standard deviation of the gray values of each row of pixels in the high-pass filtered image; determining a dynamic segmentation threshold for each row of pixels based on the average and standard deviation using the three-times-standard-deviation rule; and extracting pixels in each row whose gray values are greater than the dynamic segmentation threshold as the abnormal gray-level pixels.
[0014] This technical solution aims to give the detection system the ability to generalize over long-term operation. In industrial production environments, the long-term light decay of LED light sources and the slight differences in the transmittance of different batches of PE film will cause the overall image grayscale reference to drift. By calculating the mean and standard deviation of the grayscale of each row of pixels after the current image is filtered, the dynamic segmentation threshold is established in real time based on the three-times-standard-deviation rule, which can perform adaptive calibration according to the local statistical characteristics of the current frame image.
[0015] Furthermore, each of the suspected defect regions is determined based on the following method: all abnormal grayscale pixels in the high-pass filtered image are inversely mapped from the polar coordinate system to the Cartesian coordinate system; a density-based spatial clustering algorithm is used to perform cluster analysis on the abnormal grayscale pixels in the Cartesian coordinate system; during the cluster analysis process, according to preset density clustering parameters, abnormal grayscale pixels that meet the density connectivity condition are aggregated to generate each target pixel cluster; the bounding box of each target pixel cluster is calculated, and the image region corresponding to the bounding box in the grayscale image is taken as the suspected defect region.
[0016] This technical solution takes into account that due to noise from the underlying sensors or extremely small airborne dust, the preceding filtering operation will inevitably leave isolated abnormal high-frequency pixels. After these pixels are reverse-mapped back to the Cartesian coordinate system and then clustered, they can effectively identify and remove occasional noise points that do not meet the density connectivity condition. More importantly, it can reassemble the real broken points that are physically clustered in space into patches with clear bounding boxes, thereby providing deep learning networks with target recognition regions with high confidence and clear coordinates.
[0017] Furthermore, the dual-input lightweight convolutional network includes at least: a first input branch for extracting image features, a second input branch for receiving numerical features, a fully connected layer for feature fusion, and a normalized exponential function layer for outputting the probability distribution of a preset defect category.
[0018] Further, the defect detection result is determined as follows: Each suspected defect region is input into the first input branch to extract deep texture features, and the corresponding Euclidean distance is input into the second input branch; in the fully connected layer, a preset feature weight matrix is used to map and weight the deep texture features and the Euclidean distance to generate a feature vector that integrates visual and spatial priors; the feature vector is input into the normalized exponential function layer, and the normalized exponential function layer outputs the probability distribution of multiple preset defect categories corresponding to each suspected defect region; the preset defect category with the highest probability in the probability distribution is selected as the target defect type corresponding to each suspected defect region, and all target defect types are determined as the defect detection result.
[0019] This technical solution introduces prior constraints to deep learning models. Conventional convolutional networks often only extract local deep texture features of images, which can easily confuse real and fake defects with similar shapes. By adding an independent numerical feature branch, the absolute physical radius of the image patch from the center is fused with the texture features in the fully connected layer. This allows the network to be supervised by the absolute spatial position when making decisions. For example, when the network extracts a texture similar to a crack, if its distance happens to match the radius of the heat sealing line on the design drawing, it is highly likely to be judged as poor heat sealing; if the position is at the center of the rigid body of the valve, it is likely to be a mold scratch. This improves the network's qualitative accuracy in identifying defects with strong position correlation.
[0020] Furthermore, after obtaining the defect detection results, the process also includes: acquiring all target defect types in the defect detection results; marking the suspected defect areas corresponding to all target defect types; and generating a defect diagnosis record for the plastic valve, wherein the defect diagnosis record includes at least: the production batch of the plastic valve, all target defect types of the plastic valve, and the location of all target defect types, to form a basis for quality traceability.
[0021] Furthermore, the preset density clustering parameters include at least a minimum cluster point threshold, which is determined based on the following method: obtaining the calibrated physical resolution of the acquisition device used to acquire the grayscale image, and combining it with the preset minimum defect area to calculate the corresponding minimum number of connected pixels; setting the minimum number of connected pixels as the minimum cluster point threshold.
[0022] On the other hand, the real-time detection system for visual defects of plastic valves based on deep learning provided by the present invention includes: a memory for storing computer execution instructions; and a processor for executing the computer execution instructions stored in the memory to realize the above-mentioned real-time detection method for visual defects of plastic valves based on deep learning.
[0023] The present invention has the following effects: This invention integrates polar coordinate dimensionality reduction spatial filtering with a dual-input lightweight network that incorporates absolute physical radius, thereby eliminating diffuse reflection artifacts caused by the draft angle of the internal through-hole of the valve, and improving the accuracy and robustness of real-time detection of visual defects in plastic valves. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating the real-time visual defect detection method for plastic valves based on deep learning, as described in this invention. Figure 2 This is the original grayscale image of the present invention, including the plastic valve and the surrounding heat-sealed wire. Figure 3 The present invention will Figure 2Transform the panoramic unfolded image into polar coordinates; Figure 4 This invention is a counterpart to... Figure 3 High-pass filtered image after applying a one-dimensional high-pass filter; Figure 5 This is the final defect detection result image after the diffuse reflection artifacts are removed through classification using a dual-input convolutional neural network according to the present invention. Detailed Implementation
[0025] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0026] S1: Locates the centroid of the main body area of the plastic valve.
[0027] Considering that the IBC inner liner bag production line in the industrial setting operates at a maximum linear speed of 24 m / min, and that the PE film inevitably exhibits serpentine vibrations in a 2400 mm full-width environment, this step aims to establish a macroscopic field-of-view anchoring mechanism. This mechanism acquires high signal-to-noise ratio grayscale images through synchronously triggered imaging and locks onto the valve as the core detection target, transforming massive pixel processing into effective ROI (region of interest) locking centered on the valve.
[0028] By deploying an 8K high-speed line scan camera on the production line in conjunction with an LED transmission light source, and acquiring grayscale images containing plastic valves and surrounding heat-sealing lines proportionally based on the pulse signals of a servo encoder, an image coordinate system is established with the width of the grayscale image as the horizontal axis and the height of the grayscale image, i.e., the direction of the production line conveyor belt, as the vertical axis.
[0029] Next, the acquired grayscale image is subjected to fully adaptive binarization using the Otsu method. The Otsu method traverses all grayscale levels of the grayscale image, divides all pixels into two categories based on each grayscale level: pixels in the valve body region and pixels in the background region, calculates the inter-class variance, and automatically selects the grayscale level that maximizes the inter-class variance as the binarization threshold of the grayscale image.
[0030] The grayscale image is segmented based on the optimal binarization threshold. Pixels with higher grayscale are designated as background pixels with a value of 0, while pixels with lower grayscale are designated as pixels corresponding to the main body area of the plastic valve with a value of 1, resulting in a binary image. This adaptive threshold segmentation method can adapt to the overall brightness drift caused by the physical light decay of LED light sources or the difference in light transmittance between different batches of film materials in the production site.
[0031] Then, connected component analysis is performed on the pixels with a gray value of 1 in the binary image to obtain all initial connected components. The standard area of the IBC plastic valve is determined based on the projection of the standard IBC plastic valve on the film. Using a 20% fluctuation of the standard area as a priori condition, all initial connected components are filtered to exclude those with an area much smaller than the area threshold. The filtered initial connected components are then used as the main body area of the plastic valve.
[0032] Next, considering that during the high-speed conveyor belt operation of the IBC inner liner bag, the valve edge is often accompanied by tiny burrs left over from the injection molding process, and affected by the draft angle of the through hole and the angle of the bottom transmitted light source, the inner edge of the valve is prone to large-area, asymmetrical, cloud-like diffuse reflection bright areas. If the centroid is determined by simply averaging the coordinates of the boundary points, these locally appearing pseudo pixels will generate asymmetrical tension, causing the centroid coordinates to jitter randomly.
[0033] Geometric moments are a global integration operation where the product of the coordinates of each pixel and its grayscale weight determines the final result. For edge spikes: since spike pixels account for a very small proportion of the total pixels, usually less than 0.5%, their contribution to the integral term is greatly diluted during the accumulation process. For asymmetric bright artifacts caused by cloud-like diffuse reflection: geometric moments utilize the statistical consistency of the entire region to treat local grayscale anomalies as high-frequency disturbances. Through the global balancing effect of the first-order moment, the pulling effect of cloud-like bright areas on positioning is diluted, achieving accurate positioning with anti-interference capabilities.
[0034] Specifically, the coordinates of all pixels within the main body area of the plastic valve are obtained; the sum of the number of all pixels within the main body area of the plastic valve is taken as the zeroth-order geometric moment; the sum of the lateral coordinates of all pixels within the main body area of the plastic valve is calculated as the first-order lateral geometric moment, and the sum of the axial coordinates is calculated as the first-order axial geometric moment; the first-order lateral geometric moment and the first-order axial geometric moment are divided by the zeroth-order geometric moment to calculate the lateral and axial coordinates of the centroid of the main body area of the plastic valve.
[0035] The core formula for calculating geometric moments is: ; ; In the above formula, and These represent the horizontal and vertical coordinates of the centroid of the main body region of the plastic valve in a rectangular coordinate system. and These are the x and y coordinates of the pixel in a Cartesian coordinate system; coordinates The binary weights corresponding to the pixels are obtained by reading the binary image in coordinates. The pixel value at a given location, if the pixel is located within the main body area of the plastic valve, then its binary weight... If the pixel is located in the background region, then the binary weights are applied. .
[0036] When the plastic valve deflects or shifts on the conveyor belt The distribution of pixels with a value of 1 changes accordingly. Using the ratio of the first moment to the zeroth moment calculated above, the formula outputs... It will synchronously and accurately track the actual geometric balance center of the valve body area.
[0037] In this way, by performing geometric moment calculations on the pixels of the main body area of the plastic valve, the centroid positioning deviation caused by edge burrs or local reflections of the plastic valve is offset, thereby obtaining the accurate centroid of the main body area of the plastic valve.
[0038] S2: Construct a panoramic unfolded image through polar coordinate transformation.
[0039] After locking the centroid of the main body area of the plastic valve, given that the heat-sealed area of the plastic valve presents a regular ring distribution, but in the two-dimensional plane composed of the traditional rectangular coordinate system, these ring heat-sealed lines exhibit high-frequency alternating curve features, which can be confused with the edge features of real defects and cloud diffuse reflection. If the edge is extracted directly in the rectangular coordinate system, a large number of false feature interferences will be generated.
[0040] Therefore, this step maps the original grayscale image to a panoramic unfolded image, flattening the annular structure of the main body area of the plastic valve in the grayscale image into a horizontal structure in polar coordinate space. This transformation is the key to connecting macroscopic positioning and microscopic detection. By utilizing the physical symmetry of polar coordinates, the complex two-dimensional texture retrieval is weakened into one-dimensional radial fluctuation analysis, preserving the complete transition features of the valve edge.
[0041] First, convert the grayscale image to polar coordinates.
[0042] In the grayscale image, the centroid of the main body area of the plastic valve is taken as the pole, and the horizontal center line of the grayscale image is taken as the reference direction. The polar radius of each pixel in the grayscale image and the polar radius of the pole are obtained through the polar coordinate transformation formula, as well as the polar angle of each pixel and the reference direction. The polar angle of each pixel is mapped to the horizontal direction of the panoramic unfolded image, and the polar radius is mapped to the vertical direction of the panoramic unfolded image, thus generating a panoramic unfolded image composed of all pixels.
[0043] The polar coordinate transformation formula is as follows:
[0044] In this formula, This indicates the panoramic unfolded image at the polar radius. and polar angle The grayscale value of the pixel at that location. Represents a grayscale image in a Cartesian coordinate system. The value range is determined by the preset detection radius. Decide, Typically, the setting is based on the valve's outer diameter, combined with a resolution of 0.1 mm / pixel for conversion. For example, when setting the valve's detection physical radius... When the focal length is 50mm, the corresponding number of pixels is 500. The range of values is , and These represent the horizontal and vertical centroid coordinates of the main body area of the plastic valve in the image coordinate system.
[0045] By transforming polar coordinates, the physical rotational symmetry is converted into translational symmetry of the coordinate axes. fixed, When changes occur, the pixels at a specific radius of the valve are extracted, appearing as a whole row in the panoramic image. If the heat-sealing line is complete and normal, the grayscale values of the pixels in that row tend to be stable; however, if poor heat sealing causes localized blackening or whitening, the grayscale values of the pixels in that row will remain stable. A noticeable grayscale transition will occur at the defect location, thereby enhancing the defect.
[0046] For example, the centroid of the main body area of a plastic valve. Selecting the polar radius Corresponding to the position of the heat-sealing line, polar angle Calculate the corresponding rectangular coordinates for a 45-degree direction: , This calculation process demonstrates the process from a point in polar coordinate system space. The process of transformation with the Cartesian image coordinate system.
[0047] When mapping coordinates back to the Cartesian image coordinate system, if the calculated coordinate value is not an integer, the nearest neighbor interpolation method is used to obtain the gray value of the corresponding integer pixel, ensuring accurate correspondence of image data on discrete pixel grids. The system extracts the Cartesian coordinate system. The grayscale value of the pixel at that location is entered into the corresponding cell in the panoramic unfolded image.
[0048] Finally, all pixels of the grayscale image are transformed from the Cartesian coordinate system to the polar coordinate system. The polar angle of each pixel is mapped to the horizontal direction of the panoramic unfolded image, and the polar radius is mapped to the vertical direction of the panoramic unfolded image. By traversing all ρ and θ, the annular plastic valve body area is stretched into a linear strip image, representing the panoramic unfolded image of the plastic valve and its surrounding heat-sealing lines.
[0049] S3: Extract abnormal grayscale pixels and delineate suspected defect areas.
[0050] After obtaining the panoramic unfolded image, due to the physical light decay caused by the long-term operation of the LED light source and the cloud-like diffuse reflection interference caused by the draft angle inside the valve, this step aims to construct an environment-adaptive saliency extraction layer. By introducing a one-dimensional Gaussian high-pass filter, it aims to filter out the slow fluctuations in low-frequency background brightness caused by light decay along the polar angle direction, that is, the row direction of the image, while retaining high-frequency defect mutations and extracting statistically abnormal grayscale pixels.
[0051] S31: Perform high-pass filtering on the panoramic unfolded image.
[0052] In panoramic unfolded images, defect features are often submerged in complex background signals. This step introduces a one-dimensional high-pass filter along the polar angle direction, the core of which is to distinguish between slowly changing background signals and abruptly changing defect signals.
[0053] Based on the principle of signal separation, after polar coordinate expansion, the heat-sealed line of the valve appears as a horizontal continuous stripe. Due to the light decay of the LED light source from the center to the edge, and the cloud-like diffuse reflection caused by the draft angle inside the valve, these factors appear as low-frequency fluctuations in grayscale values in the row direction of the image. However, the real defects, such as scratches, cracks, and impurities, have abrupt changes in physical scale, and their edges appear as a sharp drop or rise in grayscale in the polar angle direction in the panoramic image, which is a typical high-frequency feature.
[0054] Therefore, considering the cloud-like diffuse reflection caused by the draft angle, which exhibits a wide, continuous, and slow gradient in the circumferential direction; while the real scratch or crack edge has a fault, exhibiting a sudden change in gray level, this step only applies a one-dimensional high-pass filter row by row along the polar angle direction, so that the gray value of the pixel that can characterize the diffuse reflection artifact with the characteristic of continuous gray level gradient approaches zero, and the gray value of the pixel that characterizes the sudden change in gray level is retained to generate a high-pass filtered image.
[0055] One-dimensional high-pass filtering uses a one-dimensional Gaussian kernel to smooth the rows of pixels, obtaining a low-frequency background image. This background is then subtracted from the panoramic unfolded image to obtain the high-pass filtered image. The key parameter for this filtering is the Gaussian standard deviation. ,like If the value is too large, it will be impossible to effectively track the local light decay trend, resulting in background residue. If the size is too small, even minor imperfections will be smoothed out as part of the background. By selecting this... The center gray level of the filtered image is normalized to near the 0 axis, while the defect signal is enhanced into high-contrast peaks or troughs, resulting in a very high signal-to-noise ratio for subsequent dynamic thresholding.
[0056] Specifically, this is achieved by obtaining the physical grayscale gradient span of the cloud-like diffuse reflection region in the polar angular direction. Mapped to a pixel scale of approximately Pixels, and the maximum physical width of truly tiny defects. Mapped to a pixel scale of approximately pixels, thereby constraining the kernel size of the one-dimensional Gaussian convolution kernel. satisfy Furthermore, it is derived by combining the classic Gaussian kernel standard deviation conversion formula. : This constraint enables the filtering operator to accurately extract and subtract the broad low-frequency background of clouds and fog without smoothing out sharp and subtle real defects, thus providing a high signal-to-noise ratio condition for subsequent segmentation.
[0057] S32: Extracting abnormal pixels from images based on high-pass filtering.
[0058] In a high-pass filtered image, the average and standard deviation of the gray values of each row of pixels are calculated as the gray-level statistical features of each row of pixels. Based on the average and standard deviation of the gray values of each row of pixels, a corresponding dynamic segmentation threshold is determined according to the three-times-standard-deviation rule. That is, the average and three times the standard deviation are accumulated, and the resulting value is used as the dynamic segmentation threshold. Pixels that exceed the dynamic segmentation threshold are extracted as abnormal gray-level pixels.
[0059] This means that only when the gray value of a pixel exceeds three times the standard deviation of the normal fluctuation range is it judged as a suspected defect, thus shielding against false interference caused by uneven film thickness or light source fluctuation.
[0060] S33: Inverse mapping and spatial density clustering generate suspected defect regions.
[0061] After extracting discrete abnormal grayscale pixels, considering the tiny dust particles or random noise generated by image acquisition equipment in the production site, these isolated point-like noise pixels do not constitute real industrial defects. Real physical defects must have continuity and compactness in space.
[0062] Therefore, this step aims to perform spatial semantic reconstruction. First, abnormal grayscale pixels in the panoramic unfolded image are restored back to the Cartesian coordinate system to recover their true physical shape. Then, isolated noise points are removed using a density clustering algorithm, and spatially adjacent pixels are merged into complete defect entities. The goal is to elevate pixel-level analysis to target-level object analysis, generating suspected defect regions that include location, area, and shape, providing structured input for the final defect detection and classification.
[0063] Specifically, abnormal grayscale pixels are reverse-mapped to a Cartesian coordinate system. During the mapping process, if non-integer coordinates are involved, the nearest neighbor interpolation method is used to determine the grayscale value attribute of the corresponding Cartesian coordinates. Then, the DBSCAN clustering algorithm is used to perform density clustering on the abnormal grayscale pixels in the Cartesian coordinate system to obtain multiple clusters.
[0064] In density clustering, distance determination satisfies the following relationship:
[0065] in, Two abnormal grayscale pixels in a Cartesian coordinate system and The Euclidean distance between them; The preset neighborhood radius, based on the detection accuracy requirement of 0.1mm / pixel, is used to address discontinuous defects such as broken heat-sealed lines. Set to 3 to 5 pixels, preferably 4 pixels.
[0066] During density clustering, outliers are automatically eliminated based on preset density clustering parameters. Specifically, the calibrated resolution of the camera used to acquire images (0.1 mm / pixel) is obtained, and combined with the industry-preset minimum defect area of 0.1 square millimeters, the corresponding minimum number of connected pixels is calculated. This minimum number of connected pixels is set as the minimum clustering point threshold for the clustering algorithm. During cluster analysis, if the number of neighboring pixels of an abnormal grayscale pixel within its neighborhood radius is greater than or equal to this threshold, a target pixel cluster is generated; otherwise, it is identified as scattered dust noise at the bottom layer and automatically eliminated.
[0067] If the abnormal grayscale pixels are only scattered, then Unable to If enough neighbors are found within the range, abnormal grayscale pixels will be marked as noise; only when abnormal pixels form a continuous cluster will they be confirmed as suspected defects.
[0068] Finally, the minimum bounding rectangle of each cluster is divided, and the image region corresponding to the minimum bounding rectangle in the grayscale image of the plastic valve is taken as the suspected defect region, thus obtaining multiple suspected defect regions.
[0069] S4: Perform dual-input feature fusion and classification to obtain defect detection results.
[0070] After identifying the suspected defect area, this step aims to extract dual features—both local visual and global location—to further reflect the spatial information of the defect's location relative to the plastic valve. By introducing the Euclidean distance between the suspected defect area and its geometric centroid as a priori feature, the goal is to eliminate misjudgments caused by hazy diffuse reflections from a spatial perspective.
[0071] Because the cloud-like diffuse reflection caused by the draft angle of the valve's main through-hole is strictly distributed within a specific inner radius range in physical space, the convolutional neural network is forced to establish a joint decision-making mechanism from visual features to physical location by fusing Euclidean distance with deep visual texture in a fully connected layer. When the network identifies a local highlight abrupt change, if the Euclidean distance is within the spatial range of the inner hole draft angle, the network will adaptively suppress the confidence of the feature through weights, determining it to be a diffuse reflection afterimage artifact; otherwise, it will be confirmed as a real defect.
[0072] This dual-input design compensates for the deficiency of a single pure vision network in being unable to recognize the spatial distribution patterns of structured light and shadow, and ultimately achieves high-precision rejection under complex diffuse reflection interference.
[0073] Specifically, the center coordinates of each suspected defect area are extracted to obtain the centroid of each suspected defect area. The Euclidean distance between the centroid of each suspected defect area and the centroid of the plastic valve body area is calculated. The Euclidean distance corresponding to the suspected defect area is synchronously input into the pre-constructed convolutional neural network to output the defect detection result.
[0074] S41: Offline stage classification network construction.
[0075] To enable the convolutional neural network to possess the aforementioned multi-dimensional feature fusion and accurate classification capabilities, a rigorous model training process was performed beforehand. The specific steps are as follows: First, an image slice dataset containing various real defects, such as mosquitoes, holes, crystal points, misaligned heat-sealing lines, poor plasticization, diffuse reflection shadows from clouds and fog, and residues from normal processes, is constructed. The slices are pre-standardized to a fixed pixel size, such as 32×32 pixels, corresponding to a field of view of approximately 3.2mm×3.2mm. This field of view is sufficient to completely encompass the local contextual features of most heat-sealing defects or crystal point defects, while ensuring extremely low computational redundancy. Based on expert experience, each type of slice is labeled with a defect type and severity level, and the corresponding Euclidean distance is calculated and recorded.
[0076] Secondly, a dual-input convolutional neural network architecture is constructed: the visual backbone extraction network adopts a lightweight MobileNet / ResNet architecture, which includes convolutional layers for extracting local spatial features of the image, batch normalization layers to eliminate dimensionality drift between different batches, nonlinear activation layers, and global average pooling layers for dimensionality reduction. This backbone network performs operations on each suspected defect region of the input and outputs a 128-dimensional feature vector; another physical prior branch of the network directly receives the Euclidean distance between the centroid of each suspected defect region and the centroid of the main body region of the plastic valve. At the end feature fusion layer of the network, the 128-dimensional feature vector is mapped and aligned with the Euclidean distance in parallel before being input into the classification decision module.
[0077] Finally, supervised learning was used for offline training. The cross-entropy loss function was selected to calculate the classification output error. The Adam optimizer was used to perform backpropagation and parameter updates. The initial learning rate was set to 0.001, and a cosine annealing strategy was used to dynamically decay the learning rate during the training cycle. The batch size was set to 64. Before inputting the data into the network, the gray values of each pixel in the slice were linearly normalized by dividing by 255 to scale them to the [0,1] interval until the model's loss function converged on the validation set and the detection rate was achieved. The model is then solidified and deployed in the deep learning classification engine of the industrial control computer.
[0078] S42: Real-time defect detection in the online phase.
[0079] On the production line, a grayscale image of a plastic valve at the current moment is acquired, and steps S1 to S4 are executed sequentially to obtain each suspected defect area corresponding to the grayscale image, as well as the Euclidean distance between the centroid of each suspected defect area and the centroid of the main body area of the plastic valve.
[0080] During the real-time inference phase of the classification network, the mathematical logic of the feature fusion classification at the end of the convolutional neural network satisfies the following relationship:
[0081] In this relation, For inclusion The classification probability vector of confidence scores for each defect category. The total number of categories for the preset defect types and levels. This is the 128-dimensional local texture feature vector corresponding to the suspected defect areas extracted by the backbone network. The distance between the centroid of the suspected defect area and the centroid of the plastic valve body area, expressed in millimeters. Let be the weight transformation matrix of the visual features, with dimension . , Let be the weight mapping vector of the location prior, with dimension . , for Bias vector of dimension It is a normalized exponential function.
[0082] Through strict matrix multiplication dimension alignment configuration, it is ensured that 128-dimensional high-dimensional eigenvectors and 1-dimensional physical scalars can be mapped to the same dimension. The decision space utilizes physical location to mathematically weight and modulate visual features: in the highly sensitive area of the heat-sealed line, When within a specific numerical range, This method assigns a positive gain to specific defect channels, significantly improving the network's sensitivity to subtle wire-like defects and misalignments; in areas where flash is permissible, such as injection holes, if similar visual features are extracted... The Euclidean distance constraint term will correct the final probability distribution backward, helping the network to judge it as a normal process structure, thereby reducing the false alarm rate.
[0083] The network output will be converted into confidence probability values for each preset defect category, such as severe scratches, poor plasticization, or normal process residue. The system will extract the one with the highest probability as the target defect type for the corresponding suspected defect area.
[0084] In actual working conditions, a plastic valve may have multiple suspected defect areas. Therefore, it is necessary to summarize the target defect types of all suspected defect areas to obtain the visual defect detection results of the plastic valve.
[0085] In this way, the Euclidean distance between the centroid of the suspected defect area and the geometric centroid of the main body of the plastic valve is used as a high-dimensional feature and deeply integrated with the semantic features extracted by the convolutional neural network. The purpose is to force the network to introduce strong constraints of physical space during classification, and to jointly determine the visual texture of the defect with its absolute physical location. This enables the accurate separation of good product process residues from real defects under complex background interference.
[0086] For example, the geometric centroid of a suspected defect region is The geometric centroid of the main body area of the plastic valve is The system's calibrated resolution is 0.1 mm / pixel, and the calculated distance... mm, after performing a normalization process of dividing the local image slice of the suspected defect area by 255, it is fed into a trained convolutional neural network to extract 128-dimensional features. At the same time, the numerical value The data is fed into the network, and through matrix mapping and weighting, the network identifies that the area is located on the main sealing ring path of the valve, and the visual features match the poor plasticization pattern. Finally, the Softmax output with the highest probability is: poor plasticization, and the defect level is severe.
[0087] Finally, the PLC-controlled marking machine performs automatic defect marking at the conveyor belt coordinates, marking the suspected defect areas corresponding to all target defect types, simultaneously triggering audible and visual alarms, and generating a defect diagnosis record for the plastic valve. The defect diagnosis record includes at least: the production batch of the plastic valve, all target defect types of the plastic valve, and the location of all target defect types, to form a basis for quality traceability.
[0088] To more intuitively verify the technical effects of the present invention, the following is a detailed description in conjunction with the appendix. Figure 2 To be continued Figure 5 The image processing results of each core step are discussed in turn. For ease of explanation, the appendix provides further details. Figure 2 To be continued Figure 5 The diffuse artifact area is marked by box A, and the real defect area is marked by box B. like Figure 2 As shown, in the original grayscale image, due to the draft angle inside the valve and the physical characteristics of the transmitted light source, a distinct asymmetric, hazy, diffuse reflective highlight area is formed at the edge of the valve's inner hole. Figure 2 In the area marked A, if defects are directly extracted from this image, the diffuse reflection edge gradient is easily misjudged as a crack or flash. Through the polar coordinate reconstruction in step S2 of this invention, in the area shown... Figure 3 Central, original Figure 2 The central ring-shaped plastic valve body is mapped into a panoramic unfolded image, allowing clear observation of the cloud-like diffuse reflection artifacts that are difficult to process using uniform rules in two-dimensional space. Figure 3 The marked box A is flattened into a grayscale bandwidth that gradually changes along the polar angle direction (lateral) within a specific range in the radial direction (vertical direction), while the actual defect ( Figure 3 The marked box B) represents a high-frequency step signal superimposed on this grayscale bandwidth. This dimensionality reduction of the spatial topology lays the physical foundation for subsequent signal separation. Figure 4 In this invention, step S31 applies a one-dimensional high-pass filter along the polar angle direction, which is strictly constrained by physical scale. Figure 3 The low-frequency background gradation is caused by light decay and diffuse reflection from clouds and fog. Figure 4 The marked box A was completely filtered out, and the image as a whole presented a uniform grayscale base. At the same time, the high-frequency step signal hidden in the edge of the cloud ( Figure 4 The bounding box B) is preserved and highlighted with high contrast, removing interference from complex backgrounds. Finally, based on the image after filtering out cloud and fog diffuse reflection interference, suspected defect areas are extracted, and spatial location priors are synchronously input into a lightweight convolutional network for feature fusion and classification, resulting in the following... Figure 5 The defect detection results show that the actual defect indicated by box B was accurately detected and marked, while... Figure 2 The diffuse artifact area indicated by the marked box A was not falsely detected as a defect.
[0089] This embodiment also provides a real-time detection system for visual defects in plastic valves based on deep learning, which is applicable to the detection method and adapted to high-speed roll material environments with speeds up to 24 m / min. The system includes: a memory for storing computer execution instructions; and a processor for executing the computer execution instructions stored in the memory to realize the real-time detection method for visual defects in plastic valves based on deep learning.
[0090] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A real-time visual defect detection method for plastic valves based on deep learning, characterized in that, include: S1: Obtain a grayscale image containing the plastic valve and surrounding heat-sealed lines, locate the main body area of the plastic valve in the grayscale image, extract the geometric moments of the main body area of the plastic valve, and use the geometric moments to locate the centroid of the main body area of the plastic valve. S2: Based on the centroid of the main body region of the plastic valve, the pixels contained in the grayscale image are mapped from the rectangular coordinate system to the polar coordinate system to obtain the panoramic unfolded image corresponding to the grayscale image; S3: Apply a one-dimensional high-pass filter to the panoramic unfolded image row by row along the polar angle direction of the polar coordinate system to obtain a high-pass filtered image. Extract the average value and standard deviation of the gray values of each row of pixels in the high-pass filtered image as gray-level statistical features. Based on the gray-level statistical features, perform adaptive threshold segmentation to extract abnormal gray-level pixels. After inversely mapping the abnormal gray-level pixels to the rectangular coordinate system, perform spatial density clustering to generate multiple suspected defect areas. S4: Obtain the Euclidean distance between the centroid of each suspected defect region and the centroid of the main body region of the plastic valve. Input each suspected defect region and its corresponding Euclidean distance into a dual-input lightweight convolutional network for feature fusion and classification to obtain the defect detection results. A two-input lightweight convolutional network includes at least: The system consists of a first input branch for extracting image features, a second input branch for receiving numerical features, a fully connected layer for feature fusion, and a normalized exponential function layer for outputting the probability distribution of a preset defect category. Defect detection results are determined in the following way: Each suspected defect area is input into the first input branch to extract deep texture features, and the corresponding Euclidean distance is input into the second input branch. In the fully connected layer, a pre-defined feature weight matrix is used to map and sum the deep texture features and Euclidean distance, generating a feature vector that integrates visual and spatial priors. The feature vector is input into the normalized exponential function layer, and the probability distribution of multiple preset defect categories corresponding to each suspected defect region is output through the normalized exponential function layer. The preset defect category corresponding to the highest probability in the probability distribution is selected as the target defect type for each suspected defect area, and all target defect types are determined as the defect detection results.
2. The real-time visual defect detection method for plastic valves based on deep learning according to claim 1, characterized in that, Locating the plastic valve body area in the grayscale image includes: The grayscale image is adaptively binarized and segmented using Otsu's method to obtain all initial connected components. The prior area of the plastic valve is introduced as a constraint to filter all initial connected regions, and the initial connected regions retained after filtering are taken as the main body region of the plastic valve.
3. The real-time visual defect detection method for plastic valves based on deep learning according to claim 1, characterized in that, The panoramic unfolded image corresponding to the grayscale image is generated based on the following method: The centroid of the main body region of the plastic valve is taken as the pole, and the horizontal center line of the grayscale image is taken as the reference direction. The polar radius of each pixel in the grayscale image and the polar point, as well as the polar angle with the reference direction, are obtained by polar coordinate transformation formula. The polar angle of each pixel is mapped to the horizontal direction of the panoramic unfolded image, and the polar radius is mapped to the vertical direction of the panoramic unfolded image, to generate a panoramic unfolded image composed of all pixels.
4. The real-time visual defect detection method for plastic valves based on deep learning according to claim 1, characterized in that, The average and standard deviation of the grayscale values of each row of pixels in the high-pass filtered image are extracted as grayscale statistical features. Based on these grayscale statistical features, adaptive threshold segmentation is performed to extract abnormal grayscale pixels, including: Calculate the average and standard deviation of the gray values of each row of pixels in the high-pass filtered image; Based on the average value and the standard deviation, the dynamic segmentation threshold of each row of pixels is determined using the three-standard-deviation rule; Pixels with gray values greater than the dynamic segmentation threshold in each row are extracted as abnormal gray-value pixels.
5. The real-time visual defect detection method for plastic valves based on deep learning according to claim 1, characterized in that, Each of the suspected defective areas was determined based on the following method: Inversely map all abnormal grayscale pixels in the high-pass filtered image from the polar coordinate system to the rectangular coordinate system; A density-based spatial clustering algorithm is used to perform clustering analysis on abnormal grayscale pixels in the Cartesian coordinate system. During the clustering analysis process, based on preset density clustering parameters, abnormal grayscale pixels that meet the density connectivity conditions are aggregated to generate various target pixel clusters. Calculate the bounding box of each target pixel cluster, and use the image region corresponding to the bounding box in the grayscale image as the suspected defect region.
6. The real-time visual defect detection method for plastic valves based on deep learning according to claim 1, characterized in that, After obtaining the defect detection results, the following is also included: Obtain all target defect types from the defect detection results; Mark the suspected defect areas corresponding to all target defect types; Generate a defect diagnosis record for the plastic valve, the defect diagnosis record including at least: The production batch of the plastic valve, all target defect types of the plastic valve, and the location of all target defect types constitute the basis for quality traceability.
7. The real-time visual defect detection method for plastic valves based on deep learning according to claim 5, characterized in that, The preset density clustering parameters include at least a minimum cluster point threshold, which is determined based on the following method: Obtain the calibrated physical resolution of the acquisition device used to acquire the grayscale image, and calculate the corresponding minimum number of connected pixels by combining it with the preset minimum defect area; set the minimum number of connected pixels as the minimum cluster point threshold.
8. A real-time visual defect detection system for plastic valves based on deep learning, characterized in that, include: Memory is used to store instructions executed by the computer; A processor is configured to execute computer execution instructions stored in the memory to implement the deep learning-based real-time detection method for visual defects in plastic valves as described in any one of claims 1 to 7.
Citation Information
Patent Citations
AI vision-based computing power card welding quality real-time detection system
CN120852422A
FPC connector quality detection method and system based on multi-mode fusion
CN120892849A