Methods, apparatus, storage media and electronic devices for text determination
By determining the position information of the target touch trajectory in the text input interface and judging its corresponding text line instead of directly dividing the characters, the problem of inaccurate character segmentation in online handwriting recognition is solved, and the accuracy of text recognition is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING XIAOMI MOBILE SOFTWARE CO LTD
- Filing Date
- 2023-01-04
- Publication Date
- 2026-06-30
AI Technical Summary
In existing technologies, online handwriting recognition has difficulty accurately identifying characters when segmenting handwriting strokes, resulting in poor support for continuous strokes, which affects recognition accuracy. Furthermore, incorrect character segmentation can lead to the loss of contextual information.
By determining the target touch trajectory in the text input interface, the position information of the touch point is obtained, and the text line corresponding to the target touch trajectory is determined based on the trajectory information, thus avoiding direct character segmentation and directly determining the target text.
It improves the accuracy of text segmentation, avoids the loss of contextual information due to stroke segmentation, and enhances the accuracy of text recognition.
Smart Images

Figure CN116185271B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of text recognition, and more particularly to a method, apparatus, storage medium, and electronic device for text determination. Background Technology
[0002] With the popularization of paperless offices, online handwriting recognition via electronic devices is becoming increasingly common. The handwritten text processed by online handwriting recognition is the text signal obtained by the writer through physical devices, such as digital pens, digital writing tablets, or touch screens. The writing trajectory is sampled at regular intervals and input into the computer in real time.
[0003] In related technologies, segmentation schemes divide input strokes into individual characters. This segmentation method requires accurate identification of the character to which a stroke belongs and has poor support for connected strokes. If the character segmentation is incorrect, it significantly affects the subsequent recognition accuracy. Even if the strokes are correctly segmented into individual characters, the contextual information of the input will be lost, thus affecting the recognition effect. Summary of the Invention
[0004] To overcome the problems existing in related technologies, this disclosure provides a method, apparatus, storage medium, and electronic device for determining text.
[0005] According to a first aspect of the present disclosure, a method for determining text is provided, comprising:
[0006] The method involves determining a target touch trajectory input on a text input interface, the target touch trajectory including at least two touch points; the current text input interface including multiple text lines; acquiring position information of each of the at least two touch points, and determining first trajectory information of the target touch trajectory based on the position information; determining the target text line corresponding to the target touch trajectory from the multiple text lines based on the first trajectory information; and determining the target text based on the target text line.
[0007] Optionally, the location information includes the horizontal and vertical coordinates based on a preset coordinate system corresponding to the text input interface, and the first trajectory information includes a first trajectory width and a first trajectory height. The first trajectory information for obtaining the location information of each of the at least two touch points and determining the target touch trajectory based on the location information includes: determining a first target horizontal coordinate with the largest horizontal coordinate and a second target horizontal coordinate with the smallest horizontal coordinate from the horizontal coordinates of the at least two touch points; determining a first target vertical coordinate with the largest vertical coordinate and a second target vertical coordinate with the smallest vertical coordinate from the vertical coordinates of the at least two touch points; using the difference between the first target horizontal coordinate and the second target horizontal coordinate as the first trajectory width; and using the difference between the first target vertical coordinate and the second target vertical coordinate as the first trajectory height.
[0008] Optionally, determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information includes: obtaining second trajectory information corresponding to one or more touch trajectories in each text line; and determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information.
[0009] Optionally, the second trajectory information includes a second trajectory width and a second trajectory height. Obtaining the second trajectory information corresponding to the touch trajectory in each text line includes: for each text line, determining the maximum and minimum horizontal coordinates, and the maximum and minimum vertical coordinates in one or more touch trajectories corresponding to the text line; using the difference between the maximum and minimum horizontal coordinates as the second trajectory width corresponding to the text line; and using the difference between the maximum and minimum vertical coordinates as the second trajectory height corresponding to the text line.
[0010] Optionally, determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information includes: determining the first text line corresponding to the last input touch trajectory; if the first text line is determined to be a specified touch trajectory, then using the first text line as the target text line; the specified touch trajectory includes touch trajectories where the number of changes in the trajectory input direction is less than or equal to a preset number threshold.
[0011] Optionally, determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information includes: determining the first text line corresponding to the last input touch trajectory; obtaining the aspect ratio of the first text line, wherein the aspect ratio represents the ratio of the width of the second trajectory to the height of the second trajectory; if the aspect ratio is greater than or equal to a first ratio threshold, determining the distance ratio between the target touch trajectory and the first text line based on the first trajectory information and the second trajectory information; wherein the distance ratio represents the ratio of the difference between the second target horizontal coordinate and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line; and determining the target text line corresponding to the target touch trajectory based on the distance ratio and the second ratio threshold.
[0012] Optionally, determining the target text line corresponding to the target touch trajectory based on the distance ratio and the second ratio threshold includes: when the distance ratio is less than the second ratio threshold, determining the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height; the height overlap ratio represents the ratio of the overlap height of the first trajectory height and the second trajectory height to the second trajectory height; when the height overlap ratio is greater than or equal to a third preset ratio threshold, the first text line is taken as the target text line corresponding to the target touch trajectory.
[0013] Optionally, the method further includes: when the distance ratio is greater than or equal to the second ratio threshold, or when the height overlap ratio is less than the third preset ratio threshold, acquiring third trajectory information of the plurality of text lines respectively; and determining the target text line corresponding to the target touch trajectory based on the first trajectory information and the third trajectory information.
[0014] Optionally, the method further includes: when the aspect ratio is less than the first ratio threshold, determining the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height; and when the height overlap ratio is greater than or equal to a third preset ratio threshold, determining that the first text line is the target text line corresponding to the target touch trajectory.
[0015] Optionally, determining the target text based on the target text line includes: when the time for detecting the stop of the input touch trajectory is greater than or equal to a preset time threshold, or when an end command is received, taking the text in the determined target text line as the target text.
[0016] Optionally, the method further includes: using the target text as input to a pre-generated text recognition model to obtain the text recognition result of the target text output by the text recognition model.
[0017] According to a second aspect of the present disclosure, a text determination apparatus is provided, comprising:
[0018] A trajectory determination module is used to determine the target touch trajectory input on the text input interface, wherein the target touch trajectory includes at least two touch points; and the current text input interface includes multiple text lines.
[0019] An information acquisition module is used to acquire the position information of each of the at least two touch points, and determine the first trajectory information of the target touch trajectory based on the position information;
[0020] The target selection module is used to determine the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information;
[0021] The text determination module is used to determine the target text based on the target text line.
[0022] Optionally, the location information includes the horizontal and vertical coordinates based on a preset coordinate system corresponding to the text input interface, and the first trajectory information includes a first trajectory width and a first trajectory height. The information acquisition module is used to determine, from the horizontal coordinates of the at least two touch points, a first target horizontal coordinate with the largest horizontal coordinate and a second target horizontal coordinate with the smallest horizontal coordinate; to determine, from the vertical coordinates of the at least two touch points, a first target vertical coordinate with the largest vertical coordinate and a second target vertical coordinate with the smallest vertical coordinate; to use the difference between the first target horizontal coordinate and the second target horizontal coordinate as the first trajectory width; and to use the difference between the first target vertical coordinate and the second target vertical coordinate as the first trajectory height.
[0023] Optionally, the information acquisition module is used to acquire second trajectory information corresponding to one or more touch trajectories in each text line; the target selection module is used to determine the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information.
[0024] Optionally, the information acquisition module is configured to, for each text line, determine the maximum and minimum horizontal coordinates, and the maximum and minimum vertical coordinates, in one or more touch trajectories corresponding to the text line, and use the difference between the maximum and minimum horizontal coordinates as the width of the second trajectory corresponding to the text line, and use the difference between the maximum and minimum vertical coordinates as the height of the second trajectory corresponding to the text line.
[0025] Optionally, the target selection module is used to determine the first text line corresponding to the last input touch trajectory; if the first text line is determined to be a specified touch trajectory, the first text line is used as the target text line; the specified touch trajectory includes touch trajectories where the number of changes in the trajectory input direction is less than or equal to a preset number threshold.
[0026] Optionally, the target selection module is configured to: determine the first text line corresponding to the previously input touch trajectory; obtain the aspect ratio of the first text line, wherein the aspect ratio represents the ratio of the width to the height of the second trajectory; if the aspect ratio is greater than or equal to a first ratio threshold, determine the distance ratio between the target touch trajectory and the first text line based on the first trajectory information and the second trajectory information; the distance ratio represents the ratio of the difference between the horizontal coordinate of the second target and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line; and determine the target text line corresponding to the target touch trajectory based on the distance ratio and the second ratio threshold.
[0027] Optionally, the target selection module is configured to determine the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height when the distance ratio is less than the second ratio threshold; the height overlap ratio represents the ratio of the overlap height of the first trajectory height and the second trajectory height to the second trajectory height.
[0028] If the height overlap ratio is greater than or equal to a third preset ratio threshold, the first text line is taken as the target text line corresponding to the target touch trajectory.
[0029] Optionally, the target selection module is further configured to acquire third trajectory information of the plurality of text lines respectively when the distance ratio is greater than or equal to the second ratio threshold, or the height overlap ratio is less than the third preset ratio threshold; and determine the target text line corresponding to the target touch trajectory based on the first trajectory information and the third trajectory information.
[0030] Optionally, the target selection module is further configured to, when the aspect ratio is less than the first ratio threshold, determine the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height; and when the height overlap ratio is greater than or equal to a third preset ratio threshold, determine that the first text line is the target text line corresponding to the target touch trajectory.
[0031] Optionally, the text determination module is used to determine the text in the target text line as the target text when the time for detecting the stop of the input touch trajectory is greater than or equal to a preset time threshold, or when an end command is received.
[0032] Optionally, the device further includes:
[0033] The text recognition module is used to take the target text as input to a pre-generated text recognition model and obtain the text recognition result of the target text output by the text recognition model.
[0034] According to a third aspect of the present disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the steps of the text determination method provided in the first aspect of the present disclosure.
[0035] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a memory having a computer program stored thereon; and a processor for executing the computer program in the memory to implement the steps of the text determination method provided in the first aspect of the present disclosure.
[0036] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: by determining a target touch trajectory input on a text input interface, the target touch trajectory including at least two touch points, obtaining position information of each of the at least two touch points, and determining first trajectory information of the target touch trajectory based on the position information; determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information; and determining the target text based on the target text line. In this way, determining the target text through the target text line avoids character segmentation based on strokes, which helps improve the accuracy of text segmentation. At the same time, it also avoids the loss of contextual information caused by stroke segmentation, thus improving the accuracy of text recognition.
[0037] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0038] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0039] Figure 1 This is a flowchart illustrating a method for determining text according to an exemplary embodiment.
[0040] Figure 2 This is a flowchart illustrating another method for determining text according to an exemplary embodiment.
[0041] Figure 3 This is a block diagram of a text determination apparatus according to an exemplary embodiment.
[0042] Figure 4 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation
[0043] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0044] It should be noted that all actions involving the acquisition of signals, information, or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where the application is located, and with the authorization granted by the owner of the relevant device.
[0045] First, the application scenario of this application is explained. This application is applied to a text recognition scenario, in which the text content input by the user needs to be segmented. In related technologies, the segmentation scheme divides the input strokes into individual characters. This segmentation method requires accurate identification of the character to which the stroke belongs, and it has poor support for connected strokes. If the character segmentation is incorrect, it will greatly affect the subsequent recognition accuracy. Even if the strokes are correctly segmented into individual characters, the contextual information of the input will be missing, thus affecting the recognition effect.
[0046] To address the aforementioned problems, this application provides a method, apparatus, storage medium, and electronic device for text recognition. The method involves determining a target touch trajectory input on a text input interface, the target touch trajectory including at least two touch points. Position information of each of the at least two touch points is acquired, and first trajectory information of the target touch trajectory is determined based on the position information. Based on the first trajectory information, a target text line corresponding to the target touch trajectory is determined from multiple text lines. Finally, the target text is determined based on the target text line. This method of determining the target text by the target text line avoids character segmentation based on strokes, improving the accuracy of text segmentation. It also avoids the loss of contextual information caused by stroke segmentation, thus improving the accuracy of text recognition.
[0047] Figure 1 This is a flowchart illustrating a method for determining text according to an exemplary embodiment, such as... Figure 1 As shown, it includes the following steps.
[0048] S101. Determine the target touch trajectory entered on the text input interface.
[0049] The target touch trajectory includes at least two touch points; the current text input interface includes multiple text lines, and the touch points of the target touch trajectory can be acquired periodically.
[0050] For example, when the user inputs the target touch trajectory, the latest point of the target touch trajectory at the current moment can be obtained every millisecond as the touch point to ensure that the obtained touch points can form a complete target touch trajectory.
[0051] S102. Obtain the position information of each of the at least two touch points, and determine the first trajectory information of the target touch trajectory based on the position information.
[0052] The location information includes the horizontal and vertical coordinates based on the preset coordinate system corresponding to the text input interface, and the first trajectory information includes the first trajectory width and the first trajectory height.
[0053] In some embodiments, the first target x-coordinate with the largest x-coordinate and the second target x-coordinate with the smallest x-coordinate can be determined from the x-coordinates of the at least two touch points; the first target y-coordinate with the largest y-coordinate and the second target y-coordinate with the smallest y-coordinate can be determined from the y-coordinates of the at least two touch points; the difference between the first target x-coordinate and the second target x-coordinate is used as the first trajectory width; and the difference between the first target y-coordinate and the second target y-coordinate is used as the first trajectory height. Thus, by using the position information of the at least two touch points, the first trajectory information of the target touch trajectory can be determined, which is beneficial for accurately identifying the text line corresponding to the target touch trajectory.
[0054] S103. Based on the first trajectory information, determine the target text line corresponding to the target touch trajectory from the multiple text lines.
[0055] In some embodiments, second trajectory information corresponding to one or more touch trajectories in each text line can be obtained; based on the first trajectory information and the second trajectory information, the target text line corresponding to the target touch trajectory can be determined from the plurality of text lines.
[0056] The second trajectory information includes a second trajectory width and a second trajectory height. To obtain the second trajectory width and height, for each text line, the maximum and minimum horizontal coordinates, as well as the maximum and minimum vertical coordinates, of one or more touch trajectories corresponding to that text line can be determined. The difference between the maximum and minimum horizontal coordinates is used as the second trajectory width for that text line, and the difference between the maximum and minimum vertical coordinates is used as the second trajectory height. In this way, by determining the second trajectory information of each text line through its respective touch trajectory, it is beneficial to accurately identify the text line corresponding to the target touch trajectory using the second trajectory information.
[0057] In one possible implementation, the first text line corresponding to the user's last input touch trajectory can be determined first; if the first text line is determined to be a specified touch trajectory, the first text line is taken as the target text line, which represents the text line where the target touch trajectory is located; the specified touch trajectory includes touch trajectories where the number of changes in the trajectory input direction is less than or equal to a preset number threshold.
[0058] For example, we can first determine the first text line where the user's last input touch trajectory is located, obtain all touch trajectories in the first text line, and if there is only one touch trajectory in the first text line, obtain the position information of all touch points in the touch trajectory, and determine whether the touch trajectory has changed direction based on the position information of all touch points; if the number of times the touch trajectory changes direction is less than or equal to a preset number threshold, we determine that the touch trajectory is a specified touch trajectory, and the specified touch trajectory represents that the touch trajectory is a part of the strokes that constitute a complete character.
[0059] For example, if it is determined that there is only one touch trajectory in the first text line where the user's last input touch trajectory should be located, the position information of all touch points in the touch trajectory is obtained. Based on the position information, the slope of the touch trajectory at at least two touch points is determined according to the preset coordinate system corresponding to the text input interface. The slope can be determined by the ratio of the difference between the vertical coordinates and the horizontal coordinates of two adjacent touch points. If the slope change difference is less than or equal to the preset slope difference, it is determined that the touch trajectory has not changed direction. If the slope change difference is greater than the preset slope difference, it is determined that the touch trajectory has changed direction.
[0060] In this way, if it is determined that there is only one touch trajectory in the text line and that the touch trajectory cannot form a complete text, the target touch trajectory of the current input can be determined to correspond to the text line. The determination method is simple and clear, which is conducive to quickly determining the target text line corresponding to the target touch trajectory.
[0061] In another possible implementation, the first text line corresponding to the user's last input touch trajectory is determined; the aspect ratio of the first text line is obtained, which represents the ratio of the width to the height of the second trajectory; if the aspect ratio is greater than or equal to a first ratio threshold, the distance ratio between the target touch trajectory and the first text line is determined based on the first trajectory information and the second trajectory information; the distance ratio represents the ratio of the difference between the second target horizontal coordinate and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line; the target text line corresponding to the target touch trajectory is determined based on the distance ratio and the second ratio threshold.
[0062] For example, the system retrieves the first text line corresponding to the user's last input touch trajectory and determines whether the text line is a horizontal input based on its aspect ratio. If the first text line is determined to be a horizontally written text line, the system further determines whether the target touch trajectory corresponds to the first text line based on the distance ratio between the target touch trajectory and the first text line.
[0063] For example, the first ratio threshold can be 3. If the aspect ratio of the first text line is greater than or equal to 3, the text line is determined to be a horizontally written text line. The second target horizontal coordinate in the target touch trajectory is obtained, i.e., the minimum horizontal coordinate of the target touch trajectory, and the maximum horizontal coordinate of the first text line is obtained. Based on the second target horizontal coordinate and the maximum horizontal coordinate of the first text line, the distance ratio of the target touch trajectory is determined, i.e., the ratio of the difference between the second target horizontal coordinate and the maximum horizontal coordinate of the first text line to the width of the second trajectory of the first text line. If this ratio is greater than the second ratio threshold, it indicates that the target touch trajectory is far from the first text line, and the text line corresponding to the target touch trajectory is not the first text line. If the ratio is less than or equal to the second ratio threshold, it indicates that the target touch trajectory is close to the first text line, and the target touch trajectory may correspond to the first text line.
[0064] In this way, if the user's previous touch trajectory was determined to be a horizontal input of the first text line, the current target touch trajectory is likely to continue to be horizontally input corresponding to the first text line. Furthermore, by performing subsequent verifications such as distance judgment, the accuracy of determining the text line corresponding to the target touch trajectory can be further improved.
[0065] To further determine the target text line corresponding to the target touch trajectory, the target text line can be determined based on the high overlap ratio between the target touch trajectory and the text line.
[0066] In another possible implementation, if the distance ratio is less than the second ratio threshold, the height overlap ratio between the target touch trajectory and the first text line is determined based on the first trajectory height and the second trajectory height; the height overlap ratio represents the ratio of the overlap height between the first trajectory height and the second trajectory height to the second trajectory height; if the height overlap ratio is greater than or equal to the third preset ratio threshold, the first text line is taken as the target text line corresponding to the target touch trajectory.
[0067] For example, the positions of the first text line in the preset coordinate system and the target touch trajectory in the preset coordinate system are obtained respectively. Based on the vertical coordinates of the positions of the first text line and the target touch trajectory, the overlap height of the first text line and the target touch trajectory is determined. The overlap height is the overlapping part of the first text line and the target touch trajectory on the vertical coordinate in the preset coordinate system. Based on the overlap height and the second trajectory height of the first text line, the height overlap ratio is determined. If the height overlap ratio is greater than or equal to a third preset ratio threshold, it is determined that the target touch trajectory corresponds to the first text line, that is, the first text line is the text line where the target touch trajectory is located.
[0068] For example, the third preset ratio threshold can be 0.6, and the height overlap ratio can be the ratio of the overlap height to the second trajectory height of the first text line. In this way, when the height overlap ratio between the target touch trajectory and the first text line is greater than or equal to 0.6, it indicates that the vertical coordinate position of the target touch trajectory largely overlaps with the vertical coordinate position of the first text line, the target touch trajectory corresponds to the first text line, and the first text line is taken as the target text line, that is, the first text line is the text line where the target touch trajectory is located; when the height overlap ratio between the target touch trajectory and the first text line is less than 0.6, it indicates that the vertical coordinate position of the target touch trajectory does not largely overlap with the vertical coordinate position of the first text line, the target touch trajectory does not correspond to the first text line.
[0069] In this way, considering various factors such as the input direction of the first text line, the distance ratio between the target touch trajectory and the first text line, and the height overlap ratio between the target touch trajectory and the first text line, it is beneficial to accurately determine the correspondence between the first text line and the target touch trajectory.
[0070] Furthermore, considering the possibility of horizontal text input, but with limited touch trajectories resulting in an aspect ratio less than the first threshold, to avoid interference from this situation, when the aspect ratio is less than the first threshold, the height overlap ratio between the target touch trajectory and the first text line is determined based on the first trajectory height and the second trajectory height. If the height overlap ratio is greater than or equal to a third preset threshold, the first text line is determined to be the target text line corresponding to the target touch trajectory. In this way, even when the touch trajectories of the first text line input are limited, the correspondence between the target touch trajectory and the first text line can be accurately determined.
[0071] Furthermore, if the correspondence between the target touch trajectory and the first text line cannot be determined through the above steps, that is, if the distance ratio is greater than or equal to the second ratio threshold, or the height overlap ratio is less than the third preset ratio threshold, the third trajectory information of the multiple text lines can be obtained respectively; and the target text line corresponding to the target touch trajectory can be determined based on the first trajectory information and the third trajectory information.
[0072] For example, the height overlap ratio between the target touch trajectory and the multiple text lines can be determined using the first trajectory information and the third trajectory information, respectively. If the height overlap ratio determined by any of the third trajectory information is greater than or equal to a third preset ratio threshold, it indicates that there is a target text line among the multiple text lines that corresponds to the target touch trajectory, that is, there is a target text line among the multiple text lines where the target touch trajectory is located. Alternatively, if the height overlap ratios determined by the multiple third trajectory information and the first trajectory information are all less than the third preset ratio threshold, the text line where the target touch trajectory is located is determined to be a new text line, and the new text line is determined to be the target text line.
[0073] In this way, by judging the high degree of overlap between the target touch trajectory and the multiple text lines, it is possible to accurately determine the text line corresponding to the content added by the user when the user adds any content among the multiple text lines, which helps to improve the accuracy of judging the text line corresponding to the target touch trajectory.
[0074] S104. Determine the target text based on the target text line.
[0075] Specifically, if the time it takes for the user to stop inputting the touch trajectory is greater than or equal to a preset time threshold, or if the user inputs an end command, the text in the determined target text line will be used as the target text.
[0076] For example, the interval can be 3 seconds. If the user stops input for more than or equal to 3 seconds, or if the user inputs an end command is received, such as when the user clicks the OK or Start Recognition button, the user stops input, and the text in the target text line determined in S102 above is taken as the target text.
[0077] In some embodiments, the target text can also be used as input to a pre-generated text recognition model to obtain the text recognition result of the target text output by the text recognition model.
[0078] The pre-generated text recognition model is trained in the following way:
[0079] Obtain the pre-generated sample text and the corresponding recognition result; train the target training model based on the sample text and the corresponding recognition result to obtain the text recognition model.
[0080] Using the above method, the target touch trajectory input by the user on the text input interface is determined. This target touch trajectory includes at least two touch points. The position information of each of the at least two touch points is obtained, and the first trajectory information of the target touch trajectory is determined based on the position information. Based on the first trajectory information, the target text line corresponding to the target touch trajectory is determined from the multiple text lines. Based on the target text line, the target text is determined. In this way, the target text is determined by the target text line, avoiding character segmentation based on strokes, which helps improve the accuracy of text segmentation. At the same time, it also avoids the loss of contextual information caused by stroke segmentation, thus improving the accuracy of text recognition.
[0081] Figure 2 This is a flowchart illustrating another method for determining text according to an exemplary embodiment, such as... Figure 2 As shown, it includes the following steps.
[0082] S201. Obtain the first trajectory information of the target touch trajectory and the second trajectory information of the first text line.
[0083] Specifically, the first trajectory information is obtained through at least two touch points in the target touch trajectory, and the second trajectory information is obtained through at least two touch trajectories in the first text line. The first text line represents the text line corresponding to the user's last input touch trajectory, and the text line corresponding to the touch trajectory is the text line where the touch trajectory is located.
[0084] S202. Determine whether the target touch trajectory corresponds to the first text line based on the first trajectory information and the second trajectory information.
[0085] To determine whether the target touch trajectory corresponds to the first text line, the following steps can be taken:
[0086] S1. Determine whether the first text line is a specified touch trajectory;
[0087] The specified touch trajectory includes touch trajectories in which the number of changes in the trajectory input direction is less than or equal to a preset threshold number. When the first text line is determined to be the specified touch trajectory, the target touch trajectory is determined to correspond to the first text line.
[0088] S2. Determine the aspect ratio of the first text line based on the second trajectory information;
[0089] Wherein, the aspect ratio is the ratio of the width of the second trajectory and the height of the second trajectory of the first text line; if the aspect ratio is greater than or equal to the first ratio threshold, step S3 is executed; if the aspect ratio is less than the first ratio threshold, step S4 is executed.
[0090] S3. Determine the distance ratio based on the first trajectory information and the second trajectory information;
[0091] The distance ratio represents the ratio of the difference between the second target horizontal coordinate of the target touch trajectory and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line; if the distance ratio is less than the second ratio threshold, step S4 is executed; if the distance ratio is greater than or equal to the second ratio threshold, it is determined that the target touch trajectory does not correspond to the first text line.
[0092] S4. Determine the high overlap ratio based on the first trajectory information and the second trajectory information;
[0093] The height overlap ratio represents the overlap height of the first trajectory height and the second trajectory height, and the ratio of the second trajectory height; when the height overlap ratio is greater than or equal to a third preset ratio threshold, it is determined that the target touch trajectory corresponds to the first text line; when the height overlap ratio is less than the third preset ratio threshold, it is determined that the target touch trajectory does not correspond to the first text line.
[0094] If the target touch trajectory corresponds to the first text line, determine that the first text line is the target text line and execute S205;
[0095] If it is determined that the target touch trajectory does not correspond to the first text line, execute S203.
[0096] S203. Obtain the third trajectory information of multiple text lines.
[0097] S204. Determine whether there is a text line corresponding to the target touch trajectory among the multiple text lines based on the first trajectory information and the third trajectory information.
[0098] The high overlap ratio is determined based on the first trajectory information and the third trajectory information;
[0099] If there is a high degree of overlap greater than or equal to a third preset threshold, it is determined that there is a text line among the multiple text lines that corresponds to the target touch trajectory, and that text line is determined to be the target text line;
[0100] If the overlap ratio is less than a third preset threshold, it is determined that no text line in the multiple text lines corresponds to the target touch trajectory, the target touch trajectory corresponds to a new text line, and the new text line is determined to be the target text line.
[0101] S205. Determine the target text based on the target text line.
[0102] By using the above method, the target text line is determined by the target touch trajectory, and the target text is determined by the target text line. This avoids character segmentation based on strokes, which helps improve the accuracy of text segmentation. At the same time, it also avoids the loss of contextual information caused by stroke segmentation, thus improving the accuracy of text recognition.
[0103] Figure 3 This is a block diagram illustrating a text-determining device according to an exemplary embodiment. (e.g.) Figure 3 As shown, the device includes:
[0104] The trajectory determination module 301 is used to determine the target touch trajectory input on the text input interface, the target touch trajectory including at least two touch points; the current text input interface includes multiple text lines;
[0105] The information acquisition module 302 is used to acquire the position information of each of the at least two touch points, and determine the first trajectory information of the target touch trajectory based on the position information;
[0106] The target selection module 303 is used to determine the target text line corresponding to the target touch trajectory from the multiple text lines based on the first trajectory information;
[0107] The text determination module 304 is used to determine the target text based on the target text line.
[0108] Optionally, the location information includes the horizontal and vertical coordinates based on the preset coordinate system corresponding to the text input interface, and the first trajectory information includes the first trajectory width and the first trajectory height. The information acquisition module 302 is used to determine the first target horizontal coordinate with the largest horizontal coordinate and the second target horizontal coordinate with the smallest horizontal coordinate from the horizontal coordinates of the at least two touch points; determine the first target vertical coordinate with the largest vertical coordinate and the second target vertical coordinate with the smallest vertical coordinate from the vertical coordinates of the at least two touch points; take the difference between the first target horizontal coordinate and the second target horizontal coordinate as the first trajectory width; and take the difference between the first target vertical coordinate and the second target vertical coordinate as the first trajectory height.
[0109] Optionally, the information acquisition module 302 is used to acquire second trajectory information corresponding to one or more touch trajectories in each text line; the target selection module 303 is used to determine the target text line corresponding to the target touch trajectory from the multiple text lines based on the first trajectory information and the second trajectory information.
[0110] Optionally, the information acquisition module 302 is used to determine, for each text line, the maximum and minimum horizontal coordinates of one or more touch trajectories corresponding to the text line, as well as the maximum and minimum vertical coordinates of the one or more touch trajectories, and to use the difference between the maximum and minimum horizontal coordinates as the width of the second trajectory corresponding to the text line, and to use the difference between the maximum and minimum vertical coordinates as the height of the second trajectory corresponding to the text line.
[0111] Optionally, the target selection module 303 is used to determine the first text line corresponding to the previous input touch trajectory; if the first text line is determined to be a specified touch trajectory, the first text line is used as the target text line; the specified touch trajectory includes touch trajectories where the number of changes in the trajectory input direction is less than or equal to a preset number threshold.
[0112] Optionally, the target selection module 303 is used to determine the first text line corresponding to the previously input touch trajectory; obtain the aspect ratio of the first text line, which represents the ratio of the width to the height of the second trajectory; if the aspect ratio is greater than or equal to a first ratio threshold, determine the distance ratio between the target touch trajectory and the first text line based on the first trajectory information and the second trajectory information; the distance ratio represents the ratio of the difference between the horizontal coordinate of the second target and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line; and determine the target text line corresponding to the target touch trajectory based on the distance ratio and the second ratio threshold.
[0113] Optionally, the target selection module 303 is used to determine the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height when the distance ratio is less than the second ratio threshold; the height overlap ratio represents the ratio of the overlap height of the first trajectory height and the second trajectory height to the second trajectory height.
[0114] If the overlap ratio is greater than or equal to the third preset ratio threshold, the first text line is taken as the target text line corresponding to the target touch trajectory.
[0115] Optionally, the target selection module 303 is further configured to acquire third trajectory information of the multiple text lines respectively when the distance ratio is greater than or equal to the second ratio threshold, or the height overlap ratio is less than the third preset ratio threshold; and determine the target text line corresponding to the target touch trajectory based on the first trajectory information and the third trajectory information.
[0116] Optionally, the target selection module 303 is further configured to, when the aspect ratio is less than the first ratio threshold, determine the height overlap ratio between the target touch trajectory and the first text line based on the first trajectory height and the second trajectory height; and when the height overlap ratio is greater than or equal to a third preset ratio threshold, determine that the first text line is the target text line corresponding to the target touch trajectory.
[0117] Optionally, the text determination module 304 is used to determine the text in the target text line as the target text when the time for detecting the stop of the input touch trajectory is greater than or equal to a preset time threshold, or when an end command is received.
[0118] Optionally, the device further includes:
[0119] The text recognition module 305 is used to take the target text as input to a pre-generated text recognition model and obtain the text recognition result of the target text output by the text recognition model.
[0120] Using the aforementioned device, a target touch trajectory input on a text input interface is determined. This target touch trajectory includes at least two touch points. The position information of each of the at least two touch points is acquired, and first trajectory information of the target touch trajectory is determined based on the position information. Based on the first trajectory information, the target text line corresponding to the target touch trajectory is determined from multiple text lines. Based on the target text line, the target text is determined. In this way, determining the target text through the target text line avoids character segmentation based on strokes, which helps improve the accuracy of text segmentation. Simultaneously, it avoids the loss of contextual information caused by stroke segmentation, thus improving the accuracy of text recognition.
[0121] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0122] This disclosure also provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the steps of the text determination method provided in this disclosure.
[0123] Figure 4 This is a block diagram illustrating an electronic device 400 for text determination according to an exemplary embodiment. For example, the electronic device 400 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0124] Reference Figure 4The electronic device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input / output interface 412, sensor component 414, and communication component 416.
[0125] Processing component 402 typically controls the overall operation of electronic device 400, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 402 may include one or more processors 420 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 402 may include one or more modules to facilitate interaction between processing component 402 and other components. For example, processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402.
[0126] Memory 404 is configured to store various types of data to support the operation of electronic device 400. Examples of such data include instructions for any application or method operating on electronic device 400, contact data, phonebook data, messages, pictures, videos, etc. Memory 404 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0127] Power supply component 406 provides power to various components of electronic device 400. Power supply component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 400.
[0128] Multimedia component 408 includes a screen that provides an output interface between the electronic device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundaries of a touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 408 includes a front-facing camera and / or a rear-facing camera. When the electronic device 400 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0129] Audio component 410 is configured to output and / or input audio signals. For example, audio component 410 includes a microphone (MIC) configured to receive external audio signals when electronic device 400 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 404 or transmitted via communication component 416. In some embodiments, audio component 410 also includes a speaker for outputting audio signals.
[0130] Input / output interface 412 provides an interface between processing component 402 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, start buttons, and lock buttons.
[0131] Sensor assembly 414 includes one or more sensors for providing state assessments of various aspects of electronic device 400. For example, sensor assembly 414 may detect the on / off state of electronic device 400, the relative positioning of components such as the display and keypad of electronic device 400, changes in position of electronic device 400 or a component of electronic device 400, the presence or absence of user contact with electronic device 400, orientation or acceleration / deceleration of electronic device 400, and temperature changes of electronic device 400. Sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 414 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 414 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0132] Communication component 416 is configured to facilitate wired or wireless communication between electronic device 400 and other devices. Electronic device 400 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 416 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0133] In an exemplary embodiment, the electronic device 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0134] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 404 including instructions, which can be executed by a processor 420 of an electronic device 400 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0135] The aforementioned device can be a standalone electronic device or a part of a standalone electronic device. For example, in one embodiment, the device can be an integrated circuit (IC) or a chip, wherein the integrated circuit can be a single IC or a collection of multiple ICs. The chip can include, but is not limited to, the following types: GPU (Graphics Processing Unit), CPU (Central Processing Unit), FPGA (Field Programmable Gate Array), DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), and SoC (System on Chip). The aforementioned integrated circuit or chip can be used to execute executable instructions (or code) to implement the aforementioned text determination method. The executable instructions can be stored in the integrated circuit or chip or obtained from other devices or equipment. For example, the integrated circuit or chip includes a processor, memory, and an interface for communicating with other devices. The executable instructions can be stored in the memory, and when the executable instructions are executed by the processor, the above-mentioned text determination method can be implemented; or, the integrated circuit or chip can receive the executable instructions through the interface and transmit them to the processor for execution to implement the above-mentioned text determination method.
[0136] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the above-described text determination method when executed by the programmable device.
[0137] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of this disclosure. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0138] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for determining text, characterized in that, include: Determine the target touch trajectory input on the text input interface, wherein the target touch trajectory includes at least two touch points; The text input interface includes multiple text lines; Obtain the position information of each of the at least two touch points, and determine the first trajectory information of the target touch trajectory based on the position information; Based on the first trajectory information, determine the target text line corresponding to the target touch trajectory from the plurality of text lines; Determine the target text based on the target text line; The location information includes the horizontal and vertical coordinates based on a preset coordinate system corresponding to the text input interface. The first trajectory information includes the first trajectory width and the first trajectory height. The step of obtaining the location information of each of the at least two touch points and determining the first trajectory information of the target touch trajectory based on the location information includes: Determine the first target horizontal coordinate with the largest horizontal coordinate and the second target horizontal coordinate with the smallest horizontal coordinate from the horizontal coordinates of the at least two touch points; Determine the first target ordinate with the largest ordinate and the second target ordinate with the smallest ordinate from the ordinates of the at least two touch points; The difference between the horizontal coordinate of the first target and the horizontal coordinate of the second target is used as the width of the first trajectory. The difference between the ordinate of the first target and the ordinate of the second target is taken as the height of the first trajectory.
2. The method according to claim 1, characterized in that, The step of determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information includes: Obtain the second trajectory information corresponding to one or more touch trajectories in each text line; Based on the first trajectory information and the second trajectory information, the target text line corresponding to the target touch trajectory is determined from the plurality of text lines.
3. The method according to claim 2, characterized in that, The second trajectory information includes a second trajectory width and a second trajectory height. Obtaining the second trajectory information corresponding to the touch trajectory in each text line includes: For each text line, determine the maximum and minimum horizontal coordinates, as well as the maximum and minimum vertical coordinates, of one or more touch trajectories corresponding to the text line. Use the difference between the maximum and minimum horizontal coordinates as the width of the second trajectory corresponding to the text line, and use the difference between the maximum and minimum vertical coordinates as the height of the second trajectory corresponding to the text line.
4. The method according to claim 3, characterized in that, The step of determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information includes: Determine the first text line corresponding to the last input touch trajectory; When the first text behavior is determined to be a specified touch trajectory, the first text line is taken as the target text line; the specified touch trajectory includes touch trajectories in which the number of changes in the trajectory input direction is less than or equal to a preset number threshold.
5. The method according to claim 3, characterized in that, The step of determining the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information and the second trajectory information includes: Determine the first text line corresponding to the last input touch trajectory; Obtain the aspect ratio of the first text line, wherein the aspect ratio represents the ratio of the width of the second trajectory to the height of the second trajectory; When the aspect ratio is greater than or equal to a first ratio threshold, the distance ratio between the target touch trajectory and the first text line is determined based on the first trajectory information and the second trajectory information; the distance ratio represents the ratio of the difference between the horizontal coordinate of the second target and the maximum horizontal coordinate in the first text line to the width of the second trajectory of the first text line. The target text line corresponding to the target touch trajectory is determined based on the distance ratio and the second ratio threshold.
6. The method according to claim 5, characterized in that, The step of determining the target text line corresponding to the target touch trajectory based on the distance ratio and the second ratio threshold includes: When the distance ratio is less than the second ratio threshold, the height overlap ratio between the target touch trajectory and the first text line is determined based on the first trajectory height and the second trajectory height; the height overlap ratio represents the ratio of the overlap height between the first trajectory height and the second trajectory height to the second trajectory height. If the height overlap ratio is greater than or equal to a third preset ratio threshold, the first text line is taken as the target text line corresponding to the target touch trajectory.
7. The method according to claim 6, characterized in that, The method further includes: When the distance ratio is greater than or equal to the second ratio threshold, or when the height overlap ratio is less than the third preset ratio threshold, the third trajectory information of the multiple text lines is obtained respectively. The target text line corresponding to the target touch trajectory is determined based on the first trajectory information and the third trajectory information.
8. The method according to claim 5, characterized in that, The method further includes: If the aspect ratio is less than the first ratio threshold, the height overlap ratio between the target touch trajectory and the first text line is determined based on the first trajectory height and the second trajectory height. If the height overlap ratio is greater than or equal to a third preset ratio threshold, the first text line is determined to be the target text line corresponding to the target touch trajectory.
9. The method according to any one of claims 1-6, characterized in that, The step of determining the target text based on the target text line includes: If the time for detecting the cessation of the touch input trajectory is greater than or equal to a preset time threshold, or if an end command is received, the text in the determined target text line will be used as the target text.
10. The method according to claim 1, characterized in that, The method further includes: The target text is used as input to a pre-generated text recognition model to obtain the text recognition result of the target text output by the text recognition model.
11. A device for determining text, characterized in that, The device includes: A trajectory determination module is used to determine the target touch trajectory input on the text input interface, wherein the target touch trajectory includes at least two touch points; and the text input interface includes multiple text lines. An information acquisition module is used to acquire the position information of each of the at least two touch points, and determine the first trajectory information of the target touch trajectory based on the position information; The target selection module is used to determine the target text line corresponding to the target touch trajectory from the plurality of text lines based on the first trajectory information; The text determination module is used to determine the target text based on the target text line; The location information includes the horizontal and vertical coordinates based on the preset coordinate system corresponding to the text input interface. The first trajectory information includes the first trajectory width and the first trajectory height. The information acquisition module is further configured to: determine the first target horizontal coordinate with the largest horizontal coordinate and the second target horizontal coordinate with the smallest horizontal coordinate from the horizontal coordinates of the at least two touch points; determine the first target vertical coordinate with the largest vertical coordinate and the second target vertical coordinate with the smallest vertical coordinate from the vertical coordinates of the at least two touch points; use the difference between the first target horizontal coordinate and the second target horizontal coordinate as the first trajectory width; and use the difference between the first target vertical coordinate and the second target vertical coordinate as the first trajectory height.
12. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When executed by a processor, the program instructions implement the steps of the method described in any one of claims 1-10.
13. An electronic device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the method according to any one of claims 1-10.