Visual analysis-based keycap detection method, terminal equipment and storage medium

By combining 3D surface data and a programmable polarized light source, the reflection interference of keycaps is separated in real time, enabling accurate detection of keycap surface texture and defects. This solves the problem of reflection interference under complex curvature and improves the accuracy and efficiency of detection.

CN121767346AInactive Publication Date: 2026-03-31SHENZHEN VISION MFG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-09
Publication Date
2026-03-31
Estimated Expiration
Not applicable · inactive patent

Smart Images

  • Figure CN121767346A_ABST
    Figure CN121767346A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of visual analysis, in particular to a keycap detection method based on visual analysis, terminal equipment and a storage medium. According to the keycap detection method based on visual analysis, by obtaining millimeter-level precision three-dimensional curved surface data of a keycap, a programmable polarization ring light source is dynamically controlled to output a polarized light sequence optimized in real time based on curvature change; synchronously acquiring a polarization image sequential sequence; meanwhile, a reflection area prediction mask is generated in combination with curvature gradient and material optical characteristics, reflection interference is thoroughly stripped through pixel level difference calculation, and real surface texture and defect characteristics are accurately extracted; and finally, normal vector space deviation calculation and multi-scale texture template matching are performed on the feature region in a three-dimensional coordinate system, geometric deformation milliscale positioning and texture defect accurate identification are realized, the problem of defect missing detection caused by key cap curved surface strong reflection interference is solved, and the detection reliability of a complex curved surface is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual analysis technology, specifically to a keycap detection method, terminal device, and storage medium based on visual analysis. Background Technology

[0002] During keyboard production, high-precision visual inspection is required to detect geometric deformations, texture defects, and injection molding flaws on the keycap surface. Current technologies face two main bottlenecks: first, the reflective properties of the keycap's curved surface cause strong reflection interference when industrial cameras capture images, obscuring the true surface features; second, traditional fixed-angle polarized light sources are difficult to adapt to the complex curvature changes of keycaps, leaving reflective artifacts in areas of abrupt curvature changes (such as character edges and corners), leading to missed defects. This is especially true for multi-material composite keycaps, where differences in their optical properties further worsen the reflection suppression effect. Summary of the Invention

[0003] The purpose of this invention is to provide a keycap detection method, terminal device, and storage medium based on visual analysis to solve the problems mentioned in the background art. Specific technical problems include how to dynamically generate a polarized lighting scheme adapted to the curvature and material properties of the keycap surface, and simultaneously fuse three-dimensional surface data to separate reflective interference areas in real time, thereby solving the technical problem of accurately extracting real surface textures and minute defects under strong reflective environments.

[0004] To achieve the above objectives, one of the objectives of this invention is a keycap detection method based on visual analysis, comprising the following method steps: S1. Based on the precise mesh model of the keycap surface, three-dimensional surface data with millimeter-level precision is generated. This three-dimensional surface data includes a curvature gradient distribution map recorded through topological mapping and material physical property codes that identify material categories and optical property parameter indices. The curvature gradient distribution map accurately describes the normal vector angle change information of each micro-unit on the keycap surface, and the material physical property codes are associated with the material optical property parameter index of the keycap body, providing a geometric and physical property basis for modeling reflection behavior.

[0005] S2. The programmable polarization ring light source is activated to execute a phased polarization angle time-series cyclic switching scheme. First, a basic polarization angle combination containing three orthogonal polarization directions is output. Then, based on the curvature gradient distribution map of the 3D surface data, highly reflective areas are identified, and supplementary polarization angles are dynamically added to form enhanced polarization angle combinations. This polarization angle sequence generates an adaptive sequence in real time according to the surface curvature change rate. Simultaneously, an industrial camera is triggered to acquire keycap polarization images under each polarization light illumination state, generating a time-series image sequence. At the same time, based on the curvature gradient distribution map of the 3D surface data and the material physical property encoding, combined with the material optical property parameter index, a 2D grayscale image marking the highly reflective area is generated as a reflective area prediction mask. The time-series image sequence and the reflective area prediction mask are subjected to pixel-level subtraction processing, and the predicted reflective interference pixels are compared and filtered point by point to completely separate the feature areas containing only the real surface texture, geometric deviations, and defects.

[0006] S3. Establish a geometric feature space transformation mechanism to map real surface feature regions back to the coordinate system of 3D curved surface data. Use inverse topological mapping to accurately align 2D pixel coordinates with the micro-units of the precision mesh model on the keycap surface. Construct a local curvature anomaly judgment model based on the normal vector angle change information of the curvature gradient distribution map. Calculate the spatial deviation angle between the actual normal vector and the theoretical normal vector of each micro-unit. When the deviation exceeds a preset threshold, automatically mark injection molding deformation or structural warping defects. At the same time, perform pixel grayscale multi-scale decomposition on the feature region. Combine the material optical property parameter index to dynamically generate a texture reference template. Accurately identify abnormal areas of material reflection characteristics through template matching and local contrast enhancement operations, and complete the synchronous analysis of geometric deformation and texture defects.

[0007] The second objective of this invention is to provide a terminal device, including a processor and a memory, wherein the memory stores a computer program, and when the program is executed, it implements a keycap detection method based on visual analysis.

[0008] The third objective of this invention is to provide a storage medium that stores a computer program, which, when executed, implements a keycap detection method based on visual analysis.

[0009] Compared with the prior art, the beneficial effects of the present invention are: By leveraging the synergistic effect of adaptive polarization illumination timing and reflection behavior modeling driven by 3D surface data, interference from keycap surface reflections is eliminated, significantly improving the completeness of real surface feature extraction. Combining multi-dimensional analysis of material optical properties and curvature gradients, millimeter-level detection of geometric deformation and precise localization of texture defects are simultaneously achieved, reducing the false detection and false negative rates of complex curved keycaps. The system response speed is improved due to adaptive optimization of polarization angle, meeting the inspection needs of high-speed production lines. Attached Figure Description

[0010] Figure 1This is a schematic diagram of the overall method of the present invention. Detailed Implementation

[0011] The technical solutions in 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.

[0012] Next, please refer to Figure 1 One of the objectives of this embodiment is a keycap detection method based on visual analysis, which includes the following steps: S1. Obtain the three-dimensional surface data of the keycap to be tested; S2. Start the programmable polarized ring light source to output dynamically changing combined polarized light to irradiate the keycap surface in a preset time sequence. Under each polarized light irradiation state, the industrial camera is synchronously triggered to collect polarized images of the keycap and generate a time sequence image sequence. At the same time, a surface reflection behavior model is established based on the three-dimensional curved surface data to output a reflection area prediction mask. The time sequence image sequence and the reflection area prediction mask are differentially calculated to separate the real surface feature area. S3. Perform defect detection operations in the actual surface feature area.

[0013] The specific process of the above steps is as follows: S1. The three-dimensional surface data of the keycap under test is obtained by directly calling the computer-aided design model database interface. This data serves as the core input of the entire optical inspection process, providing a precise benchmark for subsequent surface reflection behavior modeling and polarized illumination timing design. Specifically, this three-dimensional surface data is generated by converting a precise mesh model of the keycap surface. The precise mesh model of the keycap surface is the source of the three-dimensional surface data, which is converted into structured data containing millimeter-precision curvature gradient distribution maps and material physical property codes through topological mapping. Millimeter-precision curvature gradient distribution maps comprehensively record the normal vector angle changes of each micro-unit on the keycap surface through topological mapping, directly describing the directional gradient characteristics of the surface geometry in space; material physical property encoding clearly identifies the material category of the keycap body and its corresponding optical property parameter index, covering the definition of the material's reflection and scattering behavior of light; the three-dimensional surface data serves as the sole input source for the surface reflection behavior model, supporting three key applications, including: First, the information on the change in normal angle in the curvature gradient distribution map will serve as the basis for calculating the adaptive polarization angle sequence in the time series of the programmable polarized ring light source, enabling dynamically changing combined polarized light to dynamically adjust the basic polarization angle combination and the enhanced polarization angle combination based on the actual normal distribution. Second, the material physical property encoding will directly participate in the call to the optical characteristic parameter index, providing a material reflection characteristic benchmark for the surface reflection behavior model. Finally, the geometric spatial structure benchmark constructed from the overall 3D data ensures that the reflection area prediction mask output by the model can accurately correspond to the actual reflection area in the subsequent time series image sequence, ensuring millimeter-level geometric consistency in the separation of real surface feature areas during differential calculation. The entire data acquisition process strictly ensures that the data interface of the output matches that of subsequent steps, allowing the curvature gradient distribution map and material property encoding to be seamlessly integrated into the polarization optimization strategy and mask generation process.

[0014] S2. In the quality control stage of the keycap production system, a programmable polarized ring light source is activated to output dynamically changing combined polarized light in a preset timing sequence to irradiate the keycap surface. This preset timing design precisely arranges the light source output mode to ensure that each irradiation is adaptively optimized according to the keycap surface characteristics, thereby significantly improving the accuracy of optical inspection. Specifically, this includes: The dynamically changing combined polarized light includes a time-series cyclic switching scheme with a fixed polarization angle. The core logic of this time-series cyclic switching scheme is that the polarization angle direction is automatically optimized based on the normal distribution of the surface reflection behavior model. This means that the model reads the curvature gradient distribution map and normal vector angle change information in the 3D surface data, calculates the local normal direction of each micro-unit on the keycap surface, and thus adjusts the polarization angle in real time to match the actual geometry. This automatic optimization process avoids dependence on theoretical angles and directly achieves personalized configuration based on the actual data of the keycap, so that the polarized light can be incident on the keycap surface in the optimal direction. Furthermore, the dynamically changing combined polarized light is realized as an adaptive polarization angle sequence based on real-time calculation of the keycap surface curvature. That is, by analyzing the rate of curvature change of the 3D surface data in real time, the light source generates a continuous polarization angle sequence. For example, in areas where the curvature exceeds a preset curvature threshold, the switching frequency of the polarization angle is increased to suppress potential high-light interference. Simultaneously, the time-series cyclic switching scheme also employs a phased output strategy, including the orderly rotation of basic polarization angle combinations and enhanced polarization angle combinations. The basic polarization angle combination includes three orthogonal polarization directions, covering the main illumination modes and ensuring uniform illumination across the entire domain. The enhanced polarization angle combination specifically adds supplementary polarization angles to the highly reflective areas predicted by the surface reflection behavior model, such as adding multiple supplementary illumination directions at locations where the normal vector angle changes abruptly. This effectively compensates for local abnormal reflection points that the basic combination cannot cover. This time-series cyclic mechanism, combined with real-time surface curvature calculation results, ensures both the dynamic characteristics of the polarized light and improves the efficiency and repeatability of the entire illumination process. The surface reflection behavior model is based on the 3D surface data (including curvature gradient distribution map and material physical property encoding) output from the precise mesh model of the keycap surface. By calling the material optical property parameter index, it simulates the optical behavior of the keycap surface and generates a reflective area prediction mask (2D grayscale image). This mask accurately marks the areas that may produce strong reflection (such as areas with sudden changes in normal vector angle or high reflectivity). Its output is directly used for difference calculation with the time-series image sequence to ensure the millimeter-level consistency between the geometric spatial structure benchmark and the subsequent image acquisition. Ultimately, the preset timing output of this design not only reduces ambient light interference, but also provides highly structured and controllable lighting conditions for subsequent image acquisition and model analysis, enabling the comprehensive capture of the optical behavior of the keycap surface under complex curvature.

[0015] In step S2, when the programmable polarized ring light source outputs each dynamically changing combination of polarized light at a preset timing sequence to illuminate the keycap surface, an industrial camera trigger operation needs to be executed synchronously, specifically including: First, under each polarized light illumination condition, the industrial camera is precisely triggered to acquire polarized images of the keycaps. This process ensures that the exposure and angle of each image are strictly aligned with the corresponding polarized light condition, forming a time-series image sequence, which is a series of polarized images arranged in chronological order. This image sequence captures the real-time surface performance of the keycaps under various polarization angles. For example, the orthogonal illumination images in the basic combination will show the reflection characteristics in different directions, while the enhanced combination images will focus on recording the changing details of highly reflective areas. Simultaneously, based on the three-dimensional surface data provided by S1 (including millimeter-precision curvature gradient distribution maps and material physical property encoding), the establishment and output of the surface reflection behavior model are initiated. This model uses the input three-dimensional surface data to simulate the optical behavior of the keycap surface, and combines the material category and its material optical property parameter index to generate a reflective area prediction mask. This mask is a two-dimensional grayscale image, which marks all areas on the keycap that produce strong reflections, such as those with sudden changes in normal vector angle or where the material reflectance coefficient is greater than a preset coefficient threshold. Next, the temporal image sequence is compared with the predicted mask for reflective areas using differential calculation. This differential calculation employs pixel-level subtraction, comparing the acquired actual polarized image sequence with the predicted mask point by point to separate the real surface feature regions. Specifically, the differential calculation process filters out predicted reflective interference pixels in the mask, retaining the physical state data of the keycap surface, including the real surface texture, defects, and geometric deviations, such as micro-marks or flaws on the keycap surface. This ensures that the detection targets only the real physical state of the keycap, rather than optical reflection artifacts. Ultimately, through this synchronous processing, the combination of time-series image generation and differential calculation not only efficiently eliminates noise caused by illumination, but also enhances the ability to identify subtle surface features in quality control, providing a reliable basis for subsequent keycap quality standard evaluation.

[0016] S3. Based on the actual surface feature area output by S2, perform defect detection. The core of this operation is to fully utilize the pure surface information obtained after differential calculation, that is, the physical state data of the keycap surface after removing reflective interference. The specific detection process is as follows: A geometric feature space transformation mechanism is established to map the real surface feature region back to the S1 three-dimensional surface data coordinate system, so that the two-dimensional pixel coordinates of the region are precisely aligned with the micro-units of the keycap surface precision mesh model. This mapping transformation relies on the normal vector angle change information recorded in the curvature gradient distribution map. The planar image coordinates of the defect region are converted into three-dimensional space coordinates through an inverse topological mapping algorithm, ensuring that subsequent analysis is always based on the original surface reference with millimeter-level precision. The geometric feature space transformation mechanism is constructed by calling the three-dimensional surface data provided by S1 (including millimeter-level precision curvature gradient distribution map and material physical property encoding). Its core process is as follows: Using the normal vector angle change information recorded in the curvature gradient distribution map as the spatial transformation benchmark, the inverse topological mapping algorithm is used to reverse map the two-dimensional real surface feature area (pixel data after removing reflective interference) output by S2 to the coordinate system of the keycap surface precision mesh model. This process enables each pixel in the real surface feature area to accurately correspond to a specific micro-unit on the three-dimensional curved surface, and finally achieves millimeter-level spatial alignment between the defect detection area and the original three-dimensional curved surface data, laying a geometric consistency foundation for geometric deformation detection and material correlation evaluation.

[0017] Based on spatial alignment, a multi-dimensional joint judgment of defect features is performed, including geometric deformation detection and texture defect analysis, wherein: Geometric deformation detection: Based on the information of normal vector angle change, a local curvature anomaly judgment model is established. The spatial deviation angle between the actual normal vector and the theoretical normal vector (from 3D surface data) of each micro-unit is calculated. When the deviation exceeds the preset threshold, it is marked as injection molding deformation or structural warping defect, such as distortion at the edge of the keycap or the interface of the curved surface. Texture defect analysis: Multi-scale decomposition of pixel grayscale distribution in real surface feature areas, combined with optical characteristic parameter index in material physical property encoding, dynamically generating material-related texture reference templates; through template matching and local contrast enhancement algorithms, identifying abnormal areas that do not conform to material reflective properties, such as scratches (showing continuous directional grayscale abrupt changes) or pits (causing local scattering property attenuation). Based on the combined results of geometric deformation detection and texture defect analysis, three-dimensional feature fusion is performed in the surface texture coordinate space. For example, the gray-level anomaly area of ​​the scratch is correlated with the change in the normal vector angle at its location. The consistency of the defect in the geometric and optical dimensions is verified by the spatial convolution kernel to avoid misjudging the inherent texture of the material. The final output includes an inspection report containing the defect type, spatial location, and severity level. Each defect is labeled with its three-dimensional coordinates in a precision mesh model on the keycap surface, and its material physical property codes are linked to perform a material compatibility assessment (such as the difference in scratch tolerance between matte and glossy materials). This inspection process inherits the millimeter-level curved surface benchmark of S1 and the differential optimization results of S2, ensuring that the quality control conclusions are entirely based on the actual physical characteristics of the keycap.

[0018] The second objective of this embodiment is to provide a terminal device, including a processor and a memory, wherein the memory stores a computer program, and when the program is executed, it implements a keycap detection method based on visual analysis, specifically including: The memory stores a computer program for a keycap inspection method based on visual analysis. When the program is executed by the processor, the terminal device acquires the three-dimensional surface data of the keycap to be tested, including a curvature gradient distribution map with millimeter-level precision and material physical property encoding. Then, a programmable polarized ring light source is activated to output dynamically changing combined polarized light at a preset time sequence to illuminate the keycap surface. The polarization angle direction is optimized in real time based on the curvature gradient distribution map to generate an adaptive polarization angle sequence. Under each polarized light illumination state, an industrial camera is simultaneously triggered to acquire polarized images of the keycap to generate a time-series image sequence. At the same time, a surface reflection behavior model is established based on the three-dimensional surface data to output a reflective area prediction mask, which is a two-dimensional grayscale image marking the strongly reflective area. Next, the time-series image sequence and the reflective area prediction mask are subjected to pixel-level subtraction difference calculation to filter out the predicted reflective interference pixels to separate the real surface feature area. Finally, a defect detection operation is performed on the real surface feature area, specifically including establishing a local curvature anomaly judgment model based on the normal vector angle change information to perform geometric deformation detection, and dynamically generating a texture reference template by multi-scale decomposition of pixel grayscale distribution combined with material optical property parameter indexing to perform texture defect analysis.

[0019] The third objective of this embodiment is to provide a storage medium for storing a computer program, which, when executed, implements a keycap detection method based on visual analysis, specifically including: The terminal device acquires the 3D surface data of the keycap under test, including a curvature gradient distribution map and material physical property encoding. Then, a programmable polarized ring light source is activated to output dynamically changing combined polarized light. The polarization angle direction is optimized in real-time based on the curvature gradient distribution map using a time-series cyclic switching scheme. Under each polarized light illumination, an industrial camera is simultaneously triggered to acquire polarized images and generate a time-series image sequence. Simultaneously, a reflection area prediction mask is generated based on the 3D surface data, which is a 2D grayscale image. Next, a pixel-level subtraction differential calculation is used to compare the time-series image sequence with the reflection area prediction mask to filter reflection interference and separate the real surface feature areas. Finally, a defect detection operation is performed. A geometric feature space transformation mechanism maps the real surface feature areas back to the 3D surface coordinate system, followed by geometric deformation detection to calculate spatial deviation angles, and texture defect analysis combined with material optical property parameter indexing to identify abnormal areas.

[0020] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely preferred examples and are not intended to limit the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.

Claims

1. A keycap detection method based on visual analysis, characterized in that, The methods and steps include the following: S1. Obtain the three-dimensional surface data of the keycap to be tested; S2. Start the programmable polarized ring light source to output dynamically changing combined polarized light to irradiate the keycap surface in a preset time sequence. Under each polarized light irradiation state, the industrial camera is synchronously triggered to collect polarized images of the keycap and generate a time sequence image sequence. At the same time, a surface reflection behavior model is established based on the three-dimensional curved surface data to output a reflective area prediction mask. The time sequence image sequence and the reflective area prediction mask are differentially calculated to separate the real surface feature area. S3. Perform defect detection operation in the actual surface feature area.

2. The keycap detection method based on visual analysis according to claim 1, characterized in that, The three-dimensional surface data is generated by converting a precise mesh model of the keycap surface, including a curvature gradient distribution map and material physical property encoding; The curvature gradient distribution map records the change information of the normal vector angle of each micro-unit on the keycap surface through topological mapping, and the material physical property encoding identifies the material category of the keycap body and its material optical property parameter index.

3. The keycap detection method based on visual analysis according to claim 1, characterized in that, The dynamically changing combined polarized light includes a time-series cyclic switching scheme with a fixed polarization angle. The polarization angle direction of this time-series cyclic switching scheme is optimized in real time based on the curvature gradient distribution map of the three-dimensional surface data, and an adaptive polarization angle sequence is generated according to the surface curvature change rate.

4. The keycap detection method based on visual analysis according to claim 3, characterized in that, The time-series cyclic switching scheme adopts a phased output strategy, including the orderly rotation of basic polarization angle combinations and enhanced polarization angle combinations; wherein the basic polarization angle combinations include three orthogonal polarization directions, and the enhanced polarization angle combinations add supplementary polarization angles for the highly reflective regions predicted by the surface reflection behavior model.

5. The keycap detection method based on visual analysis according to claim 1, characterized in that, The establishment of the reflective area prediction mask in step S2 is specifically as follows: Based on the curvature gradient distribution map and material physical property encoding of the three-dimensional surface data, combined with the material optical property parameter index, a two-dimensional grayscale image marking the highly reflective area is generated.

6. The keycap detection method based on visual analysis according to claim 1, characterized in that, The difference calculation in step S2 uses pixel-level subtraction to compare the temporal image sequence with the reflection area prediction mask point by point, filtering out the predicted reflection interference pixels to retain the real surface texture, defects and geometric deviation features.

7. The keycap detection method based on visual analysis according to claim 1, characterized in that, Step S3 specifically includes: A geometric feature space transformation mechanism is established to map the real surface feature region back to the coordinate system of the three-dimensional surface data, so that the two-dimensional pixel coordinates are aligned with the micro-units of the precision mesh model of the keycap surface; inverse topological mapping coordinate transformation is performed based on the normal vector angle change information of the curvature gradient distribution map.

8. The keycap detection method based on visual analysis according to claim 1, characterized in that, The defect detection operation includes geometric deformation detection and texture defect analysis, wherein the geometric deformation detection process specifically includes: A local curvature anomaly judgment model is established based on the information of normal vector angle change. The spatial deviation angle between the actual normal vector and the theoretical normal vector of the micro-unit is calculated. When the deviation exceeds the preset threshold, injection molding deformation or structural warping defects are marked. The process of texture defect analysis specifically includes: Multi-scale decomposition of pixel grayscale distribution in real surface feature areas is performed, and texture reference templates are dynamically generated by combining material optical property parameter indexes. Abnormal areas of material reflectivity are identified by template matching and local contrast enhancement.

9. A terminal device, comprising a processor and a memory, wherein the memory stores a computer program that, when executed, implements the keycap detection method based on visual analysis as described in any one of claims 1-8.

10. A storage medium storing a computer program that, when executed, implements the keycap detection method based on visual analysis as described in any one of claims 1-8.