Word recognition method, device and storage medium
By collecting and processing word images in the translation pen, identifying and stretching their geometric positions, combined with the improved CRNN algorithm, the recognition problem of the translation pen when the text is tilted, perspective, and curved is solved, and the accuracy and accuracy of word recognition are improved. efficiency.
Patent Information
- Application Number
- CN202080000447.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-31
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-03-31
AI Technical Summary
Existing translation pens have low word recognition accuracy and efficiency when the text is tilted, perspective, bent, etc. Especially in dot-click translation pen scenarios, it is difficult to effectively recognize text.
By collecting the word image to be recognized, identifying the edge range of each character, determining its geometric position, and stretching the tilted and curved words into a horizontal position, using the improved CRNN algorithm for recognition, improving the accuracy and efficiency of word recognition. .
It effectively improves the accuracy and efficiency of word recognition, improves the user experience, and solves the problem of inaccurate recognition when text is tilted, perspective, and curved.
Smart Images

Figure CN113748429B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text recognition, and in particular to a word recognition method, device and storage medium. Background Art
[0002] A translation pen is one of the tools people use to recognize words when reading materials or books. Some translation pens (such as the point translation pen) have a relatively good recognition effect on clear and flat text content. However, when the text is tilted, perspective, curved, etc., which may make the text relatively blurred (such as when used in the point translation pen scenario), the accuracy of text recognition needs to be further improved. Summary of the invention
[0003] The present invention aims to solve one of the technical problems in the related art at least to a certain extent.
[0004] To this end, the present invention proposes a word recognition method, which can effectively improve the accuracy and recognition effect of word recognition and enhance the user experience.
[0005] The invention also provides an electronic device.
[0006] The present invention also provides a non-volatile computer-readable storage medium.
[0007] An embodiment of the present invention provides a word recognition method, comprising the following steps:
[0008] Collecting word images to be recognized;
[0009] Identifying the edge range of each character of the word to be recognized from the word image to be recognized, determining the geometric position of the word to be recognized, and stretching the geometric position of the word to be recognized into a horizontal position; and
[0010] Identify the words to be recognized in a horizontal position.
[0011] The word recognition method of the embodiment of the present invention stretches the tilted, curved, and other words that are not in a horizontal position into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. The technical problem that the accuracy of text recognition in the prior art needs to be further improved when the text is tilted, perspective, curved, and the like, which may make the text relatively blurred (such as in the point translation pen scenario) is solved.
[0012] In another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the following word recognition method is implemented, including:
[0013] Collecting word images to be recognized;
[0014] Identifying the edge range of each character of the word to be recognized from the word image to be recognized, determining the geometric position of the word to be recognized, and stretching the geometric position of the word to be recognized into a horizontal position; and
[0015] Identify the words to be recognized in a horizontal position.
[0016] The electronic device of the embodiment of the present invention stretches the tilted, bent, or other non-horizontal words into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. The technical problem in the prior art that the accuracy of text recognition needs to be further improved when the text is tilted, perspective, bent, or other conditions may make the text relatively blurred (such as in the point translation pen scenario) is solved.
[0017] In another aspect of the present invention, an embodiment provides a non-volatile computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the following word recognition method is implemented:
[0018] Collecting word images to be recognized;
[0019] Identifying the edge range of each character of the word to be recognized from the word image to be recognized, determining the geometric position of the word to be recognized, and stretching the geometric position of the word to be recognized into a horizontal position; and
[0020] Identify the words to be recognized in a horizontal position.
[0021] The non-volatile computer-readable storage medium of the embodiment of the present invention stretches tilted, curved, and other words that are not in a horizontal position into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. The technical problem that the accuracy of text recognition in the prior art needs to be further improved when the text is tilted, perspective, curved, etc., which may make the text relatively blurred (such as in the point translation pen scenario) is solved.
[0022] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0024] Figure 1 A flowchart of a word recognition method provided by an embodiment of the present invention;
[0025] Figure 2 A schematic diagram of collecting a word image to be recognized provided by an embodiment of the present invention;
[0026] Figure 3 A schematic diagram of a flow chart of text correction as described in step 102 provided in an embodiment of the present invention;
[0027] Figure 4 A schematic diagram of determining the geometric position of a word to be recognized provided by an embodiment of the present invention;
[0028] Figure 5 A schematic diagram of selecting a base point provided by an embodiment of the present invention;
[0029] FIG6 (a) is an example diagram of text correction provided by an embodiment of the present invention;
[0030] FIG6( b ) is another example diagram of text correction provided by an embodiment of the present invention;
[0031] Figure 7 A schematic flow chart of another word recognition method provided by an embodiment of the present invention;
[0032] Figure 8 A structural diagram of a CRNN algorithm provided for related technologies;
[0033] Fig. 9 A schematic diagram of the structure of an improved CRNN algorithm provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0035] The word recognition method and device according to the embodiment of the present invention will be described below with reference to the accompanying drawings.
[0036] Figure 1 A flowchart of a word recognition method provided by an embodiment of the present invention.
[0037] The word recognition method of the embodiment of the present application can be used in translation scenarios, such as the recognition function of a translation pen. The following embodiment is described by taking a point translation pen as an example.
[0038] When OCR technology recognizes printed or handwritten text (such as words), the recognition may be inaccurate and the recognition effect may be poor due to the tilt or curvature of the text.
[0039] To address this problem, an embodiment of the present invention provides a word recognition method. When the translation pen performs word recognition, the words that are tilted, bent, etc. and not in a horizontal position are stretched to a horizontal position, and then the word recognition is performed, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. Figure 1 As shown, the word recognition method comprises the following steps:
[0040] Step 101: collect word images to be recognized.
[0041] Specifically, the word recognition method provided in the embodiment of the present invention can be executed by a processor, and the processor can be set in an electronic device such as a terminal or a cloud server provided in the embodiment of the present invention. The specific implementation of the terminal includes translation devices such as a point translation pen and a point reading machine, and the present invention does not limit this.
[0042] For example, in the application scenario of the point translation pen, an image of a word to be recognized provided by a scanning head of the point translation pen may be obtained.
[0043] In specific applications, the user specifies the word to be translated through the pen tip of the translation pen. The relative positions of the pen tip and the camera are fixed, so the relative position of the pen tip in the image is fixed. Therefore, in this embodiment, the following method can be used to collect the word image to be recognized, specifically including:
[0044] The position of the pen tip is taken as the center of the bottom edge, and a rectangular area of a fixed size is set according to the size of the word in the image as the virtual pen tip; wherein the virtual pen tip is Figure 2 As shown, the rectangular area of fixed size is Figure 2 The virtual detection box shown;
[0045] Calculate the overlapping area of the fixed-size rectangular area and each detected text box respectively; the text box is as follows Figure 2 As shown;
[0046] Find the text box whose overlapping area accounts for the largest proportion of the rectangular area of a fixed size, use the words in the text box as the words to be recognized, and obtain the word image to be recognized.
[0047] Step 102, identifying the edge range of each character of the word to be recognized from the word image to be recognized, determining the geometric position of the word to be recognized, and stretching the geometric position of the word to be recognized into a horizontal position.
[0048] The geometric position may be a tilted, curved or horizontal position, and determining the geometric position of a word may be understood as determining whether the word to be recognized is tilted, curved or horizontal in the image.
[0049] If the word to be recognized is in a horizontal and clear state in the image, it can be directly recognized; however, if the word to be recognized is in a tilted, perspective, curved, etc. state in the image, in actual application, the word recognition may be inaccurate or the recognition efficiency may be low. Therefore, in the embodiment of the present invention, when recognizing, the words that are tilted, curved, etc. and not in a horizontal position are stretched to a horizontal position, thereby improving the accuracy and recognition effect of the word recognition.
[0050] Step 103, identifying the words to be recognized in the horizontal position.
[0051] In summary, the word recognition method of the embodiment of the present invention stretches the tilted, curved, and other words that are not in a horizontal position into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. This solves the technical problem in the prior art that when the text is tilted, perspective, curved, etc., the text may be relatively blurred (such as in the point translation pen scenario), and the accuracy of text recognition needs to be further improved.
[0052] In the application scenario of the point translation pen, if the paper is made of flexible material, the text in the collected image may be tilted, perspective, bent, etc. In actual application, the problem of inaccurate word recognition or low recognition efficiency may occur. Therefore, in order to improve the accuracy of word recognition, the embodiment of the present invention first stretches the tilted, bent, and other non-horizontal words into a horizontal position. The text correction process of step 102 will be described in detail below. Figure 3 , step 102 specifically includes:
[0053] Step 201, using the maximum extremum stable region algorithm to determine the edge range of each character in the word to be recognized.
[0054] Among them, the embodiment of the present invention can also determine the edge range of each character through other algorithms, such as projection method, character detection algorithm based on machine learning or deep learning, etc. Here, only the maximum extreme stable area algorithm is used as an example without specific limitation.
[0055] It can be understood that when determining a word to be recognized that contains one or more characters, the Maximum Stable Extremal Regions (MSER) algorithm is used to determine the edge range of the position of each character of the word to be recognized or the characters whose number accounts for more than a preset threshold (for example, characters whose number accounts for more than 80% in a word).
[0056] Step 202, determine the initial circumscribed rectangle of the character according to the edge range of the character, use the center point of the initial circumscribed rectangle as the rotation center point, and determine the main axis position; continuously rotate and translate the main axis to determine the boundary, and obtain the circumscribed rectangle with the smallest area by comparing the area size of the area surrounded by the boundary; establish a coordinate system with any vertex of the word image to be recognized as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis; determine the coordinates of the four vertices of the minimum circumscribed rectangle, determine the height and width of the minimum circumscribed rectangle according to the coordinates of the four vertices, and use the angle between one of the widths and the x-axis as the character orientation angle; determine the geometric position of the word to be recognized according to all the character orientation angles.
[0057] For example, Figure 4 As shown in the figure, a coordinate system is established with the upper left corner of the entire image as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis. In this coordinate system, the coordinates of the four vertices of the minimum circumscribed rectangle can be obtained as (x 0 ,y 0 )、(x 1 ,y 1 )、(x 2 ,y 2 )、(x 3 ,y 3 ), and then the height and width of the minimum enclosing rectangle can be determined. The angle between the width and the x-axis (horizontal direction) As the character orientation angle, the character orientation can be determined; then, based on the size of the character orientation angle, it can be determined whether the character is tilted or horizontal. Based on the orientation of each character, it can be determined as a whole whether the word is tilted, curved or horizontal, thereby determining the geometric position of the word.
[0058] Step 203, taking the center point of the minimum circumscribed rectangle as the center point of the character, connecting the center points of all the characters in order from left to right to obtain the text center line; sampling multiple center points at equal intervals on the text center line, and taking a point on each of the two heights of the character direction corresponding to the sampling point as a reference point; calculating the thin plate spline interpolation transformation matrix based on the reference point, and performing bilinear interpolation sampling to stretch the geometric position of the word to be recognized into a horizontal position.
[0059] For example, when selecting a reference point, Figure 5As shown, the two selected points are equivalent to taking a midpoint on the bottom edge, drawing a line perpendicular to the bottom edge, and this line passes through the center point of the rectangle and intersects the top edge at one point. The two points are points on the bottom edge and the top edge of the rectangle, respectively. All sampling points are selected in this way to obtain reference points. Of course, more points can also be selected on the line. The embodiment of the present invention takes two points as an example, and no specific limitation is made here.
[0060] Figure 3 For example, as shown in FIG6 (a), the word "statements" in the image is tilted and bent; as shown in FIG6 (b), the word "Example" in the image is tilted; the following will use FIG6 (a) as an example to illustrate text correction, which has the following characteristics:
[0061] In step 201, exemplarily, the edge range of each character (each letter is a character) in "statements" is first determined using the MSER algorithm. In step 202, exemplarily, the center point and character orientation of each character of the word text statements are determined according to the method of step 202. In step 203, exemplarily, the center points of multiple characters are connected in sequence to obtain the center line of the word text statements. Five points are sampled at equal intervals on the center line, and for each of the five points, two points are taken along the character orientation at a distance of half the character height (i.e., the midpoints of the bottom and top edges of the rectangular box where each point is located). The ten points taken along the character orientation for the five equally sampled points are the reference points. Finally, after obtaining the reference points, the thin plate spline interpolation transformation matrix can be calculated, and bilinear interpolation sampling can be performed to obtain the corrected "statements" image.
[0062] It can be seen from the text images before and after correction in FIG. 6 (a) that the embodiment of the present invention can effectively stretch words that are tilted, perspective, curved, etc. to be horizontal, and at the same time make the image smoother during the stretching process, and it is less likely for the text to be distorted due to stretching.
[0063] The embodiment of the present invention can effectively stretch tilted, perspective, curved, etc. word texts to horizontal through the above-mentioned text correction method, while making the image smoother during the stretching process, making it less likely for the text to be distorted and deformed due to stretching, thereby improving the reliability of word text correction.
[0064] Based on the previous embodiment, this embodiment provides another word recognition method to illustrate how to perform word recognition after image correction. This embodiment and the previous embodiment have different focuses in the description content, and the embodiments can refer to each other for the steps not described in detail. In this embodiment, Figure 7 As shown, the word recognition method comprises the following steps:
[0065] Step 701: collect word images to be recognized.
[0066] Step 702, identifying the position of each character of the word to be recognized from the word image to be recognized, determining the geometric properties of the text, and stretching the word image to be recognized into a horizontal image according to the geometric properties.
[0067] Among them, step 701 and step 702 can refer to the explanation of step 101 and step 102, and will not be repeated here to avoid redundancy.
[0068] Step 703: Recognize the words to be recognized in the horizontal position by using the CRNN algorithm.
[0069] The embodiment of the present invention can effectively improve the operation efficiency of the algorithm by improving the existing CRNN algorithm structure, thereby improving the efficiency and accuracy of word recognition, which will be specifically described below:
[0070] First, if Figure 8 As shown, the existing CRNN algorithm structure includes: convolutional neural network layer, recurrent neural network layer and transcription layer, specifically:
[0071] The convolutional neural network layer consists of the first to seventh convolutional layers (Convolution1-7 in the figure), the maximum pooling layer (Maxpooling) and the custom network layer (Map-to-Sequence). The image features are mainly extracted through the convolutional layer. The custom network layer is the "bridge" between the convolutional neural network layer and the recurrent neural network layer.
[0072] The recurrent neural network layer includes two bidirectional long short-term memory network layers, which are used to predict the feature vector sequence of the words to be recognized to obtain the prediction results. Among them, since the forward and backward information of the text sequence are helpful for the prediction of the sequence, two bidirectional LSTM layers are used to learn the semantic relationship between the text sequences.
[0073] The transcription layer is used to decode the prediction results into characters and remove the spacing characters and repeated characters to obtain the recognition results of the words to be recognized.
[0074] The embodiments of the present invention are as follows Figure 8 The existing CRNN algorithm structure is improved by replacing the second to sixth convolutional layers with the designed convolutional blocks. The improved algorithm is as follows Fig. 9 As shown in the figure, the difference from the existing CRNN algorithm lies in the different convolutional neural network layer structure. The recurrent neural network layer and transcription layer have the same structure as the existing CRNN algorithm, so they are not described here to avoid redundancy. Fig. 9As shown in the figure, the convolutional neural network layer consists of a convolution layer (Convolution), a convolution block (Conv Bkock) and a maximum pooling layer (Maxpooling). The convolutional neural network layer is used to extract the features of the image to be recognized. Among them, the convolutional layer includes convolution (Conv), batch normalization (Batch Normalization) and activation function (Relu).
[0075] Specifically, the convolutional neural network layer includes, in logical order, the first convolution layer, the first convolution block, the first maximum pooling layer, the second convolution block, the second maximum pooling layer, the third convolution block, the third maximum pooling layer, the fourth convolution block, the fourth maximum pooling layer, the fifth convolution block, the second convolution layer, and the custom network layer. Among them, the convolution block includes, in logical order, the first convolution sublayer, the first batch of normalization and activation function sublayers, the depth-separable convolution sublayer based on dilated convolution, the second batch of normalization and activation function sublayers, the second convolution sublayer, and the third batch of normalization and activation function sublayers.
[0076] Taking the extraction of feature sequences of words to be recognized as an example, the existing CRNN algorithm only extracts feature vector sequences of words to be recognized through convolutional layers; while the embodiment of the present invention extracts image features through convolutional layers and convolutional blocks. Compared with the existing CRNN algorithm, the embodiment of the present invention effectively increases the algorithm's perception field of view, improves the algorithm's ability to judge similar characters, and improves the algorithm's recognition accuracy, reduces the amount of calculation, and speeds up the operation efficiency, making it more suitable for the actual scenario of the translation pen. Furthermore, when the embodiment of the present invention recognizes words to be recognized through the improved CRNN algorithm, the efficiency and accuracy of word recognition can be improved.
[0077] Furthermore, before the word to be recognized in the horizontal position is recognized by the CRNN algorithm, the method further includes: scaling the image of the word to be recognized in the horizontal position to a preset height and a preset width. The preset height and the preset width can be set according to actual conditions and are not limited here.
[0078] In summary, the word recognition method of the embodiment of the present invention performs word recognition by improving the CRNN algorithm, which effectively improves the accuracy and speed of word recognition, thereby shortening the time required for recognition and improving the efficiency of recognition.
[0079] In order to implement the above embodiment, the present invention also provides an electronic device.
[0080] The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the following word recognition method is implemented, including:
[0081] Collecting word images to be recognized;
[0082] Identify the edge range of each character of the word to be recognized from the word image to be recognized, determine the geometric position of the word to be recognized, and stretch the geometric position of the word to be recognized into a horizontal position;
[0083] Identify the words to be recognized in a horizontal position.
[0084] Optionally, identifying each character edge range of the word to be recognized from the word image to be recognized specifically includes:
[0085] The maximum extremum stable region algorithm is used to determine the edge range of each character in the word to be recognized.
[0086] Further, determining the geometric position of the word to be recognized specifically includes:
[0087] Determine the initial circumscribed rectangle of the character according to the edge range of the character, take the center point of the initial circumscribed rectangle as the rotation center point, and determine the main axis position;
[0088] Continuously rotate and translate the main axis to determine the boundary, and obtain the smallest circumscribed rectangle by comparing the area of the area enclosed by the boundary;
[0089] A coordinate system is established with any vertex of the word image to be recognized as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis;
[0090] Determine the coordinates of the four vertices of the minimum circumscribed rectangle in the coordinate system, determine the height and width of the minimum circumscribed rectangle based on the coordinates of the four vertices, and use the angle between one of the widths and the x-axis as the character orientation angle;
[0091] The geometric position of the word to be recognized is determined based on the orientation angles of all characters.
[0092] Further, the geometric position of the word to be recognized is stretched into a horizontal position, specifically including:
[0093] Take the center point of the smallest circumscribed rectangle as the center point of the character, connect the center points of all characters from left to right in sequence, and get the center line of the text;
[0094] Sample multiple center points at equal intervals on the center line of the text, and select a point on each of the two heights of the character direction corresponding to the sampling point as the reference point;
[0095] The thin plate spline interpolation transformation matrix is calculated based on the reference points, and bilinear interpolation sampling is performed to stretch the geometric position of the word to be recognized into a horizontal position.
[0096] Furthermore, it also includes:
[0097] The words to be recognized in the horizontal position are recognized by the CRNN algorithm.
[0098] Furthermore, before the word to be recognized in the horizontal position is recognized by the CRNN algorithm, it also includes:
[0099] The image of the word to be recognized in the horizontal position is scaled to a preset height and a preset width.
[0100] Furthermore, the CRNN algorithm includes:
[0101] The convolutional neural network layer includes the first to second convolutional layers, the first to fifth convolutional blocks, the first to fourth maximum pooling layers and a custom network layer. The feature vector sequence of the words to be recognized in the scaled image is extracted through the convolutional layers and the convolutional blocks.
[0102] Furthermore, the convolutional neural network layer includes, in logical order, a first convolutional layer, a first convolutional block, a first maximum pooling layer, a second convolutional block, a second maximum pooling layer, a third convolutional block, a third maximum pooling layer, a fourth convolutional block, a fourth maximum pooling layer, a fifth convolutional block, a second convolutional layer and a custom network layer.
[0103] Furthermore, each convolution block consists of the first to second convolution sub-layers, the first to third batch normalization and activation function sub-layers, and a depth-separable convolution sub-layer based on dilated convolution.
[0104] Furthermore, the convolution block includes, in logical order, a first convolution sublayer, a first batch of normalization and activation function sublayers, a depth-separable convolution sublayer based on dilated convolution, a second batch of normalization and activation function sublayers, a second convolution sublayer, and a third batch of normalization and activation function sublayers.
[0105] Furthermore, the CRNN algorithm also includes:
[0106] The recurrent neural network layer includes two bidirectional long short-term memory network layers, which are used to predict the feature vector sequence of the words to be recognized to obtain the prediction results.
[0107] Furthermore, the CRNN algorithm also includes:
[0108] The transcription layer is used to decode the prediction results into characters and remove the spacing characters and repeated characters to obtain the recognition results of the words to be recognized.
[0109] Furthermore, collecting the word image to be recognized specifically includes:
[0110] The location of the pen tip is taken as the center of the bottom edge, and a fixed-size rectangular area is set according to the size of the word in the image as the virtual pen tip;
[0111] Calculate the overlapping area of the fixed-size rectangular area and each detected text box respectively;
[0112] Find the text box whose overlapping area accounts for the largest proportion of the rectangular area of a fixed size, use the words in the text box as the words to be recognized, and obtain the word image to be recognized.
[0113] It should be noted that the above explanation of the word recognition method embodiment is also applicable to the electronic device of this embodiment and will not be repeated here.
[0114] The electronic device of the embodiment of the present invention stretches the tilted, bent, or other non-horizontal words into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. The technical problem in the prior art that the accuracy of text recognition needs to be further improved when the text is tilted, perspective, bent, or other conditions may make the text relatively blurred (such as in the point translation pen scenario) is solved.
[0115] In order to implement the above embodiments, the present invention also provides a non-volatile computer-readable storage medium.
[0116] The non-volatile computer-readable storage medium stores a computer program, and when the program is executed by a processor, the following word recognition method is implemented:
[0117] Collecting word images to be recognized;
[0118] Identify the edge range of each character of the word to be recognized from the word image to be recognized, determine the geometric position of the word to be recognized, and stretch the geometric position of the word to be recognized into a horizontal position;
[0119] Identify the words to be recognized in a horizontal position.
[0120] Optionally, identifying each character edge range of the word to be recognized from the word image to be recognized specifically includes:
[0121] The maximum extremum stable region algorithm is used to determine the edge range of each character in the word to be recognized.
[0122] Further, determining the geometric position of the word to be recognized specifically includes:
[0123] Determine the initial circumscribed rectangle of the character according to the edge range of the character, take the center point of the initial circumscribed rectangle as the rotation center point, and determine the main axis position;
[0124] Continuously rotate and translate the main axis to determine the boundary, and obtain the smallest circumscribed rectangle by comparing the area of the area enclosed by the boundary;
[0125] A coordinate system is established with any vertex of the word image to be recognized as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis;
[0126] Determine the coordinates of the four vertices of the minimum circumscribed rectangle in the coordinate system, determine the height and width of the minimum circumscribed rectangle based on the coordinates of the four vertices, and use the angle between one of the widths and the x-axis as the character orientation angle;
[0127] The geometric position of the word to be recognized is determined based on the orientation angles of all characters.
[0128] Further, the geometric position of the word to be recognized is stretched into a horizontal position, specifically including:
[0129] Take the center point of the smallest circumscribed rectangle as the center point of the character, connect the center points of all characters from left to right in sequence, and get the center line of the text;
[0130] Sample multiple center points at equal intervals on the center line of the text, and select a point on each of the two heights of the character direction corresponding to the sampling point as the reference point;
[0131] The thin plate spline interpolation transformation matrix is calculated based on the reference points, and bilinear interpolation sampling is performed to stretch the geometric position of the word to be recognized into a horizontal position.
[0132] Furthermore, it also includes:
[0133] The words to be recognized in the horizontal position are recognized by the CRNN algorithm.
[0134] Furthermore, before the word to be recognized in the horizontal position is recognized by the CRNN algorithm, it also includes:
[0135] The image of the word to be recognized in the horizontal position is scaled to a preset height and a preset width.
[0136] Furthermore, the CRNN algorithm includes:
[0137] The convolutional neural network layer includes the first to second convolutional layers, the first to fifth convolutional blocks, the first to fourth maximum pooling layers and a custom network layer. The feature vector sequence of the words to be recognized in the scaled image is extracted through the convolutional layers and the convolutional blocks.
[0138] Furthermore, the convolutional neural network layer includes, in logical order, a first convolutional layer, a first convolutional block, a first maximum pooling layer, a second convolutional block, a second maximum pooling layer, a third convolutional block, a third maximum pooling layer, a fourth convolutional block, a fourth maximum pooling layer, a fifth convolutional block, a second convolutional layer and a custom network layer.
[0139] Furthermore, each convolution block consists of the first to second convolution sub-layers, the first to third batch normalization and activation function sub-layers, and a depth-separable convolution sub-layer based on dilated convolution.
[0140] Furthermore, the convolution block includes, in logical order, a first convolution sublayer, a first batch of normalization and activation function sublayers, a depth-separable convolution sublayer based on dilated convolution, a second batch of normalization and activation function sublayers, a second convolution sublayer, and a third batch of normalization and activation function sublayers.
[0141] Furthermore, the CRNN algorithm also includes:
[0142] The recurrent neural network layer includes two bidirectional long short-term memory network layers, which are used to predict the feature vector sequence of the words to be recognized to obtain the prediction results.
[0143] Furthermore, the CRNN algorithm also includes:
[0144] The transcription layer is used to decode the prediction results into characters and remove the spacing characters and repeated characters to obtain the recognition results of the words to be recognized.
[0145] Furthermore, collecting the word image to be recognized specifically includes:
[0146] The location of the pen tip is taken as the center of the bottom edge, and a fixed-size rectangular area is set according to the size of the word in the image as the virtual pen tip;
[0147] Calculate the overlapping area of the fixed-size rectangular area and each detected text box respectively;
[0148] Find the text box whose overlapping area accounts for the largest proportion of the rectangular area of a fixed size, use the words in the text box as the words to be recognized, and obtain the word image to be recognized.
[0149] It should be noted that the above explanation of the word recognition method embodiment is also applicable to the non-volatile computer-readable storage medium of this embodiment, and will not be repeated here.
[0150] The non-volatile computer-readable storage medium of the embodiment of the present invention stretches tilted, curved, and other words that are not in a horizontal position into a horizontal position when the translation pen performs word recognition, and then performs word recognition, thereby effectively improving the accuracy and recognition effect of word recognition and enhancing the user experience. The technical problem that the accuracy of text recognition in the prior art needs to be further improved when the text is tilted, perspective, curved, etc., which may make the text relatively blurred (such as in the point translation pen scenario) is solved.
[0151] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0152] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0153] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present invention belong.
[0154] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0155] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0156] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0157] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0158] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.
Claims
1. A word recognition method, It is characterized in that include: Collecting word images to be recognized; Identify the edge range of each character of the word to be recognized from the word image to be recognized, determine the geometric position of the word to be recognized, and stretch the geometric position of the word to be recognized into a horizontal position; as well as Recognizing a word to be recognized in a horizontal position; Wherein, the determining the geometric position of the word to be recognized specifically includes: Determine the initial circumscribed rectangle of the character according to the edge range of the character, and determine the main axis position by taking the center point of the initial circumscribed rectangle as the rotation center point; Continuously rotate and translate the main axis to determine the boundary, and obtain the smallest circumscribed rectangle by comparing the area of the area enclosed by the boundary; A coordinate system is established with any vertex of the word image to be recognized as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis; Determine the coordinates of the four vertices of the minimum circumscribed rectangle in the coordinate system, determine the height and width of the minimum circumscribed rectangle according to the coordinates of the four vertices, and take the angle between one of the widths and the x-axis as the character orientation angle; The geometric position of the word to be recognized is determined according to the orientation angles of all characters.
2. The method according to claim 1, It is characterized in that The step of identifying each character edge range of the word to be recognized from the word image to be recognized specifically includes: The maximum extremum stable region algorithm is used to determine the edge range of each character in the word to be recognized.
3. The method according to claim 1 or 2, It is characterized in that The step of stretching the geometric position of the word to be recognized into a horizontal position specifically includes: Take the center point of the smallest circumscribed rectangle as the center point of the character, connect the center points of all characters from left to right in sequence, and get the center line of the text; Sampling multiple center points at equal intervals on the center line of the text, and taking a point on each of the two heights of the character direction corresponding to the sampling point as a reference point; A thin plate spline interpolation transformation matrix is calculated according to the reference points, and bilinear interpolation sampling is performed to stretch the geometric position of the word to be recognized into a horizontal position.
4. The method according to claim 1, It is characterized in that Also includes: The words to be recognized in the horizontal position are recognized by the CRNN algorithm.
5. The method according to claim 4, It is characterized in that Before the word to be recognized in the horizontal position is recognized by the CRNN algorithm, it also includes: The image of the word to be recognized in the horizontal position is scaled to a preset height and a preset width.
6. The method according to claim 5, It is characterized in that The CRNN algorithm includes: A convolutional neural network layer, the convolutional neural network layer comprising first to second convolutional layers, first to fifth convolutional blocks, first to fourth maximum pooling layers and a custom network layer, extracting a feature vector sequence of a word to be recognized in the scaled image through the first to second convolutional layers and the first to fifth convolutional blocks, wherein the feature vector sequence is used to identify the word.
7. The method according to claim 6, It is characterized in that The CRNN algorithm also includes: A recurrent neural network layer, wherein the recurrent neural network layer includes two bidirectional long short-term memory network layers, and the bidirectional long short-term memory network layer is used to predict the feature vector sequence of the word to be recognized to obtain a prediction result.
8. The method according to claim 7, It is characterized in that The CRNN algorithm also includes: The transcription layer is used to decode the prediction results generated by the recurrent neural network layer into characters and remove spacing characters and repeated characters to obtain a recognition result of the word to be recognized.
9. The method according to claim 1, It is characterized in that The collecting of the word images to be recognized specifically includes: The location of the pen tip is taken as the center of the bottom edge, and a fixed-size rectangular area is set according to the size of the word in the image as the virtual pen tip; Calculating the overlapping area of the fixed-size rectangular area and each detected text box respectively; A text box whose overlapping area accounts for the largest proportion of the rectangular area of the fixed size is found, and the words in the text box are used as the words to be recognized to obtain a word image to be recognized.
10. An electronic device, It is characterized in that The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the program, the following word recognition method is implemented, including: Collecting word images to be recognized; Identifying the edge range of each character of the word to be recognized from the word image to be recognized, determining the geometric position of the word to be recognized, and stretching the geometric position of the word to be recognized into a horizontal position; and Recognize the word to be recognized in the horizontal position; Determining the geometric position of the word to be recognized specifically includes: Determine the initial circumscribed rectangle of the character according to the edge range of the character, and determine the main axis position by taking the center point of the initial circumscribed rectangle as the rotation center point; Continuously rotate and translate the main axis to determine the boundary, and obtain the smallest circumscribed rectangle by comparing the area of the area enclosed by the boundary; A coordinate system is established with any vertex of the word image to be recognized as the origin, the horizontal direction as the x-axis, and the vertical direction as the y-axis; Determine the coordinates of the four vertices of the minimum circumscribed rectangle in the coordinate system, determine the height and width of the minimum circumscribed rectangle according to the coordinates of the four vertices, and take the angle between one of the widths and the x-axis as the character orientation angle; The geometric position of the word to be recognized is determined according to the orientation angles of all characters.
11. The electronic device according to claim 10, It is characterized in that The step of identifying each character edge range of the word to be recognized from the word image to be recognized specifically includes: The maximum extremum stable region algorithm is used to determine the edge range of each character in the word to be recognized.
12. The electronic device according to claim 10 or 11, It is characterized in that The step of stretching the geometric position of the word to be recognized into a horizontal position specifically includes: Take the center point of the smallest circumscribed rectangle as the center point of the character, connect the center points of all characters from left to right in sequence, and get the center line of the text; Sampling multiple center points at equal intervals on the center line of the text, and taking a point on each of the two heights of the character direction corresponding to the sampling point as a reference point; A thin plate spline interpolation transformation matrix is calculated according to the reference points, and bilinear interpolation sampling is performed to stretch the geometric position of the word to be recognized into a horizontal position.
13. The electronic device according to claim 12, It is characterized in that Also includes: The words to be recognized in the horizontal position are recognized by the CRNN algorithm.
14. The electronic device according to claim 13, It is characterized in that Before the word to be recognized in the horizontal position is recognized by the CRNN algorithm, it also includes: The image of the word to be recognized in the horizontal position is scaled to a preset height and a preset width.
15. The electronic device according to claim 13, It is characterized in that The CRNN algorithm includes: A convolutional neural network layer, the convolutional neural network layer comprising first to second convolutional layers, first to fifth convolutional blocks, first to fourth maximum pooling layers and a custom network layer, extracting a feature vector sequence of a word to be recognized in the scaled image through the convolutional layers and the convolutional blocks, wherein the feature vector sequence is used to identify the word.
16. The electronic device according to claim 15, It is characterized in that The CRNN algorithm also includes: The recurrent neural network layer includes two bidirectional long short-term memory network layers, which are used to predict the feature vector sequence of the word to be recognized to obtain a prediction result.
17. The electronic device according to claim 16, It is characterized in that The CRNN algorithm also includes: The transcription layer is used to decode the prediction results of the recurrent neural network layer into characters and remove spacing characters and repeated characters to obtain a recognition result of the word to be recognized.
18. The electronic device according to claim 10, wherein the collecting of the word images to be recognized comprises: include: The location of the pen tip is taken as the center of the bottom edge, and a fixed-size rectangular area is set according to the size of the word in the image as the virtual pen tip; Calculating the overlapping area of the fixed-size rectangular area and each detected text box respectively; A text box whose overlapping area accounts for the largest proportion of the rectangular area of the fixed size is found, and the words in the text box are used as the words to be recognized to obtain a word image to be recognized.
19. A non-volatile computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the word recognition method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Character identification method and apparatus
CN107516096A
License plate recognition method, device and system
CN108985137A
Multi-language text recognition method and device, computer equipment and storage medium
CN110569830A
Method for recognizing word
JP1996315077A
Document recognizing method
JP1997319824A
