Glass key bubble detection method and device based on optical recognition

By employing dual illumination modes and dynamic masking technology, the problem of distinguishing between internal bubbles and surface dust in glass button bubble detection has been solved, achieving high-precision bubble recognition and reducing the false judgment rate, thereby improving production efficiency.

CN121830727APending Publication Date: 2026-04-10CONHUI HUIZHOU SEMICON
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing glass button bubble detection technologies struggle to distinguish between internal bubbles and surface dust, and are susceptible to misjudgment due to refraction interference from raised edges, affecting detection accuracy and cost.

Method used

By employing a dual illumination mode (transmission and reflection illumination) combined with dynamic masking technology, an effective detection mask is generated by identifying the contour area of ​​the glass button. The features of the bubble under transmission and reflection are used to extract features and calculate the spatial position overlap, thereby achieving accurate bubble identification.

Benefits of technology

It significantly improves the accuracy and stability of bubble detection in glass buttons, reduces the false judgment rate, and increases production efficiency and yield.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121830727A_ABST
    Figure CN121830727A_ABST
Patent Text Reader

Abstract

The invention provides a glass key bubble detection method and device based on optical recognition, and relates to the technical field of glass key manufacturing, and the method comprises the following steps: controlling an imaging device to shoot a glass key in a first illumination mode and a second illumination mode, and obtaining a first image and a second image; recognizing a contour area of the glass key according to the first image, and generating an effective detection mask for removing edge interference based on the contour area; performing feature extraction on the first image and the second image in the range of the effective detection mask to obtain a first defect candidate set and a second defect candidate set; calculating the spatial position overlap ratio of the first defect candidate set and the second defect candidate set; and if a target object with matched space coordinates exists in the first defect candidate set and the second defect candidate set, judging that the target object is a bubble defect in the glass key.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of glass button manufacturing, and particularly relates to a glass button bubble detection method and device based on optical recognition. BACKGROUND

[0002] With the upgrading of the appearance process of consumer electronic products, the application of integrated glass panels is becoming more and more widespread. Among them, the glass button directly processed on the surface of the glass substrate and having a touch function has become a landmark design of high-end products.

[0003] However, in the production process of the glass button, internal defects such as bubbles and stones, and surface defects such as dust and oil stains are inevitably generated. At present, for the finished product quality detection of the glass button, there are mainly the following two technical problems: The existing optical detection technology usually adopts a single light mode (such as pure backlight or pure front light). In the single backlight mode, the bubbles in the glass and the dust on the surface may both appear as "black spots"; in the single front light mode, the bubbles and the dust may both appear as "bright spots". Since the glass is a transparent medium, the light will penetrate the substrate, making it difficult for machine vision to judge through a single image whether the defect is in the interior of the glass (such as an irreparable bubble) or on the surface of the glass (such as erasable dust). This often leads to the false judgment of surface dirt as bubbles for scrapping, greatly increasing the production cost.

[0004] Unlike traditional flat glass, the glass button has a three-dimensional convex structure, and the edges thereof usually have chamfers (R corners) or slopes. When light is irradiated to these edge regions, strong refraction and reflection occur, forming high-contrast light spots or shadows (artifacts) on the image sensor. The existing planar detection algorithm is difficult to automatically distinguish these normal structural optical phenomena from real defects, often misreporting the refracted light of the button edge as an edge bubble or damage, seriously affecting the accuracy of the detection.

[0005] Therefore, it is necessary to improve the existing glass button bubble detection technology to overcome the defects of the prior art. SUMMARY

[0006] To overcome the problems in the related art, the purpose of the present application is to provide a glass button bubble detection method based on optical recognition, which combines the dual light modes of transmission and reflection, and uses dynamic mask technology to shield edge interference, to overcome the problems that the prior art cannot distinguish between internal bubbles and surface dust, and is easily interfered by the refraction of the convex edge of the glass button to produce false judgments.

[0007] A glass button bubble detection method based on optical recognition, comprising the following steps: The imaging device controls the glass button to be photographed in a first illumination mode and a second illumination mode respectively, and obtains a first image and a second image; wherein the first illumination mode is transmission illumination, and the second illumination mode is reflection illumination; According to the first image, a contour region of the glass button is identified, and an effective detection mask removing edge interference is generated based on the contour region; Within the range of the effective detection mask, feature extraction is performed on the first image and the second image respectively, and a first defect candidate set and a second defect candidate set are obtained; the first defect candidate set contains dark field feature points in the first image, and the second defect candidate set contains bright field feature points in the second image; The spatial position coincidence degree of the first defect candidate set and the second defect candidate set is calculated; If it is determined according to the spatial position coincidence degree that there is a target object with spatial coordinate matching in the first defect candidate set and the second defect candidate set, it is determined that the target object is a bubble defect inside the glass button.

[0008] Further, the first illumination mode adopts a parallel backlight source, and the light direction vertically penetrates the glass button; the second illumination mode adopts a low-angle ring light source, and the angle between the light direction and the surface of the glass button is less than a preset angle threshold; The step of obtaining the first image and the second image specifically includes: The parallel backlight source is controlled to be turned on, and the first image is collected through a telecentric lens, at this time the bubble presents a black closed feature; The low-angle ring light source is controlled to be turned on, and the second image is collected through the telecentric lens, at this time the bubble and surface impurities present a high-light scattering feature.

[0009] In the prior art, the illumination is usually performed by using a diffuse reflection backlight or a common coaxial light source. The diffuse reflection light can bypass the bubbles from multiple angles, resulting in blurred edges of the bubbles and low contrast. High-angle light is easy to illuminate the flat area of the glass surface, increasing the background noise. The present scheme adopts a parallel backlight source combined with a low-angle ring light source. The light emitted by the parallel backlight source has extremely high parallelism (small divergence angle). When the light passes through the bubbles inside the glass, the light will be severely deflected due to the abrupt change of the refractive index of the bubble wall, and thus cannot enter the lens, thereby forming a "black ring" feature with extremely sharp edges and transparent center on the image sensor, which significantly enhances the imaging contrast of the tiny bubbles (<0.1 mm). The low-angle ring light is nearly horizontally incident on the glass surface. The normal flat glass surface only reflects the light forward without entering the vertically arranged lens (the background is black). Only when encountering the three-dimensional structure of bubbles or impurities, the light will be scattered and enter the lens upward. This specific light path combination design makes the bubble defects "black as a pure black" in the transmission diagram and "bright as a bright light" in the reflection diagram, significantly improves the signal-to-noise ratio of the image, and solves the technical problem that the tiny bubbles are difficult to be captured by the camera under the common light source.

[0010] Further, the step of identifying the contour region of the glass key according to the first image and generating an effective detection mask removing edge interference based on the contour region specifically comprises: performing binaryzation processing on the first image to extract the outer edge contour of the glass key; calculating the geometric center and fitting boundary of the outer edge contour; taking the geometric center as a reference, the fitting boundary is inwardly retracted by a preset pixel distance to obtain an inwardly retracted contour; the preset pixel distance corresponds to the projection width of the chamfered or rounded region of the convex structure of the glass key on the imaging surface; determining the region inside the inwardly retracted contour as the effective detection mask, and setting the region outside the effective detection mask as a non-detection area.

[0011] The prior art often uses a fixed rectangular ROI (region of interest) for detection when processing different batches of glass products. However, due to the positional error of mechanical feeding, the position of the glass key on the carrier will shift slightly, and the fixed ROI is easy to cover the R-angle area of the key edge, causing the edge refracted light to be misjudged as a defect, or missing some areas due to the small ROI. The present scheme uses a mask generated by dynamically shrinking the contour, and by identifying the contour first and then calculating the center, an algorithm establishes a coordinate system that floats with the actual position of the product. The mapping relationship between the shrinkage pixel distance and the physical projection width of the glass key chamfer is established. Regardless of the product shift, the mask can always accurately cover the slope / chamfer area with strong refraction interference, while maximizing the detection area of the central plane. Eliminates the risk of misjudgment caused by insufficient positioning accuracy of the fixture, realizes adaptive detection of the maximum effective plane area of the glass key, eliminates the need for manual adjustment of the ROI position, and improves the automation adaptability of the production line.

[0012] Further, the step of respectively extracting features from the first image and the second image specifically includes: Within the effective detection mask range of the first image, extract connected domains with a gray value below a first preset threshold, and calculate the roundness of the connected domains, and retain connected domains with a roundness greater than a preset shape threshold as elements of the first defect candidate set; Within the effective detection mask range of the second image, extract connected domains with a gray value higher than a second preset threshold, and retain them as elements of the second defect candidate set.

[0013] The prior art often only relies on gray value (black or white) to judge defects, which is easily affected by scratches or irregular cotton fiber interference. The present scheme introduces roundness verification and double-threshold screening in the feature extraction stage. Due to the surface tension effect during bubble formation in a fluid, bubbles will inevitably exhibit a highly circular feature under parallel light projection; while stones or fiber debris inside the glass are usually irregular in shape. By setting a roundness threshold, non-bubble interference can be filtered out in terms of shape. In the reflection map, the gray value is required to be higher than a certain threshold, in order to confirm that the object has strong scattering characteristics, and to further exclude shallow water stains or oil prints (which usually have weak scattered light). Through the dual filtering of morphology and optical characteristics, the system can effectively distinguish "true bubbles" from "scratches, fibers" and other interference items, significantly improving the specificity and accuracy of the identification of specific defects (bubbles).

[0014] Further, if it is determined that there is a spatial coordinate matching target object in the first defect candidate set and the second defect candidate set according to the spatial position coincidence degree, then after determining that the target object is a bubble defect inside the glass key, the method further includes: If there is a target object in the second defect candidate set but no object with matching spatial coordinates in the first defect candidate set, the target object is determined to be dust or dirt on the surface of the glass button; If there is a target object in the first defect candidate set but no object with matching spatial coordinates in the second defect candidate set, the target object is determined to be an opaque impurity inside the glass button.

[0015] The prior art can generally only output an "NG (not qualified)" or "OK (qualified)" signal, and cannot inform the specific type of defect. For glass button production, surface dust can be wiped and repaired, while internal bubbles must be scrapped, and general alarms can lead to the misreporting of repairable products. The present scheme constructs a three-dimensional logical classification matrix. Only under reflection, under transmission, it is determined to be surface dust. Because dust is usually attached to the surface, and has good light transmission or is too small to block the backlight, but the surface roughness is high and the scattering is strong. Only under transmission, it is determined to be an opaque impurity. Because some black metal oxide impurities absorb light but do not reflect light. Both figures are determined to be bubbles. The detection device is given the ability to classify defects, so that the production line can take different strategies (such as prompting cleaning or executing material throwing) for different defects, thereby recovering products that are misjudged and scrapped due to surface dirt, greatly reducing production costs and improving the accuracy of good product rate statistics.

[0016] Further, the step of calculating the spatial position coincidence degree of the first defect candidate set and the second defect candidate set specifically includes: respectively acquiring the centroid coordinates of the first connected domain in the first defect candidate set and the centroid coordinates of the second connected domain in the second defect candidate set; calculating the Euclidean distance between the centroid coordinates of the first connected domain and the centroid coordinates of the second connected domain, and taking the Euclidean distance as a numerical value representing the spatial position coincidence degree; comparing the Euclidean distance with a preset matching tolerance value, if the Euclidean distance is less than the matching tolerance value, it is determined that the first connected domain and the second connected domain have a spatial position coincidence relationship.

[0017] In actual optical imaging, due to the different light source angles of the transmission light path (bottom incidence) and the reflection light path (side incidence), and the certain thickness and refractive index of the glass key itself, the imaging center coordinates of the same bubble in the two images may have a slight physical deviation (parallax). If a pixel-to-pixel AND operation is directly performed, the two sets may not be overlapped. The present scheme adopts a centroid Euclidean distance and tolerance matching algorithm, calculates the Euclidean distance of the centroids of the two connected domains, and allows a preset tolerance range (for example, 3-5 pixels), so that the algorithm can tolerate the slight misalignment of the images caused by the differences in the light paths, refractive deviation or mechanical vibration. The stability of the double-image fusion logic is enhanced, the misjudgment caused by the homonymy heterotopy phenomenon due to the optical and physical characteristics is prevented (that is, the same bubble is considered as two unrelated interference points by the system because the coordinates are not aligned), and the effective execution of the double light path detection logic is ensured.

[0018] The second purpose of the present application is to provide a glass key bubble detection device based on optical recognition, comprising: An image acquisition module controls the imaging device to capture the glass key in a first illumination mode and a second illumination mode to obtain a first image and a second image; wherein the first illumination mode is transmission illumination, and the second illumination mode is reflection illumination; A region processing module is used to identify the outline region of the glass key according to the first image, and generate an effective detection mask removing edge interference based on the outline region; A feature extraction module extracts features from the first image and the second image within the range of the effective detection mask to obtain a first defect candidate set and a second defect candidate set; the first defect candidate set contains dark field feature points in the first image, and the second defect candidate set contains bright field feature points in the second image; A defect judgment module calculates the spatial position coincidence degree of the first defect candidate set and the second defect candidate set, and determines that the target object in the first defect candidate set and the second defect candidate set matches the spatial coordinates if the spatial position coincidence degree is determined.

[0019] The third purpose of the present application is to provide an electronic device, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to realize the steps of the above method.

[0020] The fourth purpose of the present application is to provide a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to realize the steps of the above method.

[0021] The fifth object of the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method as described above.

[0022] The present application has the following advantages: The glass key bubble detection method based on optical recognition provided by the present application generates an effective detection mask that removes edge interference based on the contour region of the glass key identified from the first image, and constructs a dynamic shielding area at the algorithm level for the protruding structure unique to the glass key. Since the chamfer or slope of the edge of the glass key will inevitably cause refraction and artifacts of light, by generating an effective detection mask that is retracted, the edge refraction area that is prone to false positives can be excluded from the detection range, and only the core area is identified. This processing method fundamentally avoids the optical noise caused by the 3D structure being misjudged as a defect, significantly improving the stability of the detection.

[0023] At the same time, the spatial position coincidence degree of the first defect candidate set and the second defect candidate set is calculated by respectively acquiring the first image and the second image in the transmission illumination and the reflection illumination mode. In the transmission illumination (first illumination mode), the internal bubble will present a dark field feature (included in the first defect candidate set) due to refraction of light, but part of the opaque surface dust will also present a dark spot. In the reflection illumination (second illumination mode), the internal bubble will present a bright field feature (included in the second defect candidate set) due to light scattering, but the surface dust will also reflect light. The bubble must have both transmission light blocking / refraction characteristics and reflection scattering characteristics. By calculating the spatial coordinate matching of the two sets, only when a target object exhibits dark features in the transmission map and bright features in the reflection map, it will be judged as a bubble. This double verification logic can effectively eliminate interference items that are only black in transmission (such as opaque impurities) or only bright in reflection (such as surface shallow dirt), thereby greatly reducing the misjudgment rate. BRIEF DESCRIPTION OF DRAWINGS

[0024] Figure 1 is a schematic diagram of the glass key bubble detection method based on optical recognition provided in the present application; Figure 2 is a schematic diagram of the glass key bubble detection device based on optical recognition provided in the present application. DETAILED DESCRIPTION

[0025] Preferred embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.

[0026] Example 1 like Figure 1 , Figure 2 As shown, this embodiment provides a method for detecting air bubbles in glass buttons based on optical recognition. This method mainly operates in automated inspection systems that include image acquisition units (such as industrial cameras and matching light sources) and data processing units (such as industrial computers or embedded processors). The design logic of this method aims to solve the industry problem of difficulty in distinguishing internal air bubbles, surface dust, and edge refraction interference in transparent glass materials with three-dimensional convex structures.

[0027] When the detection process begins, the system needs to acquire two sets of image data reflecting the different optical properties of the glass button. Under the command of the control program, the imaging device quickly switches between two distinct illumination modes to continuously photograph the same glass button. One mode is set to transmitted illumination, which typically involves projecting light from the back of the glass substrate, allowing the light to penetrate the substrate and directly enter the camera lens. In this lighting environment, the light travels in a straight line through the uniform glass medium, resulting in a bright background. However, when the light encounters air bubbles inside the glass, the difference in refractive index between the air inside the bubble and the glass causes the light path to be deflected or blocked, resulting in the bubbles appearing as dark shadows or black spots in the image. The other mode is set to reflected illumination, where the light source is positioned above or around the glass button, illuminating the glass surface at a lower angle. In this dark environment, the smooth glass surface reflects light out of the lens's field of view, making the background appear black. Only when the light hits the three-dimensional interface of the bubbles or impurities inside the glass does a scattering effect occur, allowing some light to enter the lens and thus forming bright spots in the image.

[0028] Through the above acquisition process, the system obtained a first image (based on transmitted illumination) and a second image (based on reflected illumination). To ensure detection accuracy, the data processing unit does not immediately perform a blind search of the entire image, but prioritizes processing the first image to pinpoint the exact location of the glass button. Since the glass button is formed by etching or grinding, its edges often have chamfers (R-angles) with a certain slope or curvature. These edge areas will produce obvious black frames or halos under transmitted light due to strong refraction effects. If the algorithm directly performs full-image detection, it is very easy to misjudge these normal structural black frames as huge defects.

[0029] Contour recognition is performed on the first image to extract the physical boundaries of the glass buttons within the image. Based on this identified contour region, the system automatically generates an "effective detection mask" for subsequent processing. This mask is generated using an inward-shrinking logic, meaning it shrinks a certain distance towards the geometric center of the pattern, based on the identified contour boundary. This shrinkage distance is not arbitrarily set but is preset according to the projection width of the glass button's chamfered edge on the imaging plane, with the aim of precisely covering those optically unstable edge refraction areas. After this processing, the mask strictly divides the image into two regions: one is the effective detection area located inside the mask, representing the main viewing plane of the buttons; the other is the non-detection area located outside the mask, including the chamfered edges and background.

[0030] After defining a safe and effective detection mask area, the system scans and analyzes the first and second images in parallel or serially. Within the mask area of ​​the first image (transmission map), the algorithm searches for dark-field feature points with gray values ​​significantly lower than the background. These points represent all objects obstructing light propagation and may contain bubbles, opaque surface stains, or internal stones. The system records these suspicious points as the first defect candidate set. Simultaneously, within the mask area of ​​the second image (reflection map), the algorithm searches for bright-field feature points with gray values ​​significantly higher than the background. These points represent all objects causing light scattering and may also contain bubbles, surface dust, scratches, or fingerprints. The system records these points as the second defect candidate set.

[0031] At this point, neither set of images can accurately define the nature of the defect, because the transmission image cannot distinguish between bubbles and black spot impurities, and the reflection image cannot distinguish between bubbles and surface dust. To pinpoint the true "bubble," the system performs a crucial calculation of spatial alignment. This logic is based on the unique physical properties of a bubble: as a cavity existing inside the glass, it can form a dark shadow under transmitted light due to refraction, and a bright spot under reflected light due to scattering.

[0032] The system compares the spatial coordinates of each feature point in the first and second defect candidate sets. If a dark spot found in the first set has a corresponding bright spot in the second set, it indicates that the target object at that location possesses both "transmitted light blocking" and "reflected scattering" optical properties, and the system determines that the target object is a bubble defect inside the glass button. Conversely, if a feature point appears only in one set and cannot be found in the other, it is excluded and not identified as a bubble. For example, a spot that shines only in the reflection image but is invisible in the transmission image is often light dust on the surface, with good light transmission but a rough surface; a spot that appears black only in the transmission image but is not bright in the reflection image is often a flat impurity with light absorption.

[0033] Through this strict double-checking logic, the method of the embodiment can effectively eliminate false positives caused by surface dirt and edge structures in complex industrial field environments, and achieve high-precision automated detection of glass button bubbles.

[0034] Embodiment 2 As shown in Figure 1 , Figure 2 The embodiment provides a glass button bubble detection method based on optical recognition. The embodiment is further described based on embodiment 1, and focuses on the specific hardware architecture and image preprocessing algorithm used to achieve high signal-to-noise ratio imaging and edge interference resistance.

[0035] In the physical layer of the detection system, in order to overcome the perspective distortion problem caused by the three-dimensional convex structure of the glass button, the embodiment selects a double-telecentric lens as the imaging core. When shooting convex objects with thickness, ordinary industrial lenses will produce a parallax of near large and far small, which will cause the imaging of the top and bottom surfaces of the button to be unable to coincide, thereby making the edge unclear.

[0036] The double-telecentric lens has a double-telecentric optical path design on the object side and the image side, which can ensure that the magnification is constant within the depth of field regardless of the distance of the object. This feature is crucial to the scheme, as it ensures that the physical edge of the glass button is accurately and stably projected on the image sensor, providing a reliable geometric reference for the subsequent edge removal algorithm.

[0037] In the construction of the illumination subsystem, the embodiment discards the general white light illumination and instead uses a composite light path with a specific wavelength and a specific angle. For the first illumination mode (transmission illumination), the system is configured with a high-parallel blue backlight, whose emitted light wavelength is concentrated in the 460-470nm interval.

[0038] The reason for choosing blue light is that its wavelength is shorter and the diffraction effect is weaker, which can maintain better straight-line propagation characteristics when penetrating the glass medium. The light source is designed as a parallel light path. When the parallel light beam is vertically incident into the glass substrate, if it encounters an internal bubble, the light will be severely deflected due to the refraction of the bubble's spherical surface, and cannot enter the lens, thereby forming a black ring with high contrast and sharp edges in the bright background. If a general diffuse reflection backlight is used, the light will be diffracted around the bubble, causing the image to be blurred and making it difficult to capture small bubbles.

[0039] For the second illumination mode (reflective illumination), the system is configured with a low-angle red ring light source, which is installed close to the horizontal plane where the glass key is located, and the light incidence angle is close to 0 degree. Red light (wavelength about 620-630 nm) is selected to form a significant distinction with the blue backlight in the spectrum, facilitating subsequent possible spectral channel separation or time control.

[0040] Under this low-angle dark-field illumination, the smooth glass surface will totally reflect the light out of the lens field of view, keeping the background pure black; only when the light touches the three-dimensional interface of the bubble or the dust and scratches on the glass surface, diffuse reflection (scattering) will occur, guiding the red light to the lens. This design greatly suppresses the interference of the glass surface mirror reflection, making the defect points appear as bright spots in the dark background.

[0041] Based on the above high-precision imaging hardware, after obtaining the original image, the data processing unit executes a specific dynamic mask generation algorithm to solve the core pain point of edge artifacts. Since the edge of the glass key has been CNC chamfered or chemically etched, forming an R angle (round angle) or slope with a certain width. In transmission imaging, this R angle area acts like a lens, which will refract the backlight in all directions, resulting in a thick black shadow frame around the key outline. If you search for black points directly in the full image range, this normal structural black frame will be misjudged as a huge defect.

[0042] To accurately exclude this interference, the algorithm first performs binaryzation processing on the blue backlight image to extract the outermost contour of the glass key. Then, the algorithm calculates the geometric center of the contour and establishes a local coordinate system. The system presets an inward shrinkage distance, which corresponds to the physical projection width of the glass key edge R angle on the imaging target surface. For example, if the physical width of the key R angle is 0.2 mm, and the pixel equivalent of the camera is 10 μm / pixel, the system will set the inward shrinkage distance to 20 pixels (or even slightly redundant to 22 pixels to ensure safety). The algorithm uniformly shrinks the extracted outer contour inward by the above set pixel distance based on the geometric center, generating a new closed contour.

[0043] Finally, the system defines the area inside the inwardly shrunk contour as the effective detection mask (ROI), and forces all the annular areas outside the contour and between the contour and the mask to be zero (shielded). This processing process dynamically adapts to the slight positional offset of each glass key on the carrier, ensuring that regardless of how the product is placed, the system can accurately cut off the edge chamfer area with optical interference, and only the flat and optically uniform central area is retained for subsequent bubble feature extraction, thereby eliminating false positives caused by edge refraction at the source.

[0044] Example 3 AsFigure 1 、 Figure 2 The embodiment shown in FIG. 1 provides a glass button bubble detection method based on optical recognition. The embodiment is further described based on Embodiment 1. Through quantitative analysis and logical operation of multi-dimensional features, accurate classification and determination of internal bubbles, impurities and surface dust of the glass button are realized.

[0045] In the effective detection mask-determined range, feature extraction is performed on the first image (transmission illumination image). Due to the surface tension effect of bubbles in the glass melting forming process, the physical form usually presents a highly regular sphere. This characteristic is manifested as a nearly perfect circular projection in the two-dimensional transmission image. Based on this physical law, the image processing flow first performs low gray threshold segmentation on the pixels in the mask to extract all dark color connected domains that block the propagation of light. Then, morphological analysis is performed on each independent connected domain to calculate its circularity value. The formula for calculating the circularity value is usually defined as the ratio of the area to the square of the perimeter. A strict circularity screening threshold (for example, greater than 0.85) is set to retain only those connected domains with smooth outlines and close to circular as potential bubble objects, while interference items such as scratches and irregularly shaped fiber dust are filtered out at this stage. The screened dark field feature points are marked and stored in the first defect candidate set.

[0046] Feature extraction is performed on the second image (reflection illumination image). In this link, the focus is on the scattering effect of light. High gray threshold segmentation is performed on the pixels in the mask to extract all bright color connected domains with brightness values significantly higher than the background. In order to prevent false judgments caused by sensor noise or slight water marks, the brightness threshold is usually set at a high level (for example, above 200 in 255 gray levels), ensuring that the extracted objects have a strong scattering surface. All high-light feature points that meet the conditions are marked and stored in the second defect candidate set.

[0047] After obtaining the first set representing the light transmission blocking property and the second set representing the surface scattering property, the core classification and determination logic is realized through spatial coordinate matching operation. Considering the differences in optical and physical properties, the transmission light path is usually vertically incident from the bottom, while the reflection light path is obliquely incident from the side. In addition, the glass button itself has a certain thickness and refractive index, so the imaging center coordinates of the same physical defect in the two images often have a small nonlinear shift. In order to accommodate this physical parallax, instead of absolute pixel-to-pixel matching, the centroid Euclidean distance matching method is used.

[0048] Specifically, the geometric centroid coordinates of each connected domain in the first set and the geometric centroid coordinates of each connected domain in the second set are calculated respectively. The Euclidean distance between the pairs of centroid points is calculated by traversing the two sets. A matching tolerance radius (for example, 3 to 5 pixels) is preset, and if the calculated distance is less than the tolerance radius, it is determined that the two feature points belong to the same physical object, that is, the coincidence relationship of the spatial positions is established.

[0049] Based on the above matching results, the following three-dimensional logical judgment is performed: When a target object exists in both the first set and the second set, and the spatial coordinates satisfy the matching tolerance, it indicates that the object both blocks parallel light and produces strong scattering, which meets the optical characteristics of bubbles, and accordingly it is determined to be a bubble defect inside the glass key, and an NG signal is output.

[0050] When a target object only exists in the second set (reflective bright), but no matching item can be found in the first set (transmissive dark), it indicates that the object has surface roughness causing scattering, but its light transmission is good or the volume is too small to form obvious shadows, which meets the characteristics of surface dust or slight dirt, and accordingly it is determined to be surface dust, usually outputting a cleaning or ignoring signal, rather than directly scrapping.

[0051] When a target object only exists in the first set (transmissive dark), but is missing in the second set (reflective bright), it indicates that the object has strong light absorption ability but the surface does not reflect light, which meets the characteristics of metal oxide stones or black point impurities, and accordingly it is determined to be an opaque internal impurity, also outputting an NG signal.

[0052] Through this deep analysis scheme based on morphological screening, dual-spectrum logic and tolerance matching, the nature of the defect is restored, ensuring the uniqueness and accuracy of the detection results.

[0053] Embodiment 4 The embodiment provides a glass key bubble detection method and device based on optical recognition. The detection device mainly comprises four core parts of an image acquisition module, a region processing module, a feature extraction module and a defect judgment module, and each module is integrated and cooperatively works through an industrial control computer (IPC).

[0054] The image acquisition module is the visual perception end of the device, and the hardware core comprises a 5 million pixel global shutter black and white industrial camera, a 0.2X to 0.5X magnification double-telecentric lens, and a composite light source system.

[0055] In order to realize the differentiated optical imaging, the module integrates the first light source and the second light source. The first light source selects a blue parallel backlight source with a wavelength of 460-470 nm, which is arranged below the glass key carrier and emits a highly parallel transmitted light beam for capturing the refraction characteristics of the bubbles; the second light source selects a red low-angle ring light source with a wavelength of 620-630 nm, which is arranged above the glass key and close to the detection plane for capturing the scattering characteristics of the bubbles or impurities.

[0056] The image acquisition module controls the synchronization timing of the camera and the light source through a hardware trigger signal. In one detection cycle, the module first triggers the first light source to flash and synchronously exposes the camera to acquire the first image (transmission map); then after a microsecond interval, the first light source is turned off, the second light source is triggered to flash, and the camera is exposed again to acquire the second image (reflection map). This time-sharing flash mechanism ensures that the two light paths do not interfere with each other.

[0057] The region processing module is the interference shielding end of the device, mainly running in the memory of the processor. Its input end receives the first image obtained by the image acquisition module.

[0058] The module uses an edge detection algorithm (such as the Canny operator) to scan the first image and identify the black closed contour formed by the edge refraction of the glass key.

[0059] For the 3D convex structure (R angle or slope) unique to the glass key, the module reads the preset "inward shrinkage parameter" (this parameter corresponds to the projection width of the R angle on the image plane, for example, 20 pixels). The module takes the identified contour geometric center as the reference, and shrinks the contour boundary inward by the above parameter value to generate a binary mask (Mask) that does not include the edge region.

[0060] The module marks the region within the mask as the effective detection area, and marks the region outside the mask and the mask edge as the non-detection area, thereby physically shielding the optical artifacts caused by the key edge chamfer.

[0061] The feature extraction module is the feature quantization end of the device, which is used to process the first image and the second image in the effective detection area delineated by the region processing module in parallel.

[0062] For the first image (transmission map), the module searches for connected domains with a gray value below the preset dark threshold. In order to further distinguish bubbles from irregular scratches, the module embeds a morphological analysis unit to calculate the roundness value of the connected domain, and only the connected domain with a roundness greater than 0.85 and an area meeting the standard is marked as the "first defect candidate set (dark field set)".

[0063] For the second image (reflection image), the module searches for connected domains with gray value higher than a preset bright threshold, extracts all high-light nodes with light scattering, and marks them as "second defect candidate set (bright field set)".

[0064] The defect determination module is the decision output end of the device, which performs the final logical operation.

[0065] The module reads the centroid coordinates of all feature points in the first defect candidate set and the second defect candidate set. Considering the slight parallax caused by the difference in light path, the module introduces a Euclidean distance tolerance algorithm (for example, set the tolerance radius R = 5 pixels) when comparing.

[0066] The logical determination is as follows: If the distance between a point in the first set and a point in the second set is less than the tolerance radius, that is, it meets the condition of "both blocking transmitted light and reflecting scattered light", the module determines that the object is an internal bubble of the glass key, and generates an NG signal.

[0067] If there is only a high-light object in the second set, and there is no corresponding dark point in the first set, the module determines it as surface dust, and generates a cleaning signal or a pass signal.

[0068] If there is only a dark point in the first set, and there is no corresponding bright point in the second set, the module determines it as an opaque impurity, and generates an NG signal.

[0069] The module finally sends the determination result to the PLC controller through the I / O interface, and drives the rejection mechanism to sort the glass keys containing bubbles or impurities to the waste area.

[0070] Through the close cooperation of the above four modules, the device described in the embodiment can automatically and accurately complete the quality detection of the glass key, effectively solving the misjudgment and omission problems caused by the large edge interference and difficult defect classification of traditional equipment.

[0071] Embodiment 5 The embodiment provides an electronic device, which comprises a memory and a processor. The memory is used to store a computer program, and the processor is used to run the computer program. When the processor executes the computer program, the optical recognition based glass key bubble detection method of the above-mentioned embodiment is realized.

[0072] Embodiment 6 The embodiment provides a computer readable storage medium (such as a U disk, a hard disk, an optical disk or a cloud server storage space), which stores a computer program. When the computer program is executed by the processor of the computer, the computer executes the optical recognition based glass key bubble detection method of the above-mentioned embodiment.

[0073] Embodiment 7 The embodiment provides a computer program product comprising a computer program. The computer program is executed by a processor to implement the optical recognition-based glass key bubble detection method of the above embodiment.

[0074] The relative arrangement, numerical expressions, and numerical values of the components and steps set forth in the embodiments are not intended to limit the scope of the present application, unless otherwise specifically stated. In all the examples shown and discussed herein, any specific value should be interpreted as merely exemplary, and not as a limitation. Therefore, other examples of the exemplary embodiments can have different values. It should be noted that similar reference numbers and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it need not be further discussed in subsequent drawings.

[0075] In addition, it should be noted that the use of the terms "first", "second", and the like, are used to distinguish one item from another, and do not necessarily have a special meaning, unless otherwise stated. Therefore, they should not be interpreted as limiting the scope of protection of the present application.

[0076] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. The present application can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A glass key bubble detection method based on optical recognition, characterized by, The method comprises the following steps: controlling the imaging device to capture the glass key under a first illumination mode and a second illumination mode respectively to obtain a first image and a second image; the first illumination mode is transmission illumination, and the second illumination mode is reflection illumination; identifying a contour region of the glass key according to the first image, and generating an effective detection mask removing edge interference based on the contour region; performing feature extraction on the first image and the second image respectively within the range of the effective detection mask to obtain a first defect candidate set and a second defect candidate set; the first defect candidate set contains dark field feature points in the first image, and the second defect candidate set contains bright field feature points in the second image; calculating the spatial position coincidence degree of the first defect candidate set and the second defect candidate set; if it is determined according to the spatial position coincidence degree that there is a target object with spatial coordinate matching in the first defect candidate set and the second defect candidate set, then judging that the target object is a bubble defect inside the glass key.

2. The glass key bubble detection method based on optical recognition according to claim 1, characterized in that: the first illumination mode adopts a parallel backlight source, and the light direction is perpendicular to the glass key; the second illumination mode adopts a low-angle ring light source, and the angle between the light direction and the surface of the glass key is less than a preset angle threshold; the step of obtaining the first image and the second image specifically comprises: controlling the parallel backlight source to be turned on, and capturing the first image through a telecentric lens, at this time the bubble presents as a black closed feature; controlling the low-angle ring light source to be turned on, and capturing the second image through the telecentric lens, at this time the bubble and surface impurities present as high-brightness scattering features.

3. The glass key bubble detection method based on optical recognition according to claim 1, characterized in that: the step of identifying the contour region of the glass key according to the first image, and generating an effective detection mask removing edge interference based on the contour region specifically comprises: performing binaryzation processing on the first image to extract the outer edge contour of the glass key; calculating the geometric center and fitting boundary of the outer edge contour; taking the geometric center as a reference, the fitting boundary is inwardly contracted by a preset pixel distance to obtain an inwardly contracted contour; the preset pixel distance corresponds to the projection width of the chamfer or round corner region of the convex structure of the glass key on the imaging surface; the region inside the inwardly contracted contour is determined as the effective detection mask, and the region outside the effective detection mask is set as a non-detection area.

4. The glass key bubble detection method based on optical recognition according to claim 1, characterized in that: the step of performing feature extraction on the first image and the second image respectively specifically comprises: within the effective detection mask range of the first image, extracting connected domains with a gray value lower than a first preset threshold, and calculating the circularity of the connected domains, and retaining connected domains with a circularity greater than a preset shape threshold as elements of the first defect candidate set. In the effective detection mask range of the second image, a connected domain with a gray value higher than a second preset threshold is extracted as an element of the second defect candidate set.

5. The optical recognition-based glass key bubble detection method according to claim 1, wherein: after determining that the target object is a bubble defect inside the glass key according to the spatial position coincidence degree, the method further comprises: if there is a target object in the second defect candidate set but no object with a spatial coordinate matching the target object in the first defect candidate set, it is determined that the target object is dust or dirt on the surface of the glass key; if there is a target object in the first defect candidate set but no object with a spatial coordinate matching the target object in the second defect candidate set, it is determined that the target object is an opaque impurity inside the glass key.

6. The optical recognition-based glass key bubble detection method according to any one of claims 1 to 5, wherein: the step of calculating the spatial position coincidence degree of the first defect candidate set and the second defect candidate set specifically comprises: obtaining the centroid coordinates of a first connected domain in the first defect candidate set and the centroid coordinates of a second connected domain in the second defect candidate set, respectively; calculating the Euclidean distance between the centroid coordinates of the first connected domain and the centroid coordinates of the second connected domain, and taking the Euclidean distance as a numerical value representing the spatial position coincidence degree; comparing the Euclidean distance with a preset matching tolerance value, and if the Euclidean distance is less than the matching tolerance value, it is determined that the first connected domain and the second connected domain have a spatial position coincidence relationship.

7. An optical recognition-based glass key bubble detection device, characterized by, comprises: an image acquisition module configured to control an imaging device to capture a glass key under a first illumination mode and a second illumination mode to obtain a first image and a second image, wherein the first illumination mode is transmission illumination and the second illumination mode is reflection illumination; a region processing module configured to identify a contour region of the glass key according to the first image, and generate an effective detection mask removing edge interference based on the contour region; a feature extraction module configured to perform feature extraction on the first image and the second image within the range of the effective detection mask to obtain a first defect candidate set and a second defect candidate set, wherein the first defect candidate set contains dark field feature points in the first image and the second defect candidate set contains bright field feature points in the second image; a defect determination module configured to calculate a spatial position coincidence degree of the first defect candidate set and the second defect candidate set, and determine that a target object in the first defect candidate set and the second defect candidate set is a bubble defect inside the glass key according to the spatial position coincidence degree.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method according to any one of claims 1 to 6 when executing the program.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program, which when executed by the processor, implements the steps of the method as claimed in any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, The computer program, which when executed by the processor, implements the steps of the method as claimed in any one of claims 1 to 6.