Disclosure of Invention
In view of the above, one or more embodiments of the present disclosure are directed to a method, an apparatus, an electronic device, and a storage medium for inputting handwritten text.
In view of the above, one or more embodiments of the present specification provide a handwritten text input method, including:
acquiring at least one track information continuously input by a user;
determining a starting point position and an end point position of the first track information, and determining the track length of the track information according to the starting point position and the end point position;
judging whether the track length is greater than a preset length threshold value or not; and if so, matching in a preset character library according to the at least one track information, and determining character information corresponding to the at least one track information according to a matching result.
In some optional embodiments, the preset library of words comprises: at least two libraries of Chinese character library, letter library and symbol library;
the matching in a preset text library according to the at least one track information and determining text information corresponding to the at least one track information according to a matching result specifically include:
determining the amount of the at least one track information;
setting a matching sequence for the at least two libraries according to the quantity of the track information;
matching in the at least two libraries according to the matching sequence according to the at least one track information; and when a matching result is obtained in any one of the libraries, determining the text information corresponding to the at least one track information according to the matching result.
In some optional embodiments, the preset library of words comprises: a Chinese character library, a letter library and a symbol library;
when the number of the track information is one, the matching sequence is as follows: symbol library, letter library, Chinese character library;
when the number of the track information is two or three, the matching sequence is as follows: letter library, symbol library, Chinese character library;
when the number of the track information is greater than or equal to four, the matching sequence is as follows: chinese character library, letter library and symbol library.
In some optional embodiments, the determining, according to the matching result, text information corresponding to the at least one piece of track information specifically includes:
when more than one text message is determined according to the matching result, all the text messages are displayed to a user;
acquiring voice information input by a user;
performing character recognition on the voice information to obtain character selection information;
and matching the character selection information with all the character information, and determining the character information matched with the character selection information as the character information corresponding to the at least one track information.
In some optional embodiments, the length threshold is: 2W + E or 2H + E; w is the width of the keys of the default virtual keyboard, H is the height of the keys of the default virtual keyboard, and E is the distance between two adjacent keys of the default virtual keyboard.
In some optional embodiments, the method further comprises:
and determining and executing the target event corresponding to the text message according to a preset corresponding relation.
In some optional embodiments, the target event comprises: open applications and/or perform system functions.
Based on the same inventive concept, one or more embodiments of the present specification further provide a handwritten text input device, including:
the acquisition module is configured to acquire at least one track information continuously input by a user;
the determining module is configured to determine a starting point position and an end point position of the first piece of track information, and determine the track length of the track information according to the starting point position and the end point position;
a matching module configured to determine whether the track length is greater than a preset length threshold; and if so, matching in a preset character library according to the at least one track information, and determining character information corresponding to the at least one track information according to a matching result.
Based on the same inventive concept, one or more embodiments of the present specification further provide an electronic device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the method as described in any one of the above items when executing the program.
Based on the same inventive concept, one or more embodiments of the present specification also provide a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method as any one of the above.
As can be seen from the foregoing, in the handwritten text input method, the apparatus, the electronic device, and the storage medium provided in one or more embodiments of the present specification, when track information continuously input by a user is acquired, whether the user is performing handwritten input is determined by using a track length of first track information, and when it is determined that the user is performing handwritten input, matching is performed in a preset text library according to the acquired track information to determine text information, so as to implement a handwritten input process. The user can start the handwriting input process only by directly inputting the track information, the operation process is simple and convenient, the efficiency is high, the attention of the user cannot be influenced too much in the whole handwriting input process, and the safety in the handwriting input process can be improved.
Detailed Description
For the purpose of promoting a better understanding of the objects, aspects and advantages of the present disclosure, reference is made to the following detailed description taken in conjunction with the accompanying drawings.
It is to be noted that unless otherwise defined, technical or scientific terms used in one or more embodiments of the present specification should have the ordinary meaning as understood by those of ordinary skill in the art to which this disclosure belongs. The use of "first," "second," and similar terms in one or more embodiments of the specification is not intended to indicate any order, quantity, or importance, but rather is used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that the element or item listed before the word covers the element or item listed after the word and its equivalents, but does not exclude other elements or items. The terms "connected" or "coupled" and the like are not restricted to physical or mechanical connections, but may include electrical connections, whether direct or indirect.
As described in the background art, the method for inputting handwritten characters in the prior art generally has the problems of complex operation and low efficiency. Specifically, taking the case that the user inputs a text application scene in the text field as an example, the user needs to click the text field first to call out the virtual keyboard; then, selecting handwriting income by clicking keys on the virtual keyboard to switch to a handwriting input mode; and finally, performing handwriting input in the designated area provided by the handwriting input mode. In addition, in some application scenarios, a complicated operation process may also bring about a safety hazard. For example, in the driving process, when the user operates the mobile phone or the vehicle-mounted device to perform handwriting input, the complicated input process may seriously affect the concentration degree of the user on the driving process, and thus driving accidents are easily caused.
In view of the above problems, one or more embodiments of the present specification provide a handwritten text input scheme, where when track information continuously input by a user is acquired, whether the user is performing handwritten input is determined by using a track length of first track information, and when it is determined that the user is performing handwritten input, matching is performed in a preset text library according to the acquired track information to determine text information, so as to implement a handwritten input process. The user can start the handwriting input process only by directly inputting the track information, the operation process is simple and convenient, the efficiency is high, the attention of the user cannot be influenced too much in the whole handwriting input process, and the safety in the handwriting input process can be improved.
The handwritten text input scheme is further described below by specific examples.
Referring to fig. 1, one or more embodiments of the present disclosure provide a method for inputting handwritten text. The method may be performed by any apparatus, device, platform, cluster of devices having computing, processing capabilities.
Referring to fig. 1, the handwritten character input method includes the following steps:
s101, acquiring at least one track information continuously input by a user;
step S102, determining a starting position and an end position of the first track information, and determining the track length of the track information according to the starting position and the end position;
step S103, judging whether the track length is larger than a preset length threshold value or not; and if so, matching in a preset character library according to the at least one track information, and determining character information corresponding to the at least one track information according to a matching result.
In this embodiment, track information continuously input by a user is first acquired. Specifically, when the method of the present embodiment is applied to an electronic device with a touch function, the track information may be obtained by recognizing a touch operation of a user. The number of the track information is at least one; when more than one of the track information is present, the track information is continuously input by the user.
For the first track information input by the user, the track length of the track information is determined. Specifically, the start position and the end position of the track information are determined first. The start position and the end position may be realized by coordinates. As an optional implementation manner, the electronic device to which the method of this embodiment is applied has a rectangular display area, and a rectangular coordinate system is established based on the display area, with the lower left corner of the display area as the origin of coordinates (0, 0). For the first track information input by the user, the starting point position and the end point position are identified based on the established rectangular coordinate system, and the starting point position and the end point position are respectively as follows: starting point position (x)
1,y
1) And end position (x)
2,y
2) (ii) a Then, a straight-line distance between the start point and the end point of the track information, i.e., the position of the start point and the position of the end point is calculated from the position of the start point and the position of the end point
As the track length of the track information. In addition, in othersIn an embodiment, the track length may also be determined in other ways based on the starting point position and the end point position; for example, a difference between the abscissa of the start point position and the abscissa of the end point position, or a difference between the ordinate of the start point position and the ordinate of the end point position, or the like is calculated.
After the track length of the first track information input by the user is obtained, a preset length threshold value is obtained, the track length is compared with the length threshold value, and whether the track length is larger than the preset length threshold value is judged. In this embodiment, whether the track length of the first track information input by the user is long enough is determined by the length threshold. When the first track information input by the user is long enough, the user is considered to start handwriting input, and the first track information is the first stroke of the character input by the user; and when the first track information input by the user is not long enough, the user is not considered to be performing handwriting input, and only one track information is input.
As an alternative embodiment, the length threshold may be determined based on a system default virtual keyboard of the electronic device to which the method of the present embodiment is applied. Specifically, the default virtual keyboard is a virtual key keyboard provided by an operating system of the electronic device or a default input method application program for realizing input. Referring to fig. 2, an example of a default virtual keyboard is given, wherein the graphical objects in the shape of a square are keys, and the keys arranged in an array form the default virtual keyboard. For the default virtual keyboard, the width of the key is W, the height of the key is H, and the distance between two adjacent keys is E. Accordingly, the length threshold is set to 2 × W + E or 2 × H + E. In addition, in other embodiments, the length threshold may be set to other values, such as the average length of the first stroke when handwriting input is performed by a large number of users, which is obtained through big data statistics.
And comparing the track length determined by the straight-line distance between the starting point position and the end point position of the first track information input by the user with the length threshold.
When the track length is greater than the length threshold value, that is, the track length of the first track information input by the user is greater than the length (or width) of two times of keys on the default virtual keyboard plus one key interval, the user is likely to be handwriting-inputting a first stroke, such as a horizontal stroke, a left-falling stroke and the like, at this time, the obtained track information continuously input by the user is further matched in a preset character library, the track information is matched with a standard rule corresponding to characters and pre-stored in the character library, and if the matching is successful, the character information corresponding to the track information can be obtained. Further, after the text information corresponding to the track information is obtained, corresponding subsequent processing is performed according to the text information, for example, the text information is displayed in the input box.
When the track length is not greater than the length threshold, if the first track information input by the user is a circular track, the linear distance between the starting position and the end position of the first track information is smaller, so that similar track information does not accord with the characteristics of the user when inputting characters, and the track information input by the user is not subjected to subsequent processing.
In this embodiment, the track information continuously input by the user corresponds to the text input content by the user, and in order to meet the habit and characteristics of the user in inputting text, the text input by the user in sequence can be divided by the time interval between the continuously input track information. For example, the time interval is set to 1 second, when the time interval between any two adjacent track information exceeds 1 second, it is determined that the successive track information respectively corresponds to different characters input later, and the track information corresponding to the different characters are respectively subjected to a matching process in the character library, so as to obtain the character information corresponding to each track information through matching. The specific value of the time interval can be flexibly set by comprehensively considering the software and hardware configuration of the electronic equipment.
It should be noted that the track information may be obtained under other interfaces besides the interface of the virtual keyboard provided by the system of the electronic device. The other interfaces may be any interfaces which need to perform text input but do not display a virtual keyboard, and the interfaces have input boxes for users to perform text input but do not display a virtual keyboard, such as a search interface, a login interface and the like; the other interface may also be other interfaces in the system of the electronic device that allow the user to make inputs, such as a system desktop, a welcome interface of an application, and so on.
It should be noted that, the identification of the track information, the determination of the starting point position and the ending point position, and the related technologies of obtaining the text information by matching in the text library in the above embodiments are all the prior art, and the corresponding specific working mode and technical principle thereof are not detailed in this specification.
Hereinafter, a specific application example of the handwritten character input method of the present embodiment is given. The handwritten character input method of the embodiment is applied to the vehicle-mounted equipment and operates based on a vehicle-mounted machine system of the vehicle-mounted equipment. The user needs to input the destination in the navigation software in the driving process, and the user operates the control screen in the vehicle and clicks and opens the navigation software to enter the destination input interface. And directly starting handwriting input of the track information corresponding to the characters on the central control screen by the user under the input destination interface. And when the track length of the first track information is judged to be larger than the length threshold value, matching the track information continuously input by the user in the character library to obtain character information, and displaying the character information in an input box of an input destination in the interface. Therefore, in the whole process of realizing the handwriting input, the user removes the necessary operation of starting the navigation function, and all other input operations are used for realizing the handwriting input process, so that the operation is very simple and convenient; and the simple operation does not have too much concentration degree of the user in the scattered driving, and can effectively reduce the potential safety hazard.
As an optional embodiment, in the handwritten text input method, the preset text library includes: chinese character library, letter library and symbol library. The Chinese character library, the letter library and the symbol library are respectively used for matching and outputting characters of Chinese characters, letters and symbols. The letter library can correspond to letters of any language, such as English, French and the like.
In this embodiment, referring to fig. 3, the step of matching in a preset text library to determine text information specifically includes:
step S301, determining the quantity of the at least one track information;
step S302, setting a matching sequence for a Chinese character library, a letter library and a symbol library according to the number;
step S303, matching in a Chinese character library, a letter library and a symbol library according to the matching sequence according to the at least one piece of track information; and when a matching result is obtained in any one of the libraries, determining the text information corresponding to the at least one track information according to the matching result.
In the process of handwriting input, the situation of alternately inputting characters and symbols in different languages is often encountered. In the existing handwriting input scheme, after a user inputs track information, matching needs to be performed in different character libraries, and such a way affects the speed of data processing. In this embodiment, sequential matching is performed in the chinese character library, the letter library, and the symbol library according to different matching orders according to the number of the trajectory information, and after a matching result is obtained by matching in any one library, the matching process is not performed on the library subsequent to the matching order.
Specifically, when the number of the trajectory information is one, the number of strokes of the currently input character by the user is small, and from the viewpoint of general character composition characteristics, the input character has a high probability of being a symbol and then possibly being a letter. The corresponding matching order is: symbol library, letter library, and Chinese character library. That is, when the number of the track information is one, the track information is used for matching in the symbol library, if the matching result is obtained by matching, the corresponding character information is determined, and if the matching result is not obtained by matching, the matching is further sequentially carried out in the letter library and the Chinese character library until the matching result is obtained by matching.
When the number of the track information is two or three, the input characters are letters with a high probability and symbols with a low probability in terms of general character formation characteristics. The corresponding matching order is: letter library, symbol library and Chinese character library. That is, when the number of the track information is two or three, the track information is used for matching in the letter library, and the subsequent matching process is performed according to whether the matching result is obtained through matching.
When the number of the track information is more than or equal to four, the input characters are Chinese characters with higher probability and are possibly letters secondly from the aspect of general character composition characteristics. The corresponding matching order is: chinese character library, letter library and symbol library. That is, when the number of the track information is more than or equal to four, the track information is used for matching in the Chinese character library, and the subsequent matching process is carried out according to whether the matching result is obtained by matching.
In the embodiment, according to the characteristics of the number of strokes forming the character, the corresponding relationship between the number of the track information and the matching sequence of each character library is correspondingly set, so that the character information corresponding to the track information can be obtained without matching in each character library under most conditions, the data processing speed is effectively increased, and the efficiency of the handwritten character input method of the embodiment is further improved.
In addition, as an alternative embodiment, the preset character library may also include only any two of a chinese character library, a letter library, and a symbol library. Correspondingly, the matching sequence corresponding to the number of the track information is correspondingly set according to the two selected libraries. For example,
if the two libraries are a Chinese character library and a letter library respectively, the corresponding settings can be: when the number of the track information is more than three, the matching sequence is as follows: chinese character library and letter library; when the number of the track information is less than or equal to three, the matching sequence is as follows: letter library and Chinese character library.
If the two libraries are the Chinese character library and the symbol library respectively, the corresponding settings can be: when the number of the track information is more than two, the matching sequence is as follows: chinese character library and symbol library; when the number of the track information is less than or equal to two, the matching sequence is as follows: symbol library, Chinese character library;
if the two libraries are the letter library and the symbol library, the corresponding settings can be: when the number of the track information is one, the matching sequence is as follows: symbol library, letter library; when the number of the track information is more than one, the matching sequence is as follows: letter library, symbol library.
It should be noted that, the above-mentioned embodiment aims to improve the efficiency of inputting handwritten characters on the basis of conforming to the characteristics of the number of strokes of the characters by establishing the corresponding relationship between the number of track information and the matching sequence of the character library, and the specific corresponding relationship between the number of track information and the matching sequence of the character library in the foregoing embodiment is merely an example, and it can be adjusted accordingly as required in the implementation process.
As an optional embodiment, in the handwritten text input method, when matching is performed in a preset text library to determine text information corresponding to the trajectory information, there may be more than one text information obtained by matching in the same text library, and the more than one text information needs to be determined by selection of the user. Specifically, all the matched text information can be displayed to the user, and prompt information is popped up for the user to select. The selection mode can be that the user inputs a selection instruction through an input device (such as directly clicking a touch screen) or selects through a voice input mode.
Referring to fig. 4, the step of selecting the text information by a voice input method specifically includes:
s401, when more than one text message is determined according to the matching result, all the text messages are displayed to a user;
step S402, acquiring voice information input by a user;
step S403, performing character recognition on the voice information to obtain character selection information;
step S404, matching the character selection information with all the character information, and determining the character information matched with the character selection information as the character information corresponding to the at least one track information.
In this embodiment, all the text information obtained according to the matching result is displayed to the user in a prompt box or voice manner, so that the user can know all the text information. The user selects in a voice mode according to the character input requirement, namely, a voice message is input. After the voice information input by the user is obtained, carrying out character recognition on the voice information to obtain character selection information; and then, taking the character information matched with the character selection information as character information corresponding to the track information input by the user.
As an example, the user intends to input a "month" character through four continuous trajectory information by the handwritten character input method of the present embodiment, but two character information of "month" and "destination" are determined in a chinese character library by matching due to the problem of trajectory deformation caused by handwriting. At the moment, the two text messages of 'month' and 'aim' are displayed to the user through the prompt box, and the user is prompted to select through voice. The user inputs the voice information of the month and obtains the character selection information of the month through character recognition. Furthermore, the result that the text information 'month' corresponds to the track information input by the user can be finally obtained through matching.
It should be noted that the technology of using a speech device as a text in this embodiment is the prior art, and the corresponding specific working mode and technical principle are not described in detail in this specification.
As an optional embodiment, in the handwritten text input method, after determining text information corresponding to at least one piece of track information, the method further includes the following steps: and determining and executing the target event corresponding to the text message according to a preset corresponding relation.
In this embodiment, the text information obtained by the user through the handwritten text input method of this embodiment is further used to execute a predetermined target event. The corresponding relation corresponds the character information with the target event.
In this embodiment, the target event may be to start an application. For example, when the text information obtained by the user through the handwritten text input method of the embodiment is "WeChat", the WeChat is correspondingly turned on. That is, the character information corresponding to the name of the application program can be associated with the opening of the application program. When the user obtains the text information with the content being the application program name by the handwritten text input method of the embodiment, the corresponding application program is correspondingly started.
In this embodiment, the target event may also be an execution of a system function. For example, when the text information obtained by the user through the handwritten text input method of the embodiment is "restart," a restart operation is correspondingly performed. That is, the text information corresponding to the name of the system function can be associated with the execution of the system function. When the user obtains the text information with the content of the system function name by the handwritten text input method of the embodiment, the corresponding system function is executed correspondingly.
The handwritten character input method of the embodiment enables a user to simply and quickly implement the execution of the target event through the method of the embodiment, and further enriches the application range of the method of the embodiment.
It should be noted that the above description describes certain embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Based on the same inventive concept, one or more embodiments of the present specification further provide a handwritten text input device. Referring to fig. 5, the handwritten text input device includes:
an obtainingmodule 501 configured to obtain at least one track information continuously input by a user;
a determiningmodule 502 configured to determine a start position and an end position of the first piece of track information, and determine a track length of the track information according to the start position and the end position;
amatching module 503 configured to determine whether the track length is greater than a preset length threshold; and if so, matching in a preset character library according to the at least one track information, and determining character information corresponding to the at least one track information according to a matching result.
In an alternative embodiment, the predetermined library of words comprises: at least two libraries of Chinese character library, letter library and symbol library; thematching module 503 is specifically configured to determine the amount of the at least one track information; setting a matching sequence for the at least two libraries according to the quantity of the track information; matching in the at least two libraries according to the matching sequence according to the at least one track information; and when a matching result is obtained in any one of the libraries, determining the text information corresponding to the at least one track information according to the matching result.
In an alternative embodiment, the predetermined library of words comprises: a Chinese character library, a letter library and a symbol library; when the number of the track information is one, the matching sequence is as follows: symbol library, letter library, Chinese character library; when the number of the track information is two or three, the matching sequence is as follows: letter library, symbol library, Chinese character library; when the number of the track information is greater than or equal to four, the matching sequence is as follows: chinese character library, letter library and symbol library.
In an optional embodiment, thematching module 503 is specifically configured to show all the text information to the user when more than one text information is determined according to the matching result; acquiring voice information input by a user; performing character recognition on the voice information to obtain character selection information; and matching the character selection information with all the character information, and determining the character information matched with the character selection information as the character information corresponding to the at least one track information.
In an alternative embodiment, the length threshold is: 2W + E or 2H + E; w is the width of the keys of the default virtual keyboard, H is the height of the keys of the default virtual keyboard, and E is the distance between two adjacent keys of the default virtual keyboard.
In an optional embodiment, the handwritten text input device further comprises: and the execution module is configured to determine and execute the target event corresponding to the text message according to a preset corresponding relation. Wherein the target event comprises: open applications and/or perform system functions.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, the functionality of the modules may be implemented in the same one or more software and/or hardware implementations in implementing one or more embodiments of the present description.
The apparatus of the foregoing embodiment is used to implement the corresponding method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which are not described herein again.
Based on the same inventive concept, one or more embodiments of the present specification further provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the handwritten text input method according to any of the above embodiments.
Fig. 6 is a schematic diagram illustrating a more specific hardware structure of an electronic device according to this embodiment, where the electronic device may include: aprocessor 1010, amemory 1020, an input/output interface 1030, acommunication interface 1040, and abus 1050. Wherein theprocessor 1010,memory 1020, input/output interface 1030, andcommunication interface 1040 are communicatively coupled to each other within the device viabus 1050.
Theprocessor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present disclosure.
TheMemory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. Thememory 1020 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in thememory 1020 and called to be executed by theprocessor 1010.
The input/output interface 1030 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
Thecommunication interface 1040 is used for connecting a communication module (not shown in the drawings) to implement communication interaction between the present apparatus and other apparatuses. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, Bluetooth and the like).
Bus 1050 includes a path that transfers information between various components of the device, such asprocessor 1010,memory 1020, input/output interface 1030, andcommunication interface 1040.
It should be noted that although the above-mentioned device only shows theprocessor 1010, thememory 1020, the input/output interface 1030, thecommunication interface 1040 and thebus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.
Based on the same inventive concept, one or more embodiments of the present specification further provide a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the handwritten text input method according to any of the above embodiments.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, is limited to these examples; within the spirit of the present disclosure, features from the above embodiments or from different embodiments may also be combined, steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present description as described above, which are not provided in detail for the sake of brevity.
It is intended that the one or more embodiments of the present specification embrace all such alternatives, modifications and variations as fall within the broad scope of the appended claims. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of one or more embodiments of the present disclosure are intended to be included within the scope of the present disclosure.