A method, system, device and storage medium for extracting text lines from a document

By determining the line mark text blocks of the first line of the document and adjacent lines, the text lines are extracted line by line, combined with the vertical ray rotation and translation method, which solves the problems of tedious and low-efficiency document text line extraction in the existing technology, and achieves high efficiency and accuracy. Text line recognition.

CN113850258BActive Publication Date: 2024-08-23SHENZHEN AIMALL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111124778.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-25
Publication Date
2024-08-23
Estimated Expiration
2041-09-25

AI Technical Summary

Technical Problem

The existing technology is cumbersome and inefficient in extracting document text lines, and has a high error rate and operational complexity, making it difficult to adapt to complex document layout and noise interference.

Method used

By determining the line mark text block of the first line of the document, extract text lines line by line, and obtain text blocks of adjacent lines through adjacent line mark text blocks until all text lines are extracted, using vertical ray rotation and translation methods to improve recognition Precision and simplicity.

Benefits of technology

It achieves accurate and efficient extraction of document text lines, reduces recognition errors, simplifies the operation process, and improves recognition efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113850258B
    Figure CN113850258B
Patent Text Reader

Abstract

The present application discloses a method, system, device and storage medium for extracting text lines in a document, wherein the method comprises: acquiring a document image; determining the line marker text block of the first line of the document based on the document image; extracting text from the text line of the first line based on the line marker text block of the first line; after the text extraction of the text line of the first line is completed, acquiring the line marker text block of an adjacent line; extracting text from the text line of an adjacent line based on the line marker text block of an adjacent line; after the text extraction of the text line of the previous line is completed, acquiring the line marker text block of the next adjacent line and extracting text lines again, until all text lines are extracted. Through the above-mentioned scheme of the present application, the text line extraction of the document can be accurately and efficiently realized, and the extraction process is simple and intuitive, and has strong applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image recognition, and in particular to a method, system, device and storage medium for extracting text lines from a document. Background Art

[0002] With the development of computer and communication technology, information and data are growing rapidly, and users have more and more demands for automated information processing, especially document processing. In document processing, it is necessary to extract text lines first, and then analyze the structure and features within the text lines to segment and combine them to extract useful information. OCR (Optical Character Recognition) is the first step in document processing, but the most advanced OCR technology can generally only provide the location and text content of all text blocks in the document (combinations of multiple characters that are compactly located on the same text line). The text blocks are out of order, so a post-processing method is needed to sort and associate the text blocks to extract text lines.

[0003] The common method of text line extraction is to extract text lines by projecting in the horizontal and vertical directions and taking advantage of the characteristics of lines arranged in lines and large blank spaces between lines. However, due to the complexity of document typesetting and possible noise interference, the applicability of such methods is not strong.

[0004] To address the above problems, the industry has proposed methods based on graph theory, clustering, and morphology, etc. However, some of these methods have high error rates and some operations are cumbersome, which brings a lot of inconvenience to practical applications.

[0005] Therefore, the prior art needs to be improved. Summary of the invention

[0006] The purpose of this application is to solve the problem that the text line extraction process of the prior art document is complicated and inefficient.

[0007] The above technical objectives of this application are achieved through the following technical solutions:

[0008] A method for extracting text lines from a document, comprising:

[0009] Acquire document images;

[0010] Based on the document image, determine the line marker text block of the first line of the document;

[0011] Based on the line mark text block of the first line, extract the text of the first line;

[0012] After the text extraction of the first line is completed, the line mark text blocks of the adjacent lines are obtained;

[0013] Based on the line marking text blocks of the adjacent lines, text lines of the adjacent lines are extracted;

[0014] After the text extraction of the previous text line is completed, the line marker text block of the next adjacent line is obtained and the text line is extracted again until all the text lines are extracted.

[0015] The above scheme of the present application determines the row mark file block of the document image, and then extracts the text lines of the same row based on the row mark file block. After the extraction is completed, the row mark text blocks of the adjacent rows are obtained, and the text lines of the adjacent rows are extracted until all the text lines are extracted. The operation is simple and the recognition efficiency is high.

[0016] Optionally, in the method for extracting text lines from a document, the step of extracting text from the first line of text based on the line marker text block of the first line includes:

[0017] Based on the line mark text block, get the adjacent text block in the same line and set it as the current active text block;

[0018] Get the text blocks in the same row adjacent to the current active text block in the same direction as the previous one, and set them as the current active text block in sequence until there are no adjacent text blocks in the row text blocks in the same direction;

[0019] Based on the line mark text block, get the text block of the same line in the opposite direction of the previous time, set it as the current active text block, and set the adjacent text blocks as the current active text blocks in sequence until there are no adjacent text blocks in the line text blocks in the same direction.

[0020] The above scheme of the present application, when extracting the text line of the first line, obtains the adjacent text block through the determined line mark text block, extends it, and sets the adjacent text block as the current active text block, obtains the text block adjacent to the current active text block again, extends it in sequence, and finally, realizes the extraction of text blocks in the same moving direction, and then based on the line mark text block, obtains the adjacent text block at the opposite end of the previous direction, and extends it in sequence until starting from the line mark text block, extending on both sides to realize the extraction of text lines in the same line, with simple operation and high accuracy.

[0021] Optionally, in the method for extracting text lines in a document, the step of obtaining adjacent text blocks of the same line includes:

[0022] Draw a ray in the vertical direction of the line marked text block or the currently active text block;

[0023] rotating the ray clockwise or counterclockwise;

[0024] Determine the first text block that the ray passes through in the direction of the current row during rotation, which is the row mark text block or the text block adjacent to the current active text block in the same row.

[0025] The above scheme of the present application determines that the first text block passed in the row direction is an adjacent text block by rotating the ray in the vertical direction of the row mark text block or the current active text block, which has high recognition accuracy and reduces recognition errors.

[0026] Optionally, in the method for extracting text lines in a document, after the text of the first text line is extracted, the step of obtaining the line mark text blocks of adjacent lines includes:

[0027] Use the previous line as the translation line and translate it in the vertical direction of the text line direction of the previous line;

[0028] If a text block exists in the translated row during the translation process, the first text block of the translated row is determined to be a row marker text block of an adjacent row.

[0029] The above scheme of the present application, after the first line of text is extracted, performs text line extraction on adjacent lines, and needs to determine the line mark text block of the adjacent line, and performs translation in a direction perpendicular to the text line direction of the previous line to determine the adjacent line. During the translation process, if there is a text block in the translated line, the first text block of the translated line is determined to be the line mark text block of the adjacent line. Through the above scheme, the line mark text blocks of the adjacent lines can be accurately and quickly obtained, and then the adjacent lines can be extracted through the above method, thereby finally realizing the extraction of all text lines, and the operation is simple and the text extraction accuracy is high.

[0030] Optionally, in the method for extracting text lines from a document, the step of using a previous line as a translation line and performing translation in a direction perpendicular to the text line direction of the previous line comprises:

[0031] Get the first text block and the last text block of the previous line;

[0032] Set the line connecting the first and last text blocks to the text line direction of the previous line.

[0033] The above solution of the present application determines the text line direction of the previous line by obtaining the first and last two text blocks of the previous line, which facilitates determining the line direction of the adjacent line.

[0034] Optionally, in the method for extracting text lines from a document, the step of extracting text from the first text line based on the line marker text block of the first text line further comprises:

[0035] Adjacent text blocks are obtained. If the height difference or the position difference in the vertical direction between the two text blocks exceeds a predetermined range, it is determined that the two text blocks are not in the same row, and the text block obtained later is discarded.

[0036] The above scheme of the present application compares the acquired text blocks. If the error exceeds a predetermined range, the subsequently acquired text blocks are discarded, thereby improving recognition accuracy and reducing recognition errors.

[0037] Optionally, in the method for extracting text lines from a document, the step of extracting text from adjacent text lines based on the line marker text blocks of the adjacent text lines further comprises:

[0038] Determine whether the text line of the adjacent line has been extracted. If it has been extracted, obtain the line mark text block of the adjacent text line again and determine again. When the text line of the adjacent line has not been extracted, perform text line extraction.

[0039] The above-mentioned solution of the present application judges adjacent lines and extracts text lines when adjacent lines have not been extracted, thereby avoiding repeated extraction and improving the accuracy of text extraction.

[0040] On the other hand, the present application also discloses a system for extracting text lines from a document, which includes:

[0041] An image acquisition module, used for acquiring a document image;

[0042] A first line mark text block determination module is used to determine the first line mark text block of the document based on the document image;

[0043] The first line text extraction module is used to extract text from the first line of text based on the line mark text block of the first line;

[0044] An adjacent line mark text block acquisition module is used to acquire the adjacent line mark text block after the text extraction of the first line is completed;

[0045] An adjacent line text line extraction module is used to extract text from adjacent lines based on line marker text blocks of adjacent lines;

[0046] After the text extraction of the previous text line is completed, the adjacent line mark text block acquisition module again acquires the line mark text block of the next adjacent line, and the adjacent line text line extraction module performs text line extraction until all text lines are extracted.

[0047] The above scheme of the present application determines the row mark file block of the document image, and then extracts the text lines of the same row based on the row mark file block. After the extraction is completed, the row mark text blocks of the adjacent rows are obtained, and the text lines of the adjacent rows are extracted until all the text lines are extracted. The operation is simple and the recognition efficiency is high.

[0048] On the other hand, the present application also discloses a device for extracting text lines from a document, which includes a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and execute the method for extracting text lines from a document as described above.

[0049] On the other hand, the present application further discloses a storage medium, in which a computer program is stored that can be loaded by a processor and execute the method for extracting text lines from a document as described above.

[0050] In summary, the present application discloses a method, system, device and storage medium for extracting text lines in a document, wherein the method includes: acquiring a document image; determining the line marker text block of the first line of the document based on the document image; performing text extraction on the text line of the first line based on the line marker text block of the first line; after the text extraction of the text line of the first line is completed, acquiring the line marker text block of the adjacent line; performing text extraction on the text line of the adjacent line based on the line marker text block of the adjacent line; after the text extraction of the text line of the previous line is completed, acquiring the line marker text block of the next adjacent line and extracting the text line again, until all the text lines are extracted. Through the above-mentioned scheme of the present application, the text line extraction of the document can be accurately and efficiently realized, and the extraction process is simple and intuitive, and has strong applicability. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 It is a flowchart of the steps of the method for extracting text lines in a document described in this application. DETAILED DESCRIPTION

[0052] The present application is further described in detail below in conjunction with the accompanying drawings.

[0053] The present application embodiment discloses a method for extracting text lines from a document, referring to Figure 1 , is a flowchart of the steps of the method for extracting text lines from a document in this application. It includes:

[0054] Acquire document images;

[0055] Based on the document image, determine the line marker text block of the first line of the document;

[0056] Based on the line mark text block of the first line, extract the text of the first line;

[0057] After the text extraction of the first line is completed, the line mark text blocks of the adjacent lines are obtained;

[0058] Based on the line marking text blocks of the adjacent lines, text lines of the adjacent lines are extracted;

[0059] After the text extraction of the previous text line is completed, the line marker text block of the next adjacent line is obtained and the text line is extracted again until all the text lines are extracted.

[0060] In an embodiment of the present application, in order to realize text extraction of a document, a document image is obtained, which can be by photographing or scanning, and the document image is input. Based on the document image, the line marker text block of the first line is determined. When the present application is implemented, the first line will be determined from the top of the document downward by default. In actual operation, the method of determining the first line is not limited, and it can be the middle or the bottom. After determining the line marker text block of the first line, the line marker text block is extended to both sides to form line text. After the line text extraction is completed, the line marker text block of the adjacent line is obtained, and then the line text extraction of the adjacent line is performed, and the steps are repeated until all text lines are extracted.

[0061] After determining the line mark text block of the first line, the text line of the same line can be extracted based on the line mark text block. In the embodiment of the present application, specifically, the method for extracting text lines in a document, wherein the step of extracting text from the first line of text based on the line mark text block of the first line includes:

[0062] Based on the line mark text block, get the adjacent text block in the same line and set it as the current active text block;

[0063] Get the text blocks in the same row adjacent to the current active text block in the same direction as the previous one, and set them as the current active text block in sequence until there are no adjacent text blocks in the row text blocks in the same direction;

[0064] Based on the line mark text block, get the text block of the same line in the opposite direction of the previous time, set it as the current active text block, and set the adjacent text blocks as the current active text blocks in sequence until there are no adjacent text blocks in the line text blocks in the same direction.

[0065] In a preferred embodiment of the present application, when extracting the text line of the first line, the line mark text block is the leftmost text block, but in a specific implementation, the line mark text block is not necessarily the leftmost text block. After determining the line mark text block, based on the line mark text block, the adjacent text block located in the same line is obtained and set as the current active text block. The same line is defined as being in the same determined horizontal direction as the line mark text block and being adjacent. In a specific implementation, adjacent includes left adjacent and right adjacent. If the left side is adjacent, a text block adjacent to the left side is determined to be the current active text block, and the text block of the same line adjacent to the left side of the current active text block is obtained again, and is set as the current active text block again. The text blocks of the same line on the left are extracted in sequence until there is no text block on the left and the extraction of the text block on the left is completed. At this time, the line mark text block is returned, and the text blocks of the same line on the right are extracted again. In the same way as the extraction of the text block on the left, the text block adjacent to the right side is obtained and set as the current active text block. The text blocks adjacent to the right side are obtained again, and are extracted in sequence until the extraction of the text block on the right side is completed, thus completing the extraction of the text line of the entire line. In a preferred embodiment of the present application, the row mark text block is the leftmost text block. Therefore, when obtaining the adjacent text block on the left, if there is no adjacent text block on the left, then the adjacent text block on the right is obtained until the right text block is extracted. If the row mark text block is on the rightmost side, then all text blocks on the left are extracted. According to the specific position of the row mark text block, according to the adjacent text blocks, the text blocks on the same side are extracted first, and then the text blocks on the same side are extracted in the opposite direction until the entire row is extracted. In the embodiment of the present application, the steps for text line extraction of other rows are the same as those for text line extraction of the first row. The only difference is that the text line extraction of other rows requires the determination of the row mark text block. After the row mark text block is determined, the steps for extracting the same row are the same, so they will not be repeated here.

[0066] The aforementioned solution of the present application mentioned that the text blocks of all text lines are extracted by extracting adjacent text blocks. Therefore, in the embodiment of the present application, specifically, the method for extracting text lines in a document, wherein the step of obtaining adjacent text blocks of the same line includes:

[0067] Draw a ray in the vertical direction of the line marked text block or the currently active text block;

[0068] rotating the ray clockwise or counterclockwise;

[0069] Determine the first text block that the ray passes through in the direction of the current row during rotation, which is the row mark text block or the text block adjacent to the current active text block in the same row.

[0070] In an embodiment of the present application, in order to obtain adjacent text blocks of the same row, a row-marked text block or a currently active text block needs to be obtained. Therefore, a ray is drawn in the vertical direction of the row-marked text block or the currently active text block, and the ray is rotated. To determine the adjacent text block on the left, the ray is rotated counterclockwise. If it is necessary to determine the adjacent text block on the right, the ray is rotated clockwise. The first text block passed by the ray in the current row direction is the adjacent text block. The current row direction is roughly consistent with the text row direction of the previous row, and can be controlled within the error range.

[0071] The above scheme mentioned that after the first line of text is extracted, it is necessary to extract text lines of adjacent lines. In the embodiment of the present application, specifically, the method for extracting text lines in a document, wherein after the text extraction of the first line of text is completed, the step of obtaining the line mark text block of the adjacent line includes:

[0072] Use the previous line as the translation line and translate it in the vertical direction of the text line direction of the previous line;

[0073] If a text block exists in the translated row during the translation process, the first text block of the translated row is determined to be a row marker text block of an adjacent row.

[0074] In an embodiment of the present application, when extracting text lines of adjacent rows, the extraction steps are consistent with the first row extraction steps, the difference is that it is necessary to determine the row mark text block. In specific implementation, after the previous row extraction is completed, since the direction of the row is roughly the same as the previous direction, the text line that completed the text line extraction previously is used as the translation line, and is translated in a direction perpendicular to the text line direction of the previous row. For example, if the row direction is the standard horizontal direction, then the translation is performed in the vertical direction. During the translation process, it is determined whether there is a text block on the translation line. When there is a text block on the translation line, it indicates that the current translation line is an adjacent row, and then the first text block of the translation line is determined to be the row mark text block of the adjacent row. The first text block of the translation line is preferably the leftmost or rightmost text block. After the row mark text block is determined, the step of extracting the text line is consistent with the step of extracting the first row. When the next adjacent row is extracted, the row mark text block of the next row is obtained, and the process is repeated until all text lines are extracted.

[0075] The above scheme mentioned that the previous line is used as the translation line and the translation is performed in a direction perpendicular to the text line direction of the previous line. Therefore, in order to obtain the text direction of the previous line, in an embodiment of the present application, the method for extracting text lines in a document, wherein the previous line is used as the translation line and the step of performing the translation in a direction perpendicular to the text line direction of the previous line includes:

[0076] Get the first text block and the last text block of the previous line;

[0077] Set the line connecting the first and last text blocks to the text line direction of the previous line.

[0078] In the embodiment of the present application, the text line direction of the previous line is determined by obtaining the first and last text blocks of the previous line, which facilitates determining the line direction of the adjacent line.

[0079] When the present application is implemented, there may be typos in the document or interference factors in the recognition process, such as stains, or shadows in the photo scan, which may cause recognition interference. Therefore, the present application embodiment summarizes the method for extracting text lines in the document, wherein the step of extracting text from the first line of text based on the line mark text block of the first line also includes:

[0080] Adjacent text blocks are obtained. If the height difference or the position difference in the vertical direction between the two text blocks exceeds a predetermined range, it is determined that the two text blocks are not in the same row, and the text block obtained later is discarded.

[0081] In an embodiment of the present application, in order to reduce recognition errors, when extracting text lines from a document, if the difference between text blocks is small and within an error range, they are determined to be text blocks. If the difference between text blocks is outside the error range, the recognized text blocks need to be discarded to ensure recognition accuracy. Therefore, in a specific embodiment of the present application, adjacent text blocks are preferably compared. If the difference between adjacent text blocks is large, the text blocks obtained later are discarded. If the difference between the first text block and the second text block is large, and the difference between the first text block and the third text block is also large, the second text block and the third text block are compared to determine whether the first text block is an interference item, and the text block extraction accuracy of the entire document is determined.

[0082] The above scheme mentioned that after the text line extraction in the same line is completed, the text line extraction of the adjacent lines needs to be performed. In order to avoid repeated extraction, in the embodiment of the present application, the method for extracting text lines in a document, wherein the step of extracting text lines of the adjacent lines based on the line mark text blocks of the adjacent lines further includes:

[0083] Determine whether the text line of the adjacent line has been extracted. If it has been extracted, obtain the line mark text block of the adjacent text line again and determine again. When the text line of the adjacent line has not been extracted, perform text line extraction.

[0084] In an embodiment of the present application, in order to avoid repeated extraction, after one line of extraction is completed, the line marker text block of the adjacent line is obtained, and when extracting the next line of text, it is necessary to determine whether the next line of text has been extracted. If it has been extracted, the next line is skipped and subsequent text line extraction is performed to avoid repeated extraction and improve the accuracy of text line extraction.

[0085] In the specific embodiment of the present application, the overall operation process is illustrated by example:

[0086] Sets the current text line direction to completely horizontal. The first line has no other lines to refer to, so the text line direction is assumed to be completely horizontal.

[0087] All unprocessed text blocks are projected along the direction of the current text line, and the first text block encountered from top to bottom is selected as the current line marker text block.

[0088] The projection operation is equivalent to rotating the document to the horizontal direction of the current text line, and recursively expanding to the left and right to connect into lines starting from the current line mark text block. The methods of expansion to the left and right are the same, and only the expansion to the left is used as an example here. First, set the current line mark text block as the current active text block, and select the text block that is most likely to be in the same line and adjacent to the left side of the current active text block from the remaining text blocks. If it is indeed in the same line and adjacent to the left side, connect the text block to the leftmost of the current text line, and then set this text block as the current active text block. Repeat this operation until the condition is no longer met, and the current line is expanded to the left. After the expansion to the left and right is completed, the text blocks in the line are arranged in the order of connection, which is the order of the text blocks in the line.

[0089] Select the text block that is most likely to be in the same row as the current active text block and adjacent to the left side: draw a vertical upward ray from the current active text block, and the ray rotates clockwise or counterclockwise. The first text block encountered is the text block to be selected.

[0090] In the embodiment of the present application, the conditions for being in the same row and being adjacent on the left or right are: the height difference between the two text blocks is not greater than 2.0 times, and the position difference in the vertical direction of the text line is not greater than 0.5 times the average height of the two text blocks.

[0091] Update the direction of the current text line. Due to the deformation of the document and the perspective effect caused by shooting, the directions of all text lines are inconsistent, but the directions of two adjacent lines are basically close, so the direction of the previous line can be used to approximate the direction of the next line. The specific method is to calculate the direction of the line connecting the leftmost and rightmost text blocks of the current text line.

[0092] Repeat the line extraction step and the step of updating the current text line direction until all text blocks are extracted into lines.

[0093] The second embodiment of the present application, based on the above method, discloses a system for extracting text lines from a document, which includes:

[0094] An image acquisition module, used for acquiring a document image;

[0095] A first line mark text block determination module is used to determine the first line mark text block of the document based on the document image;

[0096] The first line text extraction module is used to extract text from the first line of text based on the line mark text block of the first line;

[0097] An adjacent line mark text block acquisition module is used to acquire the adjacent line mark text block after the text extraction of the first line is completed;

[0098] An adjacent line text line extraction module is used to extract text from adjacent lines based on line marker text blocks of adjacent lines;

[0099] After the text extraction of the previous text line is completed, the adjacent line mark text block acquisition module again acquires the line mark text block of the next adjacent line, and the adjacent line text line extraction module performs text line extraction until all text lines are extracted.

[0100] In the embodiments of the present application, the specific implementation of the system and each module is described in the method steps, and the functions and specific operation procedures correspond to those in the method, so they will not be repeated here.

[0101] On the other hand, the present application also discloses a device for extracting text lines from a document, which includes a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and execute the method for extracting text lines from a document as described above.

[0102] On the other hand, the present application further discloses a storage medium, in which a computer program is stored that can be loaded by a processor and execute the method for extracting text lines from a document as described above.

[0103] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0104] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0105] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0106] The embodiments of this specific implementation method are all preferred embodiments of the present application, and are not intended to limit the protection scope of the present application. Therefore, all equivalent changes made based on the structure, shape, and principle of the present application should be included in the protection scope of the present application.

Claims

1. A method for extracting text lines from a document, characterized in that: include: Acquire document images; Based on the document image, determine the line marker text block of the first line of the document; Based on the line mark text block of the first line, extract the text of the first line; After the text extraction of the first line is completed, the line mark text blocks of the adjacent lines are obtained; Based on the line marking text blocks of the adjacent lines, text lines of the adjacent lines are extracted; After the text extraction of the previous text line is completed, the line mark text block of the next adjacent line is obtained and the text line is extracted again until all the text lines are extracted; Based on the line mark text block of the first line, the steps of extracting text from the text line of the first line include: Based on the line mark text block, get the adjacent text block in the same line and set it as the current active text block; Get the text blocks in the same row adjacent to the current active text block in the same direction as the previous one, and set them as the current active text block in sequence until there are no adjacent text blocks in the row text blocks in the same direction; Based on the line mark text block, obtain the text block of the same line in the opposite direction of the previous time, set it as the current active text block, and set the adjacent text blocks as the current active text blocks in sequence until there are no adjacent text blocks in the line text blocks in the same direction; The steps of obtaining adjacent text blocks on the same line include: Draw a ray in the vertical direction of the line marked text block or the currently active text block; rotating the ray clockwise or counterclockwise; Determine the first text block that the ray passes through in the current row direction during the rotation process, which is the row mark text block or the text block adjacent to the current active text block in the same row.

2. The method for extracting text lines from a document according to claim 1, characterized in that: After the text extraction of the first text line is completed, the step of obtaining the line mark text block of the adjacent line includes: Use the previous line as the translation line and translate it in the vertical direction of the text line direction of the previous line; If a text block exists in the translated row during the translation process, the first text block of the translated row is determined to be a row marker text block of an adjacent row.

3. The method for extracting text lines from a document according to claim 2, characterized in that: The steps of using the previous line as the translation line and performing translation in a direction perpendicular to the text line direction of the previous line include: Get the first text block and the last text block of the previous line; Set the line connecting the first and last text blocks to the text line direction of the previous line.

4. The method for extracting text lines from a document according to claim 1, characterized in that: Based on the line mark text block of the first line, the step of extracting text from the text line of the first line also includes: Adjacent text blocks are obtained. If the height difference or the position difference in the vertical direction between the two text blocks exceeds a predetermined range, it is determined that the two text blocks are not in the same row, and the text block obtained later is discarded.

5. The method for extracting text lines from a document according to claim 1, characterized in that: Based on the line mark text blocks of the adjacent lines, the step of extracting text from the text lines of the adjacent lines also includes: Determine whether the text line of the adjacent line has been extracted. If it has been extracted, obtain the line mark text block of the adjacent text line again and determine again. When the text line of the adjacent line has not been extracted, perform text line extraction.

6. A system for extracting text lines from a document, characterized in that include: An image acquisition module, used for acquiring a document image; A first line mark text block determination module is used to determine the first line mark text block of the document based on the document image; The first line text extraction module is used to extract text from the first line of text based on the line mark text block of the first line; An adjacent line mark text block acquisition module is used to acquire the adjacent line mark text block after the text extraction of the first line is completed; An adjacent line text line extraction module is used to extract text from adjacent lines based on line marker text blocks of adjacent lines; After the text extraction of the previous text line is completed, the adjacent line mark text block acquisition module again acquires the line mark text block of the next adjacent line, and the adjacent line text line extraction module performs text line extraction until all text lines are extracted; The steps of obtaining adjacent text blocks on the same line include: Draw a ray in the vertical direction of the line marked text block or the currently active text block; rotating the ray clockwise or counterclockwise; Determine the first text block that the ray passes through in the current row direction during the rotation process, which is the row mark text block or the text block adjacent to the current active text block in the same row.

7. A device for extracting text lines from a document, characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program which can be loaded by the processor and execute the method for extracting text lines in a document as claimed in claims 1 to 5.

8. A storage medium, characterized in that: The computer program is stored which can be loaded by a processor and execute the method for extracting text lines in a document as claimed in claims 1 to 5.