Handwritten character recognition method, device, storage medium and electronic device

By using a text recognition model based on pen point features and continuous stroke probability in handwritten text recognition to predict continuous writing, the problem of handwritten text recognition accuracy and speed is solved, and high accuracy and fast recognition are achieved.

CN114529910BActive Publication Date: 2024-09-06BEIJING DINGSHIXINGJIAOYU CONSULTATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210101139.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2024-09-06
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

When recognizing handwritten text online, due to different writing habits of each person, differences in handwriting continuity and stroke order lead to low recognition accuracy, and the recognition speed of traditional methods is slow.

Method used

By obtaining the handwritten text to be recognized, the trained character recognition model is used to predict continuous writing. The model performs recognition based on stroke characteristics and probability of continuous strokes, including downsampling, coordinate normalization, determination of stroke characteristics, and calculation of probability of continuous strokes. and bidirectional neural network training.

Benefits of technology

The accuracy and speed of handwritten text recognition are improved, the recognition accuracy reaches 95%, and the single-word recognition time is only 21ms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114529910B
    Figure CN114529910B
Patent Text Reader

Abstract

The present disclosure relates to a handwritten text recognition method, device, storage medium and electronic device, including: obtaining handwritten text to be recognized; inputting the handwritten text to be recognized into a text recognition model, obtaining a recognition result of the text recognition model predicting the connected writing of the written text to be recognized, wherein the text recognition model is trained based on the stroke features of the sample text and the probability of connected writing between every two strokes in the sample text; and displaying the recognition result. The text recognition model is trained based on the stroke features of the sample text and the probability of connected writing between every two strokes in the sample text, and the accuracy of handwritten text recognition can be improved by predicting the connected writing of the written text to be recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of text recognition, and in particular, to a handwritten text recognition method, device, storage medium and electronic device. Background Art

[0002] When recognizing handwritten text online, it is necessary not only to recognize it quickly but also accurately. However, due to the different writing habits of each person, the connection of handwriting and the order of handwritten strokes are different. Relying only on training samples to train a recognition model and then recognizing text based on the recognition model will result in low accuracy. In addition, handwritten text is usually recognized after the handwriting is completed, resulting in a slow recognition speed. Summary of the invention

[0003] The purpose of the present disclosure is to provide a handwritten text recognition method, device, storage medium and electronic device to at least partially solve the above technical problems.

[0004] In order to achieve the above-mentioned object, the present disclosure provides a handwritten text recognition method in a first aspect, the method comprising:

[0005] Get the handwritten text to be recognized;

[0006] Inputting the handwritten characters to be recognized into a character recognition model to obtain a recognition result of the character recognition model predicting connected strokes of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of sample characters and the probability of connected strokes between every two strokes in the sample characters;

[0007] The recognition result is displayed.

[0008] Optionally, the pen point feature is determined by:

[0009] Normalizing the coordinates of the sample text after downsampling to obtain a backup sample text;

[0010] Determine the pen point features of each pen point according to the acquisition timestamp, pen point type and pen point coordinates of each pen point in the backup sample text;

[0011] The stroke point types include a starting point, a running point and an ending point.

[0012] Optionally, the probability of continuous strokes is determined by:

[0013] Determine a target stroke point corresponding to each stroke from the stroke points of the backup sample characters;

[0014] The probability of connecting every two strokes in the backup sample characters is determined according to the stroke point features of the target stroke points of each stroke.

[0015] Optionally, determining the probability of connecting every two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke includes:

[0016] Determine the first stroke and the last stroke of every two strokes in the backup sample character according to the acquisition time stamp of each stroke point;

[0017] Determine the distance between the starting and ending points of each two strokes according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, wherein the target pen point includes the ending point and the starting point;

[0018] Based on the least square method, a first straight line is obtained by fitting according to the pen point features of the end point of the first stroke and the pen point features of multiple pen points before the end point, and a second straight line is obtained by fitting according to the pen point features of the start point of the second stroke and the pen point features of multiple pen points after the start point, wherein the target pen point includes the multiple pen points before the end point and the multiple pen points after the start point;

[0019] Obtaining a straight line angle between each two strokes according to the first straight line and the second straight line;

[0020] Determine the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and the preset angle threshold;

[0021] The distance threshold is determined according to the text width of the sample text.

[0022] Optionally, determining the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and a distance threshold, and the size relationship between the straight line angle between each two strokes and a preset angle threshold, includes:

[0023] When the distance between the starting and ending points of the stroke is less than the distance threshold, and / or the straight line angle is less than the preset angle threshold, taking the preset connecting stroke probability as the connecting stroke probability of the two strokes;

[0024] When the distance between the starting and ending points of the stroke is greater than or equal to the distance threshold, and the straight line angle is greater than or equal to the preset angle threshold, the probability of connecting the two strokes is determined to be 0.

[0025] Optionally, the downsampling of the sample text includes:

[0026] For each stroke in the sample text, determining the Euclidean distance between the coordinates of adjacent stroke points;

[0027] Eliminate the stroke points whose Euclidean distance is less than the distance threshold to obtain valid stroke points;

[0028] According to the effective stroke points, the starting point and the ending point of the stroke, a sample text after downsampling is obtained.

[0029] Optionally, the step of normalizing the coordinates of the downsampled sample text to obtain the spare sample text includes:

[0030] Calculate the mean and variance of the pen point coordinates according to the pen point coordinates of each pen point in the sample text after downsampling;

[0031] According to the mean and the variance, coordinates of the downsampled sample text are normalized to obtain the backup sample text.

[0032] Optionally, the text recognition model is trained in the following manner:

[0033] Inputting the pen point features of the sample text into a bidirectional neural network layer, wherein the dimension of the hidden layer in the first neural network layer of the bidirectional neural network layer is 96 dimensions, and the dimension of the hidden layer in the second neural network layer is 64 dimensions;

[0034] Using the output of the bidirectional neural network layer as the input of the mean pooling layer to obtain the pen point features with reduced dimension;

[0035] According to a preset random probability, the connection probability between each two strokes is set to 0;

[0036] Encoding is performed through a 26-dimensional encoding layer in a fully connected layer according to the pen point features with reduced dimension and the connection probability after being randomly set to 0;

[0037] The encoded pen point features are input into the classification model for classification to obtain the text parameter quantity output by the fully connected layer, until the text parameter quantity meets the parameter quantity of the preset text classification, and the text recognition model is obtained by training.

[0038] In a second aspect of the present disclosure, a handwritten text recognition device is provided, the device comprising:

[0039] An acquisition module, configured to acquire handwritten characters to be recognized;

[0040] An input module is configured to input the handwritten characters to be recognized into a character recognition model to obtain a recognition result of the character recognition model predicting connected writing of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of sample characters and the probability of connected writing between every two strokes in the sample characters;

[0041] The display module is configured to display the recognition result.

[0042] Optionally, the device further comprises:

[0043] A downsampling module is configured to normalize the coordinates of the downsampled sample text to obtain a backup sample text;

[0044] A first determination module is configured to determine the pen point features of each pen point in the backup sample text according to the acquisition timestamp, pen point type and pen point coordinates of each pen point in the backup sample text;

[0045] The stroke point types include a starting point, a running point and an ending point.

[0046] Optionally, the device further comprises:

[0047] A second determination module is configured to determine a target stroke point corresponding to each stroke from the stroke points of each stroke of the backup sample character;

[0048] The probability determination module is configured to determine the probability of connecting every two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke.

[0049] Optionally, the probability determination module includes:

[0050] A first determination submodule is configured to determine the first stroke and the last stroke of every two strokes in the backup sample character according to the acquisition timestamp of each stroke point;

[0051] A distance determination submodule is configured to determine the distance between the starting and ending points of each two strokes according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, wherein the target pen point includes the ending point and the starting point;

[0052] The straight line fitting submodule is configured to fit a first straight line based on the pen point features of the first stroke and the pen point features of multiple stroke points before the pen point, and fit a second straight line based on the pen point features of the second stroke and the pen point features of multiple stroke points after the pen point, wherein the target pen points include the multiple stroke points before the pen point and the multiple stroke points after the pen point;

[0053] A second determining submodule is configured to obtain a straight line angle between each two strokes according to the first straight line and the second straight line;

[0054] A third determination submodule is configured to determine the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and a preset angle threshold;

[0055] The distance threshold is determined according to the text width of the sample text.

[0056] Optionally, the third determining submodule includes:

[0057] A first probability determination unit is configured to use a preset probability of connecting strokes as the probability of connecting strokes of the two strokes when the distance between the starting and ending points is less than the distance threshold and / or the angle between the straight lines is less than the preset angle threshold;

[0058] The second probability determination unit is configured to determine that the probability of connecting the two strokes is 0 when the distance between the starting and ending points is greater than or equal to the distance threshold and the straight line angle is greater than or equal to the preset angle threshold.

[0059] Optionally, the downsampling module is configured to:

[0060] For each stroke in the sample text, determining the Euclidean distance between the coordinates of adjacent stroke points;

[0061] Eliminate the stroke points whose Euclidean distance is less than the distance threshold to obtain valid stroke points;

[0062] According to the effective stroke points, the starting point and the ending point of the stroke, a sample text after downsampling is obtained.

[0063] Optionally, the downsampling module is configured to:

[0064] Calculate the mean and variance of the pen point coordinates according to the pen point coordinates of each pen point in the sample text after downsampling;

[0065] According to the mean and the variance, coordinates of the downsampled sample text are normalized to obtain the backup sample text.

[0066] Optionally, the text recognition model includes:

[0067] A sample input module is configured to input the pen point features of the sample text into a bidirectional neural network layer, wherein the dimension of the hidden layer in the first neural network layer of the bidirectional neural network layer is 96 dimensions, and the dimension of the hidden layer in the second neural network layer is 64 dimensions;

[0068] A mean pooling module is configured to use the output of the bidirectional neural network layer as an input of the mean pooling layer to obtain a pen point feature with reduced dimension;

[0069] An execution module is configured to set the connection probability between each two strokes to 0 according to a preset random probability;

[0070] An encoding module is configured to encode through a 26-dimensional encoding layer in a fully connected layer according to the pen point features with reduced dimensions and the connection probabilities after being randomly set to 0;

[0071] The classification module is configured to input the encoded pen point features into the classification model for classification, obtain the text parameter quantity output by the fully connected layer, until the text parameter quantity meets the parameter quantity of the preset text classification, and train the text recognition model.

[0072] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.

[0073] According to a fourth aspect of the present disclosure, there is provided an electronic device, comprising:

[0074] a memory having a computer program stored thereon;

[0075] A processor is used to execute the computer program in the memory to implement the steps of any method described in the first aspect.

[0076] Through the above technical solution, at least the following technical effects can be achieved:

[0077] By obtaining a handwritten character to be recognized; inputting the handwritten character to be recognized into a character recognition model, obtaining a recognition result of the character recognition model predicting the connected writing of the handwritten character to be recognized, wherein the character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between each two strokes in the sample characters; and displaying the recognition result. The character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between each two strokes in the sample characters, and further, by predicting the connected writing of the handwritten character to be recognized, the accuracy of handwritten character recognition can be improved.

[0078] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0079] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:

[0080] Figure 1 A flowchart of a handwritten text recognition method is shown according to an exemplary embodiment.

[0081] Figure 2 A flowchart of text recognition model training is shown according to an exemplary embodiment.

[0082] Figure 3 It is a schematic diagram showing a model network structure according to an exemplary embodiment.

[0083] Figure 4 It is a schematic diagram of an autoencoder structure according to an exemplary embodiment.

[0084] Figure 5 It is a schematic diagram showing a recognition result display according to an exemplary embodiment.

[0085] Figure 6 A flow chart of a method for determining pen point features is shown according to an exemplary embodiment.

[0086] Figure 7 The figure is a comparison diagram of sample text before and after downsampling according to an exemplary embodiment.

[0087] Figure 8 A flowchart of a method for determining probability of continuous strokes is shown according to an exemplary embodiment.

[0088] Fig. 9 According to an exemplary embodiment, an implementation Figure 8 Flowchart of step S82 in FIG.

[0089] Fig.10 The figure is a schematic diagram showing a method of constructing the straight line angle between every two strokes according to an exemplary embodiment.

[0090] Fig.11 The figure is a block diagram of a handwritten text recognition device according to an exemplary embodiment.

[0091] Fig.12 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0092] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0093] Figure 1 According to an exemplary embodiment, a flowchart of a handwritten text recognition method is shown, which is applied to a terminal device, for example, the terminal device can be a mobile phone, a tablet computer, an electronic blackboard, etc. Figure 1 As shown, the method includes the following steps.

[0094] In step S11, the handwritten text to be recognized is obtained.

[0095] The handwritten text to be recognized can be obtained from the handwriting input interface of the mobile terminal.

[0096] In step S12, the handwritten characters to be recognized are input into a character recognition model to obtain a recognition result of the character recognition model predicting connected writing of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between every two strokes in the sample characters;

[0097] The text recognition model can be trained based on the CASIA single-word handwriting dataset. The sample text can be the collected handwritten text or the first-level and second-level Chinese characters in GB2312. By training the text recognition model with national standard Chinese characters, the training samples can be enriched to avoid the inaccuracy of the text recognition model caused by the small number of handwritten text samples.

[0098] In one embodiment, Figure 2 According to an exemplary embodiment, a flowchart of a text recognition model training is shown. Figure 2 As shown, the method comprises the following steps:

[0099] In step S21, the pen point features of the sample text are input into the bidirectional neural network layer.

[0100] Among them, the dimension of the hidden layer in the first neural network layer of the bidirectional neural network layer is 96 dimensions, and the dimension of the hidden layer in the second neural network layer is 64 dimensions.

[0101] Among them, the pen point features of the sample text are input into the bidirectional neural network layer in time sequence, see Figure 3 As shown, the bidirectional neural network layer can be an LSTM (Long Short Term Memory Network) or a GRU (Gate Recurrent Unit).

[0102] Among them, the default dimension of the hidden layer of the general bidirectional neural network layer is 1024 dimensions or 128 dimensions. After experiments, the dimension of the hidden layer in the first neural network layer is built to 96 dimensions, and the dimension of the hidden layer in the second neural network layer is built to 64 dimensions, which can effectively reduce the number of parameters, thereby taking into account both recognition accuracy and parameter size.

[0103] In step S22, the output of the bidirectional neural network layer is used as the input of the mean pooling layer to obtain the pen point features with reduced dimension.

[0104] It is often possible to halve the dimensionality of the output of a bidirectional neural network layer.

[0105] In step S23, the connection probability between every two strokes is set to 0 according to a preset random probability.

[0106] Among them, taking the 3755 types of Chinese characters in GB2312 as sample text as an example, the dimension of the fully connected layer can be 3755 dimensions, and the number of parameters generated is 100*64 / 2*3755+3755=12019755. If the first-level and second-level Chinese characters in GB2312 are considered, plus common symbols, it will include 7356 types of Chinese characters, and the number of parameters will be more than 20 million, which is easy to cause overfitting of the fully connected layer. The dropout mechanism can effectively prevent overfitting of the fully connected layer.

[0107] Among them, setting the connection probability between every two strokes to 0 according to the preset random probability of 0.6 can prevent the fully connected layer from overfitting without reducing the accuracy of the text recognition model.

[0108] In step S24, encoding is performed through the 26-dimensional encoding layer in the fully connected layer based on the pen point features with reduced dimension and the connection probability after being randomly set to 0.

[0109] Among them, for 7356 types of Chinese characters, they are encoded in binary, that is, log27356=12.84, then at least a 13-dimensional encoding layer is required to meet the encoding requirements of 7356 types of text. In order to ensure the speed and accuracy of model encoding, the dimension of the encoding layer is selected to be twice that of the binary encoding, that is, the encoding layer in the fully connected layer is 26 dimensions.

[0110] Continue to see Figure 3As shown, the first stroke feature and the corresponding probability of continuous strokes are used as input features and input into the first bidirectional neural network layer. The output feature of the first neuron is not only used as one of the input features of the second neuron horizontally, but also input vertically into the neurons of the next layer. Similarly, the output feature of the previous neuron needs to be used as part of the input feature of the next neuron horizontally and input vertically into the neurons of the next layer. After the training of the neurons in this sub-layer is completed, the output feature of the last neuron in this sub-layer is reversed as part of the input feature of the neuron of the previous input feature. Similarly, the output feature of the next neuron in this sub-layer is reversed as part of the input feature of the neuron of the previous input feature.

[0111] Then all the outputs of the bidirectional neural network layer are input into the mean pooling and dropout layer. To avoid overfitting, the mean pooling layer can randomly lose neurons. The output features of the mean pooling layer are input into the full connection layer (full layer and dropout). After the logistic regression classification process, 3755 features are output.

[0112] Among them, due to the small dimension of the encoding layer, the network training is difficult, and the autoencoder needs to be trained separately in advance. Figure 4 The autoencoder structure shown in the figure takes the output dimension of the second layer of the neural network as 6400 as an example. The 6400-dimensional floating point input feature is input into the first layer of the neural network. When the model is stable, the 6400-dimensional feature is encoded through the 26-dimensional encoding layer to reduce the dimension of the high-dimensional feature. Furthermore, the encoded feature is decoded through the 26-dimensional encoding layer to restore the input feature to obtain the encoding parameter of the autoencoder, and the encoding parameter is put into the neural network as the initialization value to train the text recognition model.

[0113] In step S25, the encoded pen point features are input into the classification model for classification to obtain the text parameter quantity output by the fully connected layer, until the text parameter quantity meets the parameter quantity of the preset text classification, and the text recognition model is trained.

[0114] For example, see the network structure of the text recognition model shown in Table 1:

[0115]

[0116]

[0117] Table 1

[0118] Among them, bidirectional_1 is the first neural network layer of the bidirectional neural network layer, with a dimension of 96 and an output parameter quantity of 59328. Bidirectional_2 is the second neural network layer of the bidirectional neural network layer, with a dimension of 64 and an output parameter quantity of 61824. Flatten_1 unfolds the bidirectional neural network layer and has no output parameter quantity. Dropout_1 is used to set the connection probability of every two strokes to 0 according to a preset probability during model training and has no output parameter quantity. Decode_1 is the encoding layer in the fully connected layer, with a dimension of 26 and an output parameter quantity of 166426. Dense_1 is the classification layer, and through the softmax model, the recognition results of 7356 categories can be obtained, with an output parameter quantity of 198312.

[0119] Exemplarily, the model parameters and the number of text parameters can be saved in the form of 32-bit floating-point numbers. After experiments, the final size of the number of text parameters is 59328 + 61824 + 166426 + 198612 = 486190. For saving the number of text parameters at the 480,000 level, the file size of the text recognition model is less than 2M.

[0120] Adopting the above technical solution, the number of model parameters of the text recognition model is small, the number of text parameters obtained by training is also small, and thus the saved model file is small, which is convenient for the text recognition model to be applied on terminal devices.

[0121] In step S13, the recognition result is displayed.

[0122] Exemplarily, as shown in Figure 5 the recognition result can be horizontally displayed at the bottom of the handwriting interface.

[0123] In one implementation manner, the handwritten text to be recognized can be an incompletely written text. As shown in Figure 5 during the user's handwriting process, the text written by the user for each stroke is obtained. Not only can the text that has been handwritten be recognized through the text recognition model, but also the unwritten part of the last stroke can be predicted, and the recognition result of the text to be recognized can be obtained and the recognition result can be displayed in real time during the handwriting process. In this way, the speed of handwritten text recognition can be improved.

[0124] Continuing with Figure 5 the embodiment for illustration, when the first 6 strokes of "fast" are written, the text written in the first 6 strokes can be recognized, and the 7th stroke and subsequent strokes can be predicted. For another example, when the first 3 strokes of "happy" are written, due to the occurrence of connected writing, the 3rd and 4th strokes of "happy" itself, which are the 3rd stroke during the writing process, can be recognized based on the text written in the first 3 strokes, and the 4th stroke and subsequent strokes can be predicted.

[0125] Experiments have shown that the accuracy of the text recognition model can reach 95%. During the user's handwriting process, text recognition is performed based on incomplete handwritten text, and the single-word recognition time is only 21ms, which can reduce the input strokes and effectively improve the speed of handwritten text recognition.

[0126] The above technical solution obtains the handwritten characters to be recognized; inputs the handwritten characters to be recognized into the character recognition model, obtains the recognition result of the character recognition model predicting the connected writing of the written characters to be recognized, wherein the character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between each two strokes in the sample characters; and displays the recognition result. The character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between each two strokes in the sample characters, and further, the accuracy of handwritten character recognition can be improved by predicting the connected writing of the written characters to be recognized.

[0127] Based on the above embodiments, Figure 6 According to an exemplary embodiment, a flowchart of a method for determining pen point features is shown. Figure 6 As shown, the method includes the following steps.

[0128] In step S61, the coordinates of the downsampled sample text are normalized to obtain a backup sample text.

[0129] The downsampling of the sample text includes:

[0130] For each stroke in the sample text, determine the Euclidean distance between the coordinates of adjacent stroke points.

[0131] For example, first calculate the Euclidean distance between the starting point and the first stroke point after the starting point, then determine the Euclidean distance between the first stroke point after the starting point and the second stroke point after the starting point, and so on, until the Euclidean distance between the ending point and the first stroke point before the ending point is determined.

[0132] Among them, the starting point is the point where the pen is placed when the stroke is started, the ending point is the point where the stroke stops being written, and the running point is the point between the starting point and the ending point.

[0133] The stroke points whose Euclidean distance is less than the distance threshold are eliminated to obtain the valid stroke points.

[0134] For example, one-fifteenth to one-twentieth of the width of the sample text can be taken as the distance threshold. For example, according to the coordinates of each pen point in the sample text in the X-axis direction, the coordinate difference is obtained by subtracting the minimum pen point coordinate from the maximum pen point coordinate in the X-axis direction, and the distance threshold T is taken. dist for:

[0135]

[0136] Among them, ΔT is the coordinate difference obtained by subtracting the minimum pen point coordinate from the maximum pen point coordinate in the X-axis direction of the sample text.

[0137] For example, the following formula is used to remove the stroke points whose Euclidean distance is less than the distance threshold:

[0138]

[0139] Among them, x i is the horizontal coordinate of the i-th pen point, x i-1 is the horizontal coordinate of the i-1th pen point, y i is the ordinate of the i-th pen point, y i-1 is the vertical coordinate of the i-1th pen point.

[0140] According to the effective stroke points, the starting point and the ending point of the stroke, a sample text after downsampling is obtained.

[0141] See also Figure 7 As shown, the left side is the sample text before downsampling, and the right side is the sample text after downsampling.

[0142] Optionally, in step S61, the coordinates of the downsampled sample text are normalized to obtain the backup sample text, including:

[0143] According to the pen point coordinates of each pen point in the downsampled sample text, the mean and variance of the pen point coordinates are calculated.

[0144] For example, the mean of the horizontal coordinate of the sample text after downsampling is calculated based on the horizontal coordinate of each pen point. Similarly, the mean of the vertical coordinate of the sample text after downsampling is calculated based on the vertical coordinate of each pen point. The horizontal coordinate variance of the sample text after downsampling is calculated based on the horizontal coordinate of each pen point and the mean of the horizontal coordinate. Similarly, the vertical coordinate variance of the sample text after downsampling is calculated based on the vertical coordinate of each pen point and the mean of the vertical coordinate.

[0145] According to the mean and the variance, coordinates of the downsampled sample text are normalized to obtain the backup sample text.

[0146] For example, for each pen point, the normalized pen point coordinate x is calculated by the following formula: new :

[0147] X new =(X j -μ a ) / δ a

[0148] Among them, Xj is the jth pen point coordinate in the sample text after downsampling, μ a is the mean of the sample text after downsampling, δ a is the variance of the sample text after downsampling.

[0149] In step S62, the pen point features of each pen point in the backup sample text are determined according to the acquisition timestamp, pen point type and pen point coordinates of each pen point.

[0150] The stroke point types include a starting point, a running point and an ending point.

[0151] For example, the pen point feature of the pen point can be expressed as (x i ,y i ,t i ,s i ), where x i is the normalized horizontal coordinate of the i-th pen point, y i is the normalized vertical coordinate of the i-th pen point, t i is the acquisition timestamp of the i-th pen point, s i is the pen point type of the i-th pen point.

[0152] Among them, s=0 indicates that the stroke point is a stroke point, s=1 indicates that the stroke point is a stroke starting point, and s=2 indicates that the stroke point is an stroke ending point.

[0153] The above technical solution can eliminate redundant pen points in sample text, reduce the impact of device sampling rate on text recognition, normalize pen point coordinates, reduce the impact of text size on text recognition, and improve the recognition speed of the text recognition model.

[0154] Based on the above embodiments, Figure 8 According to an exemplary embodiment, a flowchart of a method for determining the probability of continuous strokes is shown. Figure 8 As shown, the method includes the following steps.

[0155] In step S81, a target point corresponding to each stroke of the prepared sample characters is determined from the points of the strokes of the prepared sample characters.

[0156] In step S82, the probability of connecting every two strokes in the backup sample characters is determined according to the stroke point features of the target stroke points of each stroke.

[0157] Based on the above embodiments, Fig. 9 According to an exemplary embodiment, an implementation Figure 8 See the flowchart of step S82 in Fig. 9As shown, in step S82, the probability of connecting every two strokes in the backup sample character is determined according to the stroke point features of the target stroke points of each stroke, including:

[0158] In step S821, the first stroke and the second stroke of every two strokes in the backup sample character are determined according to the acquisition timestamp of each stroke point.

[0159] It can be understood that the stroke with the earlier acquisition time stamp is the first stroke, and the stroke with the later acquisition time stamp is the last stroke. The target pen points of the first stroke and the last stroke are different. The target pen points of the first stroke are the end point and the multiple stroke points before the end point, and the target pen points of the last stroke are the start point and the multiple stroke points after the start point.

[0160] In step S822, the distance between the starting and ending points of each two strokes is determined according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, and the target pen point includes the ending point and the starting point.

[0161] For example, the Euclidean distance between the end point and the start point of every two strokes is calculated according to the pen point coordinates in the pen point features.

[0162] In step S823, based on the least squares method, a first straight line is fitted according to the pen point features of the end point of the first stroke and the pen point features of multiple pen points before the end point, and a second straight line is fitted according to the pen point features of the start point of the second stroke and the pen point features of multiple pen points after the start point, and the target pen points include the multiple pen points before the end point and the multiple pen points after the start point.

[0163] See also Fig.10 As shown, a1, a2, and a3 are respectively the end point of the stroke written first and the two stroke points before the end point, l1 is the first straight line fitted according to the pen point coordinates of a1, a2, and a3 based on the least squares method, that is, l1 is the directional straight line with the shortest distance to a1, a2, and a3; similarly, b1, b2, and b3 are respectively the start point of the stroke written later and the two stroke points after the start point, l2 is the second straight line fitted according to the pen point coordinates of b1, b2, and b3 based on the least squares method, that is, l2 is the directional straight line with the shortest distance to b1, b2, and b3.

[0164] In step S824, the straight line angle between each two strokes is obtained according to the first straight line and the second straight line.

[0165] The above embodiment is used for explanation. A parallel line l′1 is made to l1, and the parallel line l′1 intersects with l2. The angle θ between l′1 and l2 is the angle between the first straight line and the second straight line corresponding to the two strokes.

[0166] In step S825, the probability of connecting every two strokes in the backup sample characters is determined based on the relationship between the distance between the starting and ending points of every two strokes and the distance threshold, and the relationship between the straight line angle between every two strokes and the preset angle threshold.

[0167] The distance threshold is determined according to the text width of the sample text.

[0168] As mentioned above, one fifteenth to one twentieth of the width of the sample text can be taken as the distance threshold.

[0169] Among them, in the handwriting process, obtuse-angled strokes often exist between two strokes with a smaller distance, while when the distance between the two strokes is larger, there is often an acute angle between the two strokes. Therefore, the preset angle threshold can be 30° to 60°, and 45° is preferably used as the preset angle threshold.

[0170] On the basis of the above embodiment, in step S725, the probability of connecting each two strokes in the backup sample character is determined according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and the preset angle threshold, including:

[0171] When the distance between the starting and ending points of the stroke is less than the distance threshold, and / or the straight line angle is less than the preset angle threshold, the preset connecting stroke probability is used as the connecting stroke probability of the two strokes.

[0172] For example, when the distance between the starting and ending points of a stroke is less than the distance threshold, and / or the straight line angle is less than a preset angle threshold, a preset connecting stroke probability of 0.5 is used as the connecting stroke probability of the two strokes.

[0173] When the distance between the starting and ending points of the stroke is greater than or equal to the distance threshold, and the straight line angle is greater than or equal to the preset angle threshold, the probability of connecting the two strokes is determined to be 0.

[0174] Experiments have shown that training text recognition based on the probability of connected strokes in sample text can improve the recognition rate of the text recognition model by 0.8 percentage points without interfering with user input.

[0175] Based on the same concept, the present disclosure also provides a handwritten text recognition device for executing the steps of the handwritten text recognition method provided in the above embodiment. The device can implement the handwritten text recognition method in the form of software, hardware or a combination of both. Fig.11 is a block diagram of a handwritten text recognition device 1100 according to an exemplary embodiment. Fig.11As shown, the device 1100 includes: an acquisition module 1110 , an input module 1120 and a display module 1130 .

[0176] The acquisition module 1110 is configured to acquire the handwritten text to be recognized;

[0177] The input module 1120 is configured to input the handwritten characters to be recognized into a character recognition model, and obtain a recognition result of the character recognition model predicting connected writing of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of the sample characters and the probability of connected writing between every two strokes in the sample characters;

[0178] The display module 1130 is configured to display the recognition result.

[0179] The character recognition model in the above device is trained based on the stroke features of the sample characters and the probability of connecting strokes between every two strokes in the sample characters, and the accuracy of handwritten character recognition can be improved by predicting the connected strokes of the written characters to be recognized.

[0180] Optionally, the device 1100 further includes:

[0181] A downsampling module is configured to normalize the coordinates of the downsampled sample text to obtain a backup sample text;

[0182] A first determination module is configured to determine the pen point features of each pen point in the backup sample text according to the acquisition timestamp, pen point type and pen point coordinates of each pen point in the backup sample text;

[0183] The stroke point types include a starting point, a running point and an ending point.

[0184] Optionally, the device 1100 further includes:

[0185] A second determination module is configured to determine a target stroke point corresponding to each stroke from the stroke points of each stroke of the backup sample character;

[0186] The probability determination module is configured to determine the probability of connecting every two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke.

[0187] Optionally, the probability determination module includes:

[0188] A first determination submodule is configured to determine the first stroke and the last stroke of every two strokes in the backup sample character according to the acquisition timestamp of each stroke point;

[0189] A distance determination submodule is configured to determine the distance between the starting and ending points of each two strokes according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, wherein the target pen point includes the ending point and the starting point;

[0190] The straight line fitting submodule is configured to fit a first straight line based on the pen point features of the first stroke and the pen point features of multiple stroke points before the pen point, and fit a second straight line based on the pen point features of the second stroke and the pen point features of multiple stroke points after the pen point, wherein the target pen points include the multiple stroke points before the pen point and the multiple stroke points after the pen point;

[0191] A second determining submodule is configured to obtain a straight line angle between each two strokes according to the first straight line and the second straight line;

[0192] A third determination submodule is configured to determine the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and a preset angle threshold;

[0193] The distance threshold is determined according to the text width of the sample text.

[0194] Optionally, the third determining submodule includes:

[0195] A first probability determination unit is configured to use a preset probability of connecting strokes as the probability of connecting strokes of the two strokes when the distance between the starting and ending points is less than the distance threshold and / or the angle between the straight lines is less than the preset angle threshold;

[0196] The second probability determination unit is configured to determine that the probability of connecting the two strokes is 0 when the distance between the starting and ending points is greater than or equal to the distance threshold and the straight line angle is greater than or equal to the preset angle threshold.

[0197] Optionally, the downsampling module is configured to:

[0198] For each stroke in the sample text, determining the Euclidean distance between the coordinates of adjacent stroke points;

[0199] Eliminate the stroke points whose Euclidean distance is less than the distance threshold to obtain valid stroke points;

[0200] According to the effective stroke points, the starting point and the ending point of the stroke, a sample text after downsampling is obtained.

[0201] Optionally, the downsampling module is configured to:

[0202] Calculate the mean and variance of the pen point coordinates according to the pen point coordinates of each pen point in the sample text after downsampling;

[0203] According to the mean and the variance, coordinates of the downsampled sample text are normalized to obtain the backup sample text.

[0204] Optionally, the text recognition model includes:

[0205] A sample input module is configured to input the pen point features of the sample text into a bidirectional neural network layer, wherein the dimension of the hidden layer in the first neural network layer of the bidirectional neural network layer is 96 dimensions, and the dimension of the hidden layer in the second neural network layer is 64 dimensions;

[0206] A mean pooling module is configured to use the output of the bidirectional neural network layer as an input of the mean pooling layer to obtain a pen point feature with reduced dimension;

[0207] An execution module is configured to set the connection probability between each two strokes to 0 according to a preset random probability;

[0208] An encoding module is configured to encode through a 26-dimensional encoding layer in a fully connected layer according to the pen point features with reduced dimensions and the connection probabilities after being randomly set to 0;

[0209] The classification module is configured to input the encoded pen point features into the classification model for classification, obtain the text parameter quantity output by the fully connected layer, until the text parameter quantity meets the parameter quantity of the preset text classification, and train the text recognition model.

[0210] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0211] In addition, it is worth noting that for the convenience and simplicity of description, the embodiments described in the specification are all preferred embodiments, and the parts involved are not necessarily necessary for the present invention. For example, the input module 1120 and the display module 1130 can be independent devices or the same device in specific implementations, and the present disclosure does not limit this.

[0212] The embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the methods for handwritten text recognition.

[0213] The present disclosure also provides an electronic device, including:

[0214] a memory having a computer program stored thereon;

[0215] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods for handwritten text recognition.

[0216] Fig.12 1 is a block diagram of an electronic device 1200 according to an exemplary embodiment. The electronic device 1200 may be configured as a teaching terminal to perform the above-mentioned handwritten text recognition method. Fig.11 As shown, the electronic device 1200 may include: a processor 1201 and a memory 1202. The electronic device 1200 may also include one or more of a multimedia component 1203, an input / output (I / O) interface 1204, and a communication component 1205.

[0217] The processor 1201 is used to control the overall operation of the electronic device 1200 to complete all or part of the steps in the above-mentioned handwritten character recognition method. The memory 1202 is used to store various types of data to support the operation of the electronic device 1200, and these data may include, for example, instructions for any application or method used to operate on the electronic device 1200, and application-related data, such as school data, course data, class data, teacher and classroom data, etc. The memory 1202 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 1203 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the memory 1202 or sent through the communication component 1205. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 1204 provides an interface between the processor 1201 and other interface modules, and the above-mentioned other interface modules may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 1205 is used for wired or wireless communication between the electronic device 1200 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, etc. Therefore, the corresponding communication component 1205 may include: a Wi-Fi module, a Bluetooth module, etc.

[0218] In an exemplary embodiment, the electronic device 1200 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned handwritten text recognition method.

[0219] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned handwritten text recognition method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 1202 including program instructions, and the above-mentioned program instructions can be executed by the processor 1201 of the electronic device 1200 to complete the above-mentioned handwritten text recognition method.

[0220] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0221] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0222] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A handwritten text recognition method, characterized in that: include: Get the handwritten text to be recognized; Inputting the handwritten characters to be recognized into a character recognition model to obtain a recognition result of the character recognition model predicting connected writing of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of sample characters and the probability of connected writing between every two strokes in the sample characters; Displaying the recognition result; The probability of consecutive strokes is determined in the following way: Normalizing the coordinates of the sample text after downsampling to obtain a backup sample text; Determine a target stroke point corresponding to each stroke from the stroke points of the backup sample characters; Determining the probability of connecting every two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke; The step of determining the probability of connecting two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke includes: Determine the first stroke and the last stroke of every two strokes in the backup sample character according to the acquisition time stamp of each stroke point; Determine the distance between the starting and ending points of each two strokes according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, wherein the target pen point includes the ending point and the starting point; Based on the least square method, a first straight line is obtained by fitting according to the pen point features of the end point of the first stroke and the pen point features of multiple pen points before the end point, and a second straight line is obtained by fitting according to the pen point features of the start point of the second stroke and the pen point features of multiple pen points after the start point, wherein the target pen point includes the multiple pen points before the end point and the multiple pen points after the start point; Obtaining a straight line angle between each two strokes according to the first straight line and the second straight line; Determine the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and the preset angle threshold; The distance threshold is determined according to the text width of the sample text.

2. The method according to claim 1, characterized in that The pen point features are determined in the following way: Determine the pen point features of each pen point according to the acquisition timestamp, pen point type and pen point coordinates of each pen point in the backup sample text; The stroke point types include a starting point, a running point and an ending point.

3. The method according to claim 1, characterized in that The determining the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and the preset angle threshold, includes: When the distance between the starting and ending points of the stroke is less than the distance threshold, and / or the straight line angle is less than the preset angle threshold, taking the preset connecting stroke probability as the connecting stroke probability of the two strokes; When the distance between the starting and ending points of the stroke is greater than or equal to the distance threshold, and the straight line angle is greater than or equal to the preset angle threshold, the probability of connecting the two strokes is determined to be 0.

4. The method according to any one of claims 1 to 3, characterized in that The downsampling of the sample text includes: For each stroke in the sample text, determining the Euclidean distance between the coordinates of adjacent stroke points; Eliminate the stroke points whose Euclidean distance is less than the distance threshold to obtain valid stroke points; According to the effective stroke points, the starting point and the ending point of the stroke, a sample text after downsampling is obtained.

5. The method according to any one of claims 1 to 3, characterized in that: The step of normalizing the coordinates of the downsampled sample text to obtain the backup sample text includes: Calculate the mean and variance of the pen point coordinates according to the pen point coordinates of each pen point in the sample text after downsampling; According to the mean and the variance, coordinates of the downsampled sample text are normalized to obtain the backup sample text.

6. The method according to claim 1, characterized in that The text recognition model is trained in the following way: Inputting the pen point features of the sample text into a bidirectional neural network layer, wherein the dimension of the hidden layer in the first neural network layer of the bidirectional neural network layer is 96 dimensions, and the dimension of the hidden layer in the second neural network layer is 64 dimensions; Using the output of the bidirectional neural network layer as the input of the mean pooling layer to obtain the pen point features with reduced dimension; According to a preset random probability, the connection probability between each two strokes is set to 0; Encoding is performed through a 26-dimensional encoding layer in a fully connected layer according to the pen point features with reduced dimension and the connection probability after being randomly set to 0; The encoded pen point features are input into the classification model for classification to obtain the text parameter quantity output by the fully connected layer, until the text parameter quantity meets the parameter quantity of the preset text classification, and the text recognition model is obtained by training.

7. A handwritten character recognition device, characterized in that: The device comprises: An acquisition module, configured to acquire handwritten characters to be recognized; An input module is configured to input the handwritten characters to be recognized into a character recognition model to obtain a recognition result of the character recognition model predicting connected writing of the handwritten characters to be recognized, wherein the character recognition model is trained based on the stroke features of sample characters and the probability of connected writing between every two strokes in the sample characters; A display module, configured to display the recognition result; A downsampling module is configured to normalize the coordinates of the downsampled sample text to obtain a backup sample text; A second determination module is configured to determine a target stroke point corresponding to each stroke from the stroke points of each stroke of the backup sample character; A probability determination module, configured to determine the probability of connecting every two strokes in the backup sample characters according to the stroke point features of the target stroke points of each stroke; Wherein, the probability determination module includes: A first determination submodule is configured to determine the first stroke and the last stroke of every two strokes in the backup sample character according to the acquisition timestamp of each stroke point; A distance determination submodule is configured to determine the distance between the starting and ending points of each two strokes according to the pen point coordinates of the ending point of the first stroke and the pen point coordinates of the starting point of the second stroke, wherein the target pen point includes the ending point and the starting point; The straight line fitting submodule is configured to fit a first straight line based on the pen point features of the first stroke and the pen point features of multiple stroke points before the pen point, and fit a second straight line based on the pen point features of the second stroke and the pen point features of multiple stroke points after the pen point, wherein the target pen points include the multiple stroke points before the pen point and the multiple stroke points after the pen point; A second determining submodule is configured to obtain a straight line angle between each two strokes according to the first straight line and the second straight line; A third determination submodule is configured to determine the probability of connecting each two strokes in the backup sample character according to the size relationship between the distance between the starting and ending points of each two strokes and the distance threshold, and the size relationship between the straight line angle between each two strokes and a preset angle threshold; The distance threshold is determined according to the text width of the sample text.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 6.