Document layout analysis method based on deep learning and traditional algorithms

The document layout analysis method, which combines deep learning and traditional algorithms, solves the problem of low recognition efficiency when the document is unclear or distorted, and achieves high accuracy recognition under suboptimal conditions, thereby improving the speed of document passage on site.

CN117274972BActive Publication Date: 2024-08-27SHENZHEN MAXVISION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311560569.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-22
Publication Date
2024-08-27
Estimated Expiration
2043-11-22

AI Technical Summary

Technical Problem

Existing document layout analysis methods suffer from low recognition efficiency under conditions of insufficient light, poor image quality, or distortion, leading to failure in structured output. This is particularly true for driver's licenses and vehicle registration certificates printed on-site, which have poor recognition performance and affect traffic speed.

Method used

Combining deep learning and traditional algorithms, this method achieves accurate document location and structured output through document detection, region cropping, semantic segmentation, perspective transformation, and character recognition. This includes steps such as line detection, affine transformation, semantic segmentation, and character recognition, ensuring accurate identification of document content even in unclear or distorted conditions.

Benefits of technology

Even when the document photos are unclear or distorted, the system can accurately output structured recognition results, improving the recognition accuracy of driver's licenses and vehicle registration certificates and increasing the speed of passage for drivers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117274972B
    Figure CN117274972B
Patent Text Reader

Abstract

The present invention discloses a document layout analysis method based on deep learning and traditional algorithms, comprising the following steps: performing document detection on a collected image to obtain a document area and a photo area with an inclination angle; cropping the document area with the inclination angle, and straightening the document area, and the straightening result is divided into an upright document area and an inverted document area; performing semantic segmentation on text lines to obtain all text line coordinate information on the document; comparing the detected text line results with character recognition results to confirm the document type and the inverted and upright information of the document; performing perspective transformation on the document area to achieve document alignment; on the aligned to-be-matched picture, extracting a preset area to be identified, and performing area intersection and union ratio calculation with all text line results to obtain a structured text line result; using a deep learning algorithm crnn to perform character recognition on the structured text line result, and outputting a structured full-page recognition result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of certificate recognition, and in particular to a certificate layout analysis method based on deep learning and traditional algorithms. Background Art

[0002] Most of the existing document layout analysis methods are text detection and text recognition methods based on deep learning. After collecting the document image, the recognition area is intercepted through template matching for text recognition. However, the above schemes are often limited by the usage scenarios, such as insufficient shooting light source and poor imaging quality, which affect the recognition results, resulting in the structured output recognition information cannot be recognized and the document inspection fails. For example, when the captured image is distorted, the document verification yield is low when the deep learning-based layout analysis algorithm is used. For example, when applied to on-site printed documents such as driver's licenses and vehicle registration certificates, the printed text easily crosses the boundary, and the existing document layout analysis methods are not efficient in recognizing such documents, and cannot achieve rapid release of on-site vehicles. Summary of the invention

[0003] One purpose of the present invention is to provide a method for analyzing the layout of a certificate based on deep learning and traditional algorithms. Through deep learning and traditional algorithms, the layout of the certificate is analyzed, the character area is accurately identified, and the structured output is more accurate. When the certificate is not taken clearly or there is distortion, the recognition result can still be accurately structured and output. The improved accuracy is also beneficial to improving the driving speed.

[0004] Other advantages and features of the present invention will become more apparent from the following detailed description and may be realized by means of the instrumentalities and combinations particularly pointed out in the appended claims.

[0005] According to one aspect of the present invention, a document layout analysis method based on deep learning and traditional algorithms of the present invention, which can achieve the aforementioned purpose and other purposes and advantages, comprises the following steps:

[0006] Step (A): performing document detection on the collected image to obtain the document area and photo area with tilt angles;

[0007] Step (B): cutting out the document area with a tilted angle, and straightening the document area. The straightening result is divided into an upright document area and an inverted document area;

[0008] Step (C): semantically segment the text lines to obtain the coordinate information of all text lines on the document;

[0009] Step (D): Compare the detected text line results with the character recognition results to confirm the document type and the document inversion information;

[0010] Step (E): Perform perspective transformation on the document area to achieve document alignment;

[0011] Step (F): on the aligned image to be matched, extract the preset area to be identified, calculate the intersection and union ratio of the area with all the text line results, and obtain the structured text line results;

[0012] Step (G): For the structured text line results, use the deep learning algorithm crnn to perform character recognition and output the full-page recognition results in a structured manner.

[0013] According to an embodiment of the present invention, the step (B) includes a sub-step (B1): performing straight line detection on the straightened document area, and achieving fine adjustment of the angle of the document area by adjusting the angle of the straight line.

[0014] According to an embodiment of the present invention, the step (B) includes a sub-step (B2): using the four corner points of the document area obtained by document detection to straighten the document area, and then using an affine transformation algorithm to straighten the document area.

[0015] According to one embodiment of the present invention, the step (B) further includes a sub-step (B3): using the sauvola binarization method to obtain a text area, using an erosion and dilation algorithm to remove small noise pixels in the binary image and fill in small holes of characters in the image to make the characters more complete, and using Hough line detection to obtain all line detection results.

[0016] According to one embodiment of the present invention, the step (C) includes sub-steps: using a semantic segmentation algorithm network structure during training, removing the segmentation branch during reasoning, and detecting whether the result of the text line meets the preset conditions of this solution.

[0017] According to one embodiment of the present invention, the step (D) includes a sub-step (D1): sorting the text lines from wide to narrow according to the external frames of the text lines, taking the first n text line results, and using a character recognition algorithm to perform character recognition on the top n text lines, where n is a preset value.

[0018] According to one embodiment of the present invention, the step (D) includes a sub-step (D2): when comparing the character recognition results, if the character recognition results do not match the desired results, then in combination with the vertical axis coordinates of the text line, the text line area is flipped 180 degrees and recognized again, and then matched with the target field to verify the document type.

[0019] According to one embodiment of the present invention, the step (E) includes a sub-step (E1): obtaining the first n narrowest text line areas from the sorting results in the step (D), sending them into a character recognition model for character recognition, obtaining a key area, the coordinate points of the key area correspond to the coordinates in the template library, and performing a perspective transformation of the document area.

[0020] According to one embodiment of the present invention, the step (E) includes a sub-step (E2): sorting the text line recognition results by text area width, obtaining the first n narrowest text line areas, extracting the coordinates of the largest quadrilateral covering these areas, corresponding them to the coordinates in the known template library, performing perspective transformation, stretching the image to be matched, and aligning it with the image in the template library. In this process, a restriction condition is set. If the coordinates of the largest quadrilateral do not reach half of the entire document area, the perspective transformation is abandoned and the next step is directly entered.

[0021] According to one embodiment of the present invention, step (F) includes the sub-steps of: calculating the area intersection ratio using the coordinates of the area to be identified and the coordinate area of ​​the text line, setting a threshold, and if the threshold is met, confirming that the text line is the text content of the area to be identified; otherwise, there is no text content to be identified in the area to be identified.

[0022] The beneficial effects of the present invention are: based on the advantages of deep learning, traditional algorithms are integrated to perform layout analysis on certificates, accurately identify character areas, and make structured output more accurate. When the certificate is not taken clearly or is distorted, the recognition result can still be accurately structured and output. The certificate information in the database can be compared to check for false certificates and expired certificates. Especially for on-site printed certificates such as driver's licenses and vehicle registration certificates, the improved accuracy is also beneficial to improving the speed of travel for drivers. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 This is a flowchart of the steps of a method for analyzing a certificate layout based on deep learning and traditional algorithms according to an embodiment of the present invention.

[0024] Figure 2 This is a flow chart of the algorithm steps of the document layout analysis method based on deep learning and traditional algorithms in the above-mentioned embodiment of the present invention.

[0025] Figure 3 Schematic diagram of the tilt angle of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0026] Figure 4 This is a detailed step flow chart of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0027] Figure 5 This is an algorithm framework diagram of the document layout analysis method based on deep learning and traditional algorithms in the above-mentioned embodiment of the present invention.

[0028] Figure 6 This is an algorithm framework diagram of the document layout analysis method based on deep learning and traditional algorithms in the above-mentioned embodiment of the present invention.

[0029] Figure 7 This is a detailed step flow chart of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0030] Figure 8 This is a detailed step flow chart of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0031] Fig. 9 Schematic diagram of perspective transformation of a driver's license according to the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0032] Fig.10 It is a schematic diagram of the process of perspective transformation of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention.

[0033] Fig.11 Schematic diagram of calculation of area intersection ratio of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention. Implementation

[0034] The following description is used to disclose the present invention so that those skilled in the art can implement the present invention. The preferred embodiments described below are only examples, and those skilled in the art can think of other obvious variations. The basic principles of the present invention defined in the following description can be applied to other embodiments, variations, improvements, equivalents, and other technical solutions that do not deviate from the spirit and scope of the present invention.

[0035] Those skilled in the art should understand that, in the disclosure of the present invention, the terms "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicating the orientation or position relationship are based on the orientation or position relationship shown in the drawings, which are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the above terms should not be understood as limiting the present invention.

[0036] It is understood that the term "one" should be understood as "at least one" or "one or more", that is, in one embodiment, the number of an element can be one, while in another embodiment, the number of the element can be multiple, and the term "one" cannot be understood as a limitation on the number. In addition, in the description of the present invention, unless otherwise specified, the meaning of "multiple" is two or more than two.

[0037] In the description of the present invention, it should be understood that "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through a medium. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0038] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0039] like Figures 1 to 11 As shown, a document layout analysis method based on deep learning and traditional algorithms according to an embodiment of the present invention is disclosed. Specifically, Figure 1 As shown, the document layout analysis method based on deep learning and traditional algorithms includes the following steps:

[0040] 1) Capture the document image through an imaging device, which can be but not limited to a mobile phone or a camera terminal;

[0041] 2) Use deep learning algorithms to perform document area detection and photo area detection on document images;

[0042] 3) Extract the document area and use traditional image processing to detect the straight lines on the page in the document area, and then use affine transformation to straighten the image;

[0043] 4) Use semantic segmentation algorithm on the rectified image to segment the text lines of the document image;

[0044] 5) Perform character recognition on the segmented text lines, verify the document type, perform perspective transformation on the document image, stretch the document area, and match it with the template in the document library;

[0045] 6) Select key text line areas and conduct layout analysis of the document;

[0046] 7) For the certificate that has completed the layout analysis, the preset recognition area is extracted, and the intersection area is calculated based on the detection results of the extracted area and the segmented text line, and the text line of the intersection area is found as the text line of the area to be recognized;

[0047] 8) Identify the text lines in the area to be identified and output the recognition results in a structured manner.

[0048] like Figure 2 FIG. 1 is a flowchart of the algorithm steps of the document layout analysis method based on deep learning and traditional algorithms in the above embodiment of the present invention, and the steps are as follows:

[0049] Step 1: Perform document detection on the collected image to obtain the document area and photo area with tilt angles. In detail, the conventional algorithm structure of deep learning includes four parts: backbone, neck, head and loss function. The functions of backbone, neck and head are to obtain image features, fuse image features, and predict results respectively. The loss function is used during training and removed during inference. The function is to optimize the algorithm learning ability so that the algorithm obtains the best parameters. Preferably, the document detection algorithm of this step of the scheme can be but not limited to using yolov5-obb. The algorithm network structure of backbone and neck uses the algorithm backbone in conventional yolov5. The angle prediction of the yolov5-obb algorithm uses the idea of ​​classification to separate the prediction of the angle from the side length of the document target. In the prediction result of the angle of the document that is approximately square, the predicted angle is more accurate (in actual use, the angle may still have deviations, which will be further optimized in the subsequent algorithm steps). When the angle is transformed into a classification problem, the number of parameters that each anchor (i.e., the anchor point used to predict the angle) is responsible for predicting is: (x_c, y_c, longside, shortside, score) + target category number (2 categories) + angle category number = 97, where the angle category number is 0≤θ<90°, a total of 90 categories; different from the conventional 180 categories, since the number of categories is reduced by half, the number of parameters can be reduced by nearly half, where the number of target categories: 3 categories, namely driver's license, vehicle registration and photo area, x_c, y_c are the x-coordinate and y-coordinate of the target center point, longside is the long side of the target, shortside is the short side of the target, and score is the category confidence;

[0050] Step 2: Cut out the document area with a tilted angle and straighten the document area. The straightening result is divided into an upright document area and an inverted document area. In detail, this step mainly uses the four corner points of the document area obtained by document detection to straighten the document area, and then uses the affine transformation algorithm. Affine transformation refers to the transformation of two vector spaces. Assume there is a vector space k:

[0051] ,

[0052] and another vector space j:

[0053] ,

[0054] Among them, the vector space k becomes j, which can be achieved by the following formula:

[0055] ,

[0056] Splitting the above formula yields:

[0057] ,

[0058] Convert the above equation to matrix multiplication:

[0059] ,

[0060] The above formula realizes the conversion of two vector spaces through a two-row and three-column matrix M. The matrix M is used to rotate the document area to be matched to the target area, so that the document area is straightened and not tilted. In detail, the specific implementation steps of the straightening process are: use the line connecting the upper left vertex (x0, y0) and the upper right vertex (x1, y1) of the document area quadrilateral, assuming it is l. The process of rotating l to the horizontal direction is the process of changing the coordinates (x1, y1) to (x1', y1'). The angle θ needs to be calculated, such as Figure 3 As shown, the angle θ is Figure 3 The position of the punctuation mark,

[0061] Among them, the calculation formula of angle θ is:

[0062] ,

[0063] Among them, the new size of the rotated image is calculated by the angle θ :

[0064] ,

[0065] Among them, the size of the original image , get the affine transformation matrix through the opencv function getRotationMatrix2D , and add translation operation to prevent some pixels in the document area from leaking out of the original image,

[0066] ,

[0067] By adding the translation operation to the above formula, the original image is rotated and completely falls into the image, and the affine transformation matrix is ​​obtained. , the image after affine transformation is obtained through the opencv function warpAffine;

[0068] Step 3: Perform straight line detection on the straightened document area, and adjust the angle of the straight line to achieve micro-adjustment of the document area angle. In detail, this step is based on the characteristics of the document itself, that is, there are long dashed lines in the document pages of the driver's license and vehicle registration, so as to further adjust the tilt of the document to meet the subsequent text detection, such as Figure 4As shown, first, the sauvola binarization method is used. This binarization method is a binarization method that considers the local mean brightness and can better obtain the text area. The implementation of the algorithm is as follows: the grayscale mean m(x, y) and standard deviation S(x, y) in the area r*r are calculated.

[0069] ,

[0070] ,

[0071] Among them, the threshold T(x,y) of the sauvola binarization algorithm at the pixel point (x,y) is

[0072] ,

[0073] where R is the dynamic range of the standard deviation; k∈(0,1),

[0074] Secondly, the erosion and expansion algorithm is used, where the erosion operator is defined as follows:

[0075] ,

[0076] in, represents the method of corroding the sub-element x from the set X by the structural element B, min represents the minimum value, XB represents the value of x in the structural element B, and the erosion operator is used to remove small noise pixels in the binary image. The definition formula of the dilation operator is as follows:

[0077] ,

[0078] in, represents the expansion operation process of the structural element B on the sub-element x of the set X, max represents the maximum value, XB represents the value of x in the structural element B, and the expansion operator is used to fill the small holes of the characters in the image to make the characters more complete, where the bitwise AND is:

[0079] ,

[0080] & represents AND. In image processing, when the pixel values ​​are all 255, the result pixel value is 255, otherwise the result pixel value is 0.

[0081] Where bitwise XOR:

[0082] ,

[0083] ^ represents XOR. In image processing, when two XOR pixel values ​​are the same, the resulting pixel value is 0, otherwise the resulting pixel value is 255.

[0084] Again, using Hough line detection, the straight line equation in the Cartesian coordinate system is converted to the polar coordinate system, and the coordinate points of each pixel are substituted into the obtained equation to obtain the corresponding straight line parameters. This method can be implemented using the HoughLinesP function to obtain all straight line detection results;

[0085] Step 4: Perform semantic segmentation on the text lines to obtain the coordinate information of all the text lines on the document. This can be, but is not limited to, using the deep learning algorithm yolov8. Specifically, this step is used to predict the position of all lines of text in the document area. This step uses the semantic segmentation algorithm network structure during training. The segmentation branch is to learn image features more accurately. In this solution, the segmentation branch is removed during algorithm reasoning. This operation can effectively reduce the parameter calculation of the algorithm operation and can detect whether the result of the text line meets the preset conditions of this solution, such as the preset condition of the document area being aligned to a certain degree, such as Figure 5 As shown in the figure, this is the algorithm framework diagram of this step during training. Figure 6 As shown in the figure, it is the algorithm framework diagram of this step in the test. The characteristics of this step are: semantic segmentation image features are added during algorithm training to enrich the extracted image feature information. In this solution, since there is no curved text and the document area is the document area after being straightened, only the bounding box of all text lines needs to be obtained. Therefore, when testing the results of obtaining text lines, only the bounding box of target detection is used to obtain the position of the text line, and the results of semantic segmentation are not needed. This processing effectively improves the running speed and test accuracy of the algorithm.

[0086] Step 5: Sort the detected text line results from wide to narrow according to the text line bounding box, take the first n text line results, and then use the character recognition algorithm to perform character recognition on the top n text lines, compare the character recognition results, and confirm the document type and the information of the document inversion. In detail, this step is used to confirm the inversion of the document and the document type again, to avoid subsequent recognition errors due to errors in the document type in the document detection results, and improve the accuracy of document recognition, such as Figure 7As shown, it is the algorithm flow chart of this step. The specific operation is as follows: sort the detected text line results according to the width of the text line. The sorting rule is to sort from the widest to the narrowest. Take the first n text line results, and then use the character recognition algorithm to perform character recognition on the text lines sorted in the top n, and compare the character recognition results. If the character recognition result does not match the desired result, then combine the vertical axis coordinate of the text line, flip the text line area 180 degrees and recognize it again, and then match it with the target field. For example, the target field in the driver's license can be but not limited to xxx certificate, and the target field in the vehicle registration certificate can be but not limited to xxx certificate, etc., so as to verify the certificate type, confirm the certificate area of ​​the confirmed certificate type inverted, straighten the certificate area, and organize the text line detection results, record the text lines that have been character recognized, preferably, in the recognition of the driver's license and the vehicle registration certificate, n=3;

[0087] Step 6: Obtain the first n narrowest text line areas from the sorting results in step 5, send them to the character recognition model for character recognition, obtain the key area, and perform perspective transformation on the document area. Specifically, Figure 8 As shown, it is the algorithm flow chart of this step. The specific operation is as follows: the text line recognition results are sorted by the width of the text area to obtain the first n narrowest text line areas, which are sent to the character recognition model for character recognition. Through the known areas obtained, such as the "xxx certificate", "name" and "validity period" areas in the driver's license, the "xxx certificate", "license plate number", "registration date" and "issue date" in the vehicle registration certificate, the coordinates of the largest quadrilateral covering these areas are extracted, and the coordinates are corresponding to the coordinates in the known template library. The image to be matched is stretched and aligned with the image in the template library. A restriction condition is set in this process. If the coordinates of the largest quadrilateral do not reach half of the entire certificate area, the perspective transformation is abandoned and the next step is directly entered. Preferably, in the recognition of the driver's license and the vehicle registration certificate, n=20. Further, the specific steps of the perspective transformation are as follows. Taking the perspective transformation of the driver's license as an example, Fig. 9 As shown in FIG. 1 , it is a schematic diagram of the perspective transformation process. In the figure, the card detection algorithm, the text line detection algorithm and the character recognition algorithm are used to obtain the perspective change of the "xxx ID", "name", "validity period" and the photo area. The upper right vertex of the "xxx ID", the upper left vertex of the "name", the lower left vertex of the "validity period" and the lower right vertex of the face photo area are taken for perspective transformation. Further, as shown in FIG. Fig.10As shown in the figure, it is a schematic diagram of the perspective transformation process. For the perspective transformation coordinate points (x0, y0), (x1, y1), (x2, y2), (x3, y3), and the target coordinate points (x0', y0'), (x1', y1'), (x2', y2'), (x3', y3'), the getPerspectiveTransform algorithm in opencv is used to obtain the perspective transformation matrix, and the warpPerspective transformation is used to obtain the result image after the perspective transformation.

[0088] Step 7: On the aligned image to be matched, extract the preset area to be identified, calculate the intersection and union ratio of the area with all text line results, and obtain the structured text line result. In detail, this step is used to accurately obtain the text line result of the area to be identified. The specific acquisition process is as follows: the coordinates of the area to be identified and the coordinate area of ​​the text line are used to calculate the intersection and union ratio of the area, and a threshold γ is set. If the threshold is met, it is confirmed that the text line is the text content of the area to be identified. Otherwise, there is no text content to be identified in the area to be identified. Further, Fig.11 As shown in the figure, it is a schematic diagram for calculating the area intersection ratio, where the overlapping area m is the overlapping area of ​​the preset recognition area a and the text line bounding box b. The calculation formula is as follows

[0089] ,

[0090] If ratio>γ, it is sent to the character recognition model for subsequent processing, otherwise there is no content to be recognized in the preset recognition area;

[0091] Step 8: For the structured text line results, use the deep learning algorithm crnn to perform character recognition and output the full-page recognition results in a structured manner.

Claims

1. A document layout analysis method based on deep learning, characterized in that: The following steps are involved: Step (A): performing document detection on the collected image to obtain the document area and face area with tilt angles; Step (B): Cut out the document area with the tilt angle, and straighten the document area. The straightening result is divided into an upright document area and an inverted document area. The straight line detection is performed on the straightened document area, and the angle of the document area is finely adjusted by adjusting the angle of the straight line. Step (C): semantically segment the text lines to obtain the coordinate information of all text lines on the document; Step (D): sort the detected text line results from wide to narrow according to the text line bounding box, take the first n text line results, use the character recognition algorithm to perform character recognition on the top n text lines, where n is a preset value, compare the character recognition results, and confirm the document type and the information of the document being inverted or upright; Step (E): Perform perspective transformation of the document area to achieve document alignment; Step (F): on the aligned image to be matched, extract the preset area to be identified, calculate the intersection and union ratio of the area with all the text line results, and obtain the structured text line results; Step (G): For the structured text line results, use the deep learning algorithm crnn to perform character recognition and output the full-page recognition results in a structured manner.

2. The document layout analysis method according to claim 1, characterized in that: The step (B) includes a sub-step (B2): using the four corner points of the document area obtained by document detection, and then using an affine transformation algorithm to straighten the document area.

3. The document layout analysis method according to claim 2, characterized in that: The step (B) also includes a sub-step (B3): using the sauvola binarization method to obtain a text area, using an erosion and expansion algorithm to remove small noise pixels in the binary image and fill small holes in the characters in the image to make the characters more complete, and using Hough line detection to obtain all line detection results.

4. The document layout analysis method according to claim 3, characterized in that: The step (C) includes sub-steps: using a semantic segmentation algorithm network structure during training, removing the segmentation branch during reasoning, and detecting whether the result of the text line meets a preset condition.

5. The document layout analysis method according to claim 4, characterized in that: The step (D) includes a sub-step (D2): when comparing the character recognition results, if the character recognition results do not match the target field, then in combination with the vertical axis coordinate of the text line, the text line area is flipped 180 degrees and recognized again, and then matched with the target field to verify the document type.

6. The document layout analysis method according to claim 5, characterized in that: The step (E) includes a sub-step (E1): obtaining the first n narrowest text line areas from the sorting results in the step (D), sending them to a character recognition model for character recognition, obtaining key areas, matching the coordinate points of the key areas with the coordinates in the template library, and performing perspective transformation of the document area.

7. The document layout analysis method according to claim 6, characterized in that: The step (E) includes a sub-step (E2): sorting the text line results by text area width, obtaining the first n narrowest text line areas, extracting the coordinates of the largest quadrilateral covering these areas, corresponding them to the coordinates in the known template library, performing perspective transformation, stretching the image to be matched, and aligning it with the image in the template library. In this process, a restriction condition is set. If the coordinates of the largest quadrilateral do not reach half of the entire document area, the perspective transformation is abandoned and the next step is directly entered.

8. The document layout analysis method according to claim 7, characterized in that: The step (F) includes the sub-steps of calculating the area intersection ratio using the coordinates of the area to be identified and the coordinate area of ​​the text line, setting a threshold, and if the threshold is met, confirming that the text line is the text content of the area to be identified; otherwise, there is no text content to be identified in the area to be identified.