A Handwritten English Text Recognition Method Based on Neural Network
Through the neural network-based handwritten English text recognition method, combined with YOLO and LSTM algorithms, and using word extraction and dictionary modules, the problem of limited recognition flexibility and accuracy in the prior art is solved, and high accuracy recognition and error detection of handwritten English text is achieved.
Patent Information
- Application Number
- CN202210437836.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-25
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-04-25
AI Technical Summary
Existing handwritten English text recognition technology is difficult to combine text information before and after text, the word division is complex, the recognition flexibility and accuracy are limited, and it is easily affected by similar letter shapes and irregular writing, resulting in low recognition accuracy.
The handwritten English text recognition method based on neural network is adopted, and the letter recognition model is trained through the YOLO algorithm, the grammatical judgment model is trained in combination with the LSTM algorithm, and the recognition results are processed using the word extraction algorithm, and the recognition accuracy is improved through the dictionary module and the quadratic recognition mechanism.
It realizes accurate recognition of hand-written English text, can detect spelling and grammatical errors, provides a variety of recognition results and gives priority, and improves recognition flexibility and accuracy.
Smart Images

Figure CN114708602B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text recognition, and in particular to a handwritten English text recognition method based on a neural network. Background Art
[0002] With the development of society, more and more fields have ushered in the wave of digitalization, such as the digitization of library collections, the digitization of express delivery and postal services, and the digitization of corporate offices. In this wave of digitalization, handwritten text recognition has become an important task. At present, the language used by most of the world's population is still English, so the recognition of handwritten English text has become an important demand.
[0003] However, current solutions for handwritten English text recognition have problems such as difficulty in combining contextual information, complex word segmentation methods, and limited recognition flexibility and accuracy due to single recognition results. At the same time, in the process of handwritten English text, there is a problem that the recognition accuracy may be negatively affected due to the similar shapes of certain types of letters and irregular writing.
[0004] The existing algorithms have the problem of non-maximum suppression, which often leads to errors in recognition, such as false positive or false negative errors. At the same time, the existing algorithms often have problems in letter segmentation, which leads to words being incorrectly split, affecting the accuracy of recognition. Summary of the invention
[0005] Purpose of the invention: In view of the deficiencies in the prior art, the present invention provides a handwritten English text recognition method based on a neural network.
[0006] Technical solution: A neural network-based handwritten English text recognition method, comprising the following steps:
[0007] S101, obtaining a handwritten English text dataset including all kinds of English letters as a parent dataset;
[0008] At least one type of English letters is removed from the parent data set in sequence to construct a plurality of child data sets;
[0009] Using the parent data set and the child data set as training data, the YOLO algorithm is used to train a letter recognition parent model and several letter recognition child models;
[0010] S102, obtaining a non-handwritten English text dataset containing sentences with grammatical errors, and training a grammar judgment model using an LSTM algorithm;
[0011] S103: Obtain a dictionary containing a predetermined number of words and construct a dictionary module.
[0012] According to one aspect of the present application, it also includes:
[0013] S104, obtaining a handwritten English text test image, using the letter recognition model to perform recognition, processing the recognition result using a preset word extraction algorithm, obtaining a word initial recognition result, and forming a text initial recognition result;
[0014] S105, using the dictionary module to determine whether the initial word recognition results all exist in the dictionary, if there are words that do not exist in the dictionary, then determine that there are abnormalities in the initial word recognition results, and mark the words that do not exist in the dictionary as abnormal words;
[0015] S106, cutting out the abnormal word from the image, using the plurality of letter recognition sub-models to respectively recognize the abnormal word, obtaining a plurality of word secondary recognition results of the abnormal word, and using the word secondary recognition results to replace the initial recognition result, obtaining a plurality of text secondary recognition results;
[0016] S107, using the dictionary module to test the text secondary recognition results in turn, dividing the text secondary recognition results into text secondary recognition results in which all words exist and text secondary recognition results in which all words do not exist, and using the grammar judgment model to divide the text secondary recognition results in which all words exist into text secondary recognition results that conform to grammar specifications and text secondary recognition results that do not conform to grammar specifications;
[0017] S108. Prioritize all recognition results:
[0018] The secondary recognition result of the text that complies with the grammatical specification>the primary recognition result of the text>the secondary recognition result of the text that does not comply with the grammatical specification>the secondary recognition result of the text where the words do not all exist;
[0019] All recognition results are output in descending order of priority.
[0020] According to one aspect of the present application, the process of constructing several sub-data sets in step S101 is: collecting at least two letters that may be confused during recognition to construct an easily confused letter set; each time removing one letter from the easily confused letter set from the parent data set, constructing a sub-data set composed of other letters except the removed letters.
[0021] According to one aspect of the present application, in step S101, the convolution layer in the model structure based on the YOLO algorithm includes operations: convolution operation, batch normalization, and activation function. When generating weight and bias data for reasoning, convolution and batch normalization are combined to speed up the reasoning speed. The activation function y is:
[0022]
[0023] x is the function input and y is the function output.
[0024] According to one aspect of the present application, the specific steps of the word extraction algorithm in step S104 are as follows:
[0025] S201: The information of the recognition target frame output by the YOLO algorithm includes: the position of the center point of the recognition target frame, the length and width of the recognition target frame, the recognition target category and the confidence level. The recognition targets located in the same row are determined according to the y-axis position of the center point. The recognition objects are sorted from left to right according to the x-axis position of the center point to obtain a character sequence. The character sequence is an English sentence waiting for word segmentation. At the same time, the letter spacing is obtained using the recognition target frame information.
[0026] According to one aspect of the present application, the steps of finding letter spacing are:
[0027] Calculate the overlap between adjacent letter recognition boxes in the y-axis direction;
[0028] When the overlap is greater than the first threshold, the letter spacing is equal to the x-axis position on the left side of the right letter recognition box minus the x-axis position on the right side of the left letter recognition box;
[0029] When the overlap is greater than the second threshold and less than the first threshold, the letter spacing is equal to the value of the x-axis position on the left side of the right letter recognition frame minus the x-axis position on the right side of the left letter recognition frame divided by the cosine function of the angle between the line connecting the center points of the two frames and the x-axis;
[0030] When the overlap is less than the second threshold, the letter spacing is equal to the spacing between the center points of the two recognition frames minus half of the sum of the widths of the two recognition frames on the x-axis.
[0031] S202: Using the character sequence information in S201, spaces need to be added to the characters to convert them into actual text content.
[0032] According to one aspect of the present application, the process of adding spaces is: using the letter spacing described in S201, adding spaces to positions where the letter spacing is greater than s, which can be expressed mathematically as:
[0033] s=E(γ)×t,
[0034]
[0035] β is a sequence of all letter spacings arranged from small to large, β m is the term in β that is closest to the average value of the sequence β, n is the number of β terms divided by 4 and rounded down, i is a natural number, and γ is the β in β. m The new subsequence of all items on the left, E(γ) is the mean of γ.
[0036] According to one aspect of the present application, the secondary recognition method in step S106 is: retaining the NMS non-maximum suppression algorithm and performing the secondary recognition by utilizing the corresponding letter recognition sub-model in the letter recognition sub-model that eliminates the current maximum confidence letter category.
[0037] Beneficial effects: This method combines two artificial intelligence algorithms, YOLO and LSTM, and a new word extraction algorithm. It can detect English text content in pictures with handwritten English text in sentences, and can also detect spelling and grammatical errors that may appear in English text. When errors occur, it can provide multiple possible recognition results and give priorities to different results. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 1 is a flowchart of a neural network-based handwritten English text recognition method provided in Example 1.
[0039] Figure 2a This is a structural topological diagram of a neural network-based handwritten English text recognition method provided in Example 1.
[0040] Figure 2b This is a data flow diagram of a neural network-based handwritten English text recognition method provided in Example 1.
[0041] Figure 3 This is a graph of the first recognition results of handwritten English text without grammatical errors and spelling errors of a handwritten English text recognition method based on a neural network provided in Example 1.
[0042] Figure 4 This is a graph of the first recognition results of a handwritten English text with grammatical errors but no spelling errors according to a handwritten English text recognition method based on a neural network provided in Example 1.
[0043] Figure 5 This is a printout of the recognition results of two handwritten English texts of a handwritten English text recognition method based on a neural network provided in Example 1.
[0044] Figure 6 This is a graph of the first recognition results of a handwritten English text with spelling errors in a handwritten English text recognition method based on a neural network provided in Example 1.
[0045] Figure 7 This is a recognition result diagram of letters with secondary recognition results after the letters of abnormal words in the dictionary module of the handwritten English text recognition method based on a neural network provided in Example 1 are cut out for secondary recognition.
[0046] Figure 8This is a recognition result diagram of letters without secondary recognition results after the letters of abnormal words in the dictionary module of the handwritten English text recognition method based on a neural network provided in Example 1 are cut out for secondary recognition.
[0047] Fig. 9 This is a recognition result printout with a secondary recognition result image of a handwritten English text recognition method based on a neural network provided in Example 1. DETAILED DESCRIPTION
[0048] It should be noted that in each embodiment of the application, the English text includes 26 uppercase and lowercase ordinary English characters, as well as Greek characters and Roman characters commonly seen in the English context. In order to simplify the description, they are collectively referred to as English text. In other words, the English text here is a broad concept, not the narrow 26 English characters.
[0049] like Figure 1 As shown, the neural network-based handwritten English text recognition method adopted by the present invention comprises the following steps:
[0050] S101, obtaining a handwritten English text dataset including all kinds of English letters as a parent dataset;
[0051] At least one type of English letters is removed from the parent data set in sequence to construct a plurality of child data sets;
[0052] Using the parent data set and the child data set as training data, the YOLO algorithm is used to train a letter recognition parent model and several letter recognition child models;
[0053] In step S101, the letter recognition mother model has more recognition categories than the letter recognition child model, so the network structure is different, and the weights and biases are also different. Both need to be iterated multiple times during training until the accuracy is stable. The role and function of the mother model and the child model are described below.
[0054] S102, obtaining a non-handwritten English text dataset containing sentences with grammatical errors, and training a grammar judgment model using an LSTM algorithm;
[0055] In step S102, the English text data set should contain a variety of grammatical errors. Before using the LSTM algorithm to detect grammatical errors in the English text, the words in the data set should be converted from text to word vectors. This can also be achieved using existing methods, which will not be introduced in detail here.
[0056] S103, obtaining a dictionary containing a predetermined number of words and constructing a dictionary module;
[0057] The dictionary module construction in step 103 may adopt existing methods, which will not be described in detail here.
[0058] S104, obtaining a handwritten English text test image, using the letter recognition model to perform recognition, processing the recognition result using a preset word extraction algorithm, obtaining a word initial recognition result, and forming a text initial recognition result;
[0059] In step S104, the word extraction algorithm can divide words with the help of the center point information and length and width information of the word recognition box output by YOLO. When the text is written with a large deviation in the horizontal direction, the word extraction algorithm will adopt different methods when calculating the letter spacing.
[0060] S105, using the dictionary module to determine whether the initial word recognition results all exist in the dictionary, if there are words that do not exist in the dictionary, then determine that there are abnormalities in the initial word recognition results, and mark the words that do not exist in the dictionary as abnormal words;
[0061] In step S105, Figure 2a and 2b As shown in FIG. 1 , when all words in the initial recognition result exist in the dictionary, there is no need to enter step S106. The grammar judgment model output is directly used to determine whether there is a grammatical error and output the result. In this case, only the initial recognition is required and no secondary recognition is required. Figure 3 and Figure 4 As shown in the figure, the initial recognition results of the two English texts in this case are as follows: Figure 5 As shown, the recognition results of two English texts are printed in this case.
[0062] S106, cutting out the abnormal word from the image, using the plurality of letter recognition sub-models to respectively recognize the abnormal word, obtaining a plurality of word secondary recognition results of the abnormal word, and using the word secondary recognition results to replace the initial recognition result, obtaining a plurality of text secondary recognition results;
[0063] In step S106, Figure 2a and 2b As shown, when not all words in the initial recognition result exist in the dictionary, it is necessary to enter step S106.
[0064] like Figure 6 As shown in , the initial recognition result of the test image is "ne do it", where the word "ne" does not exist in the dictionary and is an abnormal word. Figure 7 and Figure 8 As shown in FIG. 1 , each letter of the abnormal word is intercepted and then subjected to secondary recognition. Figure 7 To have a secondary recognition result, Figure 8 There is no secondary recognition result.
[0065] If the existing YOLO algorithm is used, the correct result cannot be obtained due to the existence of non-maximum suppression. However, through the letter recognition sub-model that does not contain n, it is recognized that it also has the possibility of h, so a secondary recognition result can be generated for the user to choose.
[0066] S107, using the dictionary module to test the text secondary recognition results in turn, dividing the text secondary recognition results into text secondary recognition results in which all words exist and text secondary recognition results in which all words do not exist, and using the grammar judgment model to divide the text secondary recognition results in which all words exist into text secondary recognition results that conform to grammar specifications and text secondary recognition results that do not conform to grammar specifications;
[0067] In step S107, even if each letter in the abnormal word is recognized twice, not every letter will necessarily have other recognition results. Other recognition results need to have a certain confidence level. In this embodiment, other recognition results will only be retained when the confidence level is set to be greater than 0.25.
[0068] S108, the secondary recognition result of the text that complies with the grammatical specification>the primary recognition result of the text>the secondary recognition result of the text that does not comply with the grammatical specification>the secondary recognition result of the text in which the words do not exist uniformly;
[0069] All recognition results are output in descending order of priority.
[0070] In step S108, Fig. 9 As shown, a printout of the recognition results of a test image with secondary recognition results is shown.
[0071] Furthermore, the method of constructing multiple sub-datasets in step S101 is: the letter "i" and the letter "l" are similar, and after actual recognition, it is found that there is confusion between their recognition. Therefore, the letter "i" should be removed from the handwritten English text dataset with all kinds of English letters in step S101 to produce sub-training set A, and the letter "l" should be removed to produce sub-training set B.
[0072] The letter "a", the letter "q" and the letter "g" are similar. After actual recognition, it was found that there was confusion between them. Therefore, the letter "a" should be excluded from the handwritten English text data set with all kinds of English letters described in step S101 to produce sub-training set A, the letter "q" should be excluded to produce sub-training set B, the letter "g" should be excluded to produce sub-training set C, the letters "a" and "q" should be excluded to produce sub-training set D, the letters "g" and "q" should be excluded to produce sub-training set E, and the letters "a" and "g" should be excluded to produce sub-training set F; the same applies to other letters.
[0073] It should be noted that if 9 and g, α and a are confused with each other, and the number 1 and the English lowercase l are confused with each other, the above method can be used to construct a sub-training set.
[0074] Therefore, the letters are grouped according to the situation, and each group contains at least two easily confused letters. For this group of letters, a sub-dataset is generated by removing one of the easily confused letters from the parent data set. For other groups of easily confused letters, the sub-datasets are constructed using the same method.
[0075] Further, in step S101, the convolution layer in the model structure based on the YOLO algorithm includes operations: convolution operation, batch normalization and activation function. When generating weight and bias data for reasoning, convolution and batch normalization are combined to speed up the reasoning speed. The activation function y is:
[0076]
[0077] x is the function input and y is the function output.
[0078] Furthermore, the specific steps of the word extraction algorithm in step S104 are as follows:
[0079] S201: The output of the YOLO neural network model includes the information of the recognition target box: the position of the center point of the recognition target box, the length and width of the recognition target box, the recognition target category and the confidence level. The recognition targets located in the same row are determined according to the position of the center point on the y-axis. The recognition objects are sorted from left to right according to the size of the x-axis position of the center point to obtain a character sequence. The character sequence is an English sentence waiting for word segmentation. For example, if there is a picture with an English sentence "he did it", the recognized character sequence after sorting should be: "hedidit". At the same time, the letter spacing is obtained using the recognition target box information. The method for obtaining the letter spacing is:
[0080] Calculate the overlap between adjacent letter recognition boxes in the y-axis direction;
[0081] When the overlap is greater than 60%, the letter spacing is equal to the x-axis position on the left side of the right letter recognition box minus the x-axis position on the right side of the left letter recognition box;
[0082] When the overlap is greater than 30% and less than 60%, the letter spacing is equal to the value of the x-axis position on the left side of the right letter recognition frame minus the x-axis position on the right side of the left letter recognition frame divided by the cosine function of the angle (acute angle) between the line connecting the center points of the two frames and the x-axis (horizontal direction);
[0083] When the overlap is less than 30%, the letter spacing is equal to the spacing between the center points of the two recognition frames minus half of the sum of the widths of the two recognition frames in the x-axis direction.
[0084] In this embodiment, two thresholds are set, the first threshold is 60%, and the second threshold is 30%. In other embodiments, specific parameters can be adjusted, or the number of thresholds can be adjusted.
[0085] S202: Using the character sequence information in S201, it is necessary to add spaces to the characters to make them into actual text content. The adding method is: using the letter spacing in S201, adding spaces to the positions where the letter spacing is greater than s, which can be expressed mathematically as:
[0086] s=E(γ)×t,
[0087]
[0088] β is a sequence of all letter spacings arranged from small to large, β m is the term in β that is closest to the average value of the sequence β, n is the number of β terms divided by 4 and rounded down, i is a natural number, and γ is the β in β. m The new subsequence of all items on the left, E(γ) is the mean of γ. The specific example is as follows:
[0089] Using the character sequence information described in step S201, it is necessary to add spaces to the character sequence so that "hedidit" becomes "he did it". The sequence has 7 letters, so there are 7-1=6 intervals between the letters. Using the letter spacing described in S201, when the letter spacing is negative, the negative spacing needs to be set to zero. We take these 6 intervals as a sequence α, assuming that α is {0.0, 1.0, 0.5, 0.4, 1.5, 0.3}
[0090] Then the interval between the corresponding letters "h" and "e" is 0.0, the interval between "e" and the first "d" is 1.0, the interval between the first "d" and the first "i" is 0.5, and so on. α has 6 items in total. Divide the number of items by 4 and round down to get n, which is 1. Sort α from small to large to get the sequence β.
[0091] β is: {0.0,0.3,0.4,0.5,1.0,1.5}; E(β)=0.62
[0092] Therefore, the term closest to the mean is β m =β4=0.5, therefore:
[0093] t = sum of n terms on the right side of β4 / sum of n terms on the left side of β4
[0094] t = β5 / β3 = 1.0 / 0.4 = 2.5
[0095] Take the sequence on the left side of β4 as γ, γ is:
[0096] {0.0,0.3,0.4}
[0097] E(γ)=(0+0.3+0.4) / 3=0.23
[0098] s=E(γ)×t=0.58
[0099] When the term in α is greater than s, such as the spacing between "e" and the first "d" is 1.0 and the spacing between the second "d" and the second "i" is 1.5, a space is inserted between the two letters, resulting in a conversion from "hedidit" to "he did it".
[0100] The word extraction method of the present application also has obvious advantages over the existing clustering methods. In the process of the clustering method for binary classification of word spacing, that is, the process of dividing into two categories, two values A and B are required. When the word spacing is close to A, it is divided into Class A, and when it is close to B, it is divided into Class B. When the gap between A and B is particularly large or the gap is particularly small, the classification is affected, and the calculation amount of this algorithm is relatively large. These two values A and B need to be trained, but when the data is relatively extreme, the training effect will be unsatisfactory, and the training needs to adopt a value function, which is not easy to select. The formula given in the present application is to use a threshold method for binary classification, that is, when it is smaller than this value, it is one class, and when it is larger than this value, it is another class. The calculation amount is small, and it can also be selected in the case of extreme data.
[0101] The clustering algorithm works better when the data is close to a Gaussian distribution. It is very difficult to select the initial values of A and B of the clustering algorithm when the data distribution is extreme. It is not suitable for data with particularly large size differences. Moreover, when there are abnormal points in the data (such as particularly large or small points), the effect will be greatly affected. When the method of this application is used for recognition, many letter spacings may be set to zero when letters overlap, which will affect the clustering algorithm.
[0102] Preferably, the secondary recognition method described in step S106 is: retaining the NMS non-maximum suppression algorithm, and performing the secondary recognition by utilizing the corresponding letter recognition sub-model in the letter recognition sub-model described in step S101 that eliminates the current maximum confidence letter category.
[0103] As attached Figure 6As shown in the figure, the only result recognized by the existing YOLO algorithm is "ne do it", but this recognition result is obviously incorrect. The text should obviously be recognized as "he do it" because "he do it" is a complete sentence that conforms to grammatical norms and each word exists in the dictionary. However, due to the irregular writing, the first letter of the sentence is recognized as "n" by the existing algorithm because the model recognizes that the probability of the letter being "n" is 90% and the probability of being "h" is 30%, resulting in the "h" with a lower probability being discarded by the non-maximum suppression algorithm. However, it is obvious that the "h" with a probability of 30% is more in line with the result we expect to recognize. Therefore, this problem can be corrected by the letter recognition sub-model in the existing algorithm, which not only provides "ne do it", which is the result with the highest probability but unreasonable, but also provides "he do it", which is a result with a lower probability but reasonable, and sorts the two results and outputs them in order of priority. The result with a higher priority is more recommended.
[0104] In summary, the above embodiment has the following advantages:
[0105] 1. When anomalies are detected in the text during the recognition process, multiple possible recognition results can be provided, and the priorities of different results can be given, which improves the flexibility and accuracy of recognition. At the same time, spelling and grammatical errors that may appear in English text can be detected.
[0106] 2. In the word extraction algorithm, when the English text is written crookedly, that is, when the writing deviates from the horizontal direction to a large extent, when calculating the letter spacing, it is taken into account that the two letters may be far apart on the y-axis. Therefore, when calculating the letter spacing, different methods are used to calculate the adjacent letter spacing under different degrees of crookedness, combined with the position information of the letters on the two-dimensional plane, thereby improving the accuracy of word division.
[0107] 3. Due to the use of the NMS non-maximum suppression algorithm in the YOLO algorithm, the results of the YOLO algorithm for the recognition of specific objects only retain the unique recognition result with the maximum confidence. When used to recognize handwritten English text, there are special letters with extremely high similarity, such as: the letter "h" and the letter "n", the letter "g" and the letter "q", the letter "i" and the letter "l", etc. At present, the recognition result of the deep learning algorithm for the handwritten English text recognition task is unique, which is easy to cause negative effects such as inaccurate recognition or inflexible recognition due to the irregular writing of handwritten text. For example, for the word "he", only the recognition result of "ne" is output because the text itself is not written in a standardized way. Therefore, when it is recognized that there are abnormal words in the text that are not included in the dictionary, all the letters in the abnormal words are extracted separately and recognized twice. The other possible recognition results obtained by the secondary recognition of the letters in the abnormal words are compared with the initial recognition results to reduce the negative impact.
[0108] 4. Through actual measurement, it is found that the method of obtaining other possible recognition results and their confidences by abandoning or improving the NMS non-maximum suppression algorithm will result in too many recognition boxes for a single target, and the recognition result will affect the recognition effect of letter categories with less than the maximum confidence due to the existence of letter categories with the maximum confidence. Therefore, retaining the (Non-Maximum Suppression) NMS non-maximum suppression algorithm and performing the secondary recognition by using the corresponding letter recognition sub-model in the letter recognition sub-model described in step S101 that removes the current maximum confidence letter category can improve the accuracy of the secondary recognition.
[0109] 5. The choice of activation function for the constructed YOLO model structure will facilitate the implementation of this method on portable devices such as FPGAs. For data (binary) of x greater than 0, it remains as it is, and for data (binary) of x less than 0, it only needs to be shifted three bits to the right. At the same time, merging convolution operations and batch normalization will reduce the scale of model weights and biases, reduce the difficulty of quantization when the model is deployed, and also speed up reasoning.
[0110] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. A handwritten English text recognition method based on neural network, characterized in that: The following steps are involved: S101, obtaining a handwritten English text dataset including all kinds of English letters as a parent dataset; Eliminate certain English letters from the parent data set in order to construct several child data sets; Using the parent data set and the child data set as training data, the YOLO algorithm is used to train a letter recognition parent model and several letter recognition child models; S102, obtaining a non-handwritten English text dataset containing sentences with grammatical errors, and training a grammar judgment model using an LSTM algorithm; S103, obtaining a dictionary containing a predetermined number of words and constructing a dictionary module; S104, obtaining a handwritten English text test image, using the letter recognition model to perform recognition, processing the recognition result using a preset word extraction algorithm, obtaining a word initial recognition result, and forming a text initial recognition result; S105, using the dictionary module to determine whether the initial word recognition results all exist in the dictionary, if there are words that do not exist in the dictionary, then determine that there are abnormalities in the initial word recognition results, and mark the words that do not exist in the dictionary as abnormal words; S106, cutting out the abnormal word from the image, using the plurality of letter recognition sub-models to respectively recognize the abnormal word, obtaining a plurality of word secondary recognition results of the abnormal word, and using the word secondary recognition results to replace the initial recognition result, obtaining a plurality of text secondary recognition results; S107, using the dictionary module to test the text secondary recognition results in turn, dividing the text secondary recognition results into text secondary recognition results in which all words exist and text secondary recognition results in which all words do not exist, and using the grammar judgment model to divide the text secondary recognition results in which all words exist into text secondary recognition results that conform to grammar specifications and text secondary recognition results that do not conform to grammar specifications; S108. Prioritize all recognition results: The secondary recognition result of the text that complies with the grammatical specification>the primary recognition result of the text>the secondary recognition result of the text that does not comply with the grammatical specification>the secondary recognition result of the text where the words do not all exist; All recognition results are output in descending order of priority.
2. A neural network-based handwritten English text recognition method as claimed in claim 1, characterized in that: The process of constructing several sub-datasets in step S101 is as follows: at least two letters that may be confused during recognition are collected to construct an easily confused letter set; one letter in the easily confused letter set is removed from the parent data set each time to construct a sub-dataset composed of the other letters except the removed letters.
3. A neural network-based handwritten English text recognition method as claimed in claim 1, characterized in that: Step S101: The convolution layer in the model structure based on the YOLO algorithm includes operations: convolution operation, batch normalization and activation function. When generating weight and bias data for reasoning, convolution and batch normalization are combined to speed up the reasoning speed. The activation function y is: , x is the function input and y is the function output.
4. A neural network-based handwritten English text recognition method as claimed in claim 1, characterized in that: The specific steps of the word extraction algorithm in step S104 are as follows: S201: The information of the recognition target frame output by the YOLO algorithm includes: the position of the center point of the recognition target frame, the length and width of the recognition target frame, the recognition target category and the confidence level. The recognition targets located in the same row are determined according to the y-axis position of the center point. The recognition objects are sorted from left to right according to the x-axis position of the center point to obtain a character sequence. The character sequence is an English sentence waiting for word segmentation. At the same time, the letter spacing is obtained using the recognition target frame information.
5. A neural network-based handwritten English text recognition method as claimed in claim 4, characterized in that: The steps to find the letter spacing are: Calculate the overlap between adjacent letter recognition boxes in the y-axis direction; When the overlap is greater than the first threshold, the letter spacing is equal to the x-axis position on the left side of the right letter recognition box minus the x-axis position on the right side of the left letter recognition box; When the overlap is greater than the second threshold and less than the first threshold, the letter spacing is equal to the value of the x-axis position on the left side of the right letter recognition frame minus the x-axis position on the right side of the left letter recognition frame divided by the cosine function of the angle between the line connecting the center points of the two frames and the x-axis; When the overlap is less than the second threshold, the letter spacing is equal to the spacing between the center points of the two recognition frames minus half of the sum of the widths of the two recognition frames on the x-axis; S202: Using the character sequence information in S201, spaces need to be added to the characters to convert them into actual text content.
6. A neural network-based handwritten English text recognition method as claimed in claim 5, characterized in that: The process of adding spaces is: using the letter spacing described in S201, adding spaces to the positions where the letter spacing is greater than s, which can be expressed mathematically as: s = E(γ) × t, , β is a sequence of all letter spacings arranged from small to large, The closest sequence Average The items in n are The number of terms is divided by 4 and rounded down, i is a natural number, γ is the The new subsequence of all items on the left, E(γ) is the mean of γ.
7. A neural network-based handwritten English text recognition method as claimed in claim 6, characterized in that: The secondary recognition method in step S106 is: retaining the NMS non-maximum suppression algorithm and performing the secondary recognition by utilizing the corresponding letter recognition sub-model in the letter recognition sub-model that eliminates the letter category with the current maximum confidence.
Citation Information
Patent Citations
A CNN-based handwritten English document recognition method
CN109800746A
English handwritten text recognition method and device, electronic equipment and storage medium
CN111639527A