Text recognition method, device, equipment and storage medium

By identifying the center coordinates and line height of text boxes in text images for sorting, the problem of peer text disconnection in OCR recognition is solved, and the integrity and accuracy of text information is achieved.

CN111985465BActive Publication Date: 2024-09-06CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010825772.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-17
Publication Date
2024-09-06
Estimated Expiration
2040-08-17

AI Technical Summary

Technical Problem

During the OCR recognition process, there are problems such as background interference, distortion, deformation, low resolution, and non-uniform illumination in the text image to be recognized, which causes the text in the same row to be disconnected and detected as two or more short text lines, which in turn leads to the identification of The text information is incomplete and inaccurate.

Method used

By obtaining the text image to be recognized, the text box is identified based on the preset text detection model, the positioning information of the text box is obtained to determine the center coordinates and row height, and sorted to ensure that the text box is input to the text recognition model in the correct order for analysis.

Benefits of technology

It effectively solves the problem of integrity and accuracy of text information and ensures the integrity and accuracy of the identified text information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111985465B
    Figure CN111985465B
Patent Text Reader

Abstract

The embodiments of the present invention relate to the field of image processing technology, and disclose a text recognition method, device, equipment and storage medium. In the present invention, after multiple text boxes contained in a text image to be recognized are recognized based on a preset text detection model, the center coordinates and line heights of the corresponding text boxes are determined based on the positioning information of each text box, and then the text boxes are sorted based on the determined center coordinates and line heights, so that disconnected texts in the same line and multiple short texts can be sorted in actual order, and finally the text boxes are input into a preset text recognition model for parsing based on the target recognition order obtained by sorting that can identify the correct order of the text boxes in the text image to be recognized, thereby ensuring the integrity and accuracy of the text information recognized from the text image to be recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of image processing technology, and in particular to a text recognition method, device, equipment and storage medium. Background Art

[0002] Optical Character Recognition (OCR) refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper, determines their shape by detecting dark and light patterns, and then uses character recognition methods to translate the shape into computer text.

[0003] In the OCR recognition process, traditional image text recognition usually can only recognize standard document images because it needs to separate the text information in the text image to be recognized into individual characters, and then recognize and combine the individual characters one by one to obtain the text information. In order to overcome this defect, although the text information in the text image to be recognized is currently recognized based on a pre-built text detection model and text recognition model, in actual applications, the text image to be recognized taken by a scanner or a digital camera contains not only the text information to be recognized, but also the background, and there are many interference factors in the background part. In addition, the image quality may be affected by distortion, deformation, low resolution, non-uniform illumination, etc., so different characters in the same text line area may have large differences, long intervals, and the text may be tilted or bent. Therefore, when recognizing the text information in the text image to be recognized based on the pre-built text detection model and text recognition model, it is easy to have the text in the same line disconnected and detected as two or more short text lines, which leads to the problem that the final recognized text information is incomplete and inaccurate. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a text recognition method, device, equipment and storage medium, aiming to solve the above technical problems.

[0005] In order to solve the above technical problems, an embodiment of the present invention provides a text recognition method, comprising the following steps:

[0006] Get the text image to be recognized;

[0007] Recognize the text image to be recognized based on a preset text detection model to obtain multiple text boxes contained in the text image to be recognized;

[0008] Acquire the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information;

[0009] Based on the center coordinates and the row height, sorting the text boxes to obtain a target recognition order;

[0010] The sorted text boxes are input into a preset text recognition model according to the target recognition order for parsing, so as to obtain the text information contained in the text image to be recognized.

[0011] An embodiment of the present invention further provides a text recognition device, comprising:

[0012] A text image acquisition module, used to acquire the text image to be recognized;

[0013] A text box detection module, used to identify the text image to be identified based on a preset text detection model, and obtain multiple text boxes contained in the text image to be identified;

[0014] A positioning information acquisition module, used to acquire the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information;

[0015] A sorting module, used for sorting the text boxes based on the center coordinates and the row height;

[0016] The text information recognition module is used to input the sorted text boxes into a preset text recognition model in order for analysis, so as to obtain the text information contained in the text image to be recognized.

[0017] An embodiment of the present invention further provides a text recognition device, comprising:

[0018] at least one processor; and,

[0019] a memory communicatively connected to the at least one processor; wherein,

[0020] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the text recognition method described above.

[0021] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the text recognition method as described above when executed by a processor.

[0022] Compared with the prior art, the embodiments of the present invention, after identifying multiple text boxes contained in the text image to be recognized based on a preset text detection model, determine the center coordinates and line heights of the corresponding text boxes based on the positioning information of each text box, and then sort the text boxes based on the determined center coordinates and line heights, so that disconnected texts in the same line and multiple short texts can be sorted in actual order, and finally input the text boxes into the preset text recognition model for parsing based on the target recognition order obtained by sorting that can identify the correct order of the text boxes in the text image to be recognized, thereby ensuring the integrity and accuracy of the text information recognized from the text image to be recognized.

[0023] In addition, the obtaining of the positioning information of each text box and determining the center coordinates and line height of each text box based on the positioning information includes:

[0024] For each text box, obtain the horizontal coordinates and vertical coordinates of the four vertices of the text box to obtain the positioning information of the text box;

[0025] Determine the center coordinates of the text box based on the four horizontal coordinates and the four vertical coordinates in the positioning information;

[0026] Selecting a maximum ordinate and a minimum ordinate from the four ordinates in the positioning information;

[0027] Based on the maximum vertical coordinate and the minimum vertical coordinate, a row height of the text box is determined.

[0028] In addition, the text boxes are sorted based on the center coordinates and the line height to obtain a target recognition order, including:

[0029] Pre-sorting the text boxes based on the ordinate of the center coordinate to obtain a first recognition order;

[0030] Based on the ordinate of the center coordinate and the row height, performing same-row detection on the text boxes sorted according to the first recognition order, removing duplicate text boxes, and obtaining a second recognition order;

[0031] Based on the horizontal coordinate of the center coordinate, the text boxes sorted according to the second recognition order are reordered in the same row to obtain the target recognition order.

[0032] In addition, based on the ordinate of the center coordinate and the row height, performing same-row detection on the text boxes sorted according to the first recognition order, removing duplicate text boxes, and obtaining a second recognition order includes:

[0033] Determine a core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the row height;

[0034] According to the first recognition order, detecting whether there is overlap between core vertical sections corresponding to adjacent text boxes;

[0035] If there is overlap, the adjacent text boxes are determined to be duplicate text boxes;

[0036] Select and retain one of the repeated text boxes to obtain the second recognition order.

[0037] In addition, determining the core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the line height includes:

[0038] For each text box, a difference operation is performed between the ordinate of the center coordinate and the row height to obtain a starting value;

[0039] Performing a sum operation on the ordinate of the center coordinate and the row height to obtain a termination value;

[0040] Based on the start value and the end value, a core vertical interval of the text box is determined.

[0041] In addition, determining the core vertical interval of the text box based on the start value and the end value includes:

[0042] Adjusting the starting value and the ending value based on a preset core interval factor;

[0043] Based on the adjusted start value and the adjusted end value, a core vertical interval of the text box is determined.

[0044] In addition, the detecting whether core vertical sections corresponding to adjacent text boxes overlap according to the first recognition order includes:

[0045] According to the first recognition order, it is detected whether the starting value of the core vertical interval corresponding to the i-th text box is less than the ending value of the core vertical interval corresponding to the i+1-th text box, and whether the ending value of the core vertical interval corresponding to the i-th text box is less than the starting value of the core vertical interval corresponding to the i+1-th text box, where i is an integer greater than 0;

[0046] If the starting value of the core vertical interval corresponding to the i-th text box is less than the ending value of the core vertical interval corresponding to the i+1-th text box, and the ending value of the core vertical interval corresponding to the i-th text box is less than the starting value of the core vertical interval corresponding to the i+1-th text box, then the i-th text box and the i+1-th text box are determined to be duplicate text boxes. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplifications do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0048] Figure 1 is a specific flow chart of the text recognition method according to the first embodiment of the present invention;

[0049] Figure 2 is a schematic diagram of multiple text boxes recognized from a text image to be recognized in the text recognition method of the first embodiment of the present invention;

[0050] Figure 3 is a specific implementation flow chart of step 104 in the text recognition method of the first embodiment of the present invention;

[0051] Figure 4 is a specific implementation flow chart of step 1042 in the text recognition method of the first embodiment of the present invention;

[0052] Figure 5 is a specific flow chart of the text recognition method according to the second embodiment of the present invention;

[0053] Figure 6 is a schematic diagram of the structure of a text recognition device according to a third embodiment of the present invention;

[0054] Figure 7 It is a schematic structural diagram of a text recognition device according to a fourth embodiment of the present invention. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are provided to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented.

[0056] The division of the following embodiments is for the convenience of description and shall not constitute any limitation on the specific implementation of the present invention. The various embodiments may be combined and referenced with each other without contradiction.

[0057] The present embodiment relates to a text recognition method. After multiple text boxes contained in a text image to be recognized are recognized based on a preset text detection model, the center coordinates and line heights of the corresponding text boxes are determined based on the positioning information of each text box, and then the text boxes are sorted based on the determined center coordinates and line heights, so that disconnected texts in the same line and multiple short texts can be sorted according to the actual order. Finally, based on the target recognition order obtained by the sorting and capable of identifying the correct order of the text boxes in the text image to be recognized, the text boxes are input into a preset text recognition model for parsing, thereby ensuring the integrity and accuracy of the text information recognized from the text image to be recognized.

[0058] The implementation details of the text recognition method of this embodiment are described below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for implementing this solution.

[0059] The text recognition method provided in this embodiment is specifically applied to any terminal device that can execute the method, such as a personal computer, a tablet computer, a smart phone, etc., which are not listed one by one here, and this embodiment does not limit this.

[0060] The specific process of this implementation is as follows: Figure 1 As shown, the specific steps include:

[0061] Step 101: Obtain a text image to be recognized.

[0062] Specifically, the to-be-recognized text image in this embodiment refers to a picture containing text information and used for text recognition.

[0063] In some examples, the text image to be recognized can be a picture randomly selected from the Internet, such as a picture containing text information selected from a website; in some examples, the text image to be recognized can be a picture provided by a user, such as a picture containing text information taken by a user using an electronic device with a camera function such as a digital camera or a mobile phone.

[0064] It should be understood that the above examples are merely examples listed for a better understanding of the technical solutions of this embodiment and are not intended to be the sole limitation to this embodiment.

[0065] Step 102: recognize the text image to be recognized based on a preset text detection model to obtain a plurality of text boxes contained in the text image to be recognized.

[0066] First, it should be noted that, in this embodiment, the multiple text boxes identified from the text image to be identified based on the text detection model are all single-line text boxes, that is, a text box contains only one line of text information.

[0067] In addition, it should be understood that the text detection model mentioned in this embodiment is specifically obtained by training based on a certain number of sample images before performing the text recognition operation, and the trained text detection model can at least recognize the text inclination direction and connectivity information of the text information in the text image to be recognized.

[0068] In addition, it is worth mentioning that since the text recognition method provided in this embodiment is mainly to solve the problems of large differences and long intervals between different characters in the same text line area in the text image to be recognized, as well as tilt and curvature of the text, there will usually be multiple text boxes identified from the text image to be recognized based on the preset text detection model for this situation, that is, at least two.

[0069] For the sake of convenience, this embodiment is specifically described by taking the text recognition method applied to the text recognition scenario of the content on the home broadband installation and maintenance label as an example. Therefore, the above-obtained text image to be recognized is specifically a home broadband installation and maintenance label.

[0070] Because, in actual applications, the text image to be identified of the home broadband installation and maintenance label is usually obtained by the user through the installation and maintenance personnel using a camera, and therefore, due to the bending of the home loan installation and maintenance label, the text line area in the captured text image to be identified may cause character spacing, tilt, and other phenomena. For the convenience of subsequent description, this embodiment uses Figure 2 As an example, the text image to be recognized is Figure 2 By recognizing the text image to be recognized of the home loan maintenance label shown in the figure, eight text boxes A1, A2, A3, A4, A5, A6, A7, and A8 can be obtained.

[0071] It should be understood that the above examples are merely examples listed for a better understanding of the technical solutions of this embodiment and are not intended to be the sole limitation to this embodiment.

[0072] In addition, in actual applications, if there is only one text box identified from the text image to be identified based on the text detection model, there is no need to identify the text information based on steps 103 to 105 given in this embodiment. The text information in the text box can be obtained by directly parsing the text box using the preset text recognition model.

[0073] In addition, it should be noted that the text detection model provided in this embodiment can be directly based on the existing method of training text detection models, such as the OCR algorithm combined with the convolutional neural network algorithm training, that is, any text detection model that can be constructed to identify text boxes can be used. This embodiment does not limit its specific construction, so the specific construction method of the text detection model will not be repeated here.

[0074] Step 103: Acquire the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information.

[0075] Specifically, in this embodiment, the acquired positioning information of each text box specifically refers to the coordinate information of the four vertices of each text box.

[0076] That is to say, for each text box, when obtaining its corresponding positioning information and determining the center coordinates and line height of the text box based on the positioning information, it is specifically implemented based on the following sub-steps:

[0077] First, the horizontal coordinates and vertical coordinates of the four vertices of the text box are obtained to obtain the positioning information of the text box.

[0078] Then, based on the four horizontal coordinates and the four vertical coordinates in the positioning information, the center coordinates of the text box are determined.

[0079] Next, the maximum vertical coordinate and the minimum vertical coordinate are selected from the four vertical coordinates in the positioning information.

[0080] Finally, based on the maximum vertical coordinate and the minimum vertical coordinate, the line height of the text box is determined.

[0081] For ease of understanding, the following Figure 2 Take the center coordinates and line height of the text box A1 identified in the example as an example to explain in detail:

[0082] First, obtain the coordinate information of the four vertices of the upper left corner, upper right corner, lower left corner, and lower right corner of the text box A1, as follows: (x lu (A1),y lu (A1))、(x ru (A1),y ru (A1))、(x ll (A1),y ll (A1))、(x rl (A1),y rl (A1)).

[0083] Among them, x lu (A1) is the horizontal coordinate of the vertex in the upper left corner, y lu (A1) is the vertical coordinate of the point in the upper left corner; x ru (A1) is the horizontal coordinate of the point in the upper right corner, y ru (A1) is the ordinate of the point in the upper right corner; x ll (A1) is the horizontal coordinate of the point in the lower left corner, y ll (A1) is the ordinate of the point in the lower left corner; x rl (A1) is the horizontal coordinate of the point in the lower right corner, yrl (A1) is the vertical coordinate of the point in the lower right corner.

[0084] Then, determine the horizontal coordinate x of the center point of text box A1 according to formula (1): c (A1), determine the ordinate y of the center point of text box A1 according to formula (2) c (A1), determine the line height h(A1) of the text box A1 according to formula (3).

[0085]

[0086]

[0087] Correspondingly, the center coordinates of the center point of text box A1 are (x c (A1),y c (A1)).

[0088] h(A1)=max(y lu (A1),y ru (A1),y ll (A1),y rl (A1))-min(y lu (A1),y ru (A1),y ll (A1),y rl (A1)) (3)

[0089] Among them, max(y lu (A1),y ru (A1),y ll (A1),y rl (A1)) means to select the maximum ordinate from the ordinates corresponding to the four vertices of the text box A1, min(y lu (A1),y ru (A1),y ll (A1),y rl (A1)) means selecting the smallest vertical coordinate from the horizontal coordinates corresponding to the four vertices of the text box A1.

[0090] It should be understood that the above is only a specific method for determining the text box A1. In actual applications, the center coordinates and line height of each text box can be determined by referring to the above formulas (1), (2) and (3).

[0091] Step 104, sorting the text boxes based on the center coordinates and the line height to obtain a target recognition order.

[0092] Specifically, when sorting text boxes based on the center coordinates and row height of each text box, this embodiment mainly includes three steps: pre-sorting text boxes, same-row detection, and same-row reordering. Figure 3 To explain:

[0093] Step 1041, pre-sorting each text box based on the vertical coordinate of the center coordinate to obtain a first recognition order.

[0094] Specifically, in this embodiment, the pre-sorting operation performed on each text box based on the ordinate of the center coordinate corresponding to each text box is to sort the text boxes in order from small to large according to the value of the ordinate.

[0095] For the sake of convenience, the following is still based on Figure 2 Take the following text boxes as an example to explain:

[0096] Assume that from Figure 2 The only recognized text boxes are A1, A2, A4 and A7, that is, each text box is an independent line, and the vertical coordinates of the center coordinates of text boxes A1, A2, A4 and A7 satisfy: y c (A1) <y c (A2) <y c (A4) <y c (A7), the first recognition order finally obtained is: L A1 , L A2 , L A4 , L A7 ; Assume that, from Figure 2 The identified text boxes are A1, A2, A3, A4, A5, A6, A7, and A8. That is, there are multiple text boxes in the same row. The ordinates of the center coordinates of text boxes A1, A2, A3, A4, A5, A6, A7, and A8 satisfy: y c (A1) <y c (A2) = y c (A3) <y c (A4) = y c (A5) = y c (A6) <y c (A7) = y c (A8), that is, text box A1 is an independent row, text box A2 and text box A3 are in the same row, text box A4, text box A5 and text box A6 are in the same row, text box A7 and text box A8 are in the same row, and the text boxes are sorted in order from small to large according to the value of the vertical coordinate. The final first recognition order is: L A1 , L A2 , L A3 , LA4 , L A5 , L A6 , L A7 , L A8 .

[0097] That is to say, when there are multiple text boxes in the same row, when sorting the text boxes, they are first sorted from small to large according to the vertical coordinate value. For the same vertical coordinate value, they are sorted based on the priority of the text box in front.

[0098] Step 1042: Based on the ordinate of the center coordinate and the row height, perform same-row detection on the text boxes sorted according to the first recognition order, remove duplicate text boxes, and obtain a second recognition order.

[0099] Specifically, the same row detection method mentioned in step 1042 is specifically based on

[0100] Specifically, when the text boxes sorted in the first recognition order are detected in the same row based on the vertical coordinate of the center coordinate and the row height, the core vertical interval to which the corresponding text box belongs is determined based on the row height of the text box and the vertical coordinate of the center coordinate, and then the core vertical intervals of two adjacent text boxes are compared to see if they overlap. Figure 4 To explain:

[0101] Step 1042-1: For each text box, perform a difference operation on the vertical coordinate of the center coordinate and the row height to obtain a starting value.

[0102] That is, the starting value is y c -h.

[0103] Step 1042-2, performing a sum operation on the vertical coordinate of the center coordinate and the row height to obtain a termination value.

[0104] That is, the end value is y c +h.

[0105] Step 1042-3, determining the core vertical interval of the text box based on the start value and the end value.

[0106] That is to say, the core vertical interval is (y c -h,y c +h).

[0107] It should be understood that the above example is only a specific implementation method for determining the core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the line height, and is not the only limitation to this implementation.

[0108] Step 1042-4: Detect whether there is any overlap between core vertical sections corresponding to adjacent text boxes according to the first recognition order.

[0109] Specifically, if there is overlap, execute step 1042-5; otherwise, directly go to step 1042-6.

[0110] For ease of understanding, this implementation provides a specific detection rule, which is as follows:

[0111] According to the first recognition order, check whether the starting value of the core vertical interval corresponding to the i-th text box is less than the ending value of the core vertical interval corresponding to the i+1-th text box, and whether the ending value of the core vertical interval corresponding to the i-th text box is less than the starting value of the core vertical interval corresponding to the i+1-th text box.

[0112] It should be noted that, in this embodiment, the above-mentioned i is an integer greater than 0.

[0113] Correspondingly, if the starting value of the core vertical interval corresponding to the i-th text box is smaller than the ending value of the core vertical interval corresponding to the i+1-th text box, and the ending value of the core vertical interval corresponding to the i-th text box is smaller than the starting value of the core vertical interval corresponding to the i+1-th text box, then the i-th text box and the i+1-th text box are determined to be duplicate text boxes; otherwise, the i-th text box and the i+1-th text box are determined to be different text boxes.

[0114] Step 1042-5, determine that adjacent text boxes are duplicate text boxes, and select one of the duplicate text boxes to retain.

[0115] Step 1042-6, obtain the second recognition sequence.

[0116] It should be understood that the above examples are merely examples listed for a better understanding of the technical solutions of this embodiment and are not intended to be the sole limitation to this embodiment.

[0117] Step 1043: Based on the horizontal coordinate of the center coordinate, the text boxes sorted according to the second recognition order are reordered in the same row to obtain the target recognition order.

[0118] Specifically, when the texts in the second recognition order are reordered in the same row based on the horizontal coordinates of the center coordinates of each text box, they are sorted from small to large according to the value of the horizontal coordinates of the center coordinates of each text box, that is, the text boxes in the same row are sorted from left to right.

[0119] It is not difficult to find from the above description that the implementation mode of the present invention first pre-sorts the text boxes by the vertical coordinates of the center coordinates, then determines whether the front and rear adjacent text boxes are in the same row based on the vertical coordinates and the line height of the center coordinates, and finally reorders the same row based on the horizontal coordinates of the center coordinates, thereby simply and efficiently solving the sorting problem of incomplete text lines, so that the text information parsed by the text recognition model according to the target recognition order obtained by the current sorting is the complete text information contained in the text image to be recognized.

[0120] Step 105: input the sorted text boxes into a preset text recognition model according to the target recognition order for parsing, so as to obtain the text information contained in the text image to be recognized.

[0121] It should be understood that the text recognition model mentioned in the present embodiment is specifically obtained by training based on a certain number of sample text boxes before performing the parsing operation on the text information in the text box.

[0122] In this embodiment, the text recognition model can be specifically obtained according to a deep convolutional neural network algorithm and a recursive neural network algorithm, or a deep convolutional neural network algorithm and a recurrent neural network algorithm training, that is, the text recognition model in this embodiment is obtained based on the existing commonly used convolutional neural network algorithm training, that is, any text recognition model that can be constructed to recognize text information in a text box can be constructed, and this embodiment does not impose any restrictions on its specific construction, so the specific construction method of the text recognition model will not be repeated here.

[0123] It is not difficult to find from the above description that the text recognition method provided in the present embodiment, after identifying multiple text boxes contained in the text image to be recognized based on a preset text detection model, determines the center coordinates and line height of the corresponding text box based on the positioning information of each text box, and then sorts each text box based on the determined center coordinates and line height, so that the disconnected same-line texts and multiple short texts can be sorted in actual order, and finally, based on the target recognition order obtained by sorting that can identify the correct order of the text boxes in the text image to be recognized, the text boxes are input into the preset text recognition model for parsing, thereby ensuring the integrity and accuracy of the text information recognized from the text image to be recognized.

[0124] The second embodiment of the present invention relates to a text recognition method. The second embodiment is further improved on the basis of the first embodiment, and the main improvement is: before step 1042-3, the starting value and the ending value are first adjusted based on a preset core interval factor, and then the core vertical interval of the text box is determined based on the adjusted starting value and the adjusted ending value.

[0125] like Figure 5As shown, step 1042-1, step 1042-2, step 1042-3, step 1042-4, step 1042-5, and step 1042-6 are substantially the same as those of the first embodiment, and are not described in detail here. Only the newly added step 1042-0 is described below:

[0126] Step 1042-0, adjusting the starting value and the ending value based on a preset core interval factor.

[0127] For the sake of convenience, this embodiment uses a to represent the core interval factor, and stipulates that the value range of a is (0 <a<0.5)。

[0128] The specific value of a can be adjusted according to actual conditions. In this embodiment, a=0.25 is preferred.

[0129] Accordingly, the adjusted starting value is y c -a*h, the adjusted end value is y c +a*h.

[0130] Therefore, the core vertical interval of the text box is determined based on the starting value and the ending value in step 1042-3, specifically based on the adjusted starting value y c -a*h and adjusted end value y c + a*h, determine the core vertical interval of the text box, that is, the core vertical interval finally determined is (y c -a*h,y c +a*h).

[0131] Therefore, the text recognition method provided in this embodiment adjusts the core vertical interval corresponding to each text box by introducing the core interval factor, a dynamic threshold, so that the core vertical interval will dynamically change with the line height of different text boxes, thereby having better robustness to different characters and being able to better ensure the accuracy of same-row detection and sorting.

[0132] In addition, it should be understood that the step division of the above methods is only for clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs that do not change the core design of the algorithm and process are all within the scope of protection of this patent.

[0133] A third embodiment of the present invention relates to a text recognition device, such as Figure 6 As shown, it includes: a text image acquisition module 601, a text box detection module 602, a positioning information acquisition module 603, a sorting module 604 and a text information recognition module 605.

[0134] Among them, the text image acquisition module 601 is used to obtain the text image to be recognized; the text box detection module 602 is used to recognize the text image to be recognized based on a preset text detection model to obtain multiple text boxes contained in the text image to be recognized; the positioning information acquisition module 603 is used to obtain the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information; the sorting module 604 is used to sort the text boxes based on the center coordinates and the line height; the text information recognition module 605 is used to input the sorted text boxes into the preset text recognition model in sequence for parsing, and obtain the text information contained in the text image to be recognized.

[0135] In addition, in another example, the positioning information acquisition module 603 is specifically used to obtain the horizontal and vertical coordinates of the four vertices of each text box to obtain the positioning information of the text box; determine the center coordinates of the text box based on the four horizontal coordinates and four vertical coordinates in the positioning information; select the maximum vertical coordinate and the minimum vertical coordinate from the four vertical coordinates in the positioning information; and determine the line height of the text box based on the maximum vertical coordinate and the minimum vertical coordinate.

[0136] In addition, in another example, the sorting module 604 is specifically used to pre-sort each text box based on the vertical coordinate of the center coordinate to obtain a first recognition order; based on the vertical coordinate of the center coordinate and the line height, perform same-row detection on the text boxes sorted according to the first recognition order, remove duplicate text boxes, and obtain a second recognition order; based on the horizontal coordinate of the center coordinate, reorder the text boxes sorted according to the second recognition order in the same row to obtain the target recognition order.

[0137] In addition, in another example, the sorting module 604 is also used to determine the core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the line height; according to the first recognition order, detect whether there is overlap between the core vertical intervals corresponding to adjacent text boxes; if there is overlap, determine that the adjacent text boxes are duplicate text boxes; select one of the duplicate text boxes to retain, and obtain the second recognition order.

[0138] In addition, in another example, the sorting module 604 is also used to, for each text box, perform a difference operation on the vertical coordinate of the center coordinate and the row height to obtain a starting value; perform a sum operation on the vertical coordinate of the center coordinate and the row height to obtain an ending value; and determine the core vertical interval of the text box based on the starting value and the ending value.

[0139] In addition, in another example, the sorting module 604 is further configured to adjust the start value and the end value based on a preset core interval factor; and determine the core vertical interval of the text box based on the adjusted start value and the adjusted end value.

[0140] In addition, in another example, the sorting module 604 is also used to detect, in accordance with the first recognition order, whether the starting value of the core vertical interval corresponding to the i-th text box is less than the ending value of the core vertical interval corresponding to the i+1-th text box, and whether the ending value of the core vertical interval corresponding to the i-th text box is less than the starting value of the core vertical interval corresponding to the i+1-th text box, where i is an integer greater than 0; if the starting value of the core vertical interval corresponding to the i-th text box is less than the ending value of the core vertical interval corresponding to the i+1-th text box, and the ending value of the core vertical interval corresponding to the i-th text box is less than the starting value of the core vertical interval corresponding to the i+1-th text box, then it is determined that the i-th text box and the i+1-th text box are duplicate text boxes.

[0141] It is not difficult to find that this embodiment is a device embodiment corresponding to the first or second embodiment, and this embodiment can be implemented in conjunction with the first or second embodiment. The relevant technical details mentioned in the first or second embodiment are still valid in this embodiment, and in order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the first or second embodiment.

[0142] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.

[0143] A fourth embodiment of the present invention relates to a text recognition device, such as Figure 7 As shown, it includes at least one processor 701; and a memory 702 that is communicatively connected to the at least one processor 701; wherein the memory 702 stores instructions that can be executed by the at least one processor 701, and the instructions are executed by the at least one processor 701 so that the at least one processor 701 can execute the text recognition method described in the first or second embodiment above.

[0144] Among them, the memory 702 and the processor 701 are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus links various circuits of one or more processors 701 and the memory 702 together. The bus can also link various other circuits such as peripherals, voltage regulators, and power management circuits together, which are all well known in the art, so they are not further described in this article. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium through an antenna, and further, the antenna also receives data and transmits the data to the processor.

[0145] The processor 701 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 702 can be used to store data used by the processor 701 when performing operations.

[0146] The fifth embodiment of the present application relates to a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the portrait image quality assessment method described in the above method embodiment.

[0147] Those skilled in the art can understand that all or part of the steps in the above-mentioned implementation method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each implementation of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0148] Those skilled in the art will appreciate that the above-mentioned embodiments are specific embodiments for implementing the present invention, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present invention.

Claims

1. A text recognition method, characterized in that: include: Get the text image to be recognized; Recognize the text image to be recognized based on a preset text detection model to obtain multiple text boxes contained in the text image to be recognized; Acquire the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information; Based on the center coordinates and the row height, sorting the text boxes to obtain a target recognition order; Inputting the sorted text boxes into a preset text recognition model according to the target recognition order for parsing, to obtain text information contained in the text image to be recognized; Wherein, for each text box, the horizontal coordinates and the vertical coordinates of the four vertices of the text box are obtained to obtain the positioning information of the text box; Determine the center coordinates of the text box based on the four horizontal coordinates and the four vertical coordinates in the positioning information; Selecting a maximum ordinate and a minimum ordinate from the four ordinates in the positioning information; Determine the line height of the text box based on the maximum ordinate and the minimum ordinate; Pre-sorting the text boxes based on the ordinate of the center coordinate to obtain a first recognition order; Based on the ordinate of the center coordinate and the row height, performing same-row detection on the text boxes sorted according to the first recognition order, removing duplicate text boxes, and obtaining a second recognition order; Based on the horizontal coordinate of the center coordinate, reorder the text boxes sorted according to the second recognition order to obtain the target recognition order; Determine a core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the row height; According to the first recognition order, detecting whether there is overlap between core vertical sections corresponding to adjacent text boxes; If there is overlap, the adjacent text boxes are determined to be duplicate text boxes; Select and retain one of the repeated text boxes to obtain the second recognition order.

2. The text recognition method according to claim 1, characterized in that: The determining of the core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the line height includes: For each text box, a difference operation is performed between the ordinate of the center coordinate and the row height to obtain a starting value; Performing a sum operation on the ordinate of the center coordinate and the row height to obtain a termination value; Based on the start value and the end value, a core vertical interval of the text box is determined.

3. The text recognition method according to claim 2, characterized in that: The determining the core vertical interval of the text box based on the start value and the end value includes: Adjusting the starting value and the ending value based on a preset core interval factor; Based on the adjusted start value and the adjusted end value, a core vertical interval of the text box is determined.

4. The text recognition method according to claim 3, characterized in that: The detecting whether core vertical sections corresponding to adjacent text boxes overlap according to the first recognition order includes: According to the first recognition sequence, detect the Is the starting value of the core vertical interval corresponding to the first text box smaller than the The end value of the core vertical interval corresponding to the text box, and the Is the end value of the core vertical interval corresponding to the first text box less than the The starting value of the core vertical interval corresponding to each text box. is an integer greater than 0; Jordi The starting value of the core vertical interval corresponding to the first text box is less than The end value of the core vertical interval corresponding to the text box, and the The end value of the core vertical interval corresponding to the first text box is less than The starting value of the core vertical interval corresponding to the first text box determines the The text box and The text box is a repeated text box.

5. A text recognition device, characterized in that: include: A text image acquisition module, used to acquire the text image to be recognized; A text box detection module, used to identify the text image to be identified based on a preset text detection model, and obtain multiple text boxes contained in the text image to be identified; A positioning information acquisition module, used to acquire the positioning information of each text box, and determine the center coordinates and line height of each text box based on the positioning information; A sorting module, used to sort the text boxes based on the center coordinates and the line height to obtain a target recognition order; A text information recognition module is used to input the sorted text boxes into a preset text recognition model in order for analysis, so as to obtain the text information contained in the text image to be recognized; Wherein, for each text box, the horizontal coordinates and the vertical coordinates of the four vertices of the text box are obtained to obtain the positioning information of the text box; Determine the center coordinates of the text box based on the four horizontal coordinates and the four vertical coordinates in the positioning information; Selecting a maximum ordinate and a minimum ordinate from the four ordinates in the positioning information; Based on the maximum ordinate and the minimum ordinate, determine the line height of the text box; based on the ordinate of the center coordinate, pre-sort the text boxes to obtain a first recognition order; Based on the ordinate of the center coordinate and the row height, performing same-row detection on the text boxes sorted according to the first recognition order, removing duplicate text boxes, and obtaining a second recognition order; Based on the horizontal coordinate of the center coordinate, reorder the text boxes sorted according to the second recognition order to obtain the target recognition order; Determine a core vertical interval corresponding to each text box based on the vertical coordinate of the center coordinate and the row height; According to the first recognition order, detecting whether there is overlap between core vertical sections corresponding to adjacent text boxes; If there is overlap, the adjacent text boxes are determined to be duplicate text boxes; Select and retain one of the repeated text boxes to obtain the second recognition order.

6. A text recognition device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the text recognition method according to any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text recognition method according to any one of claims 1 to 4 is implemented.