Disclosure of Invention
The application provides an automatic modeling and positioning method for a keyboard keycap, and aims to solve the problems of complex modeling, poor efficiency and accuracy and weak adaptability of the conventional keyboard keycap detection method.
The technical scheme adopted by the application is as follows:
an automatic modeling and positioning method for a keyboard keycap comprises the following steps:
establishing a standard template library of a keyboard keycap, wherein each standard template in the standard template library stores key outline image information of the standard template and image information of key characters;
shooting a keyboard to be detected through a camera to obtain image information of the keyboard to be detected;
presetting modeling parameters according to image information of a keyboard to be detected, and performing keycap characteristic modeling according to a standard template library of keycaps of the keyboard to obtain keycap modeling image parameters of the keyboard to be detected;
the keycap modeling image parameters of the keyboard to be detected are compared with the image information parameters of the standard template, difference characteristics are searched, and detection of the keyboard quality is achieved.
Optionally, the step of shooting the keyboard to be detected through the camera to obtain the image information of the keyboard to be detected includes:
the camera is a double camera, and the complete image splicing is realized through the global positioning characteristic to obtain the image information of the keyboard to be detected.
Optionally, after the step of obtaining the image information of the keyboard to be detected by the two cameras, respectively performing keycap feature modeling on the two images shot by the two cameras in the modeling process, and performing image parameter splicing by using the global positioning feature, thereby obtaining the complete keycap modeling image parameters of the keyboard to be detected.
Optionally, in the step of obtaining a key cap modeling image parameter of the keyboard to be detected by presetting a modeling parameter for the image information of the keyboard to be detected and performing key cap feature modeling according to a standard template library of key caps of the keyboard, the key cap feature modeling is based on three feature parameters, namely, a key cap region feature parameter, a character region feature parameter and a line finding region feature parameter.
Optionally, in the step of obtaining the key cap modeling image parameters of the keyboard to be detected by presetting the modeling parameters of the image information of the keyboard to be detected and performing key cap feature modeling according to the standard template library of the key caps of the keyboard, the method includes:
processing the image information of the keyboard to be detected into binary image information through global binarization;
performing region analysis on the binary image information to obtain modeling characteristic parameters;
and carrying out positioning training according to the modeling characteristic parameters to obtain the complete keycap modeling image parameters of the keyboard to be detected.
Optionally, the area analysis is Blob analysis, key cap area characteristic parameters and character area characteristic parameters are obtained through the Blob analysis, a line finding tool is set according to the key cap area characteristic parameters, an accurate line is found, and the line finding area characteristic parameters are obtained.
Optionally, the modeling characteristic parameters include key cap region characteristic parameters, character region characteristic parameters and line finding region characteristic parameters.
Optionally, in the step of comparing the keycap modeling image parameter of the keyboard to be detected with the image information parameter of the standard template, searching for a difference characteristic, and realizing the detection of the keyboard quality, the method includes:
and performing Pattern inspection training on the key cap modeling image parameters of the complete keyboard to be detected, comparing the key cap modeling image parameters of the keyboard to be detected with preset regions of a standard template, searching for difference characteristics, and integrating the difference characteristics of all the regions to realize the detection of the keyboard quality.
Optionally, the method for automatically modeling and positioning a key cap of a keyboard includes:
the global binarization adopts a global self-adaptive mode to carry out image binarization, so that the characteristic enhancement of a keycap area and a character area is realized, and an interference area causing the connection of two keycap black areas is set as a filling area;
through the Blob analysis obtains the black key cap region, filters through the Blob screening and gets rid of the interference Blob, and the hole in the black key cap region is the character region promptly, looks for the line region and sets up according to Blob's external rectangle.
Optionally, in the step of obtaining the key cap modeling image parameters of the keyboard to be detected by presetting the modeling parameters of the image information of the keyboard to be detected and performing key cap feature modeling according to the standard template library of the key caps of the keyboard, the method includes:
and zooming the standard template in the corresponding standard template library according to the actual size of the keyboard to be detected, so that the size of the zoomed standard template is the same as the actual size of the keyboard to be detected.
The technical scheme of the application has the following beneficial effects:
according to the method, the standard template library and the preset parameters are adopted for rapid corresponding modeling, so that the modeling mode is simple, and the method has high convenience and maintainability; simultaneously standard template in this application has higher adaptability, and applicable in different detection board accomplishes the high quality short-term test to the keyboard, detects the high just application scope of precision extensively, is suitable for and popularizes and applies in the aspect of the assembly line detection of keyboard in the industry vision field.
Detailed Description
Reference will now be made in detail to embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following examples do not represent all embodiments consistent with the present application. But merely as exemplifications of systems and methods consistent with certain aspects of the application, as recited in the claims.
Referring to fig. 1, a flow diagram of an embodiment of the present application is shown.
The application provides a keyboard key cap automatic modeling and positioning method, which comprises the following steps:
s101, establishing a standard template library of a keyboard keycap, wherein each standard template in the standard template library stores key outline image information of the standard template and key character image information;
s102, shooting a keyboard to be detected through a camera to acquire image information of the keyboard to be detected;
s103, presetting modeling parameters according to image information of the keyboard to be detected, and performing keycap characteristic modeling according to a standard template library of keycaps of the keyboard to obtain keycap modeling image parameters of the keyboard to be detected;
and S104, comparing the keycap modeling image parameters of the keyboard to be detected with the image information parameters of the standard template, searching for difference characteristics, and realizing the detection of the keyboard quality.
In the embodiment, because the standard template library of the keyboard keycaps is established, illustratively, the standard template library can be preset with keyboard parameter information of various national standards of all countries, so that the standard template database with rich original data is formed, the time for real-time modeling in response to different keyboard types and specifications is saved, and the database calling has efficient and accurate technical effects.
Optionally, the step of shooting the keyboard to be detected through the camera to obtain the image information of the keyboard to be detected includes:
the camera is a double camera, and the complete image splicing is realized through the global positioning characteristic to obtain the image information of the keyboard to be detected.
In the embodiment, because the keyboard is long, the shooting of a single camera is difficult to cover the whole keyboard, so that the shooting of double cameras is adopted, and the spliced complete image is realized through the global positioning characteristic. And during modeling, the two images are subjected to modeling processing respectively. Of course, as another possible embodiment, the two images are first combined into a complete image and then subjected to modeling processing, which is also obvious based on this embodiment, and thus the invention also belongs to the protection scope of the inventive concept of this embodiment.
Optionally, after the step of obtaining the image information of the keyboard to be detected by the two cameras, respectively performing keycap feature modeling on the two images shot by the two cameras in the modeling process, and performing image parameter splicing by using the global positioning feature, thereby obtaining the complete keycap modeling image parameters of the keyboard to be detected.
Optionally, in the step of obtaining a key cap modeling image parameter of the keyboard to be detected by presetting a modeling parameter for the image information of the keyboard to be detected and performing key cap feature modeling according to a standard template library of key caps of the keyboard, the key cap feature modeling is based on three feature parameters, namely, a key cap region feature parameter, a character region feature parameter and a line finding region feature parameter.
Referring to fig. 2, in the present embodiment, the key cap region characteristic parameters, the character region characteristic parameters and the line finding region characteristic parameters required for modeling are based on the corresponding key cap region, the character region and the line finding region. The keycap area is located in the area surrounded by the larger rectangle in fig. 2, the character area is the smallest external rectangle area of the character in the figure, and the line finding area is the area of the three strip rectangles at the outermost periphery.
Optionally, in the step of obtaining the key cap modeling image parameters of the keyboard to be detected by presetting the modeling parameters of the image information of the keyboard to be detected and performing key cap feature modeling according to the standard template library of the key caps of the keyboard, the method includes:
s3001, processing the image information of the keyboard to be detected into binary image information through global binarization;
s3002, carrying out region analysis on the binary image information to obtain modeling characteristic parameters;
and S3003, performing positioning training according to the modeling characteristic parameters, and acquiring complete keycap modeling image parameters of the keyboard to be detected.
Referring to fig. 3 and 4, in the present embodiment, in the positioning training, a global positioning kernel needs to be determined, a splicing parameter feature is provided for splicing two images, and the positioning training is performed according to the same region in the two images, so that accurate positioning is realized, and a complete key cap modeling image parameter of the keyboard to be detected is obtained. For example, in fig. 4, the two images both include a space key, so that the space key is used as a global positioning core, and after positioning training, the key cap modeling image parameters of the complete keyboard to be detected can be accurately positioned and acquired.
Illustratively, in the actual modeling process, a modeling area is set: the modeling area mainly comprises a detection area (the area is subjected to Blob analysis and used for extracting key cap area characteristics and character area characteristics), a non-detection area (the area is mainly a direction key, an Enter key and the like which do not participate in detection), a filling area (the area is mainly provided with repeated key caps, interference areas and the like in the detection areas of the two images) and a global positioning area (the area is a common area of the two images, and the area is provided with global positioning characteristics used for image splicing).
Illustratively, the region analysis is Blob analysis, which includes Blob filtering, specifically: filter out all blobs (target + holes) of non-detection regions; filtering out elongated Blob according to the length-width ratio of the keycap specification of the product information; filtering out smaller black Blob according to the area of the keycap; filtering out the black Blob without the hole sub Blob; and ordering the blobs meeting the conditions according to the center coordinates in an increasing manner of Y, and arranging the blobs in the same row in an increasing manner of X into a two-dimensional matrix. Verifying that the Y coordinate deviation of the centers of the blobs in the same row does not exceed 20 pixels.
The character area for the keycap in the modeling, as shown in FIG. 5: the white hole in each keycap black Blob is externally connected with a rectangle, and the external rectangle is expanded for a certain distance to form a character area. If the character is a plurality of characters, the maximum external rectangle expansion distance of all the characters is taken as the character area. The keycap has three line finding areas, as shown in fig. 6: the left side, the right side and the upper side of a line finding tool for preliminarily setting the keycaps are shown as arrows, the positions of three edges of the area of the Blob are arranged, the positions can be slightly inside, the middle line position can be set to be 0.5 times of the distance between the keycaps which are retracted from the edge positions, and the width is the distance between the keycaps.
In another embodiment, the sorting of keycap IDs can be performed: for the convenience, the key caps can be numbered when modeling, key cap region coordinate information obtained through Blob analysis results is sorted from small to large according to the X/Y direction, and key cap IDs are unified.
Optionally, the area analysis is Blob analysis, key cap area characteristic parameters and character area characteristic parameters are obtained through the Blob analysis, a line finding tool is set according to the key cap area characteristic parameters, an accurate line is found, and the line finding area characteristic parameters are obtained.
Optionally, the modeling characteristic parameters include key cap region characteristic parameters, character region characteristic parameters and line finding region characteristic parameters.
Optionally, in the step of comparing the keycap modeling image parameter of the keyboard to be detected with the image information parameter of the standard template, searching for a difference characteristic, and realizing the detection of the keyboard quality, the method includes:
and performing Pattern inspection training on the key cap modeling image parameters of the complete keyboard to be detected, comparing the key cap modeling image parameters of the keyboard to be detected with preset regions of a standard template, searching for difference characteristics, and integrating the difference characteristics of all the regions to realize the detection of the keyboard quality.
Optionally, the method for automatically modeling and positioning a key cap of a keyboard includes:
the global binarization adopts a global self-adaptive mode to carry out image binarization, so that the characteristic enhancement of a keycap area and a character area is realized, and an interference area causing the connection of two keycap black areas is set as a filling area;
through the Blob analysis obtains the black key cap region, filters through the Blob screening and gets rid of the interference Blob, and the hole in the black key cap region is the character region promptly, looks for the line region and sets up according to Blob's external rectangle.
Referring to fig. 7, for example, as shown by a rectangular line frame in the figure, the interference region may cause the black regions of the two keycaps to be connected, a filling region may be provided, and the interference region in the binarized image is filled to 255, so as to eliminate the interference.
Optionally, in the step of obtaining the key cap modeling image parameters of the keyboard to be detected by presetting the modeling parameters of the image information of the keyboard to be detected and performing key cap feature modeling according to the standard template library of the key caps of the keyboard, the method includes:
and zooming the standard template in the corresponding standard template library according to the actual size of the keyboard to be detected, so that the size of the zoomed standard template is the same as the actual size of the keyboard to be detected.
In this embodiment, the image scaling needs to be determined: due to the difference of hardware of different detection machine platforms, the imaging of the same type of keyboard can be scaled in size, and in order to improve the applicability of the template, the specific size calculation needs to be carried out on the template, so that the proportion calculation is carried out according to the corresponding actual specific size during detection, the image scaling is realized, and the detection precision is improved; and (3) obtaining the upper edge line segment of the uppermost key cap and the edge line segments of the key caps on the left side and the right side through the key cap line finding area, and calculating the distance from the line segments to the edge line segment of the global positioning core, thereby accurately zooming after obtaining a specific size. In addition, for the present embodiment, it is needless to say that: when the size of the scaled standard template is very close to the actual size of the keyboard to be detected, the standard template is also regarded as the same and should not be regarded as a size which does not meet the standard, so that the over-killing rate is high. Therefore, the "same" in this embodiment also has similar inclusion, and should have certain elasticity.
According to the method, the standard template library and the preset parameters are adopted for rapid corresponding modeling, so that the modeling mode is simple, and the method has high convenience and maintainability; simultaneously standard template in this application has higher adaptability, and applicable in different detection board accomplishes the high quality short-term test to the keyboard, detects the high just application scope of precision extensively, is suitable for and popularizes and applies in the aspect of the assembly line detection of keyboard in the industry vision field.
The embodiments provided in the present application are only a few examples of the general concept of the present application, and do not limit the scope of the present application. Any other embodiments extended according to the scheme of the present application without inventive efforts will be within the scope of protection of the present application for a person skilled in the art.