A method and apparatus for visual inspection of glass production quality

By employing an image fusion algorithm combining non-subsampled contour wave transform, sparse representation, and guided filters, along with an improved self-attention lightweight glass defect recognition model, the problem of low grayscale contrast between defects and background in traditional methods is solved, enabling high-precision online detection of glass production quality.

CN122335828APending Publication Date: 2026-07-03HUBEI HONGSHENG GLASS TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUBEI HONGSHENG GLASS TECHNOLOGY CO LTD
Filing Date
2026-04-24
Publication Date
2026-07-03

Smart Images

  • Figure CN122335828A_ABST
    Figure CN122335828A_ABST
Patent Text Reader

Abstract

This invention discloses a visual inspection method and apparatus for glass production quality, relating to the field of glass quality inspection technology. The method includes the following steps: constructing a polarization excitation detection field; acquiring and registering a sequence of original polarization images of the glass based on the polarization excitation detection field to obtain a polarization image sequence; performing image fusion on the polarization image sequence using an image fusion algorithm based on non-subsampled contour wave transform, sparse representation, and guided filters to obtain a defect-enhanced image; inputting the defect-enhanced image into a lightweight glass defect recognition model based on improved self-attention, outputting a glass defect category, acquiring glass defect quality impact data, and classifying glass quality grades based on the glass defect category and the glass defect quality impact data, thereby achieving visual inspection of glass production quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of glass quality inspection technology, specifically to a visual inspection method and apparatus for glass production quality. Background Technology

[0002] The continuous, high-speed transport characteristics of float glass production necessitate that online quality inspection relies on polarization imaging technology to capture the difference in polarization response between defects and the glass body. To achieve accurate defect identification, the acquired multi-polarization image sequences need to be fused. By integrating image information under different polarization states, the background reflection of the glass mirror is weakened and defect features are enhanced. The fusion effect directly determines the accuracy and efficiency of subsequent defect identification, making it a core and critical step in the visual inspection process of glass production quality.

[0003] Traditional methods, after acquiring a multi-polarization image sequence of the same glass region, use a strategy of maximizing gray values ​​to fuse corresponding pixels in each frame of the sequence. By extracting the maximum gray value of pixels under each polarization state, a single-frame fused image is constructed, which serves as the basic image carrier for subsequent defect feature extraction and recognition.

[0004] However, traditional methods only perform a single maximum processing of pixel gray values, which cannot perform differential fusion processing of low-frequency background information and high-frequency defect details in multi-polarized images by scale and direction. As a result, the polarization reflection background of the glass body in the fused image is not effectively suppressed, and the gray-level contrast between defects and background in the fused image is low, which is difficult to meet the actual needs of high-precision identification of glass defects. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a visual inspection method and apparatus for glass production quality, thereby resolving the problems existing in the background technology.

[0006] To achieve the above objectives, the present invention provides the following technical solution: a visual inspection method and apparatus for glass production quality, comprising the following steps: Step S1: Construct the polarization excitation detection field; Step S2: Based on the polarization excitation detection field, acquire the original polarization image sequence of the glass and perform registration and correction to obtain the polarization image sequence; Step S3: The polarization image sequence is fused using an image fusion algorithm based on non-subsampled contour wave transform, sparse representation, and guided filter to obtain a defect-enhanced image; Step S4: Input the enhanced defect image into the lightweight glass defect recognition model based on improved self-attention, output the glass defect category, obtain the glass defect quality impact data, classify the glass quality level based on the glass defect category and the glass defect quality impact data, thereby realizing visual inspection of glass production quality.

[0007] Preferably, the construction of the polarization excitation detection field includes the following specific steps: Two rows of polarized lighting units are set along the glass conveying direction. The polarization angle of the polarized lighting units is preset, and the lighting sequence of the polarized lighting units is rotated according to a preset cycle. A polarization detector is configured at the imaging end, and the polarization detection angle is matched one-to-one with the polarization angle of the polarization illumination unit; The illumination timing of the polarization illumination unit is synchronously bound to the glass movement, and glass images at different polarization angles are synchronously acquired by a polarization detector to finally construct a polarization excitation detection field.

[0008] Preferably, the process of acquiring the original polarization image sequence of the glass and performing registration and correction to obtain the polarization image sequence involves the following steps: The original polarization image sequence was acquired using a polarization detector; The original polarized image sequence of the same glass region under illumination at a certain polarization angle is used as the reference frame, and the remaining frames are the frames to be registered. Key feature points are extracted from the original polarization image sequence, and feature point matching is performed using a distance metric. The position of the frame to be registered and the reference frame are corrected by affine transformation to obtain a polarization image sequence.

[0009] Preferably, the step of performing image fusion on the polarization image sequence using an image fusion algorithm based on non-subsampled contourlet transform, sparse representation, and guided filter to obtain a defect-enhanced image includes the following steps: A non-subsampled contour wave transform is performed on each frame of the polarization image sequence of the same glass region, and the low-frequency sub-band and high-frequency sub-band are obtained by splitting according to scale and direction. The low-frequency subband is processed using sparse representation fusion rules to obtain a globally fused low-frequency subband; The high-frequency subband is processed using a guided filter fusion rule to obtain a fused high-frequency subband; The defect enhancement image is obtained by reconstructing the globally fused low-frequency subband and the fused high-frequency subband through non-subsampled contour wave inverse transform.

[0010] Preferably, the step of processing the low-frequency subband using sparse representation fusion rules to obtain the globally fused low-frequency subband includes the following steps: The low-frequency sub-band is divided into image blocks. Based on a pre-trained overcomplete dictionary, the orthogonal matching pursuit algorithm is used to sparsely represent the image blocks and solve for the sparse coefficients. The sparse coefficients are filtered and fused using the maximum L1 norm rule, and the global fused low-frequency subband is obtained by stitching together image blocks.

[0011] Preferably, the step of processing the high-frequency subband using the guided filter fusion rule to obtain the fused high-frequency subband includes the following steps: Calculate the initial weights for the high-frequency sub-bands; Using the low-frequency sub-band corresponding to the reference frame level as the guide image, the initial weights are optimized using a guide filter to obtain the optimized weight map; The high-frequency subbands are weighted and fused based on the optimized weight graph to obtain the fused high-frequency subbands.

[0012] Preferably, the step of weighted fusion of high-frequency subbands based on the optimized weight graph to obtain fused high-frequency subbands includes the following specific steps: The high-frequency subbands are weighted and fused based on the optimized weight map, and the calculation formula is as follows: ; in, Let be the coefficient value of the k-th high-frequency sub-band of the l-th level after fusion at pixel (x, y). The optimized weights are for the k-th high-frequency subband of the l-th level in the i-th frame. It represents the coefficient value of the k-th high-frequency subband of the l-th level in the i-th frame at pixel (x, y).

[0013] Preferably, the lightweight glass defect recognition model based on improved self-attention specifically comprises: Preprocess the defect-enhanced image; The preprocessed defect enhancement image is input into a lightweight glass defect recognition model based on improved self-attention, which includes a feature extraction module, a linear self-attention global modeling layer, and a classification mapping layer. The feature extraction module uses a depthwise separable convolutional structure to extract local features; The linear self-attention global modeling layer transforms the feature map into a query, key, and value matrix through linear projection and calculates linearly approximate attention weights.

[0014] Preferably, the step of obtaining glass defect quality impact data and classifying glass quality grades based on glass defect categories and glass defect quality impact data specifically involves: Acquire glass defect quality impact data, which includes defect size, defect aggregation degree, and defect location; Calculate the quality grade score based on glass defect categories and glass defect quality impact data; ; in, To rate the quality level, This is the defect type weighting coefficient. This is the defect size weighting coefficient. This is the defect clustering weighting coefficient. This is the defect location weighting coefficient. Quantification value for defect type, This is a quantified value for the defect size. This is a metric for defect aggregation. Quantification value for defect location; The glass quality is classified into grades based on the comparison between the quality grade score and the preset grading threshold.

[0015] A visual inspection device for glass production quality includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-described method.

[0016] This invention provides a visual inspection method for glass production quality, involving machine learning and deep learning technologies, which has the following beneficial effects: (1) Using non-subsampled contour wave transform to decompose polarization images by scale and direction, and using sparse representation rules to process low-frequency subbands, the background interference of glass mirror reflection can be weakened from the root, breaking the limitation of traditional fusion methods that only perform simple pixel processing. Through hierarchical decomposition and low-frequency optimization, core support is provided for the stable presentation of defect features.

[0017] (2) Based on the low-frequency sparse processing, the high-frequency subband fusion weight is further optimized by the guided filter. It forms a complete improved fusion system with the non-subsampled contour wave transform decomposition and low-frequency sparse processing. It can accurately enhance the defect details and edge features, properly solve the core problem that traditional fusion cannot take into account both background suppression and detail preservation, and greatly improve the recognition of defect features.

[0018] (3) A lightweight glass defect identification model based on improved self-attention is suitable for the detection scenario of continuous high-speed conveying of float glass. It integrates the characteristics of convolutional local feature extraction and linear self-attention global modeling. While reducing the computational complexity of traditional self-attention, it ensures the accuracy of defect identification. It can quickly and accurately identify the defect category and can also complete the quality grade classification by combining defect indicators, thereby realizing online real-time detection of glass production quality, which meets the actual detection needs of the production line. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart of the steps of a visual inspection method for glass production quality proposed in this invention; Figure 2 This is a step hierarchy diagram of obtaining defect enhancement images in a visual inspection method for glass production quality proposed in this invention; Figure 3 This is a step hierarchy diagram of obtaining glass quality grade in a visual inspection method for glass production quality proposed in this invention. Detailed Implementation

[0021] 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.

[0022] Please see Figures 1-3 The present invention provides a technical solution: a visual inspection method for glass production quality.

[0023] Step S1: Construct the polarization excitation detection field; Using a continuous float glass production line as the implementation carrier, the glass belt conveying speed is set to 12m / min~60m / min, the inspection station is fixed at 3m downstream of the annealing furnace outlet, the width of the glass belt to be inspected is 2440mm, and the thickness ranges from 2mm to 12mm. Eight sets of polarized illumination units are evenly distributed along the width of the glass at the inspection station. Two rows of polarized illumination units are arranged along the glass conveying direction, with four sets in each row, for a total of eight sets. Two illumination units with the same polarization angle in the front and rear rows are grouped into one illumination combination, forming four illumination combinations corresponding to 0°, 45°, 90°, and 135°, respectively. The incident light wavelength is selected as 550nm, at which the glass transmittance is stable and the optical response characteristics of defects are significant. The four illumination combinations are lit sequentially according to the polarization angle, completing one cycle of illumination. The lighting duration of each group is 0.5ms, and the sequential lighting of the four groups constitutes a complete illumination cycle with a cycle duration of 2ms. The illumination sequence is precisely synchronized with the acquisition sequence of the focal plane polarization detector. When each illumination combination is lit, the detector simultaneously acquires two frames of images corresponding to the polarization state. After the four illumination combinations are lit sequentially, a total of eight frames of images are acquired, achieving a one-to-one correspondence between the eight sets of polarized illumination and the eight frames of image acquisition.

[0024] The imaging end is equipped with a focal plane polarization detector with a detector pixel size of 3.45μm×3.45μm and an effective pixel size of 2464×2056. The polarization analysis angle of the imaging end polarization analysis structure is matched one-to-one with the polarization angle of the polarization illumination unit to achieve a precise correspondence between polarization excitation and polarization analysis. A multi-field-of-view, multi-aperture polarization ray tracing method was used to quantitatively model the polarization transmission characteristics of the optical system. Five x-field-of-view angles were selected: 0°, 0.7°, 1.4°, 2.8°, and 4.1°. Six y-field-of-view angles were selected: 0.0040°, 0.0080°, 0.0122°, 0.0163°, 0.0203°, and 0.0245°. The pupil coordinate sampling values ​​were set to ±0.5 and ±1, respectively, using a normalized coordinate system. The sampling values ​​in the y-direction form four symmetrically distributed pupil sampling points ((0.5, 0.5), (0.5, -0.5), (-0.5, 0.5), (-0.5, -0.5), (1, 1), (1, -1), (-1, 1), (-1, -1)), covering the full aperture range of the pupil. Each combination of the x-field angle and the y-field angle corresponds to the above eight pupil sampling points. Through comprehensive sampling of multiple fields of view and multiple pupil coordinates, the integrity and accuracy of the polarization transmission characteristics modeling of the optical system are ensured.

[0025] Polarization aberration correction is achieved by calibrating the polarization transmission parameters of optical elements interface by interface. The biaxial attenuation of the front mirror group is controlled within 0.7%, and the phase delay is controlled within 0.029 rad. The biaxial attenuation of the rear mirror group is controlled within 0.85%, and the phase delay is controlled within 0.047 rad. This calibration process directly eliminates the interference of the polarization distortion of the optical system itself on the defect optical signal, ensuring the stability and consistency of the polarization excitation of the detection field. The final polarization excitation detection field is constructed, which divides the specular reflection, near-surface scattering reflection, and defect edge disturbance reflection of the glass surface into four independent response segments with different polarization directions. The imaging time of a single polarization response segment is 0.5ms, and the total excitation cycle is consistent with the illumination cycle of 2ms, which perfectly matches the glass conveyor speed. Based on the position signal output by the encoder of the production line, the illumination timing is precisely bound to the glass movement. When a physical area of ​​the glass conveyor enters the detection field, the illumination unit is triggered to start according to the preset grouping and rotation timing. Within the 2ms window period of the area passing through the detection field, the four polarization angles (two illumination units in each group are lit simultaneously) are excited sequentially. At the same time, the split-focus plane polarization detector simultaneously acquires eight frames of images, ensuring that the same physical area of ​​the glass is sequentially covered and imaged by eight groups of illumination with different polarization configurations. This achieves accurate correspondence of multiple polarization states in the same area, providing a temporal and spatial basis for the construction of the polarization image sequence of the same area in step S2.

[0026] Step S2: Based on the polarization excitation detection field, acquire the original polarization image sequence of the glass and perform registration and correction to obtain the polarization image sequence; Based on the polarization excitation detection field, a rigid synchronous correlation is established between the position signal output by the production line encoder, the motor speed pulse signal, and the imaging trigger signal. The encoder resolution is set to 1024 lines / revolution. This value is based on the following: the conveyor roller diameter is 0.5m, the glass belt moves 1.57m per revolution, and the position detection resolution can reach 1.53mm, which meets the positioning requirements of the glass area. The sampling frequency of the rotational speed pulse signal is set to 10kHz. Based on the maximum speed of the glass belt of 60m / min (1m / s), a 10kHz sampling frequency can achieve a position sampling interval of 0.1mm, ensuring real-time capture of motion. The synchronization error between the imaging trigger signal and the illumination unit switching sequence is controlled within ≤1μs. This is determined based on the following: when the glass belt is transported at its maximum speed of 60m / min, the distance moved within 1μs is (60m / 60s)×1× s=0.001mm, which is much smaller than the detector pixel size of 3.45μm in step 1, and can completely avoid regional misalignment caused by displacement.

[0027] The original polarization image sequence of the glass was acquired and registered and corrected to obtain the polarization image sequence as follows: When the same physical area of ​​the glass strip is sequentially excited by 8 sets of polarized illumination, the focal plane polarization detector acquires 8 frames of images at a period of 2ms to form an original polarization image sequence. The size of a single frame image is 2464×2056 pixels, the image bit depth is 16 bits, and the pixel grayscale value range is 0~65535. This bit depth is based on the fact that the grayscale difference between the glass defect and the background is only 5~10 grayscale levels. The 16-bit bit depth can avoid the loss of difference caused by grayscale truncation.

[0028] To address image position shifts caused by glass edge sway (maximum sway amplitude ≤ 5 mm), micro-vibration of the conveyor rollers (amplitude ≤ 0.1 mm), and localized thermal flow disturbances, a polarization image registration algorithm is employed for internal region mapping correction within the sequence. This algorithm uses one frame of the same glass region under 0° polarization angle illumination as the reference frame (this frame serves as the baseline frame for the same physical region), and the remaining seven frames are the frames to be registered. These seven frames include another frame of the same glass region under 0° polarization angle illumination, and two frames each under 45°, 90°, and 135° polarization angle illumination. All of these frames correspond to the imaging images of the same physical glass region. Key feature points of each frame are extracted using SIFT feature point detection. The feature point detection threshold is set to 0.03, determined based on the fact that the texture feature density of the glass surface is approximately 50 points / 100×100 pixels. This threshold ensures that the number of feature points extracted from each frame is ≥ 2000, guaranteeing registration accuracy while avoiding feature point redundancy. Feature point matching is performed on key feature points using a distance metric, with a matching distance threshold set to 1.5. This threshold is based on the statistical distribution of grayscale similarity of feature points on the glass surface, ensuring a matching accuracy of ≥98%. False matching feature points are eliminated using the Random Sample Consensus Algorithm (RANSAC), with 1000 iterations calculated based on a statistical confidence level of 99.9%, ensuring the elimination of over 99% of false matching points. The interior point threshold is set to 2 pixels, based on the detector pixel size of 3.45 μm. 2 pixels correspond to an actual distance of 6.9 μm, which is smaller than the size of the smallest glass defect (diameter ≥10 μm), thus preventing the false elimination of valid defect feature points. Finally, the position correction between the frame to be registered and the reference frame is completed through affine transformation. After correction, the normalized cross-correlation coefficient of the overlapping area of ​​any two frames in the imaging sequence is ≥0.95, and the registration error is ≤0.5 pixels. The physical meaning of this process is: synchronous association ensures that the multi-polarized image is completely synchronized with the glass band movement in the time dimension through precise temporal and positional binding; and registration correction eliminates positional offset and artifacts in the spatial dimension through feature point matching and geometric transformation.

[0029] Finally, a polarization image sequence with different polarization states for the same glass region is constructed. The spatial consistency of each frame in the polarization image sequence meets the requirements of subsequent polarization difference processing for image accuracy, ensuring the positional stability of defect features in multiple frames and avoiding motion artifacts being misjudged as defects.

[0030] Step S3: The polarization image sequence is fused using an image fusion algorithm based on non-subsampled contour wave transform, sparse representation, and guided filter to obtain a defect-enhanced image; Using a polarization image sequence as input, where each frame has a size of 2464×2056 pixels, a bit depth of 16 bits, and a pixel grayscale value range of 0~65535, the polarization image sequence is fused using an image fusion algorithm based on non-subsampled contourlet transform (NSCT) to obtain a defect-enhanced image. The steps are as follows: First, NSCT decomposition is performed on each frame of polarization image. The decomposition scale is set to 5 levels, determined based on the following: the glass defect scale range is 10μm~500μm, which corresponds to 3~145 image pixels according to the detector pixel size of 3.45μm in step 1. The 5-level decomposition can completely cover this scale range. Among them, levels 1 and 2 capture small defects of 10μm~50μm, levels 3 and 4 capture medium defects of 50μm~200μm, and level 5 captures large defects of 200μm~500μm. The number of directions for each decomposition level is 2, 4, 8, 16, and 1 respectively, with a total of 31 high-frequency subbands and 1 low-frequency subband. The decomposition process achieves multi-scale decomposition through a non-subsampled pyramid filter (NSP) and multi-directional decomposition through a dual-channel non-subsampled directional filter bank (NSDFB). The calculation formula is as follows:

[0031] in, The input polarization image is the i-th frame. This represents the initial low-frequency sub-band corresponding to the original image. This represents the low-frequency subband after the l-th level decomposition. This represents the high-frequency subband of the l-th level in the k-th direction. The number of directions for the l-th level decomposition (where there are 5 levels of decomposition scale, and the preset number of directions for each level of decomposition is as follows). =2、 =4、 8. =16、 =1, used to limit the number of outputs for multi-directional decomposition). The NSCT decomposition operator is used to split the image by scale and orientation, so that the defect features are presented differently in different sub-bands, avoiding the mixing of background and defect features. It also ensures that the image size remains unchanged without downsampling and that there is no pseudo-Gibbs effect to interfere with the defect outline.

[0032] It should be noted that this formula employs a two-level decomposition logic, first multi-scale and then multi-directional. First, a non-subsampled pyramid filter is used to decompose the input low-frequency subband of the previous level. Perform scale splitting to obtain the l-th level low-frequency subband. Then, using the current direction number... Using core parameters, directional decomposition is performed through a dual-channel non-downsampled directional filter bank to achieve accurate output. A high-frequency sub-band in a corresponding direction.

[0033] The 8 low-frequency sub-bands obtained from the decomposition of 8 frames of images are fused using a sparse representation rule. First, each low-frequency sub-band is divided into image blocks of 8×8 pixels, corresponding to the actual physical size of 27.6μm×27.6μm, which matches the smallest glass defect (10μm), ensuring that the features of tiny defects are completely contained in a single image block. Each low-frequency sub-band is divided into (2464÷8)×(2056÷8)=79156 image blocks, and an overcomplete dictionary is obtained by training with the K-SVD algorithm. The dictionary atom count was set to 1024. This size was chosen because it allows for capturing low-frequency energy features of defects while keeping dictionary training time within 10 minutes, meeting the efficiency requirements of industrial online inspection. The overcomplete dictionary D was pre-trained based on a historical glass defect annotation dataset. This dataset contains standard sample images of three types of defect regions: scratches, bubbles / pockmarks, and inclusions / stones, as well as defect-free backgrounds, covering the full-scale defect range of 10μm to 500μm. During pre-training, a hierarchical random sampling method with full defect type coverage was used. 10,000 image patches were extracted from the low-frequency sub-bands of the historical dataset to construct the training sample set. The proportion of image patches of each type of defect region was no less than 20%, and the proportion of image patches of defect-free background regions was no more than 40%. During online inspection, the pre-trained overcomplete dictionary was directly called, eliminating the need for real-time training.

[0034] The objective function for training the K-SVD dictionary is:

[0035] in, For the j-th image patch in the training sample set, This represents the sparse coefficient vector of the corresponding image patch. The dictionary is an overcomplete dictionary pre-trained based on glass defect samples. It consists of multiple atoms representing low-frequency features of defects and background, and is used for sparse feature decomposition of image patches. As a sparse regularization parameter, this embodiment sets it to . Used to balance reconstruction error and sparsity. For L2 norm operators, This is the L0 norm operator (for counting non-zero elements); The goal of finding the minimum value of the objective function is to make the image patch reconstructed by the dictionary and sparse coefficients approximate the original training image patch as closely as possible, while constraining the sparsity of the sparse coefficients, eliminating redundant features, and improving the dictionary's accurate representation and generalization ability of low-frequency features of glass defects.

[0036] The training iterations were set to 20 to ensure that the dictionary convergence accuracy met the requirement of reconstruction error ≤ 0.05 (normalized error). Subsequently, for all image patches in each low-frequency sub-band, the orthogonal matching pursuit (OMP) algorithm was used to solve for the sparse coefficients, under the constraints. The optimization objective of the OMP algorithm is as follows:

[0037] in, This refers to the m-th image block of the low-frequency sub-band of the i-th frame. Let be the sparse coefficient vector of the m-th image block at the corresponding position in the i-th frame. The threshold for the number of iterations was determined based on statistical analysis. This number of iterations ensures that the sparse coefficient reconstruction error is ≤0.3 (normalization error), guaranteeing that no low-frequency features of defects are lost. The sparse coefficient fusion adopts the Max-L1 rule, selecting the value with the largest L1 norm of the sparse coefficients at corresponding positions in 8 frames as the fusion coefficient. The fusion formula is as follows:

[0038]

[0039] in, Let m be the sparse coefficient vector of the m-th image patch after fusion. The frame index with the largest L1 norm of sparse coefficients. For the first The sparse coefficient vector of the m-th image block at position m in the frame image. The L1 norm operator, in its physical sense, preserves the most significant low-frequency energy characteristics of defects in each polarization state, suppresses redundant background caused by uniform specular reflection from the glass body, and obtains a globally fused low-frequency subband by stitching together image patches after fusion. During splicing, the overlapping areas are smoothed using the mean to avoid block effects.

[0040] 31 high-frequency subbands obtained by decomposing 8 frames of images Using the guided filter fusion rule, firstly, the initial weights of the high-frequency sub-bands are calculated by taking the largest value. The calculation formula is as follows:

[0041] in, For the i-th frame The initial weight of the k-th high-frequency subband at pixel (x, y). The coefficient value of the k-th high-frequency sub-band of the l-th level in the i-th frame is given at pixel (x, y). This formula allocates the initial weight by the proportion of the absolute value of the high-frequency coefficients, highlighting the strong high-frequency response corresponding to the defect edge.

[0042] Subsequently, a guided filter is used to optimize the initial weight map. The guided filter uses the low-frequency subband corresponding to the level of the reference frame. As a guide image, the low-frequency subband of the reference frame has the characteristics of strong background stability and low noise interference. Using it as a guide image can ensure that the weight optimization process always fits the real spatial distribution of the glass area, and avoid the background fluctuation of the low-frequency subband of different polarization frames affecting the enhancement effect of defect edge details.

[0043] The filter window radius is set to 8 pixels (corresponding to an actual size of 27.6μm, matching the minimum scale of defect edges), and the blur factor is set to... The basis for this determination is that the combination of parameters can suppress environmental noise in production (such as grayscale fluctuations caused by roller vibration and detector thermal noise) while not blurring the details of defect edges.

[0044] The core logic of the guided filter is as follows: First, a linear model is established for each window to solve for temporary coefficients, and then the final pixel-level coefficients are obtained by averaging the coefficients. The specific process is as follows: For the i-th frame, for the currently processed pixels Center, size Pixel window ( Using the window radius parameter (r=8), a linear model of the guided filter is established, and the calculation is as follows:

[0045] in, For the i-th frame window Temporary weights within, The coefficient values ​​of the low-frequency subband corresponding to the l-th level decomposition of the reference frame at pixel (x,y) are used as the guide image for the guide filter. In pixels Center, size A window of pixels. and The linear coefficients within the window in the i-th frame are obtained by solving the least squares method and are used to describe the linear relationship between the guide image and the temporary weights within the window. For each pixel (x, y) in the i-th frame, collect the temporary coefficients corresponding to all windows containing that pixel. and The final coefficient is obtained by taking the average of the values. and This eliminates local bias in a single window and improves the spatial continuity of weights.

[0046] The optimized weights of pixels (x, y) are calculated based on the final coefficients. The formula for calculating the optimized weights for the i-th frame is as follows: ,in, The optimized weights are for the i-th frame. and The linear coefficient mean of the corresponding pixel in the i-th frame is used to ensure that the weight optimization takes into account both the enhancement of defect details and the suppression of background noise. For the high-frequency sub-band of the 8-frame polarization image, the guided filter weight optimization process is executed independently for each frame, forming 8 sets of independent optimized weight maps.

[0047] The high-frequency subbands are weighted and fused based on the optimized weight map, and the calculation formula is as follows:

[0048] in, Let be the coefficient value of the k-th high-frequency sub-band of the l-th level after fusion at pixel (x, y). The optimized weights are for the k-th high-frequency subband of the l-th level in the i-th frame. The coefficient value of the k-th high-frequency sub-band of the l-th level in the i-th frame is located at pixel (x, y). The physical meaning of this process is to enhance the high-frequency response of the defect outline, filter out meaningless high-frequency noise, and ensure the continuity and integrity of the defect edge.

[0049] Finally, the global fusion low-frequency subband was analyzed. With 31 fused high-frequency subbands Perform the inverse NSCT transform to obtain the enhanced image of the defect.

[0050] Step S4: Input the enhanced defect image into the lightweight glass defect recognition model based on improved self-attention, output the glass defect category, obtain the glass defect quality impact data, classify the glass quality level based on the glass defect category and the glass defect quality impact data, thereby realizing visual inspection of glass production quality.

[0051] The enhanced image of the defect is input into a lightweight glass defect recognition model based on improved self-attention, and the output is the glass defect category. This lightweight glass defect recognition model integrates convolutional local feature extraction with linear self-attention global modeling, improving upon traditional self-attention... Computational complexity reduced to At the same time, it ensures the accuracy of defect feature identification and adapts to the high-speed online inspection needs of glass production lines.

[0052] First, the defect enhancement image is preprocessed using Adaptive Histogram Equalization (CLAHE) to enhance local contrast. The CLAHE clipLimit is set to 2.0, and the grid size is set to 8×8 pixels. This parameter combination is chosen because it can further enhance the grayscale differences of small defects while avoiding the amplification of background noise. After preprocessing, the image is normalized to the [0, 1] interval. The normalization formula is: ,in, To enhance the original grayscale value of the image at pixel coordinates (x, y) to improve the appearance of defects, and These represent the minimum and maximum gray values ​​of the defect-enhanced image, respectively. The normalized pixel grayscale value represents the physical meaning of this process: to unify the grayscale range of the image, eliminate the residual influence of light intensity fluctuations, and provide a stable data distribution for model input.

[0053] The constructed lightweight glass defect recognition model comprises five feature extraction modules, one LSA global modeling layer, and two classification mapping layers. The feature extraction modules employ a depthwise separable convolutional structure, with each convolutional kernel measuring 3×3 pixels, a stride of 1, and padding of 1 to ensure the feature map size remains constant. The output channel numbers of the five feature extraction modules are 32, 64, 128, 256, and 128, respectively. The channel number design is based on the following principle: the first three layers progressively increase the channel number to capture multi-scale defect features (32 channels for small defects, 64 channels for medium defects, and 128 channels for large defects), while the last two layers decrease the channel number to compress model parameters and reduce computational overhead. Each feature extraction module is followed by a BatchNorm layer (momentum = 0.99, epsilon = 1e-5) and a ReLU activation function to prevent gradient vanishing and improve model convergence speed.

[0054] The feature map output by the feature extraction module is first processed by edge normalization and cropping. Since 16×16 pixel block global average pooling requires the feature map size to meet an integer divisibility requirement, redundant pixels at the edges are cropped along the feature map height direction, normalizing the feature map size from 2464×2056 to 2464×2048. Then, it undergoes downsampling processing using 16×16 pixel block global average pooling. After downsampling, the feature map dimension is reduced to 154×128×128 (2464÷16=154, 2048÷16=128), and the total number of pixels N is reduced to 19712. This downsampling method significantly reduces the computational cost of global modeling while preserving local feature spatial correlations. The block size is set based on the minimum defect pixel scale of the glass, ensuring that each block can completely contain the minute defect features. The feature map output by the feature extraction module is input to the LSA global modeling layer for global feature correlation. The LSA layer transforms the downsampled feature map into a query matrix through linear projection. Key matrix Sum matrix (where N is the total number of pixels and C is the number of channels). Linear projection is implemented using 1×1 convolution to ensure lightweight parameters. The projection formula is:

[0055] in, The feature matrix output by the feature extraction module. and The projection weight matrix (initialized using a Xavier uniform distribution) is... and This is the bias vector (initialized as a 0 vector).

[0056] The attention weights of the LSA layer are calculated using a linear approximation strategy, and the calculation formula is as follows:

[0057] in, For attention weights, Softmax is a scaling factor, evenly distributed based on the number of channels C=128, used to balance the numerical range of attention weights. T is the matrix transpose operator, indicating that the key matrix K is transposed. () is the normalization function. The physical meaning of this formula is to establish the feature correlation between global pixels through linear calculation, accurately capture global features such as the contour continuity and texture heterogeneity of defects, and at the same time reduce the computational complexity from Down to It is adapted to the computing power requirements of industrial online inspection.

[0058] The global feature map output by the LSA layer has a dimension of 2464×2056×128. After being compressed into a 128-dimensional feature vector by global average pooling (GAP), it is input into the classification mapping layer. The classification mapping layer consists of two fully connected layers. The first layer has an output dimension of 64 and uses ReLU activation function. The second layer has an output dimension of 4 (corresponding to four categories: scratches, bubbles / pockmarks, inclusions / stones, and no defects) and uses Softmax activation function, outputting the probability values ​​of each category. .

[0059] Defect type identification employs a combined method of maximum probability and morphological feature threshold. The probability threshold is set at 0.85, determined based on statistical analysis of 100,000 defect samples. This threshold ensures high classification accuracy. The morphological feature thresholds include: the aspect ratio threshold for scratch-type defects is [value missing]. (Set to 5, corresponding to length / width ≥ 5), statistically obtained based on the linear continuous extension morphological characteristics of scratches; the roundness threshold for bubble / pockmark defects. (The formula for calculating roundness is:) ,in, The defect area is... For the perimeter of the defect, (Circularity) is determined based on the closed-cluster morphological characteristics of bubbles / pockmarks; the texture heterogeneity threshold for inclusions / stone-like defects. (Calculated through the gray-level co-occurrence matrix), set according to the characteristics of disordered internal textures; The specific discrimination rules are as follows: When the probability value of a certain category reaches or exceeds 0.85, and the corresponding morphological features meet the threshold requirements of that type of defect, it is judged as that type of defect; if the probability values ​​of all categories are lower than 0.85, or the morphological features corresponding to the category with the highest probability do not meet the threshold, the feature extraction and global modeling process is re-verified to ensure no misjudgment. For two scenarios where the probability and morphological feature judgment results conflict, specific processing procedures are formulated: First, if the probability value of a certain defect category is ≥0.85 but the morphological features do not meet the corresponding threshold, the morphological features of that region are refined, the defect contour edge detection is optimized, and the calculation accuracy of area / perimeter is corrected. If the morphological features still do not meet the requirements after refined extraction, it is judged as a suspected defect and marked; Second, if the morphological features meet the threshold of a certain defect category but the probability value is <0.85, the model output probability value is linearly corrected by combining the neighborhood feature weights of that region. If the probability value is ≥0.85 after correction, it is judged as the corresponding defect; otherwise, it is marked as a suspected defect. All suspected defects are included in the subsequent manual review process.

[0060] After defect type identification, glass defect quality impact data is obtained, including defect size, defect clustering, and defect location. Based on the glass defect category and the glass defect quality impact data, glass quality grades are determined. The formula for calculating the quality grade score is as follows:

[0061] in, To rate the quality level, This is the defect type weighting coefficient. This is the defect size weighting coefficient. This is the defect clustering weighting coefficient. The defect location weighting coefficient is determined statistically based on the degree of impact of defects on glass quality. Defect type has the greatest impact and therefore the highest weight. (This embodiment...) , , , , Quantification values ​​are assigned to defect types (no defects = 0, bubbles / pitting = 1, scratches = 3, inclusions / stones = 5), based on the severity of different defects. The defect size is quantified as follows: 0.5 for defect size ≤ 50μm, 1.5 for 50μm < defect size ≤ 100μm, 3 for 100μm < defect size ≤ 200μm, and 5 for defect size > 200μm. This value is set according to the degree of impact of defect size on performance. The value is a quantified value for defect aggregation (the value is taken when there are no defects). Defect clustering degree ≤ 0.5 / When the value is 1, it is in indivual / The value is 3 when it is between 2 and 3, and greater than 2. (Value 5), based on the quantification of the impact of defect aggregation on structural strength. The defect location is quantified (0.5 for non-critical areas, 3 for critical areas). Critical areas are the cutting core area less than 50mm from the glass edge, and non-critical areas are areas greater than or equal to 50mm from the edge. Defect size is calculated using pixel count (1 pixel). The defect clustering degree was calculated using a 10mm×10mm statistical window.

[0062] The physical meaning of this formula is to quantify the comprehensive impact of different defect indicators on glass quality, avoiding the one-sidedness of judging by a single indicator.

[0063] Quality grades are divided into four categories: Grade A (Excellent), Grade B (Acceptable), Grade C (Needs Rework), and Grade D (Scrapped). The mapping rule between the scoring results and the quality grades is as follows: Grade A It was classified as Grade B. It was rated as Grade C. It is classified as Grade D.

[0064] It should be noted that the quality grades are only used for internal quality control and sorting in the glass production process and do not replace relevant industry legal standards, product quality specifications, and mandatory product certification requirements. Each grade of glass is suitable for the general quality requirements of the corresponding application scenario. Specifically, Grade A glass is suitable for high-end fields with stringent quality requirements, such as automotive glass, photovoltaic cover glass, and electronic display panel glass; Grade B glass is suitable for conventional building decoration fields, such as building curtain walls and interior partition glass; Grade C glass requires rework and repair and is suitable for low-requirement protective and enclosure glass products; Grade D glass is deemed unqualified and is prohibited from leaving the factory, but can be remelted.

[0065] The final output includes an online inspection report containing defect type, quantity, size, location, quality grade score and grade result, forming a complete technical solution from polarization excitation, imaging correction, fusion enhancement to classification and grading.

[0066] Furthermore, based on the above method embodiments, the present invention also provides an apparatus, including a memory, a processor, and a computer program stored in the memory, which is adapted to be loaded and executed by the processor to implement the above-described visual inspection method for glass production quality.

[0067] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, the phrase "comprising an element defined as..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0068] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A visual inspection method for glass production quality, characterized in that: Includes the following steps: Step S1: Construct the polarization excitation detection field; Step S2: Based on the polarization excitation detection field, acquire the original polarization image sequence of the glass and perform registration and correction to obtain the polarization image sequence; Step S3: The polarization image sequence is fused using an image fusion algorithm based on non-subsampled contour wave transform, sparse representation, and guided filter to obtain a defect-enhanced image; Step S4: Input the enhanced defect image into the lightweight glass defect recognition model based on improved self-attention, output the glass defect category, obtain the glass defect quality impact data, classify the glass quality level based on the glass defect category and the glass defect quality impact data, thereby realizing visual inspection of glass production quality.

2. The visual inspection method for glass production quality according to claim 1, characterized in that: The construction of the polarization excitation detection field includes the following specific steps: Two rows of polarized lighting units are set along the glass conveying direction. The polarization angle of the polarized lighting units is preset, and the lighting sequence of the polarized lighting units is rotated according to a preset cycle. A polarization detector is configured at the imaging end, and the polarization detection angle is matched one-to-one with the polarization angle of the polarization illumination unit; The illumination timing of the polarization illumination unit is synchronously bound to the glass movement, and glass images at different polarization angles are synchronously acquired by a polarization detector to finally construct a polarization excitation detection field.

3. The visual inspection method for glass production quality according to claim 2, characterized in that: The original polarization image sequence of the acquired glass is registered and corrected to obtain a polarization image sequence. The specific steps are as follows: The original polarization image sequence was acquired using a polarization detector; The original polarized image sequence of the same glass region under illumination at a certain polarization angle is used as the reference frame, and the remaining frames are the frames to be registered. Key feature points are extracted from the original polarization image sequence, and feature point matching is performed using a distance metric. The position of the frame to be registered and the reference frame are corrected by affine transformation to obtain a polarization image sequence.

4. The visual inspection method for glass production quality according to claim 3, characterized in that: The step of fusing the polarization image sequence using an image fusion algorithm based on non-subsampled contour wave transform, sparse representation, and guided filter to obtain a defect-enhanced image includes the following steps: A non-subsampled contour wave transform is performed on each frame of the polarization image sequence of the same glass region, and the low-frequency sub-band and high-frequency sub-band are obtained by splitting according to scale and direction. The low-frequency subband is processed using sparse representation fusion rules to obtain a globally fused low-frequency subband; The high-frequency subband is processed using a guided filter fusion rule to obtain a fused high-frequency subband; The defect enhancement image is obtained by reconstructing the globally fused low-frequency subband and the fused high-frequency subband through non-subsampled contour wave inverse transform.

5. The visual inspection method for glass production quality according to claim 4, characterized in that: The process of using sparse representation fusion rules to process low-frequency subbands to obtain globally fused low-frequency subbands includes the following steps: The low-frequency sub-band is divided into image blocks. Based on a pre-trained overcomplete dictionary, the orthogonal matching pursuit algorithm is used to sparsely represent the image blocks and solve for the sparse coefficients. The sparse coefficients are filtered and fused using the maximum L1 norm rule, and the global fused low-frequency subband is obtained by stitching together image blocks.

6. The visual inspection method for glass production quality according to claim 5, characterized in that: The process of processing the high-frequency subband using guided filter fusion rules to obtain the fused high-frequency subband includes the following steps: Calculate the initial weights for the high-frequency sub-bands; Using the low-frequency sub-band corresponding to the reference frame level as the guide image, the initial weights are optimized using a guide filter to obtain the optimized weight map; The high-frequency subbands are weighted and fused based on the optimized weight graph to obtain the fused high-frequency subbands.

7. The visual inspection method for glass production quality according to claim 6, characterized in that: The step of weighted fusion of high-frequency subbands based on the optimized weight graph to obtain fused high-frequency subbands includes the following specific steps: The high-frequency subbands are weighted and fused based on the optimized weight map, and the calculation formula is as follows: ; in, Let be the coefficient value of the k-th high-frequency sub-band of the l-th level after fusion at pixel (x, y). The optimized weights are for the k-th high-frequency subband of the l-th level in the i-th frame. It represents the coefficient value of the k-th high-frequency subband of the l-th level in the i-th frame at pixel (x, y).

8. The visual inspection method for glass production quality according to claim 7, characterized in that: The lightweight glass defect identification model based on improved self-attention is specifically as follows: Preprocess the defect-enhanced image; The preprocessed defect enhancement image is input into a lightweight glass defect recognition model based on improved self-attention, which includes a feature extraction module, a linear self-attention global modeling layer, and a classification mapping layer. The feature extraction module uses a depthwise separable convolutional structure to extract local features; The linear self-attention global modeling layer transforms the feature map into a query, key, and value matrix through linear projection and calculates linearly approximate attention weights.

9. A visual inspection method for glass production quality according to claim 8, characterized in that: The acquisition of glass defect quality impact data, and the classification of glass quality grades based on glass defect categories and glass defect quality impact data, specifically involves: Acquire glass defect quality impact data, which includes defect size, defect aggregation degree, and defect location; Calculate the quality grade score based on glass defect categories and glass defect quality impact data; ; in, To rate the quality level, This is the defect type weighting coefficient. This is the defect size weighting coefficient. This is the defect clustering weighting coefficient. This is the defect location weighting coefficient. Quantification value for defect type, This is a quantified value for the defect size. This is a metric for defect aggregation. Quantification value for defect location; The glass quality is classified into grades based on the comparison between the quality grade score and the preset grading threshold.

10. A visual inspection device for glass production quality, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-9.