Method for correcting curved text lines in contract documents

By performing text detection and curve fitting on text images, the complexity and cost of curved text correction in the prior art are solved, and simple and effective text correction and OCR recognition are improved, which is suitable for multiple text image scenarios. .

CN113989298BActive Publication Date: 2024-12-24SHENZHEN QIANHAI HUANRONG LIANYI INFORMATION TECHNOLOGY SERVICES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111250594.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2024-12-24
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

The prior art is difficult to effectively handle the curved text correction of structural document text, the accumulation of single-character detection errors has a great impact, and the model-based method is costly and complex, so it is impossible to describe the learned mapping content significance.

Method used

By performing text detection on the text image, obtaining the minimum external rectangle, determining whether the connecting area needs to be processed, calculating the overlap ratio of the number of pixels and area, performing curve fitting and inflection point correction, determining whether correction is needed based on the curve slope change, and Correct the text box and output the corrected text image.

Benefits of technology

It realizes simple and effective correction of curved text, reduces the possibility of normal text deformation due to correction, improves the recovery effect of document text, and improves the accuracy of OCR recognition. It is suitable for multiple text image scenes, with relatively high quality Strong versatility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113989298B_ABST
    Figure CN113989298B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of contract documents, and in particular to a method for correcting curved text lines in contract documents, comprising the following steps: step S1: performing text detection on a text image to obtain a segmented binary image of the text image; step S2: traversing connected areas in the binary image to obtain a minimum circumscribed rectangle; step S3: judging whether all connected areas in the binary image have been processed, if yes, directly jumping to step S9, if no, entering the next step; step S4: calculating the actual overlap ratio between the number of pixel points in the connected area and the area of ​​the circumscribed rectangle, setting an overlap ratio threshold, comparing the overlap ratio threshold with the actual overlap ratio, if the actual overlap ratio is greater than the overlap ratio threshold, entering the next step, if no, returning to step S3; step S5: performing curve fitting on the connected area and obtaining the inflection point of the curve; step S6: correcting the inflection point.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to the technical field of contract documents, and in particular to a method for correcting curved text lines in contract documents. [Background technology]

[0002] The existing curved text processing is generally aimed at processing curved text in specific scenarios and cannot process structured document text. For the correction of curved text in specific scenarios, it is necessary to detect the position of each character and some clustering algorithm fitting curves. The operation is complicated and depends on the cumulative error of the detection algorithm of a single character. Single character detection is prone to detection errors due to its small features. At the same time, if it is a document structured text line, the clustering fitting text curve is prone to serialization, which greatly affects the final correction result. At present, there are very mature text line detection algorithms with very high detection accuracy, so this single character detection error accumulation can be greatly avoided. The model-based method requires the construction of a data set and the design of a network model for training. The cost is relatively high, the network is relatively complex, and it is impossible to describe the meaning of the learned mapping content.

[0003] Therefore, the prior art is insufficient and needs to be improved. [Summary of the invention]

[0004] In order to overcome the above technical problems, the present invention provides a method for correcting curved text lines in a contract document.

[0005] The solution to the technical problem provided by the present invention is to provide a method for correcting curved text lines in a contract document, comprising the following steps:

[0006] Step S1: Perform text detection on the text image to obtain a binary image after segmentation of the text image;

[0007] Step S2: traverse the connected areas in the binary graph and find the minimum circumscribed rectangle;

[0008] Step S3: Determine whether all connected areas in the binary graph have been processed. If yes, directly jump to step S9; if no, go to the next step;

[0009] Step S4: Calculate the actual overlap ratio between the number of pixels in the connected region and the area of ​​the circumscribed rectangle, set an overlap ratio threshold, and compare the overlap ratio threshold with the actual overlap ratio. If the actual overlap ratio is greater than the overlap ratio threshold, proceed to the next step; otherwise, return to step S3.

[0010] Step S5: performing curve fitting on the connected area and obtaining the inflection point of the curve;

[0011] Step S6: correcting the inflection point;

[0012] Step S7: On multiple detection frames of the same text line, the arc length of each curve segment is calculated with the inflection point, and whether the text frame needs correction is determined according to the change of the curve slope. If yes, proceed to the next step, otherwise, directly jump to step S9;

[0013] Step S8: Correct the text box;

[0014] Step S9: Output the corrected text image.

[0015] Preferably, in step S1, a segmentation-based psenet text detection algorithm is used to perform text detection.

[0016] Preferably, in step S5, an array of pixel centers arranged from left to right in the connected region is obtained, and the array is fitted using the least squares method.

[0017] Preferably, in step S5, the inflection point of the curve is a segmentation point of the text line.

[0018] Preferably, in step S6, the binary image is mapped to the text image, the segmentation points are corrected, the text lines are vertically projected, and the character separators are found as the final segmentation points.

[0019] Preferably, in step S8, the target text image is redefined so that its height is the height of the minimum circumscribed rectangle of the segmentation curve, and its width is the arc length of the curve.

[0020] Compared with the prior art, the method for correcting curved text lines in contract documents of the present invention has the following advantages:

[0021] Through the method of the present invention, the curved samples can be corrected on the segmentation map, and only the curved text is processed, which effectively reduces the possibility of normal text being deformed due to correction, and thus helps to restore the corrected text lines. The operation process is relatively simple, and there is no need to build a model for learning and training. The correction effect is better, and there is no need to perform single-character segmentation, which avoids dependence on text content and helps to restore the document text. At the same time, the better text correction results are also beneficial to improving the accuracy of OCR recognition. It is suitable for multiple text image scenarios and has strong versatility.

Brief Description of the Drawings

[0022] Figure 1 It is a specific flow chart of the method for correcting curved text lines in contract documents according to the present invention. [Specific implementation method]

[0023] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and implementation examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0024] See also Figure 1 The present invention provides a method for correcting curved text lines in a contract document, comprising the following steps:

[0025] Step S1: Perform text detection on the text image to obtain a binary image of the segmented text image.

[0026] Specifically, in step S1, the segmentation-based PSENET text detection algorithm is used to perform text detection to obtain a segmented binary image of the entire text image. Among them, the segmentation-based text detection algorithm is the basic model of the binary segmentation image of the text image. This detection method directly affects the positioning of the text box and affects the positioning of the text box in the later stage, so it is necessary to train a text detection model. The text detection model uses the PSENET network structure, and the sample annotation uses the annotation format of CTW1500, and 14 surface annotation points of the text box are input. PSENET adopts a segmentation-based approach, but predicts different kernel sizes for text lines, and then uses a progressive expansion algorithm to expand the small-scale kernel to the final text line size. Because there is a relatively large margin between small-scale kernels, it is possible to distinguish adjacent text lines well, and finally output the segmented binary image.

[0027] Furthermore, step S2: traverse the connected areas in the binary graph to find the minimum circumscribed rectangle.

[0028] In the binary graph obtained after text detection, each connected graph represents the location of the text line, so the minimum bounding rectangle is calculated for the connected areas of the binary graph of the text image.

[0029] Further, step S3: determine whether all connected areas in the binary graph have been processed, if yes, directly jump to step S9, if no, go to the next step;

[0030] Step S4: Calculate the actual overlap ratio between the number of pixels in the connected area and the area of ​​the circumscribed rectangle, set an overlap ratio threshold, and compare the overlap ratio threshold with the actual overlap ratio. If the actual overlap ratio is greater than the overlap ratio threshold, proceed to the next step; otherwise, return to step S3.

[0031] By comparing the actual overlap ratio with the overlap ratio threshold, it is determined whether the image is a curved sample. When the actual overlap ratio is less than the overlap ratio threshold, the image of the current connected area is considered to be a curved sample, and text box segmentation is required to increase the actual overlap ratio.

[0032] Furthermore, step S5: performing curve fitting on the connected area and obtaining the inflection point of the curve.

[0033] Specifically, in step S5, the center array of pixels arranged from left to right in the connected area is obtained, and the array is fitted by the least square method, and the inflection point of the curve is obtained. The specific fitting process is: the fitting area is selected according to the principle of minimum sum of square deviations, and the following equation is used to achieve the minimum sum of square deviations.

[0034]

[0035] It can be understood that the inflection point of the curve in the present invention is the segmentation point of the text line.

[0036] Furthermore, step S6: correcting the inflection point.

[0037] Specifically, in step S6, the binary image is mapped to the text image, the segmentation points are corrected, the text lines are vertically projected, and the character separators are found as the final segmentation points so that the segmented rectangular frame does not contain text, and falls on the blank separators to ensure that the characters will not be at least partially segmented.

[0038] Further, step S7: on multiple detection boxes of the same line of text, calculate the arc length of each curve segment with the inflection point, and judge whether the text box needs to be corrected according to the change of the slope of the curve. If yes, go to the next step, otherwise, jump directly to step S9.

[0039] Step S8: Correct the text box.

[0040] Correct the text box that needs to be corrected. Specifically, redefine the target text image so that its height is the height of the minimum circumscribed rectangle of the segmentation curve, and its width is the arc length of the curve. The original text image is the minimum circumscribed rectangle and corrected to the target image. The pixel points of the original text image are mapped to the target image through bilinear interpolation.

[0041] Step S9: Output the corrected text image.

[0042] By using the method of the present invention, the curved text is corrected, the deformed curved text is restored, and the final result is corrected at the same time to restore the text data of the contract document, which is beneficial to improving the OCR recognition rate.

[0043] Compared with the prior art, the method for correcting curved text lines in contract documents of the present invention has the following advantages:

[0044] Through the method of the present invention, the curved samples can be corrected on the segmentation map, and only the curved text is processed, which effectively reduces the possibility of normal text being deformed due to correction, and thus helps to restore the corrected text lines. The operation process is relatively simple, and there is no need to build a model for learning and training. The correction effect is better, and there is no need to perform single-character segmentation, which avoids dependence on text content and helps to restore the document text. At the same time, the better text correction results are also beneficial to improving the accuracy of OCR recognition. It is suitable for multiple text image scenarios and has strong versatility.

[0045] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any modifications, equivalent substitutions and improvements made within the concept of the present invention should be included in the patent protection scope of the present invention.

Claims

1. A method for correcting curved text lines in a contract document, characterized in that: The method for correcting curved text lines in a contract document comprises the following steps: Step S1: Perform text detection on the text image to obtain a binary image after segmentation of the text image; Step S2: traverse the connected areas in the binary graph and find the minimum circumscribed rectangle; Step S3: Determine whether all connected areas in the binary graph have been processed. If yes, directly jump to step S9; if no, go to the next step; Step S4: Calculate the actual overlap ratio between the number of pixels in the connected region and the area of ​​the circumscribed rectangle, set an overlap ratio threshold, and compare the overlap ratio threshold with the actual overlap ratio. If the actual overlap ratio is greater than the overlap ratio threshold, proceed to the next step; otherwise, return to step S3. Step S5: performing curve fitting on the connected area and obtaining the inflection point of the curve; Step S6: correcting the inflection point; Step S7: On multiple detection frames of the same text line, the arc length of each curve segment is calculated with the inflection point, and whether the text frame needs correction is determined according to the change of the curve slope. If yes, proceed to the next step, otherwise, directly jump to step S9; Step S8: Correct the text box; Step S9: Output the corrected text image.

2. The method for correcting curved text lines in a contract document according to claim 1, characterized in that: In step S1, text detection is performed using a segmentation-based Psenet text detection algorithm.

3. The method for correcting curved text lines in a contract document according to claim 1, characterized in that: In step S5, an array of pixel centers arranged from left to right in the connected region is obtained, and the array is fitted using the least square method.

4. The method for correcting curved text lines in a contract document according to claim 1, characterized in that: In step S5, the inflection points of the curve are the segmentation points of the text lines.

5. The method for correcting curved text lines in a contract document according to claim 4, characterized in that: In step S6, the binary image is mapped to the text image, the segmentation points are corrected, the text lines are vertically projected, and the character separators are found as the final segmentation points.

6. The method for correcting curved text lines in a contract document according to claim 1, characterized in that: In step S8, the target text image is redefined so that its height is the height of the minimum circumscribed rectangle of the segmentation curve and its width is the arc length of the curve.