A method and system for detecting flaws in tempered glass based on machine vision
Patent Information
- Application Number
- CN202610812829.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-08
- Publication Date
- 2026-08-28
AI Technical Summary
[0006]本发明提供了一种基于机器视觉的钢化玻璃瑕疵检测方法及系统,以解决现有技术中基于固定光源角度与静态检测参数的机器视觉方案,在复杂光照条件下无法有效分离钢化玻璃表面的反光干扰,导致细微瑕疵特征提取不准、定位困难,且缺乏根据环境光变化自适应调节光源与采集参数的能力,难以兼顾检测灵敏度与误判率的技术问题
(1)本发明通过多角度光源照射与光谱选择性提取相结合,构建了面向钢化玻璃表面反光干扰的主动分离与剔除机制。该方法的技术推导在于,现有固定角度光源方案难以区分反光亮斑与真实瑕疵。本发明利用反光区域与真实瑕疵在特定光谱波段下的反射特性差异,精准判定并剔除反光干扰区域,同时通过邻域插值修复保持图像连续性,从而在源头有效剥离反光干扰,为后续瑕疵定位提供干净的基础图像。
Smart Images

Figure CN122651708A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision and industrial defect detection technology, and in particular to a machine vision-based method and system for detecting defects in tempered glass. Background Technology
[0002] Currently, tempered glass is a core safety material in fields such as automobile manufacturing and building curtain walls. The accurate detection of surface defects in tempered glass directly impacts product qualification rates and safety in use. Therefore, achieving high-precision automated detection of minute surface defects in tempered glass under complex lighting conditions is a key requirement for improving industrial quality inspection standards.
[0003] In existing technologies, a common approach is to use a glass surface defect detection scheme based on fixed-angle light source illumination and machine vision. This scheme illuminates the glass surface with a single or fixed combination of LED light sources, captures surface images using an industrial camera, and then identifies and classifies abnormal areas in the images using traditional image processing algorithms such as edge detection or grayscale thresholding. Some schemes introduce smart sensors to monitor light intensity or image acquisition parameters at single points, but they are essentially still passive detection frameworks based on static light source layout and fixed detection parameters. The light source angle, illumination intensity, and algorithm discrimination threshold remain unchanged during the detection process, lacking dynamic adaptability to changes in ambient light and differences in product surface materials.
[0004] This detection method based on static light sources and fixed parameters has inherent technical limitations. Tempered glass surfaces generate large-area reflective interference under strong light reflection or in dark environments. The brightness gradient of the reflective area is highly coupled with the characteristics of minute scratches and internal inclusions, and a fixed-angle light source cannot effectively separate the two. Simultaneously, the ambient light data collected by the intelligent sensor is only used for monitoring and does not participate in the closed-loop control of the light source parameters. This causes the system to still use preset thresholds for judgment when lighting conditions fluctuate, making it difficult to distinguish between real defects and light and shadow artifacts. Minor defects are easily masked by reflection and missed, while environmental noise is easily misjudged as defects. The fundamental reason is that existing methods do not combine intelligent sensor feedback with multi-angle light source scanning and spectral selective extraction, lacking the ability to actively separate reflective interference from the glass surface and dynamically enhance defect features.
[0005] Therefore, the core technical problem faced by existing technologies is that machine vision solutions based on fixed light source angles and static detection parameters cannot effectively separate reflective interference on the surface of tempered glass under complex lighting conditions, resulting in inaccurate extraction and positioning of subtle defect features. Furthermore, they lack the ability to adaptively adjust the light source and acquisition parameters according to changes in ambient light, making it difficult to balance detection sensitivity and false positive rate. Summary of the Invention
[0006] This invention provides a machine vision-based method and system for detecting defects in tempered glass, which solves the technical problems of existing machine vision solutions based on fixed light source angles and static detection parameters, which cannot effectively separate reflective interference on the surface of tempered glass under complex lighting conditions, resulting in inaccurate extraction and difficulty in locating subtle defect features, and lack of ability to adaptively adjust the light source and acquisition parameters according to changes in ambient light, making it difficult to balance detection sensitivity and false positive rate.
[0007] In a first aspect, to address the aforementioned technical problems, the present invention provides a machine vision-based method for detecting defects in tempered glass, comprising: Acquire initial images of tempered glass under illumination from multiple angles; The initial image is preprocessed to obtain an edge-enhanced image; Based on the edge enhancement image, pixel features under a specific spectral band are extracted, and reflective interference areas are identified and removed based on the pixel features to obtain a de-interference base image. The light source angle is dynamically scanned on the base image to remove interference, and the sensitivity of the acquisition device is adjusted to obtain light and shadow change data at different angles. Local contrast features are extracted based on the light and shadow change data, and the location coordinates of potential defects are determined based on the local contrast features to obtain the preliminary location distribution of defects. Based on the preliminary location and distribution of defects, high-incidence areas where the defect density exceeds a preset density threshold are identified. Local grayscale features are extracted from these high-incidence areas. If the local grayscale features are lower than a preset grayscale threshold, adaptive enhancement of the light source brightness is applied to these high-incidence areas to obtain an optimized defect distribution map. Based on the optimized defect distribution map, the defect distribution density is calculated. If the defect distribution density exceeds the preset density range, a parameter adjustment instruction is generated. Based on the parameter adjustment instructions, the light source angle parameters and the acquisition device sensitivity parameters are updated to obtain optimized acquisition data for the next acquisition cycle.
[0008] Secondly, the present invention provides a machine vision-based defect detection system for tempered glass, comprising: The image acquisition module is used to acquire initial images of tempered glass under illumination from multiple angles of light sources. The image processing module is used to preprocess the initial image to obtain an edge-enhanced image; The interference removal module is used to extract pixel features under a specific spectral band based on the edge enhancement image, identify and remove reflective interference areas based on the pixel features, and obtain a de-interference base image. The defect localization module is used to dynamically scan the light source angle of the interference-free base image, adjust the sensitivity of the acquisition device, obtain light and shadow change data at different angles, extract local contrast features based on the light and shadow change data, determine the location coordinates of potential defects based on the local contrast features, and obtain the preliminary defect localization distribution. The image enhancement module is used to determine the high-incidence areas where the defect density exceeds a preset density threshold based on the preliminary location and distribution of the defects, extract local grayscale features from the high-incidence areas, and if the local grayscale features are lower than the preset grayscale threshold, then adaptively enhance the light source brightness of the high-incidence areas to obtain an optimized defect distribution map. The parameter generation module is used to calculate the defect distribution density based on the optimized defect distribution map. If the defect distribution density exceeds the preset density range, a parameter adjustment instruction is generated. The parameter update module is used to update the light source angle parameters and the sensitivity parameters of the acquisition device according to the parameter adjustment instructions, so as to obtain optimized acquisition data for the next acquisition cycle.
[0009] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention constructs an active separation and removal mechanism for reflective interference on tempered glass surfaces by combining multi-angle light source illumination with spectral selective extraction. The technical derivation of this method lies in the fact that existing fixed-angle light source schemes have difficulty distinguishing between reflective bright spots and real defects. This invention utilizes the difference in reflective characteristics between reflective areas and real defects in specific spectral bands to accurately determine and remove reflective interference areas. At the same time, it maintains image continuity through neighborhood interpolation repair, thereby effectively stripping away reflective interference at the source and providing a clean base image for subsequent defect localization.
[0010] (2) This invention achieves active detection and fine imaging of minute defects on the surface of tempered glass by dynamically scanning the light source angle and coordinating the sensitivity adjustment of the acquisition device, combined with local contrast analysis and adaptive enhancement of regional grayscale. The technical derivation of this method lies in the fact that the contrast of tiny scratches under a fixed-angle light source is limited and easily masked or ignored by reflection. This invention controls the periodic scanning of the light source to stimulate changes in light and shadow from multiple angles, synchronously adjusts the sensitivity to capture subtle differences, extracts local contrast features to determine the coordinates of potential defects, and then performs grayscale threshold judgment and adaptive enhancement of light source brightness in areas with high defect incidence, so that hidden minute defects can be clearly presented and accurately located, significantly improving the detection rate and boundary clarity of micron-level defects.
[0011] (3) This invention constructs a complete closed-loop adaptive system from detection to regulation by monitoring the defect distribution density and dynamically updating the light source angle and acquisition parameters. The technical derivation of this method lies in the fact that existing static parameter schemes are not sensitive to ambient light fluctuations and changes in production line conditions, and the detection performance decays with environmental changes. This invention calculates the defect distribution density based on the optimized defect distribution map, and triggers parameter adjustment instructions when the indicators are abnormal. Based on this, the light source angle and the sensitivity parameters of the acquisition equipment are updated and applied to the next acquisition cycle, so that the detection system can continuously adapt to the current environmental conditions and maintain stable detection accuracy and robustness in long-term operation. It is especially suitable for industrial scenarios such as automotive glass production lines that have strict requirements for real-time detection and reliability. Attached Figure Description
[0012] Figure 1 This is a schematic diagram of the machine vision-based defect detection method for tempered glass provided in the first embodiment of the present invention. Figure 2 This is a schematic diagram of the structure of a machine vision-based tempered glass defect detection system provided in the second embodiment of the present invention. Detailed Implementation
[0013] 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.
[0014] Reference Figure 1 The first embodiment of the present invention provides a machine vision-based method for detecting defects in tempered glass, comprising the following steps: S11, acquire the initial image of the tempered glass under illumination from multiple angles; S12, preprocess the initial image to obtain an edge-enhanced image; S13. Based on the edge enhancement image, extract pixel features under a specific spectral band, identify and remove reflective interference areas based on the pixel features, and obtain a de-interference basic image. S14, dynamically scan the light source angle of the interference-free base image and adjust the sensitivity of the acquisition device to obtain light and shadow change data at different angles. Extract local contrast features based on the light and shadow change data, determine the location coordinates of potential defects based on the local contrast features, and obtain the preliminary location distribution of defects. S15. Based on the preliminary location and distribution of defects, determine the high-incidence areas where the defect density exceeds a preset density threshold, extract local grayscale features from the high-incidence areas, and if the local grayscale features are lower than the preset grayscale threshold, perform adaptive enhancement of light source brightness on the high-incidence areas to obtain an optimized defect distribution map. S16, Calculate the defect distribution density based on the optimized defect distribution map; if the defect distribution density exceeds the preset density range, generate a parameter adjustment command. S17, according to the parameter adjustment command, update the light source angle parameter and the acquisition device sensitivity parameter to obtain the optimized acquisition data for the next acquisition cycle.
[0015] In step S11, an initial image of the tempered glass under illumination from multiple angle light sources is acquired, including: The tempered glass surface is illuminated by multiple LED light sources at preset multi-angle directions, and the surface texture data is collected by an image sensor to generate the original texture image. The original texture image is subjected to response bias calibration to obtain the initial image.
[0016] In this embodiment, a multi-angle light source setting module first uses multiple LED light sources to illuminate the tempered glass surface at preset angles. For example, the LED light sources are arranged above the glass surface at three tilt angles: 30 degrees, 45 degrees, and 60 degrees. The tilt angle is defined as the angle between the light source's illumination direction and the glass surface normal. The 30-degree light source uses a low-angle illumination method, with the light-emitting surface approximately 150 mm from the glass surface. It utilizes the diffuse reflection effect generated by the large incident angle to suppress specular glare and effectively highlight longitudinal scratches on the surface. The 60-degree light source uses a high-angle illumination method, with the light-emitting surface approximately 100 mm from the glass surface. It highlights the reflection differences between internal inclusions and transverse textures through near-normal incident light. The 45-degree light source serves as an intermediate transition angle, with the light-emitting surface approximately 120 mm from the glass surface, providing a supplementary viewing angle between grazing reflection and near-normal illumination. The azimuth angle of each group of light sources is evenly distributed along the circumference of the glass surface, and the three tilt angle light sources are arranged at 120-degree intervals in the horizontal plane. An industrial camera is fixed directly above the glass surface, with its optical axis perpendicular to the surface. The working distance is set to 300 mm to ensure complete coverage of the inspection area within a 30 cm × 20 cm field of view. The combination of three angles enables coverage of defects from multiple directions with a limited number of light sources, avoiding directional omissions caused by single-angle illumination. The light source intensity is uniformly adjusted to 5000 lumens via the control system to ensure even light distribution on the glass surface, avoiding localized overexposure or shadow interference. The system automatically records the light source parameters for each angle, including angle value, brightness value, and illumination time, for subsequent traceability and analysis. Under multi-angle illumination conditions, a high-precision CMOS image sensor with a resolution of 4000 × 3000 pixels acquires data from the glass surface, capturing fine textures and generating original texture images. Within a 30 cm × 20 cm inspection field of view, the physical size of a single pixel corresponding to a 4000 × 3000 pixel resolution is the field of view width of 30 cm divided by the horizontal pixel count of 4000, which equals 0.075 mm / pixel. According to the Nyquist sampling theorem commonly used in machine vision, each feature requires at least two pixel samples to fully recover the smallest feature signal. Therefore, an accuracy of 0.075 mm / pixel corresponds to a minimum resolvable feature size of approximately 0.15 mm. Since the minimum defect width to be detected in the tempered glass production line is approximately 0.02 mm, local resolution needs to be improved in step S15 using adaptive local brightness enhancement and region focusing techniques. This compensates for the insufficient pixel accuracy in the global acquisition stage, ensuring that minute defects occupy sufficient pixel sampling points in the locally enhanced image, providing a spatial sampling basis for subsequent edge detection and feature extraction.
[0017] It is worth noting that, to ensure the image sensor's consistent response to incident light from different angles, a response deviation calibration based on grayscale gradients is required. Specifically, before formal acquisition, the system first captures an image of a standard grayscale reference board under the same lighting conditions, calculates the grayscale gradient value of each pixel in the image, and compares the gradient change rate with a preset gradient change threshold. This gradient change threshold is typically set to 0.05, based on the fact that, under uniform illumination, the grayscale gradient of the standard grayscale reference board should theoretically approach zero. Considering the inherent photoelectric noise of the sensor and the microscopic non-uniformity of the reference board surface, gradient fluctuations of no more than 0.05 are allowed. If the grayscale change rate in a certain area exceeds this threshold, it is determined that the sensor's response in that area has a deviation. The system automatically calculates the deviation value and generates calibration parameters, which are then used to correct the subsequent acquired original texture image pixel by pixel, thereby eliminating the non-uniformity of the sensor's response. The calibration parameters are generated by mapping the deviation between the grayscale gradient value of each pixel in the standard grayscale reference board image and the gradient threshold to a correction coefficient for the corresponding pixel position, forming a calibration parameter matrix consistent with the image resolution. During correction, the grayscale value of each pixel in the original texture image is multiplied by the corresponding correction coefficient to obtain the calibrated grayscale value. The calibration process is automatically executed once each time the light source conditions change or the system starts, ensuring that the sensor response remains consistent under different operating conditions. After calibration, the system stores the corrected image in a 16-bit lossless TIFF format. 16-bit depth provides 65,536 grayscale levels, far exceeding the 256 grayscale levels of a conventional 8-bit image, which can completely preserve the subtle grayscale differences caused by micro-texture changes on the glass surface. The lossless TIFF format avoids compression artifacts introduced at image edges by lossy compression formats such as JPEG, ensuring that the input data for subsequent edge enhancement and defect localization processing is not subject to secondary contamination during storage. Metadata files are generated to record the acquisition time, light source parameters, and sensor calibration data. During storage, the integrity of the file is verified using a hash algorithm. If the verification fails, the data is restored from a temporary cache to finally obtain the initial image.
[0018] In step S12, the initial image is preprocessed to obtain an edge-enhanced image, including: The ambient light intensity is detected. If the ambient light intensity exceeds a preset ambient light threshold, ambient light interference masking is performed on the initial image to obtain a masked image. The edge feature sharpening and enhancement processing is performed on the masked image to generate the edge-enhanced image; Calculate the structural similarity between the initial image and the edge-enhanced image. If the structural similarity is lower than a preset similarity threshold, adjust the sharpening enhancement parameters and re-execute the edge feature sharpening enhancement process until the structural similarity reaches the preset similarity threshold.
[0019] In this embodiment, ambient light intensity is first detected in real time by a photosensitive sensor deployed on the side of the inspection station. Since the lighting conditions in the tempered glass production workshop may fluctuate due to factors such as skylight lighting and switching of lighting between adjacent workstations, changes in ambient light directly affect image acquisition quality. Therefore, ambient light is monitored and shielded during the preprocessing stage. The ambient light threshold is preset based on the allowable range of ambient light fluctuations under normal production line inspection conditions; for example, this threshold is set to 200 lux. The value of 200 lux is based on statistical analysis of the glass surface reflectivity, which shows that when ambient light exceeds 200 lux, the standard deviation of pixel brightness in the background area of the initial image increases significantly, and the signal-to-noise ratio decreases to the point of affecting edge extraction. If the currently detected ambient light intensity exceeds this threshold, the system automatically activates the shielding mode, reducing the interference of external light on the inspection area through an adjustable light shield, reducing the ambient light illuminating the glass surface to below 10 lux, and dynamically adjusting the brightness of the internal LED light source to 3000 lumens to ensure consistent lighting in the acquisition environment. After shielding, the shielded image is output.
[0020] Next, sharpening enhancement is performed on the shielded image. The purpose of sharpening enhancement is to highlight the edge details of the glass surface, making the outlines of scratches, cracks, and other defects more prominent in the image. In this embodiment, the Laplacian sharpening algorithm is used to process the image, with the sharpening kernel size set to a 3×3 pixel area and the sharpening intensity parameter set to 1.2. The selection of a 3×3 sharpening kernel size is based on the following considerations: a smaller sharpening kernel has a better response to the fine texture edges in the image, and can highlight the edge features of micron-level scratches with a width of only a few pixels; at the same time, the computational cost of a 3×3 kernel is low, which facilitates real-time processing within the production line inspection cycle. If a 5×5 or larger sharpening kernel is used, although a smoother edge enhancement effect can be obtained, it may cause the edges of adjacent small defects to overlap, reducing the positioning accuracy of defect boundaries. The selection of the sharpening intensity parameter 1.2 is based on the following considerations: this value enhances edge contrast without excessively amplifying residual high-frequency noise in the image, and actual testing shows that it achieves a good balance between edge sharpness and noise suppression. After sharpening, an edge detection algorithm is used to extract edge features from the sharpened image. In this embodiment, the Canny algorithm is used for edge detection, with a low threshold of 50 and a high threshold of 150. The selection of the two thresholds is based on the fact that the low threshold of 50 can effectively filter out weak grayscale fluctuations caused by sensor dark current, while the high threshold of 150 is used to define strong edges. If the proportion of extracted edge pixels to the total number of pixels in the image is less than 5%, it indicates insufficient edge information. The system automatically increases the sharpening intensity parameter to 1.5 and re-executes sharpening and edge extraction until the proportion of edge pixels meets the requirements, and finally generates the edge-enhanced image. The 5% edge pixel proportion threshold is based on statistics from a large number of qualified tempered glass samples. In a clear glass image under normal lighting conditions, edge pixels caused by surface texture, contours, and defects usually account for 5% to 12% of the total pixels. When the proportion is less than 5%, it usually means that the image contrast is insufficient or that it has been over-smoothed. The reason for increasing the parameter to 1.5 instead of a higher value is that over-sharpening will amplify the residual noise in the background area and introduce false edges. 1.5 times the base strength is the upper limit determined in actual measurement. Beyond this value, the number of false edges increases exponentially.
[0021] It's worth noting that the structural similarity index can be used to verify the preservation of image quality before and after edge enhancement processing. During processing, the system calculates the structural similarity index between the initial image and the edge-enhanced image. If this index is below 0.9, it indicates that excessive image distortion has been introduced during processing. This triggers a secondary optimization process, adjusting the sharpening parameters and reprocessing to ensure that the edge-enhanced image maintains structural consistency with the original image while highlighting edge details. The 0.9 threshold is based on the human eye's perceptible limit for image quality changes. When the index is not lower than 0.9, the differences in structural information between the two images are usually imperceptible to the human eye, indicating that the enhancement processing has not altered the image's basic structural features. The specific strategy of the secondary optimization process is to progressively reduce the sharpening intensity parameter in increments of 0.1, recalculating the index after each reduction until it recovers to above 0.9, thus achieving an optimal balance between edge enhancement effect and image fidelity.
[0022] It is worth noting that after completing ambient light shielding and edge enhancement, the LED light source brightness needs to be restored from 3000 lumens in shielded mode to 5000 lumens in the initial acquisition state as the reference lighting conditions for subsequent steps.
[0023] In step S13, pixel features under a specific spectral band are extracted based on the edge enhancement image, and reflective interference areas are identified and removed based on the pixel features to obtain a de-interference base image, including: Perform grayscale gradient analysis on the edge enhancement image and mark areas with gradient values exceeding a preset grayscale gradient threshold as potential reflective areas; Based on the potential reflective areas, the pixel reflection intensity features under the preset spectral band are extracted, and pixels whose pixel reflection intensity features exceed the preset intensity threshold are identified as reflective interference points. Image inpainting based on neighborhood interpolation is performed on the area where the reflective interference points are located to obtain the interference-free base image.
[0024] In this embodiment, grayscale gradient analysis is first performed on the edge enhancement image. The grayscale gradient reflects the degree of brightness change of each pixel in the image. Due to the specular reflection effect, reflective areas typically exhibit high brightness jumps at their edges. Specifically, the system calculates the gradient value of each point in the image pixel by pixel. The gradient value is calculated based on the grayscale difference between each pixel and its four adjacent pixels (up, down, left, and right). The larger of the horizontal and vertical differences is taken as the gradient value of that point. This method is highly efficient and can quickly locate the jump position of reflective boundaries. The gradient value is then compared with a preset gradient threshold of 80. The grayscale gradient threshold of 80 is set based on statistical analysis of a large number of tempered glass surface samples. The grayscale gradient values of normal texture areas are usually distributed between 10 and 50, while the gradient values of reflective edges are generally higher than 70. Selecting 80 as the discrimination threshold can effectively identify reflective boundaries while preserving texture details. If the gradient value of a certain area exceeds 80, that area is initially marked as a potential reflective area. To further improve recognition accuracy, the system also performs region connectivity analysis on the marked potential reflective areas, filtering connected regions with an area greater than 100 pixels and excluding sporadic high-gradient points caused by surface blemishes or isolated noise, generating a reflectivity distribution map. The 100-pixel area threshold is set because actual reflective areas typically appear as continuous bright spots due to specular reflection, with an imaging area generally exceeding 200 pixels, while false positives caused by surface blemishes or sensor noise are usually sporadic discrete points with an area less than 50 pixels. The 100-pixel threshold establishes a reliable distinction between the two. Furthermore, this threshold creates a gradient difference with the 20-pixel noise removal area threshold in the defect localization stage, preventing small defects from being misidentified as reflective areas.
[0025] Next, the system activates the multispectral imaging module to extract pixel features in specific spectral bands for the marked potential reflective areas. The multispectral imaging module employs a filter wheel structure, consisting of multiple narrow-band filters with different center wavelengths mounted on a rotatable filter wheel. The filters operate within the 550-600 nm green spectral band. The filter wheel is driven by a stepper motor, rotating the corresponding filter into the camera's optical path according to the detection requirements, enabling rapid switching between different bands. The filter wheel structure offers advantages in industrial visual inspection, including simple structure, convenient maintenance, and the ability to achieve full-space resolution imaging across all bands, making it suitable for online inspection scenarios in tempered glass production lines. The selection of the 550-600 nm green spectral band is based on comparative tests of the reflection spectra of glass surface reflection and actual defects at different bands. The results showed that the reflection intensity of tempered glass surface reflection in the green spectral band was significantly higher than that of actual defects such as scratches and inclusions. The specific comparative test covered three wavelength bands: blue light at 450 nm, green light from 550 to 600 nm, and red light at 650 nm. In the blue light band, the ratio of reflective intensity to blemish intensity was approximately 1.3:1, with limited distinguishability. In the red light band, the ratio was approximately 1.4:1, showing slight improvement but still exhibiting overlap. In the green light band, this ratio reached over 1.7:1, indicating the greatest difference in reflectivity between the two. Therefore, the green spectral band from 550 to 600 nm was selected as the feature extraction band to maximize the separation of reflective and blemish signals. The two exhibit the greatest difference in reflectivity within this band, thus effectively distinguishing between reflective and blemish signals. The system extracted the reflective intensity features of each pixel in this spectral band and compared the reflective intensity values with a preset intensity threshold of 120. The intensity threshold of 120 was determined by statistically analyzing the reflection intensity of known reflective and defective samples within the spectral band. The average reflection intensity of reflective points was approximately 145, while the average reflection intensity of defective points was approximately 85. A conservative threshold of 120 was chosen, balancing reflection recognition rate and defect retention rate. Pixels with a reflection intensity exceeding 120 were identified as interference points. Simultaneously, the system constructed a reflection intensity histogram, statistically analyzing the proportion of interference points within the total pixels in the potential reflective area. If this proportion exceeded 3%, the spectral wavelength was automatically fine-tuned to 610 nm for feature re-extraction. The selection of 610 nm was based on the fact that, although the difference in reflection intensity between reflective and defective points was slightly lower in the red light band than in the green light band, the overall reflectivity of the glass substrate further decreased. This effectively reduced residual reflection interference caused by low-angle diffuse reflection, and the absorption effect of genuine defects was more significant under red light, thereby improving the secondary discrimination capability for high-proportion reflective areas. If the proportion of interference points still exceeds 3% after fine-tuning, further fine-tune to 530 nanometers and fine-tune towards the blue light band. Utilize the strong scattering characteristics of short wavelengths of blue light to enhance the contrast of subtle textures at the edges of defects until the proportion of interference points drops below 3%, ensuring the accuracy of reflection removal.
[0026] It is worth noting that before performing reflective area identification and removal in step S13, the system has accumulated historical detection data from several acquisition cycles. Based on this historical data, the system uses the defect location results and high-incidence area judgment results obtained in previous cycles in steps S14 to S15 to establish prior information on the distribution of defects on the glass surface. Specifically, the system spatially overlays and statistically analyzes the high-incidence areas identified in step S15 from multiple historical acquisition cycles to generate a historical high-incidence area location map. This location map identifies the historical frequency distribution of defects appearing at different locations on the glass surface. When performing reflective area judgment in step S13 of this cycle, the system uses this historical high-incidence area location map as a priori reference.
[0027] After identifying the reflective interference points, the spatial location of the currently detected reflective area is compared with the location map of historical high-incidence areas to calculate the overlap ratio. The preset overlap ratio threshold is set to 0.3 based on production line experience. If the overlap ratio exceeds this threshold, meaning that more than 30% of the reflective area overlaps with a historical high-incidence area, it indicates that there is a high probability of a real defect in the reflective area. This area is marked as a region to be retained, and subsequent interpolation repair operations are not performed. Instead, the coordinate information of this area is recorded and passed to step S15. In subsequent processing, S15 performs local grayscale feature analysis and adaptive enhancement of light source brightness on this area to further confirm whether a real defect exists. The overlap ratio threshold of 0.3 is set based on the statistical analysis of historical inspection data from the production line. When real defects and reflective areas overlap spatially, the overlap ratio is generally between 0.25 and 0.6 because the defect size is usually smaller than the reflective spot size. Selecting 0.3 can preserve the real defects while avoiding too much reflective residue from not being repaired due to an excessively low threshold.
[0028] Then, image inpainting based on neighborhood interpolation is performed on the areas containing reflective interference points, excluding the areas to be preserved. Specifically, the area containing the reflective interference points is taken as the target for inpainting. First, the minimum bounding rectangle of this area is calculated, and then extended outwards by 20 pixels as the neighborhood. If the extended neighborhood is less than 64×64 pixels, a fixed 64×64 pixel neighborhood is used to ensure sufficient non-interference pixels participate in the interpolation calculation. Within this neighborhood, a weighted average of the pixel values of all non-reflective interference points is calculated. The weighting coefficient is the reciprocal of the shortest distance from each pixel in the neighborhood to the boundary of the area to be inpainted; pixels closer to the boundary have a higher weight. For large reflective areas exceeding 200 pixels, a block-based inpainting strategy is adopted, dividing the reflective area into 16×16 pixel sub-blocks for sequential inpainting to avoid texture discontinuities introduced by a single interpolation. After the repair is completed, the system calculates the texture consistency index of the repaired area. If the index is lower than 0.85, it indicates that the connection between the repaired area and the surrounding texture is not natural enough. The interpolation parameters need to be adjusted and the calculation repeated until the texture consistency index meets the requirements. After the above reflection recognition and repair processing, the final output is the interference-free base image.
[0029] It is worth noting that, based on actual production line data verification, the above process can achieve a rejection rate of over 95% for reflective interference, and the residual reflective area in the base image after interference removal accounts for less than 0.5%.
[0030] In step S14, the base image for interference removal is dynamically scanned from different light source angles, and the sensitivity of the acquisition device is adjusted to obtain light and shadow change data at different angles. Local contrast features are extracted based on the light and shadow change data, and the location coordinates of potential defects are determined based on these local contrast features to obtain the preliminary defect location distribution, including: The illumination angle of the light source is controlled to perform periodic scanning within a preset angle range in preset steps, and the sensitivity of the acquisition device is adjusted simultaneously to acquire image sequences at adjacent angles. Perform a difference operation on adjacent angle images in the image sequence to generate a gray-level difference distribution. Mark the regions in the gray-level difference distribution whose difference exceeds a preset difference threshold as light and shadow sensitive regions to obtain the light and shadow change data. Local contrast calculation is performed on the light-sensitive area, and pixels with local contrast exceeding a preset contrast threshold are identified as potential defects. Using the potential defect points as the center, clustering and merging are performed on defect points within a preset neighborhood range, and the geometric center coordinates of each group of defect points after clustering are extracted to generate the preliminary location distribution of the defects.
[0031] Specifically, the system uses a programmable light source control module to control the illumination angle of the LED light source, starting from an initial 30 degrees and performing periodic scans within an angle range of 30 to 60 degrees in 5-degree increments. The selection of the 30-60 degree scanning angle range is based on the reflectivity test of surface defects in tempered glass. When the incident angle is below 30 degrees, the light is almost perpendicular, and shallow defects such as surface scratches produce almost no light and shadow changes, resulting in an insignificant scanning effect. When the incident angle is above 60 degrees, the light is almost grazing, and the overall reflectivity of the glass surface drops sharply, resulting in excessively low overall image brightness, which is detrimental to subsequent contrast analysis. The 30-60 degree range covers the transition from near-perpendicular to near-grazing illumination, representing the angle range where the light and shadow changes of defects are most significant. The 5-degree step size balances scanning precision and acquisition efficiency, generating seven angular positions within this step size, enabling coverage of the response range of typical defects to different angles of illumination within a limited acquisition time. During each angle switch, the system synchronously adjusts the sensitivity of the acquisition device, increasing the CMOS sensor sensitivity from the default value of 100 to 120. The reason for increasing the sensitivity to 120 is that during angle scanning, the intensity of reflected light from the glass surface decreases as the incident angle increases. Appropriately increasing the sensitivity compensates for this light attenuation, ensuring consistent overall brightness of the acquired images at each angle and avoiding deviations in subsequent differential calculations due to brightness differences. After sensitivity adjustment, the system captures one frame at each light source angle, acquiring a total of seven frames to form an image sequence for adjacent angles. It should be noted that the acquisition device sensitivity in this article specifically refers to the analog gain factor of the CMOS sensor, which is dimensionless. The default value of 100 corresponds to a gain of 1.0, and each increase of 1 represents a gain increase of 0.01, meaning a sensitivity of 120 corresponds to a gain of 1.2. The sensor maintains a linear response within the gain range of 1.0 to 2.0.
[0032] Next, a difference operation is performed on adjacent angle images in the image sequence. Specifically, for two adjacent frames, the absolute difference in grayscale values is calculated pixel-by-pixel to generate a grayscale difference distribution map. Regions in the grayscale difference distribution map whose differences exceed a preset difference threshold of 50 are marked as light-sensitive regions. The difference threshold of 50 is set as follows: Statistical analysis of the grayscale differences of flawless glass samples at adjacent angles shows that grayscale fluctuations on normal surfaces due to changes in the light source angle are typically between 15 and 35, while areas with scratches, due to their surface microstructure being sensitive to the incident angle, generally have grayscale differences exceeding 45. Selecting 50 as the threshold effectively distinguishes between normal fluctuations and abnormal changes. The marked light-sensitive regions and their corresponding difference values together constitute the light-shadow change data.
[0033] Then, local contrast is calculated for the light-sensitive areas. The calculation method involves taking a 5×5 pixel neighborhood around each pixel. The 5×5 neighborhood size balances the local sensitivity and statistical stability of the contrast calculation. A smaller 3×3 neighborhood is easily affected by single noise points, leading to unstable contrast estimation, while a larger 7×7 neighborhood may include adjacent normal textures in the calculation, diluting the contrast features of defective areas. At a 4000×3000 resolution, a 5×5 neighborhood corresponds to a physical area of approximately 0.4 mm square, matching the width of a typical scratch. The difference between the maximum and minimum grayscale values within this neighborhood is calculated, and this difference is used as the local contrast of that pixel. Pixels with a local contrast exceeding a preset contrast threshold of 0.7 are identified as potential defects. The contrast threshold of 0.7 was determined based on the following statistics: After analyzing the contrast distribution of real defect samples such as scratches and inclusions, the average local contrast of the defect area was about 0.85, while the average contrast of the normal surface area was about 0.4. Choosing 0.7 as the discrimination threshold can effectively suppress false triggering of normal textures while covering most defects.
[0034] Finally, spatial clustering and merging are performed using the identified potential defects as the center. Specifically, for any two potential defects, if the spatial distance between them is less than 10 pixels, they are grouped together. The 10-pixel clustering distance is based on the fact that typical scratches on tempered glass surfaces generally appear as continuous line segments in a 4000×3000 resolution image, with a pixel span usually greater than 10 pixels. This distance allows discrete defect points belonging to the same scratch to be aggregated into a complete target, while avoiding the incorrect merging of two adjacent but independent defects. After clustering, the system extracts the geometric center coordinates of each group of defect points, with a coordinate accuracy to 0.1 pixel units, and records the pixel area of each group of defect points. Defect point groups with an area less than 20 pixels are considered noise and discarded. The 20-pixel area threshold is based on the minimum identifiable size of actual defects, which corresponds to a physical scratch width of approximately 0.02 mm. Detection points smaller than this size are usually residual noise or dust particles and have no practical quality judgment significance. After the above processing, the preliminary location distribution of the defects is generated, and the location accuracy rate can reach more than 92% as verified by production line samples.
[0035] In step S15, based on the preliminary location and distribution of defects, high-incidence areas where the defect density exceeds a preset density threshold are identified. Local grayscale features are extracted from these high-incidence areas. If the local grayscale features are lower than a preset grayscale threshold, adaptive enhancement of the light source brightness is applied to these high-incidence areas to obtain an optimized defect distribution map, including: Based on the preliminary location and distribution of the defects, the defect density in each region is calculated, and the region where the defect density exceeds a preset density threshold is identified as the high-incidence region. Local grayscale features are extracted from the high-incidence area, and the grayscale mean of the area is calculated. If the grayscale mean is lower than a preset grayscale threshold, the brightness of the light source is adjusted by increasing the preset brightness step size until the grayscale mean of the high-incidence area reaches the preset grayscale threshold. The edge details of the image of the high-incidence area after adjusting the light source brightness are enhanced to obtain the optimized defect distribution map.
[0036] Specifically, the system first calculates the number of defect points per unit area in each region based on the preliminary location and distribution of the defects. The calculation method involves dividing the entire image into several detection units of 1 square centimeter, counting the number of defect points contained in each unit, and obtaining the defect density value for each region. A preset density threshold is set at 0.5 defects per square centimeter. This threshold is determined based on the analysis of production line defect statistics. On a normal glass surface, the average density of sporadic detection points caused by residual noise or fine dust is approximately 0.2 defects per square centimeter. However, in areas with genuine defects, due to the continuity of scratches or the concentrated distribution of inclusions, the density value is usually higher than 0.5 defects per square centimeter. Selecting this value effectively captures areas of genuine defect clusters while filtering out random noise. Regions with more defects than this density threshold are identified as high-incidence areas.
[0037] For identified high-incidence areas, local resolution needs to be improved using area focusing technology. Specifically, after determining the spatial coordinates of the high-incidence area, the motorized zoom lens mounted on the industrial camera is controlled to gradually adjust the focal length from the initial 25mm to 50mm. Simultaneously, the camera's working distance is adjusted or a digital focusing algorithm is used to enlarge the image size of the high-incidence area on the image sensor from approximately 3mm × 3mm to 6mm × 6mm, thereby improving the local area resolution from 0.075mm / pixel to 0.0375mm / pixel. If the high-incidence area is large (exceeding 5 square centimeters), a two-dimensional motorized displacement platform is used to move the camera directly above the high-incidence area. Multiple high-resolution images are acquired in blocks, and then stitched together to create a complete image of the high-incidence area. All the zoom and movement operations are automatically completed under system control, without changing the overall detection field of view of the initial image acquisition. Secondary fine imaging is performed only on the identified high-incidence areas to ensure sufficient pixel sampling density for micron-level defects in the locally enhanced image.
[0038] Next, local grayscale features are extracted from the identified high-incidence areas. This embodiment uses grayscale histogram statistics to calculate the average grayscale value of pixels within each high-incidence area. The average grayscale value comprehensively reflects the overall brightness level of the area. The preset grayscale threshold is set to 80. The grayscale threshold of 80 is based on the statistical analysis of the optical characteristics of common defects on tempered glass surfaces. Under standard lighting conditions, the average grayscale value of a normal glass substrate is typically between 100 and 130, while the average grayscale value of scratches, dents, and internal inclusions is generally between 60 and 75. Selecting 80 as the threshold effectively distinguishes most defective areas from the normal background. If the calculated average grayscale value is lower than 80, it indicates that the area is generally dark, and the grayscale difference between the defect and the background is insufficient, thus indicating abnormal grayscale features.
[0039] Based on the determination of the grayscale anomaly, the system activates the adaptive brightness enhancement mechanism of the light source. The enhancement method involves progressively increasing the brightness of the LED light source in increments of a preset brightness adjustment ratio, starting from the current reference brightness. The preset brightness adjustment ratio is set based on the principle that grayscale value and light intensity are approximately proportional within the linear response range of a CMOS sensor; for example, this ratio is set to 10%. The 10% ratio balances adjustment efficiency and imaging safety. Under 16-bit depth imaging conditions, with a current reference brightness of 5000 lumens, the initial brightness increase of 500 lumens to 5500 lumens, combined with a current target area grayscale average of approximately 70, allows for an increase of approximately 7 units in grayscale average, based on the proportional relationship between grayscale value and light intensity. This effectively improves contrast without causing localized overexposure due to excessive adjustment. After each adjustment, the system re-acquires the image of the high-incidence area and calculates the average grayscale value, comparing it with the preset grayscale threshold of 80. If the difference is still greater than 5, the system continues to increase the grayscale value proportionally until the average grayscale value reaches 80. During the brightness increase process, the system sets a maximum brightness increment limit of 80% of the base brightness, i.e., the cumulative increment does not exceed 4000 lumens, to prevent excessive enhancement from causing image saturation. This limit is based on the fact that, at 16-bit depth, when the light intensity increases to 1.8 times the base condition, the grayscale value of the highlight area does not reach the saturation limit of 65535, leaving a margin of about 10%, which fully utilizes the dynamic range of the sensor and avoids the loss of grayscale information due to saturation. If the average grayscale value is still below 80 after reaching the limit, the adjustment is stopped and the area is recorded as a low-contrast abnormal area, which is then handed over to the subsequent manual re-inspection process.
[0040] After brightness adjustment, edge detail enhancement is performed on the high-incidence area image. The system uses the Canny edge detection operator to extract edges from the adjusted image, setting dual thresholds of 100 and 200. Compared to the dual threshold settings for global edge enhancement in step S12, the dual thresholds here are increased because the edge contrast of the blemish area has been significantly improved after local brightness enhancement. Appropriately increasing the threshold can filter out residual noise that may be amplified by brightness enhancement while maintaining the clarity of blemish boundaries. The extracted blemish edges are superimposed on the optimized high-incidence area image to form a high-quality blemish image with clear boundaries, and finally outputting an optimized blemish distribution map. According to actual tests, compared with the initial localization distribution map without brightness adaptive enhancement, the clarity of blemish boundaries in the optimized blemish distribution map is improved by an average of about 18%.
[0041] In step S16, based on the optimized defect distribution map, the defect distribution density is calculated. If the defect distribution density exceeds a preset density range, a parameter adjustment instruction is generated, including: Based on the optimized defect distribution map, the grid is divided according to the preset area units, and the defect density value of each grid unit is calculated. The defect distribution density is generated based on the defect density value of each grid cell; If the defect distribution density value of any grid cell exceeds the preset density range, it is determined to be an abnormal state. Based on the degree of deviation of the abnormal state, the corresponding light source and acquisition parameter adjustment amount is determined, and the parameter adjustment instruction containing the grid cell position information is generated.
[0042] Specifically, the system first divides the optimized defect distribution map into a grid according to preset area units. The size of the preset area unit is set to 1 square centimeter, which is consistent with the division standard of the high-incidence area detection unit in step S15, facilitating data connection and comparison. After the grid division is completed, the system traverses each grid unit, counts the number of defect points contained within it, and calculates the defect density value of the grid unit. The density value is calculated by dividing the number of defect points in the grid unit by the area of the unit. Since the area of each grid unit is 1 square centimeter, the actual density value is equivalent to the number of defect points.
[0043] Next, the defect density values of each grid cell are summarized to obtain the defect distribution density. The defect distribution density is a multi-dimensional dataset composed of the density values of all grid cells, which can reflect the overall distribution pattern and local concentration of defects in the entire image.
[0044] The preset density range is a threshold set defining the normal fluctuation range, set at 0.3 to 1.2 points per square centimeter. This range is determined based on statistical analysis of a large number of qualified glass samples and actual defective samples under normal and stable testing conditions. On qualified glass surfaces, the density of sporadic detection points caused by residual noise is typically below 0.2 points per square centimeter, while the density of typical defective areas is generally not less than 0.3 points per square centimeter. Furthermore, a single-point density exceeding 1.2 points per square centimeter usually indicates the presence of severe continuous scratches or large areas of inclusions, exceeding the conventional processing range of this testing system. Therefore, using 0.3 as the lower limit and 1.2 as the upper limit effectively covers the fluctuation range of normal defect distribution. If the defect density value of a certain grid cell exceeds the preset density range, for example, reaching 1.5 defects per square centimeter, it indicates that the defects in that area are abnormally dense, possibly due to improper light source angle causing ineffective removal of reflective interference and the aggregation of false defect points; or, for example, below 0.1 defects per square centimeter, it indicates that the area may have insufficient lighting leading to missed detections, or that excessive shielding by the light shield has suppressed fine surface textures. The system determines both of these conditions as abnormal. Through a two-way anomaly detection mechanism, the system can not only respond to the risk of false detections caused by excessively dense defects, but also capture the risk of missed detections reflected by excessively sparse defects, achieving two-way closed-loop monitoring of detection quality.
[0045] If an abnormal state is detected, the system automatically generates a parameter adjustment command containing the location information of the grid cells. The command includes the coordinates of the abnormal grid cell, its current density value, and an anomaly type identifier. This command is transmitted to the parameter update module via an internal communication protocol, triggering the adjustment of the light source angle and acquisition sensitivity in the next cycle. The internal communication protocol uses a combination of shared memory and a message queue. Once generated, the command is written to the shared memory area, and the parameter update module monitors the command queue in a polling manner, ensuring that the delay from anomaly detection to command reception is controlled within milliseconds, meeting the real-time requirements of the production line's inspection cycle. Through this closed loop from density monitoring to command generation, the system can continuously monitor inspection quality and quickly respond when abnormalities occur in defect distribution.
[0046] In step S17, according to the parameter adjustment command, the light source angle parameter and the acquisition device sensitivity parameter are updated to obtain optimized acquisition data for the next acquisition cycle, including: Based on the target position information in the parameter adjustment command, determine the corresponding light source angle compensation value and sensitivity compensation value; The illumination angle of the light source is updated to the light source angle compensation value, and the sensitivity parameters of the acquisition device are updated to the sensitivity compensation value; Based on the updated light source angle parameters and sensitivity parameters, the next cycle of image acquisition is performed to obtain the optimized acquisition data.
[0047] In this embodiment, after the density index calculation and anomaly determination in step S16, when the defect density value of a certain grid cell exceeds the preset density range, the system has generated a parameter adjustment instruction containing the location information of the abnormal grid cell. The purpose of this step is to respond to this instruction and dynamically update the light source angle and acquisition sensitivity parameters through a closed-loop feedback mechanism, so that the detection system can operate with optimized parameters in the next acquisition cycle and continuously adapt to changes in ambient light and fluctuations in production line conditions.
[0048] Specifically, the system first determines the corresponding light source angle compensation value and sensitivity compensation value based on the target location information in the parameter adjustment command. The parameter adjustment command includes the coordinate position of the abnormal grid cell and the current defect density value. The system uses a feedback data integration module to perform weighted fusion analysis on the density data of the abnormal area and historical ambient light intensity data. The weight ratio is set to 60% for density data and 40% for ambient light data. This weight allocation is based on the fact that abnormal defect density is mainly caused by improper lighting conditions, which are affected by both the light source angle and ambient light. The light source angle directly determines the distribution pattern of reflective interference, and its influence is experimentally verified to be approximately 60%, while the influence of ambient light changes is approximately 40%. A comprehensive environmental adaptability index is obtained through weighted calculation. This index reflects the degree of adaptation of the current detection parameters to the actual working conditions. The comprehensive environmental adaptability index ranges from 0 to 1, with 1 indicating that the parameters are perfectly adapted to the working conditions. The preset threshold of 0.9 is based on statistical data from long-term production line operation. When the index is not lower than 0.9, the accuracy and false detection rate of defect detection are both within the allowable range of the process specifications. When the index is lower than 0.9, the detection indicators show a statistically significant deterioration trend, requiring parameter adjustment. This threshold is an empirical value accumulated by the system during long-term operation and can be appropriately adjusted upwards or downwards according to the specific process requirements of the production line. The system calculates the light source angle compensation value and sensitivity compensation value based on the index deviation. For example, if the current light source illumination angle is 30 degrees, the comprehensive environmental adaptability index is 0.85, and the deviation is 0.05, then the light source angle compensation value is determined to be an increase of 5 degrees on the original angle, i.e., the compensated angle is 35 degrees. The correspondence between the angle compensation value and the deviation can be determined through a preset mapping function. For example, it is adjusted based on a linear relationship of 0.05 deviation corresponding to 5 degrees of compensation. The sensitivity compensation value is determined in a similar way, calculated by multiplying the deviation by a preset sensitivity adjustment coefficient. The sensitivity adjustment coefficient is preset based on the regression relationship between the deviation and the sensitivity increment in historical adjustment records. For example, the sensitivity adjustment coefficient is set to 300. When the deviation is 0.05, the sensitivity compensation value is 15, that is, the sensitivity is adjusted from 100 to 115.
[0049] Next, the illumination angle of the light source is updated to the light source angle compensation value, and the sensitivity parameters of the acquisition device are updated to the sensitivity compensation value. The update of the light source angle is executed by the programmable light source control module. After receiving the compensation angle value, this module drives the mechanical steering mechanism of the LED light source to adjust to the target angle position. Simultaneously, illumination uniformity analysis is performed during the update process. If the light coverage uniformity index after the updated angle is lower than 0.8, the angle is automatically fine-tuned until the uniformity meets the requirements. The illumination uniformity index is evaluated by calculating the dispersion of illuminance values at each sampling point in the detection area. The detection area is divided into several equal-area sub-regions, and the illuminance value at the center of each sub-region is measured. The deviation of each illuminance value from the overall mean is calculated. The uniformity index is equal to the average absolute deviation of the illuminance value of each sub-region from the mean, divided by the mean and then rounded up. The closer the index is to 1, the more uniform the illumination. A threshold of 0.8 corresponds to an illuminance deviation of no more than 20% in each sub-region, which is a common requirement for illumination uniformity in industrial visual inspection. The sensitivity parameter update is completed through a sensor feedback mechanism, adjusting the sensitivity of the CMOS sensor from the current value to the sensitivity compensation value. For example, based on the original sensitivity of 100, it can be adjusted to 115 according to the compensation value to enhance the sensor's ability to respond to subtle changes in light and shadow.
[0050] Then, based on the updated light source angle and sensitivity parameters, the next cycle of image acquisition is performed to obtain the optimized acquisition data. The system starts a new round of multi-angle light source illumination and image acquisition process with the updated parameters, binding the light source angle and sensitivity parameters with the current ambient light conditions to form an adaptive acquisition strategy. For example, under the condition that the current ambient light intensity is 400 lux, the system maintains the sensitivity at the adjusted value and sets the light source angle to the compensated angle value. All parameter adjustment records, including adjustment time, parameter values before and after adjustment, abnormal grid positions and density values that triggered the adjustment, are uploaded to the system database to form a historical traceability chain of parameter adjustments. By analyzing the frequency and amplitude distribution of historical adjustment records, the long-term stability of the detection environment and the attenuation trend of the light source device can be evaluated. When the adjustment frequency per unit time continues to rise or the compensation amplitude increases unidirectionally, it can be determined as an aging signal of the light source device. Based on this, the system generates a preventive maintenance prompt, realizing the functional extension from adaptive detection parameters to equipment health management, ensuring the continuity and traceability of parameter management in subsequent acquisition cycles. Through the aforementioned closed-loop feedback mechanism, the detection system can automatically adapt to environmental changes during long-term operation and maintain stable detection performance for defects on the surface of tempered glass.
[0051] In summary, this invention discloses a machine vision-based method for detecting defects in tempered glass, comprising: acquiring an initial image under multi-angle light source illumination and preprocessing it to obtain an edge-enhanced image; extracting and identifying pixel features in specific spectral bands to identify and remove reflective interference areas to obtain a de-interference base image; performing dynamic scanning of the light source angle and coordinated sensitivity adjustment on the de-interference base image to extract local contrast features and determine the preliminary location and distribution of defects; extracting local grayscale features from high-incidence defect areas and obtaining an optimized defect distribution map through adaptive enhancement of light source brightness; calculating the defect distribution density based on the optimized defect distribution map and generating parameter adjustment instructions when indicators are abnormal; updating the light source angle parameters and the sensitivity parameters of the acquisition device according to the parameter adjustment instructions to obtain optimized acquisition data for the next acquisition cycle. This invention, through the technical path of "multi-angle light source acquisition - spectral selective de-reflection - dynamic angle scanning positioning - local brightness adaptive enhancement - density feedback closed-loop control," effectively separates reflective interference on the tempered glass surface under complex lighting conditions, achieving high-precision positioning and clear imaging of minute defects, and ensuring the stability and reliability of the detection system during long-term operation through a dynamic parameter adaptation mechanism.
[0052] Reference Figure 2 The first embodiment of the present invention provides a machine vision-based tempered glass defect detection system, comprising: The image acquisition module is used to acquire initial images of tempered glass under illumination from multiple angles of light sources. The image processing module is used to preprocess the initial image to obtain an edge-enhanced image; The interference removal module is used to extract pixel features under a specific spectral band based on the edge enhancement image, identify and remove reflective interference areas based on the pixel features, and obtain a de-interference base image. The defect localization module is used to dynamically scan the light source angle of the interference-free base image, adjust the sensitivity of the acquisition device, obtain light and shadow change data at different angles, extract local contrast features based on the light and shadow change data, determine the location coordinates of potential defects based on the local contrast features, and obtain the preliminary defect localization distribution. The image enhancement module is used to determine the high-incidence areas where the defect density exceeds a preset density threshold based on the preliminary location and distribution of the defects, extract local grayscale features from the high-incidence areas, and if the local grayscale features are lower than the preset grayscale threshold, then adaptively enhance the light source brightness of the high-incidence areas to obtain an optimized defect distribution map. The parameter generation module is used to calculate the defect distribution density based on the optimized defect distribution map. If the defect distribution density exceeds the preset density range, a parameter adjustment instruction is generated. The parameter update module is used to update the light source angle parameters and the sensitivity parameters of the acquisition device according to the parameter adjustment instructions, so as to obtain optimized acquisition data for the next acquisition cycle.
[0053] It should be noted that the machine vision-based tempered glass defect detection system provided in this embodiment of the invention is used to execute all the process steps of the machine vision-based tempered glass defect detection method in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0054] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0055] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for detecting defects in tempered glass based on machine vision, characterized in that, include: Acquire initial images of tempered glass under illumination from multiple angles; The initial image is preprocessed to obtain an edge-enhanced image; Based on the edge enhancement image, pixel features under a specific spectral band are extracted, and reflective interference areas are identified and removed based on the pixel features to obtain a de-interference base image. The light source angle is dynamically scanned on the base image to remove interference, and the sensitivity of the acquisition device is adjusted to obtain light and shadow change data at different angles. Local contrast features are extracted based on the light and shadow change data, and the location coordinates of potential defects are determined based on the local contrast features to obtain the preliminary location distribution of defects. Based on the preliminary location and distribution of defects, high-incidence areas where the defect density exceeds a preset density threshold are identified. Local grayscale features are extracted from these high-incidence areas. If the local grayscale features are lower than a preset grayscale threshold, adaptive enhancement of the light source brightness is applied to these high-incidence areas to obtain an optimized defect distribution map. Based on the optimized defect distribution map, the defect distribution density is calculated. If the defect distribution density exceeds the preset density range, a parameter adjustment instruction is generated. Based on the parameter adjustment instructions, the light source angle parameters and the acquisition device sensitivity parameters are updated to obtain optimized acquisition data for the next acquisition cycle.
2. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The process of acquiring an initial image of tempered glass under illumination from multiple angles includes: The tempered glass surface is illuminated by multiple LED light sources at preset multi-angle directions, and the surface texture data is collected by an image sensor to generate the original texture image. The original texture image is subjected to response bias calibration to obtain the initial image.
3. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The preprocessing of the initial image to obtain an edge-enhanced image includes: The ambient light intensity is detected. If the ambient light intensity exceeds a preset ambient light threshold, ambient light interference masking is performed on the initial image to obtain a masked image. The edge feature sharpening and enhancement processing is performed on the masked image to generate the edge-enhanced image; Calculate the structural similarity between the initial image and the edge-enhanced image. If the structural similarity is lower than a preset similarity threshold, adjust the sharpening enhancement parameters and re-execute the edge feature sharpening enhancement process until the structural similarity reaches the preset similarity threshold.
4. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The step of extracting pixel features under a specific spectral band from the edge-enhanced image, identifying and removing reflective interference areas based on the pixel features, and obtaining a de-interference base image includes: Perform grayscale gradient analysis on the edge enhancement image and mark areas with gradient values exceeding a preset grayscale gradient threshold as potential reflective areas; Based on the potential reflective areas, pixel reflection intensity features under a preset spectral band are extracted, and pixels whose pixel reflection intensity features exceed a preset intensity threshold are identified as reflective interference points. Image inpainting based on neighborhood interpolation is performed on the area where the reflective interference points are located to obtain the interference-free base image.
5. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The process involves dynamically scanning the light source angle of the de-interference base image and adjusting the sensitivity of the acquisition device to obtain light and shadow change data at different angles. Local contrast features are extracted based on the light and shadow change data, and the location coordinates of potential defects are determined based on these local contrast features to obtain a preliminary defect location distribution. This includes: The illumination angle of the light source is controlled to perform periodic scanning within a preset angle range in preset steps, and the sensitivity of the acquisition device is adjusted simultaneously to acquire image sequences at adjacent angles. Perform a difference operation on adjacent angle images in the image sequence to generate a gray-level difference distribution. Mark the regions in the gray-level difference distribution whose difference exceeds a preset difference threshold as light and shadow sensitive regions to obtain the light and shadow change data. Local contrast calculation is performed on the light-sensitive area, and pixels with local contrast exceeding a preset contrast threshold are identified as potential defects. Using the potential defect points as the center, clustering and merging are performed on defect points within a preset neighborhood range, and the geometric center coordinates of each group of defect points after clustering are extracted to generate the preliminary location distribution of the defects.
6. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The process involves identifying high-incidence areas where the defect density exceeds a preset density threshold based on the preliminary defect location distribution, extracting local grayscale features from these high-incidence areas, and if the local grayscale features are below a preset grayscale threshold, then adaptively enhancing the light source brightness in these high-incidence areas to obtain an optimized defect distribution map. This includes: Based on the preliminary location and distribution of the defects, the defect density in each region is calculated, and the region where the defect density exceeds a preset density threshold is identified as the high-incidence region. Local grayscale features are extracted from the high-incidence area, and the grayscale mean of the area is calculated. If the grayscale mean is lower than a preset grayscale threshold, the brightness of the light source is adjusted by increasing the preset brightness step size until the grayscale mean of the high-incidence area reaches the preset grayscale threshold. The edge details of the image of the high-incidence area after adjusting the light source brightness are enhanced to obtain the optimized defect distribution map.
7. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The step involves calculating the defect distribution density based on the optimized defect distribution map. If the defect distribution density exceeds a preset density range, a parameter adjustment instruction is generated, including: Based on the optimized defect distribution map, the grid is divided according to the preset area units, and the defect density value of each grid unit is calculated. The defect distribution density is generated based on the defect density value of each grid cell; If the defect distribution density value of any grid cell exceeds the preset density range, it is determined to be an abnormal state. Based on the degree of deviation of the abnormal state, the corresponding light source and acquisition parameter adjustment amount is determined, and the parameter adjustment instruction containing the grid cell position information is generated.
8. The machine vision-based defect detection method for tempered glass according to claim 1, characterized in that, The step of updating the light source angle parameters and the acquisition device sensitivity parameters according to the parameter adjustment command to obtain optimized acquisition data for the next acquisition cycle includes: Based on the target position information in the parameter adjustment command, determine the corresponding light source angle compensation value and sensitivity compensation value; The illumination angle of the light source is updated to the light source angle compensation value, and the sensitivity parameters of the acquisition device are updated to the sensitivity compensation value; Based on the updated light source angle parameters and sensitivity parameters, the next cycle of image acquisition is performed to obtain the optimized acquisition data.
9. A machine vision-based defect detection system for tempered glass, characterized in that, include: The image acquisition module is used to acquire initial images of tempered glass under illumination from multiple angles of light sources. The image processing module is used to preprocess the initial image to obtain an edge-enhanced image; The interference removal module is used to extract pixel features under a specific spectral band based on the edge enhancement image, identify and remove reflective interference areas based on the pixel features, and obtain a de-interference base image. The defect localization module is used to dynamically scan the light source angle of the interference-free base image, adjust the sensitivity of the acquisition device, obtain light and shadow change data at different angles, extract local contrast features based on the light and shadow change data, determine the location coordinates of potential defects based on the local contrast features, and obtain the preliminary defect localization distribution. The image enhancement module is used to determine the high-incidence areas where the defect density exceeds a preset density threshold based on the preliminary location and distribution of the defects, extract local grayscale features from the high-incidence areas, and if the local grayscale features are lower than the preset grayscale threshold, then adaptively enhance the light source brightness of the high-incidence areas to obtain an optimized defect distribution map. The parameter generation module is used to calculate the defect distribution density based on the optimized defect distribution map. If the defect distribution density exceeds the preset density range, a parameter adjustment instruction is generated. The parameter update module is used to update the light source angle parameters and the sensitivity parameters of the acquisition device according to the parameter adjustment instructions, so as to obtain optimized acquisition data for the next acquisition cycle.
