CN113379673B - Method, device and equipment for detecting small red cap of keyboard - Google Patents
Method, device and equipment for detecting small red cap of keyboard Download PDFInfo
- Publication number
- CN113379673B CN113379673B CN202110467708.8A CN202110467708A CN113379673B CN 113379673 B CN113379673 B CN 113379673B CN 202110467708 A CN202110467708 A CN 202110467708A CN 113379673 B CN113379673 B CN 113379673B
- Authority
- CN
- China
- Prior art keywords
- image
- keyboard
- key
- letter
- outline
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/70—Determining position or orientation of objects or cameras
- G06T7/73—Determining position or orientation of objects or cameras using feature-based methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10004—Still image; Photographic image
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20112—Image segmentation details
- G06T2207/20164—Salient point detection; Corner detection
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a method, a device and equipment for detecting a small red cap of a keyboard, which comprises the steps of obtaining a keyboard object image and a corresponding keyboard template image; determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image; determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter; determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter; determining a first image region containing a plurality of key keys in the keyboard template image based on the plurality of determined key keys; correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area; based on the image pixel analysis, it is determined whether there is a small red cap in the second image region. Through the matching of a real object and the template and the concave-convex degree of the letter outline, the problem that whether the small red cap exists can not be confirmed due to layout errors between the keyboards is avoided, and the accuracy of keyboard detection is improved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device and equipment for detecting a small red cap of a keyboard.
Background
In a notebook inherent detection item, the position abnormality of the small red cap needs to be detected, namely whether the small red cap exists on the notebook is detected.
The existing method of setting local characteristics of threshold translation pictures and utilizing the relation of horizontal and vertical coordinates between keycaps is adopted in a mode of relatively low calculation cost, but because keyboard samples are thousands of, small errors are allowed, the method is not intelligent enough, the keyboard is complex, whether small red caps of various keyboards should be in positions or not is difficult to confirm, and the inspection item is difficult to ensure the product yield.
Disclosure of Invention
The embodiment of the invention provides a method, a device and equipment for detecting a small red cap of a keyboard, which have the technical effects of improving the accuracy of keyboard detection and ensuring the yield of products.
One aspect of the present invention provides a method for detecting a red cap of a keyboard, the method comprising: acquiring a keyboard object image and a corresponding keyboard template image; determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image; determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter; determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter; determining a first image region in the keyboard template image containing a plurality of key keys based on the determined plurality of key keys; correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area; determining whether a small red cap is present in the second image region based on image pixel analysis.
In one embodiment, the determining the outline of each keycap letter and the convex hull of each letter based on the keyboard template image comprises: carrying out binarization processing on the keyboard template image to obtain a first intermediate image; acquiring the outline of each keycap letter from the first intermediate image based on image pixels; based on the outline of each keycap letter, the convex hull of each letter is determined.
In an embodiment, the determining the concave-convex degree of each letter outline based on the outline and convex hull of each key cap letter comprises: calculating a maximum pixel separation distance between the contour and the convex hull; determining a degree of concavity and convexity of each letter profile based on the maximum pixel interval distance.
In an embodiment, the determining the degree of concavity and convexity of each letter outline based on the maximum pixel separation distance includes: calculating the maximum pixel spacing distance according to the image proportion of the keyboard object image and the corresponding keyboard template image to obtain a first intermediate value; normalizing the first intermediate value obtained by calculation to obtain a second intermediate value; based on the second intermediate value, the degree of concavity and convexity of the letter outline is determined.
In one embodiment, the plurality of key positions are a G key, an H key and a B key in the keyboard; correspondingly, the second intermediate value is larger than 83 mm-85 mm.
In an embodiment, said determining a first image region of said keyboard template image containing a plurality of said key keys based on said determined plurality of key keys comprises: according to the concave points of the G key, the H key and the B key, the positions of the G key, the H key and the B key in the keyboard are respectively; and determining a first image area containing the G key, the H key and the B key in the keyboard template image based on the positions of the G key, the H key and the B key in the keyboard.
In one embodiment, the determining whether a small red cap exists in the second image region based on image pixel analysis comprises: displaying the second image region in HSV space; improving the brightness of a red range area in the HSV space, and obtaining an area outline; and judging whether the obtained area outline is the outline of the small red hat or not through the maximum inertia degree or the circle rate parameter, and if so, further judging whether the small red hat is in the correct position or not.
In an embodiment, after obtaining the region profile, the method further comprises: removing noise in the region contour by morphology.
Another aspect of the present invention provides a keyboard red cap detection apparatus, comprising: the image acquisition module is used for acquiring a keyboard real object image and a corresponding keyboard template image; the keyboard template image processing module is used for processing the keyboard template image to obtain a keyboard template image, wherein the keyboard template image is used for generating a keyboard template image; the concave-convex determining module is used for determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter; the key position determining module is used for determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter; a first image area obtaining module, configured to determine, based on the determined plurality of key keys, a first image area in the keyboard template image that includes the plurality of key keys; the second image area acquisition module is used for correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area; and the small red cap judging module is used for determining whether a small red cap exists in the second image area based on image pixel analysis.
Another aspect of the invention provides a keyboard red cap detection apparatus, the apparatus comprising a memory and a processor; the memory is configured to store instructions for controlling the processor to operate for performing any of the keyboard red cap detection methods described above.
Another aspect of the invention provides a computer-readable storage medium comprising a set of computer-executable instructions that, when executed, perform any of the keyboard red cap detection methods described above.
In the embodiment of the invention, the outline and the convex hull of each letter are determined by utilizing a keyboard template image corresponding to a keyboard real object image, a plurality of key positions in the keyboard template image are determined according to the concave-convex degree of each letter outline, a first image area containing the key positions is intercepted from the keyboard template image, and a second image area is intercepted from the keyboard real object image based on the position of the first image area; finally, it is determined whether there is a small red cap in the second image region based on image pixel analysis. Compared with the traditional method, the method has the advantages that some local characteristics of the translated pictures with the threshold values are set with relatively low relative calculation cost, and the horizontal and vertical coordinate relation between the keycaps is utilized, so that the problem that the positions of the small red caps cannot be accurately judged due to layout errors between different keyboards can be solved through a mode of matching a real object and a template and the concave-convex degree of letter outlines, the accuracy of keyboard detection can be improved, and the product yield is guaranteed.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
in the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
FIG. 1 is a schematic diagram illustrating an implementation flow of a method for detecting a red hat on a keyboard according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a keyboard template image in a method for detecting a red hat on a keyboard according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an alphabet contour and a convex hull contour in a method for detecting a small red hat on a keyboard according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a keyboard with a small red cap binarized according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a keyboard red hat detection apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, an aspect of the present invention provides a method for detecting a red hat on a keyboard, the method comprising:
102, determining the outline of each keycap letter and the convex hull of each letter based on the keyboard template image;
103, determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter;
104, determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter;
In this embodiment, the keyboard caps refer to red finger bars on some notebooks such as the keyboard of the ThinkPad associated notebook, and it should be noted that the keyboard may be a keyboard on the notebook or a keyboard of a desktop.
In step 101, the keyboard real-object image is a keyboard image to be detected, the keyboard template image corresponds to the keyboard real-object keyboard, that is, the keyboard layout of the keyboard template image and the keyboard real-object keyboard is the same, the keyboard template image may or may not include a small red cap, and fig. 2 is a template image of one of the keyboard real-object keyboards of the keyboard template image.
In step 102, after the keyboard template image is acquired, determining the outline of each keycap letter and the convex hull of each keycap letter in the keyboard image, wherein the determining manner of the outline of the keycap letter can be obtained by distinguishing the keycap letter by using a set pixel threshold value based on the difference between the pixel value of the letter on the image and the background pixel value. After the contours of the letters are obtained, the Convex Hull of each letter is calculated based on the obtained contours, where Convex Hull (Convex Hull) is a concept in the computational geometry (graphics), i.e. in a real vector space V, the intersection S of all Convex sets containing X for a given set X is called the Convex Hull of X. For the purposes of this embodiment, a convex hull is a convex polygon formed by connecting the outermost points of the letters, and can contain all the pixels of the letters.
In step 103, after the contour of each letter and the corresponding convex hull are obtained, the concave-convex degree of each letter is determined, where the determination manner may be calculating a maximum distance between the contour of the letter and the contour of the convex hull, comparing the maximum distance with a preset threshold or a preset threshold range, and if the maximum distance exceeds the preset threshold or the threshold range, it may be determined that the corresponding letter is too concave, otherwise, if the maximum distance does not exceed the preset threshold or the threshold range, it may be determined that the corresponding letter is not too concave, where the preset threshold or the preset threshold range may be adjusted according to the actual detection item.
In step 104, a plurality of key locations in the keyboard may be specifically designated according to convenience of actual detection, that is, the key locations may be any key locations in the keyboard, but generally, the current small red hat is located between the G key, the H key, and the B key, and then the plurality of key locations preferentially select the G key, the H key, and the B key. Accordingly, the preset threshold in step 103 is set to 83.3mm or an interval range around 83.3mm, and when there is a letter whose maximum distance exceeds 83.3mm, it can be determined as the G key, the H key, or the B key.
In step 105, after determining the key location, a first image region at least containing the key location may be intercepted in the keyboard template image, wherein the intercepted first image region may be a square, a circle, or the like, and the size of the region is not limited.
In step 106, after the first image region is determined in the keyboard template image, a second image region with the same region size can be cut out from the keyboard real object image according to the determined coordinate position of the first image region, and the second image region also includes the determined key locations and additionally includes small red caps, as shown in fig. 3.
In step 107, since the small red hat in the second image region is obviously different from the letter or background color, the red region can be distinguished based on the pixel threshold value, and the shape and size of the obtained red region are comprehensively judged to be in accordance with the shape characteristics of the small red hat, so as to determine whether the small red hat exists in the second image region.
Therefore, the outline and the convex hull of each letter are determined by utilizing the keyboard template image corresponding to the keyboard real object image, a plurality of key positions in the keyboard template image are determined according to the concave-convex degree of each letter outline, a first image area containing the key positions is intercepted from the keyboard template image, and a second image area is intercepted from the keyboard real object image based on the position of the first image area; finally, it is determined whether there is a small red cap in the second image region based on image pixel analysis. Compared with the traditional method, the method has the advantages that some local characteristics of the translated pictures with the threshold values are set with relatively low relative calculation cost, and the horizontal and vertical coordinate relation between the keycaps is utilized, so that the problem that the positions of the small red caps cannot be accurately judged due to layout errors between different keyboards can be solved through a mode of matching a real object and a template and the concave-convex degree of letter outlines, the accuracy of keyboard detection can be improved, and the product yield is guaranteed.
In one embodiment, determining the outline of each keycap letter and the convex hull of each letter based on the keyboard template image comprises:
carrying out binarization processing on the keyboard template image to obtain a first intermediate image;
acquiring the outline of each keycap letter from the first intermediate image based on the image pixel;
based on the outline of each keycap letter, the convex hull of each letter is determined.
In this embodiment, the specific implementation process of determining the letter outline and the convex hull in step 102 is as follows:
and (3) carrying out binarization processing on the keyboard template image, namely adjusting the pixel value of a bright color part representing letters in the keyboard template image to 255 and adjusting the pixel value of a dark color part representing a background to 0, and further obtaining a first intermediate image.
At this time, the pixel values of the letter part and the background part are greatly different, and the letter part can be extracted from the first intermediate image by setting a pixel threshold (any one of values between 0 and 255), that is, the outline of each key cap letter is acquired.
The outline of each key cap letter is composed of a plurality of pixel points, and a corresponding convex hull outline can be formed based on the pixel points of each letter outline.
In one embodiment, determining the degree of concavity and convexity of each letter outline based on the outline and convex hull of each key cap letter comprises:
calculating the maximum pixel spacing distance between the contour and the convex hull;
the degree of concavity and convexity of each letter outline is determined based on the maximum pixel interval distance.
In this embodiment, as mentioned above, the letter profile and the convex hull profile are both formed by pixel points, and thus, the specific process of the degree of concavity and convexity in step 103 is:
calculating the maximum pixel spacing distance between the outline and the convex hull, and as shown in fig. 4, assuming that the letter outline of the inner ellipse represents any letter outline, and the outer ellipse is the corresponding convex hull outline, the maximum pixel spacing distance is the maximum straight-line distance of the shaded area in fig. 4, and determining the concave-convex degree of each letter outline according to the maximum straight-line distance.
In one embodiment, determining the degree of concavity and convexity of each letter profile based on the maximum pixel separation distance includes:
calculating the maximum pixel spacing distance according to the image proportion of the keyboard object image and the corresponding keyboard template image to obtain a first intermediate value;
normalizing the first intermediate value obtained by calculation to obtain a second intermediate value;
based on the second intermediate value, the degree of concavity and convexity of the letter outline is determined.
In this embodiment, generally, although the shapes of the keyboard real image and the corresponding keyboard template image are the same, there is a certain proportional size relationship, and thus, the specific process of determining the concave-convex degree of each letter outline is as follows:
and calculating the maximum pixel spacing distance obtained previously according to the preset image proportion size to obtain a first intermediate value.
And performing normalization processing on the obtained first intermediate value to obtain a second intermediate value, wherein the normalization processing is specifically a process of converting the numerical units of the first intermediate value into uniform units.
If the second intermediate value exceeds a specified threshold, it indicates that the letter outline is too concave, whereas if the second intermediate value does not exceed the specified threshold, it indicates that the letter outline is not too concave.
In one embodiment, the plurality of key positions are a key G, a key H and a key B in the keyboard;
correspondingly, the second intermediate value is greater than 83mm to 85 mm.
In the present embodiment, when the second intermediate value exceeds any one value (preferably 83.3mm) in the threshold range of 83mm to 85mm, the G key, the H key, and the B key in the keyboard can be determined.
In one embodiment, determining a first image region of the keyboard template image containing the plurality of key keys based on the determined plurality of key keys comprises:
according to the most concave points of the G key, the H key and the B key, the positions of the G key, the H key and the B key in the keyboard are respectively;
and determining a first image area containing the G key, the H key and the B key in the keyboard template image based on the positions of the G key, the H key and the B key in the keyboard.
In this embodiment, each letter contour has a concave point at a different position, the concave point is a pixel point of the letter contour when the maximum pixel spacing distance is calculated, generally, the concave point of the G key is located at the lower right of the letter contour of the G key, the concave point of the H key is located at the lower left of the letter contour of the H key, and the concave point of the B key is located above the letter contour of the B key.
According to the positions of the G key, the H key and the B key in the keyboard, a first image area containing the G key, the H key and the B key can be intercepted from the keyboard template image.
Further, before the second image area is cut out from the keyboard real object image according to the first image area, the method further comprises the following steps:
and correcting the direction of the keyboard object image based on the keyboard template image. Specifically, the image direction is determined by obtaining the coordinate position of the keyboard template image, and the keyboard object image is adjusted based on the determined coordinate position and image direction, so that the coordinate position or image direction of the keyboard object image is consistent with the keyboard template image.
In one possible embodiment, determining whether a small red cap is present in the second image region based on image pixel analysis comprises:
displaying the second image region in the HSV space;
improving the brightness of a red range area in an HSV space, and obtaining an area outline;
and judging whether the obtained area outline is the outline of the small red hat or not according to the maximum inertia degree or the circle rate parameter, and if so, further judging whether the small red hat is in the correct position or not.
In this embodiment, since the color of the small red cap is red, after the second image region is displayed in the HSV space, the brightness of the red range region is increased, and the binarized second image region can be obtained, as shown in fig. 5.
Judging whether the obtained area contour is the contour of a small red cap or not according to the maximum inertia degree or the circle rate parameter, wherein the maximum inertia degree is the maximum polar inertia moment of the letter contour, and judging whether the maximum inertia degree accords with the inertia degree corresponding to the circle; the circle rate parameter can be obtained by calculating the perimeter of the red range area, whether the calculated circle rate parameter meets the circle parameter corresponding to the circle is judged, and if the maximum inertia degree and the circle rate both meet the parameter corresponding to the circle image, the obtained area outline is judged to be the outline of the small red cap.
After the obtained area outline is determined to be the outline of the small red hat, whether the small red hat is in the correct position is further judged, specifically, the coordinate position of the red area in the keyboard real object image is obtained, if the obtained coordinate position is located at the fixed position in the keyboard real object image, the small red hat in the real object image is finally judged to exist and the position of the small red hat is correct, otherwise, the small red hat is judged to fail to be detected.
In an embodiment, after obtaining the region profile, the method further includes:
the noise in the region contour is removed by morphology.
In the present embodiment, the morphology in the prior art can be regarded as a special digital image processing method and theory, and the morphological characteristics of the image are taken as a research object. The morphological processing algorithm mainly comprises operations of expansion, corrosion, opening, closing and the like, and is used for eliminating boundary points and enabling boundaries to contract inwards so as to be used for eliminating small and meaningless objects.
Another aspect of the present invention provides a keyboard red cap detection apparatus, comprising:
the image acquisition module 201 is configured to acquire a keyboard real object image and a corresponding keyboard template image;
a letter outline calculation module 202 for determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image;
the concave-convex determining module 203 is used for determining the concave-convex degree of each letter outline based on the outline and convex hull of each key cap letter;
a key position determining module 204 for determining a plurality of key positions in the keyboard based on the degree of concavity and convexity of each letter;
a first image region obtaining module 205, configured to determine, based on the determined plurality of key keys, a first image region containing the plurality of key keys in the keyboard template image;
a second image region obtaining module 206, configured to correspondingly obtain, according to the determined first image region, a second image region including a plurality of key keys from the keyboard real-object image;
and a small red cap judging module 207, configured to determine whether a small red cap exists in the second image region based on the image pixel analysis.
In this embodiment, the keyboard caps refer to red finger bars on some notebooks such as the keyboard of the ThinkPad associated notebook, and it should be noted that the keyboard may be a keyboard on the notebook or a keyboard of a desktop.
In the image obtaining module 201, the keyboard real object image is a keyboard image to be detected, the keyboard template image corresponds to the keyboard real object keyboard, that is, the keyboard layout of the keyboard template image and the keyboard real object keyboard is the same, the keyboard template image may or may not include a small red cap, and fig. 2 is a template image of one of the real object keyboards of the keyboard template image.
In the letter outline calculation module 202, after the keyboard template image is acquired, an outline of each key cap letter and a convex hull of each letter in the keyboard image are determined, wherein the determination manner of the outline of the key cap letter can be obtained by distinguishing the key cap letter by using a set pixel threshold value based on the difference between the letter pixel value and the background pixel value on the image. After the contours of the letters are obtained, the Convex Hull of each letter is calculated based on the obtained contours, where Convex Hull (Convex Hull) is a concept in the computational geometry (graphics), i.e. in a real vector space V, the intersection S of all Convex sets containing X for a given set X is called the Convex Hull of X. For the purposes of this embodiment, a convex hull is a convex polygon formed by connecting the outermost points of the letters, and can contain all the pixels of the letters.
In the concave-convex determining module 203, after the contour of each letter and the corresponding convex hull are obtained, the concave-convex degree of each letter is determined, where the determining manner may be calculating a maximum distance between the contour of the letter and the contour of the convex hull, comparing the maximum distance value with a preset threshold or a preset threshold range, and if the maximum distance exceeds the preset threshold or the threshold range, it may be determined that the corresponding letter is too concave, otherwise, if the maximum distance does not exceed the preset threshold or the threshold range, it may be determined that the corresponding letter is not too concave, where the preset threshold or the preset threshold range may be adjusted according to an actual detection item.
In the key position determining module 204, a plurality of key positions in the keyboard can be specifically designated according to the convenience of actual detection, i.e., the key position can be any key position in the keyboard, but generally, the small red cap is located among the G key, the H key and the B key at present, and the plurality of key positions preferentially select the G key, the H key and the B key. Accordingly, the preset threshold in step 103 is set to 83.3mm or an interval range around 83.3mm, and when there is a letter whose maximum distance exceeds 83.3mm, it can be determined as the G key, the H key, or the B key.
In the first image region obtaining module 205, after determining the key, a first image region at least containing the key may be cut out from the keyboard template image, wherein the cut-out first image region may be square, circular, or the like, and the size of the region is not limited.
In the second image region obtaining module 206, after the first image region is determined in the keyboard template image, a second image region with the same region size can be cut out from the keyboard real object image according to the determined coordinate position of the first image region, and the second image region also includes the determined key locations and additionally includes small red caps, as shown in fig. 3.
In the small red cap determining module 207, since the small red cap in the second image region is obviously different from the color of the letter or the background, the red region can be determined based on the pixel threshold, and the shape and the size of the obtained red region are comprehensively determined to be in accordance with the shape characteristics of the small red cap, so as to determine whether the small red cap exists in the second image region.
Therefore, the outline and the convex hull of each letter are determined by utilizing the keyboard template image corresponding to the keyboard real object image, a plurality of key positions in the keyboard template image are determined according to the concave-convex degree of each letter outline, a first image area containing the key positions is intercepted from the keyboard template image, and a second image area is intercepted from the keyboard real object image based on the position of the first image area; finally, it is determined whether there is a small red cap in the second image region based on image pixel analysis. Compared with the traditional method, the method has the advantages that some local characteristics of the translated pictures with the threshold values are set with relatively low relative calculation cost, and the horizontal and vertical coordinate relation between the keycaps is utilized, so that the problem that the positions of the small red caps cannot be accurately judged due to layout errors between different keyboards can be solved through a mode of matching a real object and a template and the concave-convex degree of letter outlines, the accuracy of keyboard detection can be improved, and the product yield is guaranteed.
In an implementation, the letter outline calculation module 202 is specifically configured to:
carrying out binarization processing on the keyboard template image to obtain a first intermediate image;
acquiring the outline of each keycap letter from the first intermediate image based on the image pixel;
based on the outline of each keycap letter, the convex hull of each letter is determined.
In this embodiment, the specific implementation process of determining the letter outline and the convex hull in the letter outline calculation module 202 is as follows:
and (3) carrying out binarization processing on the keyboard template image, namely adjusting the pixel value of a bright color part representing letters in the keyboard template image to 255 and adjusting the pixel value of a dark color part representing a background to 0, and further obtaining a first intermediate image.
At this time, the pixel values of the letter part and the background part are greatly different, and the letter part can be extracted from the first intermediate image by setting a pixel threshold (any one of values between 0 and 255), that is, the outline of each key cap letter is acquired.
The outline of each key cap letter is composed of a plurality of pixel points, and a corresponding convex hull outline can be formed based on the pixel points of each letter outline.
In an implementation, the irregularity determining module 203 is specifically configured to:
calculating the maximum pixel spacing distance between the contour and the convex hull;
the degree of concavity and convexity of each letter outline is determined based on the maximum pixel interval distance.
In this embodiment, as mentioned above, the letter profile and the convex hull profile are both formed by pixel points, and thus, the specific process of the degree of concavity and convexity in step 103 is:
calculating the maximum pixel spacing distance between the outline and the convex hull, and as shown in fig. 4, assuming that the letter outline of the inner ellipse represents any letter outline, and the outer ellipse is the corresponding convex hull outline, the maximum pixel spacing distance is the maximum straight-line distance of the shaded area in fig. 4, and determining the concave-convex degree of each letter outline according to the maximum straight-line distance.
In an implementation manner, the concave-convex determining module 203, when performing the determining of the concave-convex degree of each letter outline based on the maximum pixel separation distance, is specifically configured to:
calculating the maximum pixel spacing distance according to the image proportion of the keyboard object image and the corresponding keyboard template image to obtain a first intermediate value;
normalizing the first intermediate value obtained by calculation to obtain a second intermediate value;
based on the second intermediate value, the degree of concavity and convexity of the letter outline is determined.
In this embodiment, generally, although the shapes of the keyboard real image and the corresponding keyboard template image are the same, there is a certain proportional size relationship, and thus, the specific process of determining the concave-convex degree of each letter outline is as follows:
and calculating the maximum pixel spacing distance obtained previously according to the preset image proportion size to obtain a first intermediate value.
And performing normalization processing on the obtained first intermediate value to obtain a second intermediate value, wherein the normalization processing is specifically a process of converting the numerical units of the first intermediate value into uniform units.
If the second intermediate value exceeds a specified threshold, it indicates that the letter outline is too concave, whereas if the second intermediate value does not exceed the specified threshold, it indicates that the letter outline is not too concave.
In one embodiment, the plurality of key positions are a key G, a key H and a key B in the keyboard;
correspondingly, the second intermediate value is greater than 83mm to 85 mm.
In this embodiment, when the second intermediate value exceeds any one value (preferably 83.3mm) in the threshold range of 83mm to 85mm, the first image area obtaining module 205 may determine the G key, the H key, and the B key in the keyboard.
In an implementation manner, the first image region obtaining module 205 is specifically configured to:
according to the most concave points of the G key, the H key and the B key, the positions of the G key, the H key and the B key in the keyboard are respectively;
and determining a first image area containing the G key, the H key and the B key in the keyboard template image based on the positions of the G key, the H key and the B key in the keyboard.
In this embodiment, each letter contour has a concave point at a different position, the concave point is a pixel point of the letter contour when the maximum pixel spacing distance is calculated, generally, the concave point of the G key is located at the lower right of the letter contour of the G key, the concave point of the H key is located at the lower left of the letter contour of the H key, and the concave point of the B key is located above the letter contour of the B key.
According to the positions of the G key, the H key and the B key in the keyboard, a first image area containing the G key, the H key and the B key can be intercepted from the keyboard template image.
Further, before the second image area is cut out from the keyboard real object image according to the first image area, the method further comprises the following steps:
and correcting the direction of the keyboard object image based on the keyboard template image. Specifically, the image direction is determined by obtaining the coordinate position of the keyboard template image, and the keyboard object image is adjusted based on the determined coordinate position and image direction, so that the coordinate position or image direction of the keyboard object image is consistent with the keyboard template image.
In an implementation manner, the small red cap determining module 207 is specifically configured to:
displaying the second image region in the HSV space;
improving the brightness of a red range area in an HSV space, and obtaining an area outline;
and judging whether the obtained area outline is the outline of the small red hat or not according to the maximum inertia degree or the circle rate parameter, and if so, further judging whether the small red hat is in the correct position or not.
In this embodiment, since the color of the small red cap is red, after the second image region is displayed in the HSV space, the brightness of the red range region is increased, and the binarized second image region can be obtained, as shown in fig. 5.
Judging whether the obtained area contour is the contour of a small red cap or not according to the maximum inertia degree or the circle rate parameter, wherein the maximum inertia degree is the maximum polar inertia moment of the letter contour, and judging whether the maximum inertia degree accords with the inertia degree corresponding to the circle; the circle rate parameter can be obtained by calculating the perimeter of the red range area, whether the calculated circle rate parameter meets the circle parameter corresponding to the circle is judged, and if the maximum inertia degree and the circle rate both meet the parameter corresponding to the circle image, the obtained area outline is judged to be the outline of the small red cap.
After the obtained area outline is determined to be the outline of the small red hat, whether the small red hat is in the correct position is further judged, specifically, the coordinate position of the red area in the keyboard real object image is obtained, if the obtained coordinate position is located at the fixed position in the keyboard real object image, the small red hat in the real object image is finally judged to exist and the position of the small red hat is correct, otherwise, the small red hat is judged to fail to be detected.
In an implementation manner, after obtaining the region contour, the small red cap determining module 207 is further specifically configured to:
the noise in the region contour is removed by morphology.
In the present embodiment, the morphology in the prior art can be regarded as a special digital image processing method and theory, and the morphological characteristics of the image are taken as a research object. The morphological processing algorithm mainly comprises operations of expansion, corrosion, opening, closing and the like, and is used for eliminating boundary points and enabling boundaries to contract inwards so as to be used for eliminating small and meaningless objects.
Another aspect of the invention provides a keyboard red cap detection apparatus, the apparatus comprising a memory and a processor;
the memory is configured to store instructions for controlling the processor to operate so as to implement the keyboard red hat detection method when executed.
In an embodiment of the present invention, a computer-readable storage medium comprises a set of computer-executable instructions, which when executed, are configured to obtain a keyboard object image and a corresponding keyboard template image; determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image; determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter; determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter; determining a first image region containing a plurality of key keys in the keyboard template image based on the plurality of determined key keys; correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area; based on the image pixel analysis, it is determined whether there is a small red cap in the second image region.
Therefore, the outline and the convex hull of each letter are determined by utilizing the keyboard template image corresponding to the keyboard real object image, a plurality of key positions in the keyboard template image are determined according to the concave-convex degree of each letter outline, a first image area containing the key positions is intercepted from the keyboard template image, and a second image area is intercepted from the keyboard real object image based on the position of the first image area; finally, it is determined whether there is a small red cap in the second image region based on image pixel analysis. Compared with the traditional method, the method has the advantages that some local characteristics of the translated pictures with the threshold values are set with relatively low relative calculation cost, and the horizontal and vertical coordinate relation between the keycaps is utilized, so that the problem that the positions of the small red caps cannot be accurately judged due to layout errors between different keyboards can be solved through a mode of matching a real object and a template and the concave-convex degree of letter outlines, the accuracy of keyboard detection can be improved, and the product yield is guaranteed.
Another aspect of the invention provides a computer-readable storage medium comprising a set of computer-executable instructions that, when executed, perform any of the keyboard red hat detection methods described above.
In an embodiment of the present invention, a computer-readable storage medium comprises a set of computer-executable instructions, which when executed, are configured to obtain a keyboard object image and a corresponding keyboard template image; determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image; determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter; determining a key G, a key H and a key B in the keyboard based on the concave-convex degree of each letter; determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter; determining a first image region containing a plurality of key keys in the keyboard template image based on the plurality of determined key keys; correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area; based on the image pixel analysis, it is determined whether there is a small red cap in the second image region.
Therefore, the outline and the convex hull of each letter are determined by utilizing the keyboard template image corresponding to the keyboard real object image, a plurality of key positions in the keyboard template image are determined according to the concave-convex degree of each letter outline, a first image area containing the key positions is intercepted from the keyboard template image, and a second image area is intercepted from the keyboard real object image based on the position of the first image area; finally, it is determined whether there is a small red cap in the second image region based on image pixel analysis. Compared with the traditional method, the method has the advantages that some local characteristics of the translated pictures with the threshold values are set with relatively low relative calculation cost, and the horizontal and vertical coordinate relation between the keycaps is utilized, so that the problem that the positions of the small red caps cannot be accurately judged due to layout errors between different keyboards can be solved through a mode of matching a real object and a template and the concave-convex degree of letter outlines, the accuracy of keyboard detection can be improved, and the product yield is guaranteed.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (10)
1. A method of keyboard pinky-hat detection, the method comprising:
acquiring a keyboard object image and a corresponding keyboard template image;
determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image;
determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter;
determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter;
determining a first image region in the keyboard template image containing a plurality of key keys based on the determined plurality of key keys;
correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area;
determining whether a small red cap is present in the second image region based on image pixel analysis.
2. The method of claim 1, wherein determining an outline of each keycap letter and a convex hull of each letter based on the keyboard template image comprises:
carrying out binarization processing on the keyboard template image to obtain a first intermediate image;
acquiring the outline of each keycap letter from the first intermediate image based on image pixels;
based on the outline of each keycap letter, the convex hull of each letter is determined.
3. The method of claim 1, wherein determining the degree of concavity and convexity of each letter outline based on the outline and convex hull of each keycap letter comprises:
calculating a maximum pixel separation distance between the contour and the convex hull;
determining a degree of concavity and convexity of each letter profile based on the maximum pixel interval distance.
4. The method of claim 3, wherein determining the degree of concavity and convexity of each letter profile based on the maximum pixel separation distance comprises:
calculating the maximum pixel spacing distance according to the image proportion of the keyboard object image and the corresponding keyboard template image to obtain a first intermediate value;
normalizing the first intermediate value obtained by calculation to obtain a second intermediate value;
based on the second intermediate value, the degree of concavity and convexity of the letter outline is determined.
5. The method of claim 4, wherein the plurality of key locations are the G, H, and B keys of a keyboard;
correspondingly, the second intermediate value is larger than 83 mm-85 mm.
6. The method of claim 5, wherein said determining a first image region of the keyboard template image containing a plurality of key keys based on the determined plurality of key keys comprises:
according to the concave points of the G key, the H key and the B key, the positions of the G key, the H key and the B key in the keyboard are respectively;
and determining a first image area containing the G key, the H key and the B key in the keyboard template image based on the positions of the G key, the H key and the B key in the keyboard.
7. The method of claim 1, wherein determining whether a small red cap is present in the second image region based on image pixel analysis comprises:
displaying the second image region in HSV space;
improving the brightness of a red range area in the HSV space, and obtaining an area outline;
and judging whether the obtained area outline is the outline of the small red hat or not through the maximum inertia degree or the circle rate parameter, and if so, further judging whether the small red hat is in the correct position or not.
8. The method of claim 7, wherein after obtaining the region profile, the method further comprises:
removing noise in the region contour by morphology.
9. A keyboard pinky red cap detection apparatus, the apparatus comprising:
the image acquisition module is used for acquiring a keyboard real object image and a corresponding keyboard template image;
the keyboard template image processing module is used for processing the keyboard template image to obtain a keyboard template image, wherein the keyboard template image is used for generating a keyboard template image;
the concave-convex determining module is used for determining the concave-convex degree of each letter outline based on the outline and convex hull of each keycap letter;
the key position determining module is used for determining a plurality of key positions in the keyboard based on the concave-convex degree of each letter;
a first image area obtaining module, configured to determine, based on the determined plurality of key keys, a first image area in the keyboard template image that includes the plurality of key keys;
the second image area acquisition module is used for correspondingly acquiring a second image area containing a plurality of key keys from the keyboard real object image according to the determined first image area;
and the small red cap judging module is used for determining whether a small red cap exists in the second image area based on image pixel analysis.
10. A keyboard pinkeye detection device, comprising a memory and a processor;
the memory is configured to store instructions for controlling the processor to operate so as to implement the keyboard red cap detection method of any one of claims 1-8 when executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110467708.8A CN113379673B (en) | 2021-04-28 | 2021-04-28 | Method, device and equipment for detecting small red cap of keyboard |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110467708.8A CN113379673B (en) | 2021-04-28 | 2021-04-28 | Method, device and equipment for detecting small red cap of keyboard |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113379673A CN113379673A (en) | 2021-09-10 |
CN113379673B true CN113379673B (en) | 2022-02-01 |
Family
ID=77570195
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110467708.8A Active CN113379673B (en) | 2021-04-28 | 2021-04-28 | Method, device and equipment for detecting small red cap of keyboard |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113379673B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116452580B (en) * | 2023-06-13 | 2023-09-01 | 山东古天电子科技有限公司 | Notebook appearance quality detection method |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103207686A (en) * | 2012-01-11 | 2013-07-17 | 联想(北京)有限公司 | Pointing stick, method and device for pointing stick information conversion, and electronic equipment |
CN109738450A (en) * | 2019-01-09 | 2019-05-10 | 合肥联宝信息技术有限公司 | The detection method and device of keyboard of notebook computer |
CN110596121A (en) * | 2019-09-12 | 2019-12-20 | 南京旷云科技有限公司 | Keyboard appearance detection method and device and electronic system |
CN111754461A (en) * | 2020-05-28 | 2020-10-09 | 江苏理工学院 | Method and device for positioning image character area of semiconductor chip |
CN112525925A (en) * | 2020-11-24 | 2021-03-19 | 英业达(重庆)有限公司 | Keyboard detection method, system, electronic equipment and medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7274355B2 (en) * | 2003-04-25 | 2007-09-25 | Oqo, Inc. | Blended transfer function for computer pointing devices |
-
2021
- 2021-04-28 CN CN202110467708.8A patent/CN113379673B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103207686A (en) * | 2012-01-11 | 2013-07-17 | 联想(北京)有限公司 | Pointing stick, method and device for pointing stick information conversion, and electronic equipment |
CN109738450A (en) * | 2019-01-09 | 2019-05-10 | 合肥联宝信息技术有限公司 | The detection method and device of keyboard of notebook computer |
CN110596121A (en) * | 2019-09-12 | 2019-12-20 | 南京旷云科技有限公司 | Keyboard appearance detection method and device and electronic system |
CN111754461A (en) * | 2020-05-28 | 2020-10-09 | 江苏理工学院 | Method and device for positioning image character area of semiconductor chip |
CN112525925A (en) * | 2020-11-24 | 2021-03-19 | 英业达(重庆)有限公司 | Keyboard detection method, system, electronic equipment and medium |
Non-Patent Citations (2)
Title |
---|
Design of a novel convex hull based feature set for recognition of isolated handwritten Roman numerals;N. Das et al.;《Proceedings (CD) of UB-NE ASEE 2009 conference》;20090430;第1-8页 * |
自动光学检测中的键盘缺陷字符关键检测技术研究;管兴坚;《中国优秀硕士学位论文全文数据库 信息科技辑》;20150215;第2015年卷(第2期);第I138-1336页 * |
Also Published As
Publication number | Publication date |
---|---|
CN113379673A (en) | 2021-09-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP7113657B2 (en) | Information processing device, information processing method, and program | |
CN112215800B (en) | Machine learning-based overlapped chromosome recognition and segmentation method | |
CN110503054B (en) | Text image processing method and device | |
CN111598889B (en) | Identification method and device for inclination fault of equalizing ring and computer equipment | |
CN108256454B (en) | Training method based on CNN model, and face posture estimation method and device | |
CN104102347A (en) | Fingertip positioning method and fingertip positioning terminal | |
CN113379673B (en) | Method, device and equipment for detecting small red cap of keyboard | |
CN116168351B (en) | Inspection method and device for power equipment | |
CN116452580B (en) | Notebook appearance quality detection method | |
CN112966618B (en) | Dressing recognition method, apparatus, device and computer readable medium | |
US11906441B2 (en) | Inspection apparatus, control method, and program | |
CN112215811A (en) | Image detection method and device, electronic equipment and storage medium | |
CN113610809A (en) | Fracture detection method, fracture detection device, electronic device, and storage medium | |
CN109784257B (en) | Transformer thermometer detection and identification method | |
CN112288372B (en) | Express bill identification method capable of simultaneously identifying one-dimensional bar code and three-segment code characters | |
CN115830606A (en) | Character flaw detection method, computer device and storage medium | |
CN113298803A (en) | Magnet piece detection method, system, equipment and computer readable storage medium | |
CN112308842A (en) | Automatic positioning kernel extraction method based on printed matter image | |
CN111967469A (en) | Deformed text correction method and system and character recognition method | |
Pingping et al. | Research on recognition technology of license plate image | |
CN112446894B (en) | Image segmentation method based on direction space | |
CN117115867B (en) | Palm vein image living body detection method | |
US11640535B2 (en) | Probability acquisition apparatus and probability acquisition method | |
US20240221352A1 (en) | Image processing device | |
CN115830043B (en) | Boundary detection method, device, equipment and storage medium for wireless charging magnet |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |