Keyboard key character detection method

By using the positive and negative matching methods of character outline templates and combined with image preprocessing technology, the problem of time-consuming and misjudgment of traditional algorithms in detecting complex characters is solved, and efficient and accurate keyboard key character detection is achieved.

CN114299496BActive Publication Date: 2025-06-24FREESENSE IMAGE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111622715.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-06-24
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

The traditional keyboard key character detection algorithm consumes high time and costs when detecting complex characters, and has misjudgment problems, resulting in low detection efficiency and accuracy.

Method used

The detection is carried out using the method of positive and negative matching of character outline templates and image preprocessing as the auxiliary method, including input image preprocessing, determining whether there are characters in the character area, matching characters in the character template diagram as the template, and combining the character matching data in the original image to determine the character outline matching degree.

Benefits of technology

It greatly improves the efficiency and accuracy of keyboard key character detection, reduces the difficulty of detection in complex characters, alleviates development pressure, shortens development cycle, and improves the stability of the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114299496B_ABST
    Figure CN114299496B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for detecting keyboard key characters, which includes the following steps: Step S1: Input an image and perform preprocessing; Step S2: Detect whether there are characters in the character area; Step S3: Perform matching with the characters in the character template image as the template; Step S4: Perform matching with the characters in the original image as the template and combine the data obtained by matching with the character template image to judge the character contour matching degree. The detection efficiency and accuracy of the algorithm of the present invention have also been greatly improved. The more complex the characters are, the lower the detection difficulty of this algorithm. It greatly alleviates the pressure of all parties, shortens a certain development cycle, improves the stability of the device, and has great practical value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field:

[0001] The present invention relates to the field of optical character verification. Background Art:

[0002] Character detection, also known as OCR or OCV detection, is specifically for identifying and detecting characters printed or engraved on the surfaces of various electronic components, mobile phone keyboards, computer keyboards, etc. Common characters include numbers, English letters, symbols, Chinese characters, etc.

[0003] At present, many domestic and foreign enterprises researching machine vision have developed corresponding detection software. After simple settings, it can automatically identify and detect the characters to be detected. If an abnormality occurs, it can prompt an alarm or control the machine to stop. After detecting workpieces that do not meet the requirements, it can output a control signal to reject unqualified products, with a relatively high degree of automation. When detecting key characters, using traditional character detection algorithms consumes a high time cost, and there are certain misjudgments in detecting the presence, integrity, and correctness of characters, etc.

[0004] During the process of detecting the characters of keyboard keys using traditional detection algorithms, there are certain similarities and complexities in individual characters. For example, keys such as F1 and F2, R and F, Fn, etc., result in a high time cost for the algorithm, and there are certain misjudgments in detecting the presence, integrity, and correctness of characters, etc., thus bringing many difficulties to the progress of the project. Summary of the Invention:

[0005] Aiming at the deficiencies of the existing technology, the purpose of the embodiments of the present invention is to provide a method for detecting keyboard key characters. The purpose of developing this algorithm is to solve related difficulties. Now, a method mainly using forward matching and reverse matching of character contour templates supplemented by image preprocessing is used for detection, accurately solving related problems and greatly improving the detection efficiency.

[0006] To achieve the above purpose, the present invention provides the following technical solutions:

[0007] A method for detecting keyboard key characters, comprising the following steps:

[0008] Step S1: Input an image and perform preprocessing;

[0009] Step S2: Detect whether there are characters in the character area;

[0010] Step S3: Perform matching with the characters in the character template image as templates;

[0011] Step S4: Perform matching with the characters in the original image as templates and combine the data matched with the character template image to determine the character contour matching degree.

[0012] As a further solution of the present invention, the input images in step S1 include: the original image to be detected, the keyboard area template image, and the standard character image; the preprocessing steps include: calculating the gray value distribution of the area within the keyboard area template image, obtaining its absolute histogram of gray values, extracting the corresponding key areas according to the histogram, and then obtaining the surrounding rectangles of all key areas.

[0013] As a further solution of the present invention, the surrounding rectangle is described by the coordinates of the corner pixels, where the calculation of the rectangle is based on the central coordinates of the area pixels. By using the obtained standard area template, each character of the other two images is extracted, and the domain of the given image is reduced to the specified area, and the required image is obtained after being processed by the corresponding image threshold preprocessing technology.

[0014] As a further solution of the present invention, step S2 specifically includes: performing a local threshold segmentation image operation on each character area of each of the two processed images, and selecting the pixels with gray value g in the input image that satisfy the following conditions for the threshold:

[0015] MinGray ≤ g ≤ MaxGray, returning all the points of the image that meet the conditions as a region, then calculating the character area and making a judgment. If the area has a value, proceed to the next detection; otherwise, directly jump out of the detection.

[0016] As a further solution of the present invention, step S3 specifically includes: S1.1: In the traversal operation, create a character contour model memory for each character in the processed character template image, obtain the corresponding template handle according to the provided angle step, maximum pyramid level number, angle step, matching metric, and the minimum contrast of the object in the search image, and then use the template handle to perform the best match at the corresponding position in the processed original image to obtain the row and column coordinates and scores of the first batch of character areas; S1.2: Compare the row and column coordinates with the row and column coordinates of the character area in the character template image to determine whether there is a row and column offset between the two characters; S1.3: Input the matching parameters during the character matching process, and then judge the obtained matching score. If the score is <0.90 points, it means that the character contour matching is not good, and the detection ends.

[0017] As a further solution of the present invention, step S4 specifically includes: step S4.1: When the matching score of the input matching parameters during the character matching process ≥ 0.90 points, perform a traversal matching operation with the characters in the original image as the template to obtain the row and column coordinates and scores of the second batch of characters; step S4.2: Then judge the obtained scores. If the score is >0.9, it means that the character contour matching is okay, and the detection ends.

[0018] Most traditional algorithms directly make comparison judgments in character detection and have high requirements for accuracy. In the case of insufficient character accuracy or relatively complex characters, the detection results are not very satisfactory. If traditional detection methods are used, the requirements for hardware are relatively high, and the work difficulty of algorithm engineers also increases to a certain extent. The algorithm developed this time can just solve this problem, and the detection efficiency and accuracy have also been greatly improved. The more complex the characters are, the lower the detection difficulty of this algorithm, which greatly alleviates the pressure on all parties, shortens a certain development cycle, improves the stability of the device, and has great practical value.

[0019] To more clearly elaborate the structural features and effects of the present invention, the present invention will be described in detail below in conjunction with the accompanying drawings and specific embodiments. Brief Description of the Drawings:

[0020] Figure 1 It is a schematic diagram of the calculation of the rectangle based on the central coordinates of the region pixels in the method for detecting keyboard key characters of the present invention.

[0021] Figure 2 It is a process diagram of image preprocessing in the method for detecting keyboard key characters of the present invention;

[0022] Figure 3 It is an effect diagram of character matching detection in the method for detecting keyboard key characters of the present invention;

[0023] Figure 4 It is a display diagram of the detection result in the method for detecting keyboard key characters of the present invention;

[0024] Figure 5 It is a flowchart of the algorithm in the method for detecting keyboard key characters of the present invention. Detailed Embodiment:

[0025] The present invention will be further described below in conjunction with the accompanying drawings and relevant knowledge, and will be described clearly and completely. Obviously, the described applications are only a part of the embodiments of the present invention, rather than all the embodiments.

[0026] In the present invention, through the keyboard key character detection method, a method mainly using the forward matching and reverse matching of character contour templates supplemented by image preprocessing is used for detection, accurately solving relevant problems, greatly improving the detection efficiency. Most traditional algorithms directly make comparison judgments in character detection and have relatively high requirements for accuracy. In the case of insufficient character accuracy or relatively complex characters, the detection results are not very satisfactory. If traditional detection methods are used, the requirements for hardware are relatively high, and the work difficulty of algorithm engineers also increases to a certain extent. The algorithm developed this time can just solve this problem, and the detection efficiency and accuracy have also been greatly improved. The more complex the characters are, the lower the detection difficulty of this algorithm, greatly alleviating the pressure on all parties, shortening a certain development cycle, and improving the stability of the device, having great practical value.

[0027] See Figure 2 As shown, the keyboard key character detection method includes the following steps:

[0028] Step S1: Input an image and perform preprocessing;

[0029] Step S2: Detect whether there are characters in the character area;

[0030] Step S3: Perform matching with the characters in the character template image as the template;

[0031] Step S4: Perform matching with the characters in the original image as the template and combine the data obtained from the matching with the character template image to judge the character contour matching degree.

[0032] Among them, in inputting an image and performing preprocessing, the input image includes: inputting the original image to be detected, the keyboard area template image, and the standard character image; the steps of preprocessing include: calculating the gray value distribution of the area within the keyboard area template image, obtaining its absolute histogram of gray values, extracting the corresponding key areas according to the histogram, and then obtaining the surrounding rectangles (parallel to the coordinate axes) of all key areas. Specifically, it includes: calculating the gray value distribution of the area within the keyboard area template image, obtaining its absolute histogram of gray values, and the quantization parameter is defined as a frequency value plus the frequencies of how many adjacent gray values. The generated histogram AbsoluteHisto is a tuple, whose index is mapped to the gray values of the input image Image, and its elements contain the frequencies of gray values, and the calculation is as follows:

[0033]

[0034] Where MIN represents the minimum gray value, and the index i of the frequency value is determined by the gray value g and the quantization q;

[0035] Extract the corresponding key areas according to the histogram, and then obtain the surrounding rectangles (parallel to the coordinate axes) of all key areas.

[0036] Further preferably, the surrounding rectangle is described by the coordinates of the corner pixels, wherein the calculation of the rectangle is based on the central coordinates of the regional pixels. By using the obtained standard regional template, each character of the other two pictures is extracted, and the domain of the given image is reduced to a specified area, and the required image is obtained after being processed by the corresponding image threshold preprocessing technique.

[0037] The surrounding rectangle is described by the coordinates of the corner pixels (Row1, Column1, Row2, Column2). The calculation of the rectangle is based on the central coordinates of the regional pixels. As Figure 1 shown, by using the obtained standard regional template, each character of the other two pictures is extracted, the domain of the given image is reduced to a specified area, and the detection process is as Figure 2 shown, and the required image is obtained after being processed by the corresponding image threshold preprocessing technique.

[0038] In the present invention, step S2 specifically includes: performing a local threshold segmentation image operation on each character region of each of the two processed images, and selecting pixels with a gray value g in the input image that satisfy the following conditions for the threshold:

[0039] MinGray ≤ g ≤ MaxGray, returning all points of the image that meet the conditions as a region, then calculating the character area and making a judgment. If the area has a value, the next detection is carried out; otherwise, the detection is directly terminated.

[0040] In the present invention, step S3 specifically includes: S1.1: In the traversal operation, create a character contour model memory for each character in the processed character template image, obtain the corresponding template handle according to the provided angle step, maximum pyramid level number, angle step, matching metric, and minimum contrast of the object in the search image, and then use the template handle to perform the best match at the corresponding position in the processed original image. As shown in the appendix Figure 3 shown, obtain the row and column coordinates and scores of the first batch of character regions; S1.2: Compare the row and column coordinates with the row and column coordinates of the character region in the character template image to determine whether there is a row and column offset between the two characters, mainly detecting the occurrence of key mixing on the left and right sides of the shift key, etc.; S1.3: Input matching parameters during the character matching process, and then judge the obtained matching score. If the score is <0.90, it means that the character contour matching is ng, and the detection is terminated. Specifically, certain input parameters are required during the character matching process, such as the matching angle, the minimum score of the model instance to be found, the number of model instances to be found, sub-pixel accuracy, the greediness of the search heuristic, etc., and then judge the obtained matching score. If the score is <0.90, it means that the character contour matching is ng, and the detection is terminated.

[0041] In the present invention, step S4 specifically includes: Step S4.1: When the matching score of the input matching parameter during the character matching process >= 0.90, traverse and match with the characters in the original image as templates, so as to obtain the row and column coordinates and scores of the second batch of characters; Step S4.2: Then judge the obtained scores. If the score > 0.9, it means that the character contour matching is okay, and the detection ends. After the detection ends, the corresponding detection results are displayed on the picture, and the display results are as shown in the appendix Figure 4 as shown, green is okay and red is ng.

[0042] The following provides a specific embodiment of the present invention

[0043] Embodiment 1

[0044] Referring to Figures 1 - 5 as shown, the method for detecting keyboard key characters of the present invention; specifically includes inputting pictures and preprocessing of images; inputting three pictures, namely the original picture to be detected, the keyboard area template picture and the standard character picture. First, calculate the gray value distribution in the area of the keyboard area template image, obtain its absolute histogram of gray values, and the quantization parameter is defined as a frequency value adding the frequencies of how many adjacent gray values. The generated histogram AbsoluteHisto is a tuple, whose index is mapped to the gray values of the input image Image, and its elements contain the frequencies of gray values, and the calculation is as follows:

[0045]

[0046] where MIN represents the minimum gray value, and the index i of the frequency value is determined by the gray value g and quantization q;

[0047] Extract the corresponding key areas according to the histogram, and then obtain the surrounding rectangles (parallel to the coordinate axes) of all key areas. The surrounding rectangle is described by the coordinates of the corner pixels (Row1, Column1, Row2, Column2). The calculation of the rectangle is based on the central coordinates of the area pixels. Each character of the other two pictures is extracted through the obtained standard area template, and the domain of definition of the given image is reduced to the specified area, and the detection process is as shown in the appendix Figure 2 as shown, and the required image is obtained after processing with the corresponding image threshold preprocessing technology.

[0048] In this embodiment, the detection of whether there are characters in the character area specifically includes:

[0049] Based on the above steps, perform local threshold segmentation image operation on each character area of the two processed images. The threshold selects the pixels whose gray value g in the input image satisfies the following conditions:

[0050] MinGray ≤ g ≤ MaxGray

[0051] Return all points of the image that meet the conditions as a region, then calculate the character area and make a judgment. If there is a numerical value for the area, proceed to the next step of detection; otherwise, directly jump out of the detection.

[0052] In this embodiment, the matching with the characters in the character template image specifically includes: creating a character contour model memory for each character in the processed character template image during the traversal operation, obtaining the corresponding template handle according to parameters such as the provided angle step, the maximum pyramid level number, the angle step, the matching metric, and the minimum contrast of the object in the search image, and then using the template handle to perform the best matching at the corresponding position in the processed original image. As shown in the appendix Figure 3 shown, to obtain the row and column coordinates and scores of the first batch of character regions.

[0053] Compare the row and column coordinates with the row and column coordinates of the character region in the character template image to determine whether there is a row and column offset between the two characters, mainly detecting the key mixing on the left and right sides of the shift key, etc.

[0054] Certain input parameters are required during the character matching process, such as the matching angle, the minimum score of the model instance to be found, the number of model instances to be found, the sub-pixel accuracy, the greediness of the search heuristic, etc. Then, judge the obtained matching score. If it is < 0.90 points, it means that the character contour matching is ng, and the detection ends.

[0055] In this embodiment, the matching with the characters in the original image specifically includes: when the matching score ≥ 0.90 points during the matching with the characters in the character template image, perform a traversal matching operation with the characters in the original image, so as to obtain the row and column coordinates and scores of the second batch of characters. Then, judge the obtained scores. If the score is > 0.9, it means that the character contour matching is ok, and the detection ends.

[0056] In this embodiment, displaying the corresponding detection results specifically includes: after the detection ends, display the corresponding detection results on the picture. The display results are as shown in the appendix Figure 4 shown, green is ok, and red is ng (at the marked position a in Figure 4 ).

[0057] Compared with traditional algorithms, most of the traditional algorithms directly make comparison judgments in character detection and have relatively high requirements for accuracy. In the case of insufficient character accuracy or relatively complex characters, the detection results are not very satisfactory. If the traditional detection method is used, the requirements for hardware are relatively high, and the work difficulty of algorithm engineers also increases to a certain extent. The algorithm of the present invention can just solve this problem, and the detection efficiency and accuracy have also been greatly improved. The more complex the characters are, the lower the detection difficulty of this algorithm. It greatly alleviates the pressure of all parties, shortens a certain development cycle, improves the stability of the device, and has great practical value.

[0058] The technical principle of the present invention has been described above in combination with specific embodiments, which are only the preferred embodiments of the present invention. The protection scope of the present invention is not limited to the above embodiments. Any technical solutions falling within the idea of the present invention belong to the protection scope of the present invention. Those skilled in the art can think of other specific embodiments of the present invention without creative labor, and these embodiments will fall within the protection scope of the present invention.

Claims

1. A method for detecting keyboard key characters, characterized in that, It includes the following steps: Step S1: Input an image and perform preprocessing; The process of inputting an image specifically includes: inputting the original image to be detected, the keyboard area template image, and the standard character image; the process of preprocessing specifically includes: calculating the gray value distribution of the area within the keyboard area template image, obtaining its absolute gray value histogram, extracting the corresponding key areas according to the absolute histogram, obtaining the surrounding rectangles of all key areas to get the standard area template, extracting each character of the original image and the standard character image through the obtained standard area template, and obtaining the required preprocessed original image and preprocessed standard character image through image threshold preprocessing technology; Step S2: Determine whether there are characters in the character areas of the preprocessed original image and the preprocessed standard character image. If there are characters, proceed to the next detection; Step S3: Perform matching with the characters in the preprocessed standard character image as templates, specifically including: creating a character contour model memory for each character in the preprocessed standard character image during the traversal operation, obtaining the corresponding template handle according to the provided angle step, maximum pyramid level number, angle step, matching metric, and minimum contrast of the object in the search image, and then using the template handle to perform the best matching at the corresponding position in the preprocessed original image to obtain the row and column coordinates and scores of the first batch of character areas; comparing the row and column coordinates with the row and column coordinates of the character area in the preprocessed standard character image to determine whether there is a row and column offset between the two characters; inputting matching parameters during the character matching process, and then judging the obtained matching score. If the score is <0.90 points, it indicates that the character contour matching fails and the detection ends; Step S4: Perform matching with the characters in the preprocessed original image as templates and combine the data obtained from the matching with the preprocessed standard character image to judge the character contour matching degree, specifically including: when the matching score of the matching parameters input during the character matching process >= 0.90 points, perform a traversal matching operation with the characters in the preprocessed original image as templates to obtain the row and column coordinates and scores of the second batch of characters; then judge the obtained scores. If the score is >0.9, it indicates that the character contour matching is successful and the detection ends.

Citation Information

Patent Citations

  • Character defect detection method and device based on morphology

    CN109142383A

  • Keyboard detection method and keyboard detection equipment

    CN110658194A