A machine vision method for detecting distribution of a keyboard shaft lubricant
Patent Information
- Application Number
- CN202611261074.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-10-30
AI Technical Summary
但是键盘轴体使用的润滑脂或润滑油形态的润滑剂多为透明或半透明,视觉特征极弱,因此常规仅依靠单源RGB图像的检测方式,会存在难以准确识别键盘轴体润滑剂涂覆特征的现象,如会存在无法精准判别润滑剂涂覆区域与塑料基底,而引起的涂覆特征难以识别或识别精度低的问题,进而会导致键盘轴体润滑剂涂覆质量检测效果较差
[0009]有益效果:首先本发明提供的检测方法打破了传统单源RGB机器视觉检测的局限,一方面利用涂抹前后表面NIR(近红外)图像中同位置反射率进行对比的结果,精准识别润滑液漏涂区域,有效解决了透明或半透明润滑油视觉特征弱、RGB可见光图像难以精准捕捉识别的痛点,另一方面结合RGB转换得到的灰度图像进一步挖掘涂覆区域的灰度细节特征,补足了NIR图像仅能区分油脂有无、无法识别油脂涂覆状态的信息量短板,从而避免了单源检测的信息盲区;其次,本发明提供的检测方法在提取两类图像的涂覆区域分布特征时,完全贴合键盘轴体润滑剂的实际扩散分布规律,既结合漏涂区域的数量、面积、分布间隔精准评估涂覆连续性,又匹配润滑剂涂覆起伏产生的视觉阴影特征甄别涂覆不均区域,规避了轴体自身刚性结构带来的识别误判,最终得到远优于传统单源检测的润滑剂分布检测准确度;因此本发明提供的检测方法能够为键盘轴体生产环节提供更精准的润滑剂涂覆质量判定依据,进而能够为轴体的按键手感一致性、机械可靠性和生产质量稳定性提供更精准的质量控制支撑。
Smart Images

Figure CN123015498A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of machine vision technology, and more specifically to a machine vision detection method for the distribution of lubricant on keyboard switches. Background Technology
[0002] As the core functional component of a mechanical keyboard, the consistency of key feel, mechanical reliability, and long-term production quality stability of the keyboard switch are key quality control indicators in the keyboard manufacturing process. Lubricant, as a crucial medium inside the switch, not only plays a vital role in reducing frictional loss between components, but its actual distribution also directly determines the switch's motion characteristics. Therefore, lubricant coating distribution testing has become an indispensable and important step in the quality control of keyboard switch production.
[0003] Currently, the field of automated production is gradually adopting machine vision solutions to automate the inspection of lubricant distribution in keyboard switches. Industrial cameras capture the lubricant application within the keyboard switches, replacing traditional manual visual inspection and thus improving production inspection efficiency. Existing technologies typically use single-source RGB images for inspection. However, the grease or oil-based lubricants used in keyboard switches are mostly transparent or semi-transparent, with very weak visual characteristics. Therefore, conventional inspection methods relying solely on single-source RGB images often struggle to accurately identify the lubricant coating features. For example, they may fail to precisely distinguish the lubricant coating area from the plastic substrate, leading to problems with poor coating feature identification or low accuracy, resulting in poor quality inspection results for keyboard switch lubricant coating. Therefore, developing an accurate coating quality assessment method to improve the detection effect of keyboard switch lubricant coating quality has become an urgent problem to be solved. Summary of the Invention
[0004] To address the above problems, this invention provides a machine vision inspection method for the distribution of lubricant in keyboard switches, the specific technical solution of which is as follows:
[0005] One embodiment of the present invention provides a machine vision inspection method for the distribution of lubricant on keyboard switches, comprising the following steps:
[0006] By comparing the reflectance of pixels at the same position in the NIR images of the surface before and after coating, the missing coating areas are identified. Based on the number of missing coating areas, the size of a single missing coating area, and the overall interval distance of all missing coating areas, the continuity of the current keyboard switch lubricant coating is obtained.
[0007] Based on the frequency of grayscale occurrence of each grayscale pixel in the grayscale image of the coated surface, the degree of grayscale change of each grayscale pixel is obtained, and grayscale pixels whose grayscale change degree meets the threshold condition are selected to form grayscale change regions. Based on the distribution characteristics of the number of pixels at the edge of the grayscale change region and the chain of pixels with unchanged direction, the degree of shadow region feature of each grayscale change region is evaluated. Based on the degree of shadow region feature of each grayscale change region, the comprehensive grayscale of the corresponding grayscale change region is weighted and fused to obtain the uniformity of the current keyboard switch lubricant coating.
[0008] Based on the coating continuity and coating uniformity, a coating quality assessment value for the current keyboard switch surface lubricant is obtained, and the coating quality of the current keyboard switch lubricant is judged based on the coating quality assessment value.
[0009] Beneficial effects: First, the detection method provided by this invention breaks through the limitations of traditional single-source RGB machine vision detection. On the one hand, it uses the comparison of reflectance at the same location in NIR (near-infrared) images of the surface before and after coating to accurately identify areas where lubricant has been missed, effectively solving the pain point that transparent or semi-transparent lubricants have weak visual features and that RGB visible light images are difficult to accurately capture and identify. On the other hand, it combines the grayscale image obtained by RGB conversion to further mine the grayscale detail features of the coated area, making up for the information deficiency of NIR images, which can only distinguish the presence or absence of grease but cannot identify the grease coating state, thus avoiding the information blind spot of single-source detection. Second, the detection method provided by this invention... When extracting the coating area distribution features of the two types of images, the method perfectly matches the actual diffusion distribution law of keyboard switch lubricant. It accurately assesses the coating continuity by combining the number, area, and distribution interval of the missed coating areas, and identifies uneven coating areas by matching the visual shadow features generated by the undulation of lubricant coating. This avoids the identification misjudgment caused by the rigid structure of the switch itself, and finally achieves a lubricant distribution detection accuracy that is far superior to traditional single-source detection. Therefore, the detection method provided by this invention can provide a more accurate basis for judging the lubricant coating quality in the keyboard switch production process, and thus provide more accurate quality control support for the consistency of key feel, mechanical reliability, and production quality stability of the switches. Attached Figure Description
[0010] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart of a machine vision inspection method for the distribution of lubricant on keyboard switches according to the present invention. Detailed Implementation
[0012] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention are within the protection scope of the embodiments of the present invention.
[0013] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art.
[0014] This embodiment provides a machine vision detection method for the distribution of lubricant in keyboard switches, detailed below:
[0015] like Figure 1 As shown, the machine vision inspection method for the distribution of lubricant on the keyboard switches includes the following steps:
[0016] Step S001: Obtain the NIR images of the keyboard switch surface before and after application, as well as the grayscale image of the surface after application.
[0017] This embodiment addresses the problem of poor performance in detecting keyboard switch lubricant coating quality due to the visual characteristics of the grease or lubricant used in keyboard switches, which is often caused by relying solely on single-source RGB images. This embodiment introduces NIR images in addition to RGB images. Specifically, this embodiment first acquires NIR images of the keyboard switch surface before and after lubricant application, as well as an RGB image of the keyboard switch surface surface after lubricant application. The RGB images are then converted to grayscale to obtain grayscale images. The acquired NIR images of the keyboard switch surface before and after lubricant application are denoted as the "before application NIR image" and "after application NIR image," respectively. The grayscale image of the keyboard switch surface after lubricant application is denoted as the "after application grayscale image." Pixels on the NIR image are denoted as reflectance pixels, and pixels on the grayscale image are denoted as grayscale pixels. The "current keyboard switch" refers to the keyboard switch currently undergoing lubricant coating quality detection. The acquisition process for the NIR images of the keyboard switch before and after lubrication, and the RGB image of the keyboard switch after lubrication, is as follows: Before the lubricant application process, the keyboard switch is placed on a testing base, with a testing light source positioned directly above it. A near-infrared camera is used to acquire the NIR image of the switch before lubrication. After the lubricant application process is completed, but before the subsequent switch assembly and pressing operation, the lubricated keyboard switch is placed on a testing base with the same positioning posture as before the lubrication acquisition. A testing light source with the same parameters as before the lubrication acquisition is positioned directly above it. Simultaneously, a near-infrared camera and an RGB camera are used to acquire the switch image, resulting in the NIR image and RGB image of the keyboard switch after lubrication. In this embodiment, it is required that the pixels at the same position in the NIR image before and after lubrication correspond to the same position on the keyboard switch.
[0018] Therefore, this embodiment obtains the NIR images of the keyboard switch before and after coating, as well as the grayscale image of the coated surface, through the above process. After obtaining the NIR images and grayscale images of the surface before and after coating, this embodiment will analyze and extract features reflecting the coating quality from the surface NIR images and the coated surface grayscale images respectively. That is, the surface NIR images before and after coating will be analyzed to extract the continuity of lubricant coating, and the surface grayscale images after coating will be analyzed to extract the uniformity of lubricant coating. Both the continuity and uniformity of coating can reflect the coating quality.
[0019] Step S002: Compare the reflectance of pixels at the same position in the NIR images of the surface before and after coating to identify the missed areas. Based on the number of missed areas, the size of a single missed area, and the overall interval distance of all missed areas, the continuity of the current keyboard switch lubricant coating is obtained.
[0020] In this embodiment, after obtaining the NIR images of the surface before and after coating, the reflectance of pixels at the same position in the NIR images before and after coating is compared to identify areas of missed coating. Areas of missed coating can reflect the continuity of the coating process. The specific process for obtaining areas of missed coating in the NIR image of the surface after coating is as follows:
[0021] Because the near-infrared optical response of the entire surface changes after grease application, the infrared reflectance after lubrication is not the same as the infrared reflectance of the shaft without grease. That is, the near-infrared reflectance of grease and plastic are different. The NIR image acquired after applying lubricant to the shaft surface typically only shows areas covered by grease and areas of plastic without grease. Therefore, this embodiment can identify areas on the shaft covered by lubricant and areas without lubricant by comparing the reflectance of pixels at the same location in the NIR images before and after application. Specifically:
[0022] First, in the NIR image of the coated surface, the reflectance values of pixels at the same location in the NIR image of the pre-coating surface are compared one by one. Pixels with unchanged reflectance are marked as uncoated pixels, and pixels with different reflectance are marked as coated pixels. That is, for any pixel in the NIR image of the coated surface, if its reflectance is the same as that of the pixel at the same coordinate position in the NIR image of the pre-coating surface, it is determined to be an uncoated pixel; if its reflectance is different, it is determined to be a coated pixel. Then, connected component analysis is performed on the uncoated pixels in the NIR image of the coated surface to obtain uncoated regions. That is, all uncoated pixels that are adjacent in eight neighborhoods are connected, thus obtaining multiple uncoated regions. Moreover, the more uncoated regions on the coated shaft that are not covered by grease, the more uncoated breaks the shaft has, the weaker the continuity of the coated region, and the worse the coating quality.
[0023] Considering that under normal circumstances, after the switch is installed and pressed down, the lubricant will be squeezed out, and smaller gaps in the coating will be filled by the lubricant in adjacent areas. Therefore, the smaller and more dispersed the gaps in the coating, the stronger the continuity of the lubricant coating area, and the smaller the adverse impact on the quality of the lubricant coating. However, lubricant is a viscous gel with limited diffusion. Relatively concentrated or large gaps in the coating cannot be filled by the lubricant in distant adjacent areas even after installation and pressing down. Therefore, an unlubricated area of the switch will be formed in that part, which will have a greater adverse impact on the quality of the lubricant coating. That is, the smaller and more dispersed the gap area, the stronger the continuity of the lubricant coating area, and the better the current quality of the keyboard switch lubricant coating. Conversely, the larger and more concentrated the gap area, the weaker the continuity of the coating area, and the worse the current quality of the keyboard switch lubricant coating.
[0024] Based on the above analysis, this embodiment will next determine the continuity of the keyboard switch lubricant coating based on the number of uncoated areas in the NIR image of the surface after coating, the size of a single uncoated area, and the overall interval distance between all uncoated areas; specifically:
[0025] The inverse mapping normalized result of the number of uncoated areas on the NIR image of the surface after coating is recorded as the scale index value; the inverse mapping normalized result of the total area of all uncoated areas on the NIR image of the surface after coating is recorded as the area index value; the average distance between each uncoated area and other uncoated areas on the NIR image of the surface after coating is recorded as the neighborhood distance of the corresponding uncoated area, and the normalized result of the average neighborhood distance of all uncoated areas is recorded as the distance index value; the result of adding the distance index value and the area index value and then multiplying it by the scale index value is recorded as the continuity of the current keyboard switch lubricant coating; in this embodiment, the inverse mapping is the reciprocal, and the normalization refers to linear normalization, that is, the maximum and minimum value normalization.
[0026] The formula for calculating the continuity of the current keyboard switch lubricant coating is as follows:
[0027]
[0028] Where L represents the continuity of the current keyboard switch lubricant coating, and norm() is a linear normalization function. The larger L is, the stronger the continuity of the current keyboard switch lubricant coating, and the smaller the adverse effect on the lubricant coating quality, which means the current keyboard switch lubricant coating quality is better. Conversely, the smaller L is, the weaker the continuity of the current keyboard switch lubricant coating, and the greater the adverse effect on the lubricant coating quality, which means the current keyboard switch lubricant coating quality is worse. This represents the number of uncoated areas on the NIR image of the surface after coating. The smaller the value, the fewer the gaps in the lubricant coating on the keyboard switch surface, and the stronger the continuity of the coating area. Let be the area of the i-th uncoated region in the set of uncoated regions formed by all uncoated regions on the NIR image of the surface after coating. The area of the uncoated region is also the number of reflectance pixels in the corresponding uncoated region. This represents the total area of all unpainted areas. The smaller the value, the less adverse the effect of the missing coating porosity on the quality of lubricating oil coating, and the stronger the continuity of the coating area; The spacing index value of the i-th missed coating region in the set of missed coating regions is obtained by taking the average of the Euclidean distances between the centroid of the i-th missed coating region and the centroids of each missed coating region in the remaining set corresponding to the i-th missed coating region. , Let be the number of unpainted areas in the remaining set corresponding to the i-th unpainted area. The remaining set corresponding to the i-th unpainted area refers to the set of all unpainted areas remaining except for the i-th unpainted area in the set of unpainted areas. Let be the Euclidean distance between the centroid of the i-th unpainted region and the centroid of the j-th unpainted region in the corresponding residual set. The average value of the spacing index representing all missed areas indicates that the larger the overall distribution interval of all missed areas, the more dispersed the overall missed area distribution, the more concentrated the coating area distribution, the easier it is for the missed areas to be compensated by the lubricant in adjacent coating areas, and the stronger the continuity of the lubricant coating area. When linearly normalizing each term in the current keyboard switch coating continuity calculation process, the maximum and minimum values used are taken from the extreme values of the corresponding terms calculated for all historical keyboard switches to obtain the coating continuity. The purpose of normalization is to unify the magnitude of each part of the formula. Furthermore, in this embodiment, the historical keyboard switches are consistent with the current keyboard switch material type, switch model, injection molding parameters, surface treatment process (such as surface cleaning, polishing, or anti-static treatment before coating), and near-infrared imaging equipment parameters. Additionally, when there are no missed areas on the surface NIR image after coating, that is... If no missing areas are found on the surface of the keyboard switch, the maximum value of the coating continuity is assigned to the coating continuity of the keyboard switch lubricant. In other words, the coating continuity is set to 2. This means that when only one missing area exists on the NIR image of the surface after coating, the coating continuity is considered complete. When the concentration of the coating area is considered to be at its maximum, the formula will be in this case. The item defaults to the maximum value of 1.
[0029] Therefore, this embodiment can obtain the continuity of the current keyboard switch lubricant coating through the above process.
[0030] Step S003: Based on the frequency of grayscale occurrence of each grayscale pixel in the grayscale image of the coated surface, the degree of grayscale change of each grayscale pixel is obtained, and grayscale pixels whose grayscale change degree meets the threshold condition are selected to form a grayscale change region; based on the distribution characteristics of the number of edge pixels with changing direction and the chain of pixels with unchanged direction in the grayscale change region, the degree of shadow region feature of each grayscale change region is evaluated, and the comprehensive grayscale of the corresponding grayscale change region is weighted and fused based on the degree of shadow region feature of each grayscale change region to obtain the uniformity of the current keyboard switch lubricant coating.
[0031] Since NIR images cannot provide further coating information for the coated area, and uneven coating thickness can affect the actual lubrication effect on the shaft, this embodiment will further analyze the coating uniformity by combining the surface grayscale image of the shaft. Furthermore, because the lubricating oil is a white, transparent or semi-transparent viscous grease, its surface grayscale cannot directly reflect the coating thickness of each area. However, uneven surface coating will create undulations, and under actual testing lighting conditions, light shining on these undulations will produce shadow edges or connected regions. Therefore, this embodiment can characterize the coating uniformity of the lubricant based on the distribution of shadow areas.
[0032] Since the wrinkles and undulations caused by uneven coating are usually small, the number of pixels in the shadow area is also relatively small compared to the original number of pixels in the lubricating oil. Therefore, in this embodiment, the candidate pixel set (grayscale variation area) containing all potential shadow features can be identified first based on the number of similar grayscale values or the frequency of grayscale occurrence in the surface grayscale image. The grayscale variation area is the key to accurately identifying the coating uniformity. The specific process of obtaining the grayscale variation area is as follows:
[0033] First, based on the frequency of grayscale values of each grayscale pixel in the grayscale image of the surface after smearing, the degree of grayscale change of each grayscale pixel is obtained; that is, the degree of grayscale change of any grayscale pixel is the result of inverse mapping normalization processing of the frequency of grayscale occurrence of that grayscale pixel in the grayscale image of the surface after smearing; the expression for calculating the degree of grayscale change of the q-th grayscale pixel in the grayscale image of the surface after smearing is:
[0034]
[0035] The gray level change of the q-th gray pixel is represented by the gray level change value. Let be the frequency of the grayscale value of the q-th grayscale pixel in the grayscale image of the surface after smearing. This refers to the grayscale value that appears least frequently in the grayscale image of the surface after the coating is applied. The gray value that appears most frequently in the grayscale image of the surface after smearing; and Its main function is to Normalize, The smaller, that is The larger the value, the better it matches the characteristic that the number of pixels in the folded shadow area is extremely small. The stronger the grayscale change of the q-th grayscale pixel, the more likely it is to be a candidate pixel with shadow characteristics; conversely, the smaller the value, the better it matches the characteristic that the number of pixels in the folded shadow area is. The smaller the value, the less it matches the characteristic that the number of pixels in the folded shadow area is extremely small. The weaker the gray level change of the q-th gray pixel, the less likely it is to be a candidate pixel with shadow features.
[0036] Next, grayscale pixels whose grayscale changes meet the threshold condition are selected to form grayscale change regions. That is, grayscale pixels whose grayscale changes exceed the preset grayscale change threshold are first selected and identified as grayscale change pixels. Then, the region obtained by performing connected component analysis on the grayscale change pixels is recorded as the grayscale change region; that is, the connected component formed by connecting eight adjacent grayscale change pixels is the grayscale change region. In specific applications, the implementer can set the preset grayscale change threshold according to the actual situation. Since the grayscale change degree calculation method in this embodiment divides pixels with more grayscale change characteristics from pixels with unchanged grayscale values into two ends of the grayscale change degree value range, this embodiment can take the median value of the grayscale change degree value range, 0.5, as the preset grayscale change threshold.
[0037] However, the structure of keyboard switches is complex, and the lubricant is transparent or semi-transparent and viscous. The grayscale image captured by the camera can directly penetrate the lubricant layer and capture the grayscale pixels of the original structure of the switch. If the grayscale change area is directly judged as the shadow area of uneven coating, it is easy to be affected by the complex shape of the switch surface. This may lead to the switch's own structural shape area being mistaken for the shadow area caused by uneven coating, or the wrinkles and shadows caused by the undulation of the grease coating, resulting in serious deviations in the detection results of coating uniformity. Since grayscale variation areas caused by different factors have different edge morphology characteristics, this embodiment will introduce edge morphology feature analysis to ensure the accuracy of coating uniformity detection: the edges of shadow areas formed by uneven coating are irregular curves, the direction of the pixels on the edge changes at any time, the overall distribution is unstable and the shape is arbitrary; while the keyboard switch structure has a regular and neat shape, so the grayscale variation edges corresponding to the switch structure are usually composed of rigid straight lines, and the slope of the pixels on the edge only changes abruptly at the corners of the structure, while the rest remains constant; therefore, this embodiment can perform point-by-point detection on the extracted edge pixel sequence of the grayscale variation area and evaluate whether the slope of each edge pixel changes, so as to characterize whether the corresponding edge pixel has a change in extension direction. The fewer edge pixels with changes in direction and the stronger the continuity of edge pixels without changes in direction, the more the grayscale variation area conforms to the characteristics of the switch structure. The more edge pixels with changes in direction and the weaker the continuity of edge pixels without changes in direction, the more the grayscale variation area conforms to the characteristics of the shadow area.
[0038] Based on the above analysis, this embodiment will next evaluate the shadow region feature degree of each gray-level change region based on the distribution characteristics of the number of edge pixels with changing direction and the chain of pixels with unchanged direction in the gray-level change region. The shadow region feature degree can reflect the degree to which the corresponding gray-level change region conforms to the shadow region feature, and the shadow region feature degree can characterize the gray-level feature participation degree of the gray-level change region when obtaining the coating uniformity. The specific process for obtaining the shadow region feature degree of the gray-level change region is as follows:
[0039] First, obtain the edge pixels with changing orientation and the chain of pixels with unchanged orientation for each grayscale change region. Specifically, for any grayscale change region: obtain the edge line of the grayscale change region. For example, the edge line of the grayscale change region can be extracted based on an edge detection operator. Then, select any edge pixel on the edge line of the grayscale change region as the starting point and traverse the edge line in a clockwise direction until the starting point is reached again. Record the sequence of edge pixels formed according to the traversal order as the edge pixel sequence corresponding to the edge line of the grayscale change region. The slope of each edge pixel in the edge pixel sequence is analyzed, and each edge pixel in the sequence is judged point by point. Edge pixels with a slope different from the previous edge pixel are judged as edge pixels with a change in direction, while edge pixels with a slope the same as the previous edge pixel are judged as edge pixels with no change in direction. That is, in the edge pixel sequence corresponding to the edge line of the gray-level change region, if the slope of a certain edge pixel is not the same as the slope of the previous edge pixel, then the edge pixel is judged as an edge pixel with a change in direction in the gray-level change region. If the slope of the preceding edge pixel is the same, then the edge pixel is determined to be an edge pixel whose direction has not changed in the grayscale change region; the slope of the v-th edge pixel in any edge pixel sequence is the slope of the line connecting the v-th edge pixel and the (v+1)-th edge pixel in the same edge pixel sequence, where v is not the last point in the edge pixel sequence, meaning the slope is not calculated at the end point of the edge pixel sequence; no judgment is made between edge pixels whose direction has changed and edge pixels whose direction has not changed at the starting point of the edge pixel sequence; the end point of the edge pixel sequence is the previous traversal point when traversing back to the starting point; non-closed When traversing the edge line, the process goes from one endpoint to the other. In the edge pixel sequence corresponding to the grayscale change region, the sequence of continuous pixels with unchanged direction between any two adjacent pixels with changed direction is a chain of pixels with unchanged direction in the grayscale change region. The sequence of continuous pixels with unchanged direction from the starting point of the edge pixel sequence to its nearest neighbor with changed direction is also considered a chain of pixels with unchanged direction. Similarly, the sequence of continuous pixels with unchanged direction from the nearest neighbor with changed direction to the end point of the edge pixel sequence is also considered a chain of pixels with unchanged direction.
[0040] Then, the normalized result of the number of edge pixels with changing direction in each gray-level change region is calculated, and the normalized result of the squared mean of the chain length of pixels with unchanged direction in the corresponding gray-level change region is calculated. This product is denoted as the shadow region feature degree of the corresponding gray-level change region. The specific expression for calculating the shadow region feature degree of the p-th gray-level change region is as follows:
[0041]
[0042] in, The degree of shadow region feature in the p-th grayscale variation region. Let be the number of pixels at the edge of the direction change in the p-th grayscale change region. Let be the number of pixel chains whose orientation remains unchanged in the p-th grayscale change region. Let be the length of the r-th direction-unchanged pixel chain in the p-th grayscale change region. The length of the pixel chain is the number of direction-unchanged pixels in the pixel chain. The larger the value, the more pixels there are at the edge of the p-th grayscale change region where the direction changes, and the stronger the shadow region feature. To summarize the mean value of all unchanged pixel chains that conform to rigid rule changes, The larger the value, the more the p-th grayscale change region conforms to the characteristics of a shadow region; while The greater the sum When it is larger, The larger, therefore A larger value indicates that the p-th grayscale change region more closely matches the characteristics of a shadow region, and vice versa. The smaller the value, the less the p-th grayscale change area conforms to the characteristics of a shadow area. When linearly normalizing each term in the formula for calculating the shadow area characteristic degree of the current keyboard switch grayscale change area, the maximum and minimum values used are taken from the extreme values of the calculated terms corresponding to the shadow area characteristic degree of all grayscale change areas of all historical keyboard switches. The purpose of normalization is to unify the magnitude of each part of the formula.
[0043] Since the stronger the shadow area feature of a grayscale change area, the more reliable the index representing the degree of undulation and wrinkling is in characterizing the degree of coating unevenness, in order to obtain a more accurate evaluation result of coating uniformity, this embodiment will next perform a weighted fusion of the comprehensive grayscale of the corresponding grayscale change area based on the shadow area feature of each grayscale change area, and then obtain the coating uniformity of the current keyboard switch lubricant; the higher the comprehensive grayscale of the grayscale change area, the stronger the undulation and wrinkling of that part, the more uneven the coating of that part, and the weaker the coating uniformity of that part should be; the specific process of obtaining the coating uniformity is as follows:
[0044] The sum of the gray values of all gray pixels within each gray-level change region is recorded as the comprehensive gray value of the corresponding gray-level change region. The inverse mapping normalization result, obtained by multiplying the shadow feature intensity of each gray-level change region by the comprehensive gray value of the corresponding gray-level change region and then summing the results, is recorded as the uniformity of the current keyboard switch lubricant coating. The expression for calculating the uniformity of the current keyboard switch lubricant coating is:
[0045]
[0046] Where R represents the uniformity of the current keyboard switch lubricant application, and M represents the number of grayscale variation areas on the surface grayscale image after application. The degree of shadow region feature in the p-th grayscale variation region. Let be the number of gray-level pixels in the p-th gray-level change region. Let be the gray value of the s-th gray pixel within the p-th gray-level change region; The higher the value, the more likely the p-th grayscale change region is to be a wrinkle shadow caused by uneven lubricant coating, and the more likely it is to be a reliable area of uneven coating. In other words, the greater the contribution of the overall grayscale of the p-th grayscale change region to the degree of coating uniformity. The larger the value, the larger the denominator of the formula, and the smaller the final calculated coating uniformity R value will be, indicating a poorer coating uniformity for the current shaft. The smaller the value, the closer the p-th grayscale change region is to the regular structure of the shaft itself, and the less likely it is to be a region of uneven coating. The denominator of the formula decreases accordingly, and the larger the final value of R, the better the coating uniformity of the current shaft. The larger the value, the darker the shadow color of the p-th grayscale variation region, and the stronger the undulation and wrinkling of the lubricating oil. The larger the value, the greater the denominator in the formula will be. The smaller the final calculated value of R, the more prominent the coating unevenness problem in that area, and the worse the overall coating uniformity of the shaft. The smaller the value of R, the smaller the denominator in the formula, resulting in a larger R value. This indicates a weaker degree of undulation and wrinkling in the area, and better overall coating uniformity of the switch. Therefore, a larger R indicates better overall coating uniformity of the current keyboard switch, and a smaller R indicates worse overall coating uniformity. When linearly normalizing each term in the formula for calculating the coating uniformity of the current keyboard switch lubricant, the maximum and minimum values used are taken from the extreme values of the corresponding terms for the coating uniformity of all historical keyboard switches. The purpose of normalization is to unify the magnitude of each part of the formula.
[0047] Therefore, this embodiment obtains the uniformity of the current keyboard switch lubricant coating through the above process.
[0048] Step S004: Based on the coating continuity and coating uniformity, obtain the coating quality assessment value of the current keyboard switch surface lubricant, and determine the coating quality of the current keyboard switch lubricant based on the coating quality assessment value.
[0049] Since both coating continuity and coating uniformity reflect coating quality, this embodiment, after obtaining the coating continuity and coating uniformity, fuses them to obtain the coating quality evaluation value of the current keyboard switch surface lubricant. Furthermore, this embodiment uses the product of half of the current keyboard switch lubricant coating continuity and the current keyboard switch lubricant coating uniformity as the current keyboard switch surface lubricant coating quality evaluation value. This is the coating quality assessment value; the coating continuity is taken as half to ensure that it is consistent with the magnitude of the coating uniformity, thus making the coating quality assessment effective.
[0050] After obtaining the coating quality assessment value of the current keyboard switch surface lubricant, the coating quality of the current keyboard switch lubricant is judged based on the current coating quality assessment value. The value range of the coating quality assessment value is [0,1], and the value directly corresponds to the overall lubricant coating quality level of the switch. The higher the value, the better the coating continuity and uniformity of the switch, and the better the overall lubrication quality. Specifically, this embodiment divides the quality inspection into three levels. When the coating quality assessment value exceeds the preset first judgment threshold, the current keyboard switch lubricant coating quality is judged to be excellent and can be directly judged as qualified, and can directly flow into the subsequent production process without additional rework. When the coating quality assessment value exceeds the second judgment threshold but is less than the preset first judgment threshold, the current keyboard switch lubricant coating may have defects. The coating quality of such switches does not reach the excellent standard, but the problem is minor. If only a few discrete, scattered small gaps in the coating exist, or if there is slight uneven coating in local areas, direct scrapping is not necessary. Instead, the device needs to be transferred to the re-inspection stage. After manual confirmation of the defects, targeted recoating operations are performed on the gaps and missing coating areas. When the coating quality assessment value is less than the preset second judgment threshold, it is determined that the lubricant coating of the current keyboard switch has a significant defect. Such switches are likely to have large areas of concentrated gaps in the coating, or a large number of severe undulations and wrinkles in the coating area, which cannot meet the lubrication requirements of the switch and will directly affect the consistency of key feel and mechanical reliability. A comprehensive recoating must be performed, or even the original lubricant must be completely removed and the coating operation must be completed to ensure the stability of the final production quality of the switch. In specific applications, the implementer can set the second judgment threshold and the preset first judgment threshold according to the actual situation such as quality requirements. For example, in this embodiment, the preset first judgment threshold can be preferably set to 0.66 and the preset second judgment threshold to 0.33.
[0051] Thus, this embodiment completes the machine vision inspection of keyboard switch lubricant distribution, which is equivalent to the inspection of keyboard switch lubricant coating quality. Furthermore, the coating quality assessment method constructed in this embodiment, by integrating NIR and RGB multi-source machine vision inspection results, accurately identifies lubricant leakage areas by utilizing the difference in near-infrared reflectivity at the same location before and after application. This effectively compensates for the shortcomings of traditional RGB visible light images in capturing the visual features of transparent or semi-transparent lubricants and in accurately judging lubricant distribution areas. On the other hand, it further combines the grayscale image obtained after converting the RGB image to grayscale to analyze the grayscale visual features of the coated area, making up for the insufficient information in NIR image detection. Simultaneously, when analyzing the coating area distribution characteristics of the two types of images, it adheres to the actual diffusion distribution law of keyboard switch lubricant, and combines the visual shadow features generated by the undulating distribution of lubricant in the switch for calculation. Ultimately, it achieves results far superior to traditional single-source inspection of keyboard switch lubricant coating quality or distribution, providing more precise quality control support for the consistency of key feel, mechanical reliability, and production quality stability of the switches.
[0052] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A machine vision inspection method for the distribution of lubricant in keyboard switches, characterized in that, The method includes the following steps: Obtain the NIR images of the keyboard switch surface before and after application, as well as the grayscale image of the surface after application. By comparing the reflectance of pixels at the same position in the NIR images of the surface before and after coating, the missing coating areas are identified. Based on the number of missing coating areas, the size of a single missing coating area, and the overall interval distance of all missing coating areas, the continuity of the current keyboard switch lubricant coating is obtained. Based on the frequency of grayscale occurrence of each grayscale pixel in the grayscale image of the coated surface, the degree of grayscale change of each grayscale pixel is obtained, and grayscale pixels whose grayscale change degree meets the threshold condition are selected to form grayscale change regions. Based on the distribution characteristics of the number of pixels at the edge of the grayscale change region and the chain of pixels with unchanged direction, the degree of shadow region feature of each grayscale change region is evaluated. Based on the degree of shadow region feature of each grayscale change region, the comprehensive grayscale of the corresponding grayscale change region is weighted and fused to obtain the uniformity of the current keyboard switch lubricant coating. Based on the coating continuity and coating uniformity, a coating quality assessment value for the current keyboard switch surface lubricant is obtained, and the coating quality of the current keyboard switch lubricant is judged based on the coating quality assessment value.
2. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, Methods for obtaining missed areas include: On the NIR image of the surface after coating, the reflectance values of pixels at the same position in the NIR image of the surface before coating are compared one by one. Pixels whose reflectance does not change are marked as uncoated pixels. Connectivity analysis is performed on the uncoated pixels to obtain the uncoated area.
3. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, Methods for obtaining the degree of coating continuity include: The inverse mapping normalized result of the number of missed areas is recorded as the scale index value; the inverse mapping normalized result of the total area of all missed areas is recorded as the area index value; the average distance between each missed area and other missed areas is recorded as the neighborhood distance of the corresponding missed area; the normalized result of the average neighborhood distance of all missed areas is recorded as the distance index value; the result of adding the distance index value and the area index value and then multiplying it by the scale index value is recorded as the continuity of the current keyboard switch lubricant coating.
4. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, The degree of grayscale change of any grayscale pixel is the inverse mapping normalization result of the frequency of grayscale occurrence of the grayscale pixel in the grayscale image of the surface after smearing.
5. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, The grayscale variation region is the region obtained by performing connected component analysis on pixels whose grayscale variation exceeds a preset grayscale variation threshold.
6. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, Methods for obtaining edge pixels with changing orientation and edge pixels with unchanged orientation include: For any edge pixel in the edge pixel sequence corresponding to the edge line of any grayscale change region, if the slope of the edge pixel is not the same as the slope of the previous edge pixel, then the edge pixel is determined to be an edge pixel with a change in direction; if the slope of the edge pixel is the same as the slope of the previous edge pixel, then the edge pixel is determined to be an edge pixel with no change in direction. The slope of any edge pixel in the edge pixel sequence is the slope of the line connecting the edge pixel and the next edge pixel.
7. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, A chain of pixels with unchanged orientation consists of consecutive edge pixels with unchanged orientation between adjacent pixels with changed orientation on the edge line of the grayscale change region.
8. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, The feature degree of the shadow region in any gray-level change region is the product of the normalized result of the number of edge pixels of the gray-level change region with the normalized result of the square mean of the chain length of pixels with no change in direction in the gray-level change region.
9. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, Methods for obtaining coating uniformity include: The sum of the gray values of all gray pixels in each gray-scale change region is recorded as the comprehensive gray value of the corresponding gray-scale change region. The inverse mapping normalization result of multiplying the shadow feature degree of each gray-scale change region with the comprehensive gray value of the corresponding gray-scale change region and then summing them is recorded as the uniformity of the current keyboard switch lubricant coating.
10. The machine vision inspection method for the distribution of lubricant in keyboard switches as described in claim 1, characterized in that, The coating quality assessment value is the product of half of the coating continuity and the coating uniformity.
