English word handwriting recognition method and terminal device

By setting the English character height classification table and target image parameters, adjusting the character parameters, generating suitable training and test data sets, and using the deep learning CNN model, the problem of English word handwriting recognition is solved and the recognition efficiency and accuracy are improved. Reduced costs.

CN115082936BActive Publication Date: 2024-08-27SHENZHEN HANGSHENG ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210587207.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2024-08-27
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

Existing technology cannot effectively recognize handwritten input of English words. Single-character data sets cannot meet word recognition requirements. Images scanned or photographed of paper documents contain interference information and are very different from handwritten images, making it difficult to be used for deep learning training.

Method used

Set the initial data set to include English uppercase and lowercase handwritten strokes and word sets, generate target image parameters through the English character height classification table, adjust the character width, height and starting position, generate training and test data sets for multiple writing methods, and use deep learning The CNN model is trained, and quantization processing is used to reduce the model complexity.

Benefits of technology

It significantly improves model training efficiency, reduces costs, has strong scalability, the data set is closer to human handwriting habits, and improves the accuracy of English word recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115082936B
    Figure CN115082936B
Patent Text Reader

Abstract

The present invention provides an English word handwriting recognition method and terminal device, belonging to the field of handwriting recognition technology. The English word handwriting recognition method of the present invention comprises the steps of: setting an initial data set; initialization operation: setting an English character height classification table, generating parameters of a target image according to words in the English word set; obtaining words from the English word set in sequence, and obtaining a flag value of the character type combination of the word based on the English character height classification table; calculating the actual width, height, and vertical starting position of each character of the word; obtaining adjusted target character parameters; setting different drawing parameters to obtain multiple writing methods based on the word; generating a training data set and a test data set containing data of a second set value; using a training model to train on the generated training data set and test data set to generate a handwriting recognition model. The beneficial effects of the present invention are: greatly improving the development efficiency of the English word handwriting recognition system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a handwriting recognition technology, and in particular to an English word handwriting recognition method, and a terminal device adopting the handwriting recognition method. Background Art

[0002] The basic principle of existing handwriting input recognition technology is to use training model technology to train on manually collected data sets, and then use the trained model to infer the recognition results. At present, most English handwriting data sets are single-character data sets, and the handwriting data sets for English words are all images cropped from paper document scans or photos, rather than stroke data.

[0003] Technical defects of existing technology:

[0004] The stroke dataset of a single character does not meet the requirements of word recognition, and the images generated by scanning or photographing paper documents contain a lot of interference information and are very different from the images generated by handwriting. They cannot be used for deep learning training of handwriting recognition in input methods for English words. Summary of the invention

[0005] In order to solve the problems in the prior art, the present invention provides an English word handwriting recognition method and also provides a terminal device using the handwriting recognition method.

[0006] The present invention comprises the following steps:

[0007] S1: Setting an initial data set, the initial data set includes an English uppercase and lowercase handwritten stroke data set and an English word set;

[0008] S2: Initialization operation: set the English character height classification table and generate parameters of the target image according to the words in the English word set;

[0009] S3: obtaining a word from the English word set, and obtaining a flag value of the character type combination of the word based on the English character height classification table;

[0010] S4: Calculate the actual width, height, and vertical starting position of each character of the word;

[0011] S5: adjusting the actual width, height, and vertical starting position of the character according to the width parameter of the target image, and obtaining the adjusted target character parameters;

[0012] S6: drawing strokes based on the target character parameters, setting different drawing parameters, and obtaining multiple writing methods based on the word;

[0013] S7: repeating steps S3-S6, obtaining different ways of writing a set number of words in the English word set, and generating a training data set and a test data set containing data of a second set value;

[0014] S8: Use the training model to train on the generated training dataset and test dataset to generate a handwriting recognition model.

[0015] The present invention is further improved to include step S9: quantizing the file of the handwriting recognition model to reduce the complexity of the model and obtain a handwriting recognition model file with a smaller accuracy loss.

[0016] The present invention is further improved. In step S2, the English character height classification table includes five categories, namely, upper middle, middle, upper, lower and full height categories.

[0017] The present invention is further improved, and the parameters of the target image include the target image height, width, the interval between each character and the number of target images generated for each word.

[0018] The present invention is further improved. In step S3, the flag value setting method of the character type combination is: obtain the category of each character from left to right in the word in the English character height classification table, and correspond the 1st to 5th bits of the integer flag value Flag to the 5 categories of the English character height classification table respectively; if there is a character in the word that belongs to one of the categories, the position is 1, otherwise it is set to 0, and finally a flag value including a string of characters is obtained.

[0019] The present invention is further improved. Based on the flag value of the character type combination, the flag value of the character type combination of a word can be divided into 2 to the fifth power, i.e., 32 types, according to different combinations of 5 types, and the actual width coefficient wc, height coefficient hc and vertical starting position coefficient yc of each character in the word are obtained respectively.

[0020] The present invention is further improved. In step S4, the actual width w, height h, and vertical starting position y of each character ch of the word are calculated as follows:

[0021] (1) Randomly obtain a stroke data from the stroke set of the character ch, and obtain the width wo and height ho of the stroke data converted into the image; the width wa of the target icon in the full-height case is CHAR_IMG_SIZE*wo / ho;

[0022] (2) Combining the actual width coefficient, height coefficient, and vertical starting position coefficient of the character, the target width w of each character is wa*wc, the target height h is CHAR_IMG_SIZE*hc, and the target vertical starting position y is CHAR_IMG_SIZE*yc, where CHAR_IMG_SIZE is the target image height.

[0023] The present invention is further improved. In step S5, the method for adjusting the actual width, height and vertical starting position of the character is as follows:

[0024] (a) Add the width w of each character obtained in step S5 to obtain total_w;

[0025] (b) Get the number of characters in the word, word_length;

[0026] (c) The scaling ratio ratio is calculated as: ratio = (FULL_IMG_WIDTH - FIXED_GAP * word_length) / total_w;

[0027] (d) After scaling each character according to the ratio, add the character interval FIXED_GAP to get the total width. If the calculated total width deviates from the set target image width, the calculation result is adjusted according to the deviation, and finally the target width w' of each character is obtained.

[0028] The present invention is further improved. In step S8, a deep learning CNN training model is used for training, and the Adam optimization algorithm is used to update the trainable parameters in the model. The training model includes: a plurality of convolutional layers and a fully connected layer, and also includes:

[0029] Batch normalization layer: set at the output of each convolutional layer and the first fully connected layer, used to normalize the input of each layer;

[0030] Max pooling layer: It is set at the output of several batch normalization layers to divide the input data into several small blocks of the same size without overlapping. In each small block, only the largest number is taken and other data is discarded, so as to compress feature data, simplify network complexity and reduce the amount of calculation.

[0031] Flattening layer: It is set at the output of the last pooling layer to flatten the input, that is, to make the multi-dimensional input one-dimensional, for the transition from the convolutional layer to the fully connected layer.

[0032] The present invention also provides a terminal device, which is provided with the handwriting recognition model file and is used to execute the English word handwriting recognition method to realize handwriting recognition of English words.

[0033] Compared with the prior art, the beneficial effects of the present invention are: greatly improving the efficiency of model training, spending very little money, and being able to easily expand the data set later, the invention greatly improves efficiency and scalability, and significantly reduces costs. In addition, the training data set and the test data set consider the expansion of various handwriting habits, making the data set of the present invention closer to people's handwriting habits, and being able to more easily recognize handwritten English words. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 is a flow chart of the method of the present invention;

[0035] Figure 2 This is a structural diagram of an embodiment of a training model of the present invention. DETAILED DESCRIPTION

[0036] The present invention is further described in detail below with reference to the accompanying drawings and embodiments.

[0037] like Figure 1 As shown, the identification of the present invention includes the following steps:

[0038] S1: Setting an initial data set, the initial data set includes an English uppercase and lowercase handwritten stroke data set and an English word set;

[0039] S2: Initialization operation: set the English character height classification table and generate parameters of the target image according to the words in the English word set;

[0040] S3: obtaining a word from the English word set, and obtaining a flag value of the character type combination of the word based on the English character height classification table;

[0041] S4: Calculate the actual width, height, and vertical starting position of each character of the word;

[0042] S5: adjusting the actual width, height, and vertical starting position of the character according to the width parameter of the target image, and obtaining the adjusted target character parameters;

[0043] S6: drawing strokes based on the target character parameters, setting different drawing parameters, and obtaining multiple writing methods based on the word;

[0044] S7: repeating steps S3-S6, obtaining different ways of writing a set number of words in the English word set, and generating a training data set and a test data set containing data of a second set value;

[0045] S8: Use the training model to train on the generated training dataset and test dataset to generate a handwriting recognition model

[0046] Then the handwritten English is recognized by the handwriting recognition model.

[0047] Preferably, this example also includes step S9: performing int8 quantization processing on the handwriting recognition model file to reduce the model complexity, thereby obtaining a smaller handwriting recognition model file with less precision loss, which is suitable for embedded operating environments.

[0048] The present invention also provides a terminal device, which is provided with the handwriting recognition model file. For example, it can be applied to a smart device such as a car computer or a mobile phone to execute the English word handwriting recognition method, and realize the handwriting recognition of English words through deep learning reasoning calculation.

[0049] The various steps of the present invention are described in detail below through specific embodiments.

[0050] 1. Set an initial data set, which includes an English uppercase and lowercase handwritten stroke data set and an English word set.

[0051] a) Initial Dataset 1 - English Uppercase and Lowercase Handwritten Strokes Dataset: There is an existing English character dataset with 52 categories, including 26 lowercase letters and 26 uppercase letters. There are about 800 samples in each category, and the sample format is a stroke set (Stroke), that is, each stroke is a combination of multiple points, each point is an (x, y) coordinate value, and each sample is a combination of multiple strokes.

[0052] b) Initial Dataset 2 - 60,000 Most Common Words: We have a list of common English words from Google statistics. We take the top 20,000 most common words and add two variants: capitalized first character and all capitalized, to generate a total of 60,000 categories.

[0053] 2. Initialization, used to set the English character height classification table and generate parameters for the target image based on the words in the English word set.

[0054] a) English character height classification table: The 52 English characters are divided into 5 categories according to the usual handwriting style and corresponding to the fifth 'full height' position below. The first category is the upper middle, denoted by MUP, including ['i', 't']; the second category is the middle, denoted by MID, including ['a', 'c', 'e', ​​'m', 'n', 'o', 'r', 's', 'u', 'v', 'w', 'x', 'z']; the third category is the upper part, denoted by UPP, including ['b', 'd', 'h', 'k', 'l', 'A', 'B', 'C', 'D', 'E' ,'F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; the fourth is the lower part, recorded as LOW, including ['g','p','q','y']; the fifth is the full height, recorded as ALL, including ['f','j']; this value is immutable;

[0055] b) Target image height: Set the target image height, which is the height of a single character (denoted as CHAR_IMG_SIZE). The default value is 18; this value can be changed.

[0056] c) Target image width: Set the width of the target image (represented as FULL_IMG_WIDTH). The default value is 90, which is 5*CHAR_IMG_SIZE. This value can be changed.

[0057] d) The gap between each character: Set the gap between each character (denoted as FIXED_GAP). The default value is 1, and this value is variable.

[0058] e) Number of images generated for each word: Set the number of images generated for each word (denoted as OUTPUT_IMG_NUM). The default value is 400, which is a variable value.

[0059] 3. Calculate the flag value of the character type combination: This step obtains the flag value of the character type combination in a word: obtain a word from the initial data set 2 - the 60,000 most commonly used words in order, obtain the category of each character from left to right in the word in the English character height classification table, and correspond the 1st to 5th bits of the integer flag value Flag to the 5 categories of the English character height classification table: ALL, LOW, UPP, MID, MUP; if there is a character in the word that belongs to one of the categories, the position is 1, otherwise it is set to 0;

[0060] 4. Calculate the actual width coefficient, height coefficient and vertical starting position coefficient of the character: The five categories in the English character height classification table only correspond to the fifth 'full height' position. When the character type combination in a word is different, the actual position of each character in the word is different. For example, the position of 'a' in "face" is in the middle, but the 'a' in "as" is full height, and the 'a' in "date" is in the lower half. According to the different combinations of the five categories, the [flag value of the character type combination] of the word can be divided into 2 to the fifth power, that is, 32 types, and the actual width coefficient (denoted as wc), height coefficient (denoted as hc) and vertical starting position coefficient (denoted as yc) of each character in the word are obtained respectively. The specific processing method is:

[0061] a) The value is [0,1,2,4,8,16], which means there is only one category in the word, then all characters wc and hc are 1, and yc is 0;

[0062] b) The value is 3, indicating that there are two categories in the word: LOW and ALL, such as "pf". If the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0063] c) The value is 5, indicating that there are two categories in the word: UPP and ALL, such as "bf". If the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0064] d) The value is 6, indicating that there are two categories in the word: UPP and LOW, such as "bp". If the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3;

[0065] e) The value is 7, indicating that there are three categories in the word: UPP, LOW, and ALL, such as "bpf". If the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0066] f) The value is 9, indicating that there are two categories in the word: LOW and ALL, such as "of". 'o' category is MID, then wc and hc are 1 / 3, yc is 1 / 3; 'f' category is ALL, then wc and hc are 1, yc is 0;

[0067] g) The value is 10, indicating that there are two categories in the word: MID and LOW, such as "ap". If the category of 'a' is MID, then wc and hc are 1 / 2, and yc is 1 / 2; if the category of 'p' is LOW, then wc and hc are 1, and yc is 0;

[0068] h) The value is 11, indicating that there are three categories in the word: MID, LOW, and ALL, such as "apf". If the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0069] i) The value is 12, indicating that there are two categories in the word: MID and UPP, such as "eb". If the category of 'e' is MID, then wc and hc are 1 / 2, and yc is 1 / 2; if the category of 'b' is UPP, then wc and hc are 1, and yc is 0;

[0070] j) The value is 13, indicating that there are three categories in the word: MID, UPP and ALL, such as "abf". If the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0071] k) value is 14, indicating that there are three categories in the word: MID, UPP and LOW, such as "abp". If the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3;

[0072] l) The value is 15, indicating that there are four categories in the word: MID, UPP, LOW and ALL, such as "abpf". If the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0073] m) value is 17, indicating that there are two categories in the word: MUP and ALL, such as "if". 'i' category is MUP, then wc and hc are 1 / 2, yc is 1 / 6; 'f' category is ALL, then wc and hc are 1, yc is 0;

[0074] n) value is 18, indicating that there are two categories in the word: MUP and LOW, such as "tp". If the category of 't' is MUP, then wc and hc are 3 / 5, and yc is 0; if the category of 'p' is LOW, then wc and hc are 4 / 5, and yc is 1 / 5;

[0075] o) The value is 19, which means there are three categories in the word: MUP, LOW and ALL, such as "tpf". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0076] p) value is 20, indicating that there are two categories in the word: MUP and UPP, such as "tb". If the category of 't' is MUP, then wc and hc are 3 / 4, and yc is 1 / 4; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0;

[0077] q) The value is 21, indicating that there are three categories in the word: MUP, UPP, and ALL, such as "tbf". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0078] r) value is 22, indicating that there are three categories in the word: MUP, UPP and LOW, such as "tbp". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3;

[0079] s) value is 23, indicating that there are four categories in the word: MUP, UPP, LOW and ALL, such as "tbpf". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0080] t) value is 24, indicating that there are two categories in the word: MUP and MID, such as "ta". If the category of 't' is MUP, then wc and hc are 3 / 4, and yc is 1 / 4; if the category of 'a' is MID, then wc and hc are 2 / 3, and yc is 1 / 3;

[0081] u) value is 25, indicating that there are three categories in the word: MUP, MID and ALL, such as "taf". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0082] v) The value is 26, which means there are three categories in the word: MUP, MID and LOW, such as "tap". If the category of 't' is MUP, then wc and hc are 3 / 5, and yc is 0; if the category of 'a' is MID, then wc and hc are 2 / 5, and yc is 1 / 5; if the category of 'p' is LOW, then wc and hc are 4 / 5, and yc is 1 / 5;

[0083] w) value is 27, indicating that there are four categories in the word: MUP, MID, LOW and ALL, such as "tapf". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3; if the category of 'f' is ALL, then wc and hc are 1, and yc is 0;

[0084] x) value is 28, indicating that there are three categories in the word: MUP, MID and UPP, such as "tab". 't' category is MUP, then wc and hc are 3 / 4, yc is 1 / 4; 'a' category is MID, then wc and hc are 1 / 2, yc is 1 / 2; 'b' category is UPP, then wc and hc are 1, yc is 0;

[0085] y) value is 29, indicating that there are four categories in the word: MUP, MID, UPP and ALL, such as "tabf". 't' category is MUP, then wc and hc are 1 / 2, yc is 1 / 6; 'a' category is MID, then wc and hc are 1 / 3, yc is 1 / 3; 'b' category is UPP, then wc and hc are 2 / 3, yc is 0; 'f' category is ALL, then wc and hc are 1, yc is 0;

[0086] z) value is 30, indicating that there are four categories in the word: MUP, MID, UPP and LOW, such as "tabp". If the category of 't' is MUP, then wc and hc are 1 / 2, and yc is 1 / 6; if the category of 'a' is MID, then wc and hc are 1 / 3, and yc is 1 / 3; if the category of 'b' is UPP, then wc and hc are 2 / 3, and yc is 0; if the category of 'p' is LOW, then wc and hc are 2 / 3, and yc is 1 / 3;

[0087] aa) value is 31, indicating that there are five categories in the word: MUP, MID, UPP, LOW and ALL, such as "tabpf". 't' category is MUP, then wc and hc are 1 / 2, yc is 1 / 6; 'a' category is MID, then wc and hc are 1 / 3, yc is 1 / 3; 'b' category is UPP, then wc and hc are 2 / 3, yc is 0; 'p' category is LOW, then wc and hc are 2 / 3, yc is 1 / 3; 'f' category is ALL, then wc and hc are 1, yc is 0;

[0088] 5. Calculate the actual width, height, and vertical starting position of the character: The actual width (denoted as w), height (denoted as h), and vertical starting position (denoted as y) of each character (denoted as ch) in the word are calculated as follows:

[0089] a) Randomly obtain a stroke data from the character ch stroke set in the initial data set 1-English uppercase and lowercase handwritten stroke data set, and obtain its width (denoted as wo) and height (denoted as ho) converted into an image; the width of the target icon in the full-height case (denoted as wa) is CHAR_IMG_SIZE*wo / ho;

[0090] b) Combine the coefficients obtained in the step [Calculate the actual character width coefficient, height coefficient, and vertical starting position coefficient] to obtain the target width w of each character as wa*wc, the target height h as CHAR_IMG_SIZE*hc, and the target vertical starting position y as CHAR_IMG_SIZE*yc;

[0091] 6. Adjust the actual width, height, and vertical starting position of the characters.

[0092] Since the number of characters in each word is different, if the image width generated according to the actual width, height, and vertical starting position in step 5 is variable, it cannot be used for deep learning training. Therefore, the width of each character must be scaled proportionally, and the final unified image width is FULL_IMG_WIDTH. The specific processing steps are as follows:

[0093] a) Add the width w of each character obtained in step [Calculate the actual width, height, and vertical starting position of the character] to get total_w;

[0094] b) Get the number of characters in the word, recorded as word_length;

[0095] c) The scaling ratio (denoted as ratio) is calculated as: ratio = (FULL_IMG_WIDTH-FIXED_GAP*word_length) / total_w

[0096] d) Scale each character according to the ratio and add FIXED_GAP to get the total width. Since the result of floating-point operation may have a deviation of -1 to 1 from the width of the target image, if it is too large, the width w of the character with the largest width is reduced by 1. If it is too small, the width w of the character with the smallest width is increased by 1. Finally, the target width w' of each character is obtained;

[0097] 7. Draw strokes using the Bresenham algorithm: scale each character in the word and set the corresponding position according to the target width w', height h, and vertical starting position y, and draw strokes using the Bresenham algorithm;

[0098] 8. According to the above steps 3-7 and FIXED_GAP is set to 1, that is, the character spacing is kept at 1, and OUTPUT_IMG_NUM = 400 training data are generated for [initial data 2 - the most commonly used 60,000 words] in sequence;

[0099] 9. According to the above steps 3-7 and FIXED_GAP is set to 1, that is, the character spacing is kept at 1, and the target vertical starting position y of each character is randomly adjusted up and down by [-2, 2] pixels without exceeding the boundary to simulate irregular handwriting, and OUTPUT_IMG_NUM = 400 training data are generated for [initial data 2-the most commonly used 60,000 words] in sequence;

[0100] 10. According to the above steps 3-7 and FIXED_GAP is set to 0, that is, there is no character spacing to simulate the situation of connected strokes, OUTPUT_IMG_NUM = 400 training data are generated for [initial data 2-the most commonly used 60,000 words] in sequence;

[0101] 11. Follow the above steps 3-7 and set FIXED_GAP to 0, that is, no character spacing, to simulate irregular handwriting, and randomly adjust the target vertical starting position y of each character by [-2, 2] pixels up and down without exceeding the boundary, and generate OUTPUT_IMG_NUM = 400 training data for [initial data 2 - the most commonly used 60,000 words] in sequence;

[0102] 12. Generate OUTPUT_IMG_NUM=100 test data for each word in the manner of steps 8-11;

[0103] 13. The above completes the generation of 1,600 training data and 400 test data for [initial data 2 - the most commonly used 60,000 words]; of course, the specific amount of training data and test data can be changed and adjusted according to actual conditions or expanded data sets;

[0104] 14. Use deep learning CNN technology to train on the generated training and test data.

[0105] like Figure 2 As shown in the figure, the training model in this example consists of 9 convolutional layers (Conv2D) and 3 fully connected layers (Dense); a BatchNormalization layer is added after the convolutional layer and the first fully connected layer to normalize the input of each layer, control the data within a stable distribution, avoid gradient disappearance, and accelerate convergence; a MaxPooling layer is added to divide the input data into several small blocks of the same size without overlapping, and only the largest number is taken from each small block, and other data is discarded, so as to compress feature data, simplify network complexity, and reduce the amount of calculation; the Flatten layer is used to flatten the input, that is, to make the multi-dimensional input one-dimensional, which is used for the transition from the convolutional layer to the fully connected layer; the Adam optimization algorithm, namely Adaptive Moment Estimation, is used to update the trainable parameters in the model, which has the advantages of efficient calculation and small memory usage.

[0106] The manual collection of English word handwriting data sets for input method handwriting recognition training is a huge project. Because the number of English words is large, there are at least 20,000 commonly used words in lowercase, and two variants, capitalized first characters and all uppercase, need to be added. The number of data set categories is at least 60,000, and at least 800 training and test data samples are required under each category, requiring 800 people to manually input. Such a large amount of work requires a lot of manpower, time and cost. The use of the technical solution of the present invention will greatly improve the efficiency of creating training data sets and test data sets, cost very little, and the data sets can be easily expanded later. The invention greatly improves efficiency and scalability, and significantly reduces costs. In addition, the training data set and the test data set make the data set of the present invention closer to people's handwriting habits by considering the expansion of various handwriting habits, and can more easily recognize handwritten English words.

[0107] The specific implementation modes described above are preferred implementation modes of the present invention, and are not intended to limit the specific implementation scope of the present invention. The scope of the present invention includes but is not limited to the specific implementation modes, and all equivalent changes made according to the present invention are within the protection scope of the present invention.

Claims

1. A method for English word handwriting recognition, characterized in that: The steps include: S1: Setting an initial data set, the initial data set includes an English uppercase and lowercase handwritten stroke data set and an English word set; S2: Initialization operation: setting the English character height classification table and generating parameters of the target image according to the words in the English word set; S3: obtaining a word from the English word set, and obtaining a flag value of the character type combination of the word based on the English character height classification table; S4: Calculate the actual width, height, and vertical starting position of each character of the word; S5: adjusting the actual width, height, and vertical starting position of the character according to the width parameter of the target image, and obtaining the adjusted target character parameters; S6: drawing strokes based on the target character parameters, setting different drawing parameters, and obtaining multiple writing methods based on the word; S7: repeating steps S3-S6, obtaining different ways of writing a set number of words in the English word set, and generating a training data set and a test data set containing data of a second set value; S8: Use the training model to train on the generated training data set and test data set to generate a handwriting recognition model. Handwritten English is recognized by the handwriting recognition model.

2. The English word handwriting recognition method according to claim 1, characterized in that: The step S9 is also included: quantizing the handwriting recognition model file to reduce the model complexity and obtain a handwriting recognition model file with less precision loss.

3. The English word handwriting recognition method according to claim 1 or 2, characterized in that: In step S2, the English character height classification table includes five categories, namely, upper middle, middle, upper, lower and full height categories.

4. The English word handwriting recognition method according to claim 3, characterized in that: The parameters of the target image include the target image height, width, the interval between each character and the number of target images generated for each word.

5. The English word handwriting recognition method according to claim 4, characterized in that: In step S3, the flag value setting method of the character type combination is: obtain the category of each character from left to right in the word in the English character height classification table, and correspond the 1st to 5th bits of the integer flag value Flag to the 5 categories of the English character height classification table respectively; if there is a character in the word that belongs to one of the categories, the position is 1, otherwise it is set to 0, and finally a flag value including a string of characters is obtained.

6. The method for English word handwriting recognition according to claim 5, characterized in that: Based on the flag value of the character type combination, the flag value of the character type combination of the word is divided into 2 to the fifth power, i.e. 32 types, according to different combinations of 5 types, and the actual width coefficient wc, height coefficient hc and vertical starting position coefficient yc of each character in the word are obtained respectively.

7. The method for English word handwriting recognition according to claim 6, characterized in that: In step S4, the actual width w, height h, and vertical starting position y of each character ch of the word are calculated as follows: (1) Randomly obtain a stroke data from the stroke set of the character ch, and obtain the width wo and height ho of the stroke data converted into the image; the width wa of the target icon in the full-height case is CHAR_IMG_SIZE*wo / ho; (2) Combining the actual width coefficient, height coefficient, and vertical starting position coefficient of the character, the target width w of each character is wa*wc, the target height h is CHAR_IMG_SIZE*hc, and the target vertical starting position y is CHAR_IMG_SIZE*yc, where CHAR_IMG_SIZE is the target image height.

8. The method for English word handwriting recognition according to claim 7, characterized in that: In step S5, the actual width, height, and vertical starting position of the character are adjusted as follows: (a) Add the width w of each character obtained in step S5 to obtain total_w; (b) Get the number of characters in the word, word_length; (c) The scaling ratio ratio is calculated as: ratio = (FULL_IMG_WIDTH - FIXED_GAP * word_length) / total_w, where FULL_IMG_WIDTH is the width of the target image and FIXED_GAP is the interval between each character; (d) After scaling each character according to the ratio, add the character interval FIXED_GAP to get the total width. If the calculated total width deviates from the set target image width, the calculation result is adjusted according to the deviation, and finally the target width w' of each character is obtained.

9. The English word handwriting recognition method according to claim 1 or 2, characterized in that: In step S8, a deep learning CNN training model is used for training, and the Adam optimization algorithm is used to update the trainable parameters in the model. The training model includes: a plurality of convolutional layers and fully connected layers, and also includes: Batch normalization layer: set at the output of each convolutional layer and the first fully connected layer, used to normalize the input of each layer; Max pooling layer: It is set at the output of several batch normalization layers to divide the input data into several small blocks of the same size without overlapping. In each small block, only the largest number is taken and other data is discarded, so as to compress feature data, simplify network complexity and reduce the amount of calculation. Flattening layer: It is set at the output of the last pooling layer to flatten the input, that is, to make the multi-dimensional input one-dimensional, for the transition from the convolutional layer to the fully connected layer.