Text image processing method, system and readable storage medium

By calculating the approximate circular parameters and coordinate conversion of arc text, the arc text is converted into horizontal text, which solves the problem of relying on a large amount of training data in the prior art and improves the accuracy and efficiency of text image processing.

CN113610076BActive Publication Date: 2024-11-12YONYOU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110812094.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-19
Publication Date
2024-11-12
Estimated Expiration
2041-07-19

AI Technical Summary

Technical Problem

In the prior art, the straightening processing of arc text requires a large amount of training data and it is difficult to construct simulation data, resulting in poor final results.

Method used

By obtaining the arc text area in the text image, calculating its approximate circular parameters, and performing polar and rectangular coordinate conversions, converting arc text into horizontal text, avoiding relying on a large amount of training data.

Benefits of technology

It improves the accuracy and efficiency of text image processing, is suitable for complex application scenarios, simplifies the process of converting arc text into horizontal text, and avoids the problem of inaccurate recognition results caused by incomplete training data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113610076B_ABST
    Figure CN113610076B_ABST
Patent Text Reader

Abstract

The present invention provides a text image processing method, system and readable storage medium. The text image processing method includes: obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text area containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text area; obtaining a first length and a first width of the first circumscribed rectangle; generating a target circular image containing the arc-shaped text area according to the first length, the first width and a preset circular image; performing coordinate conversion on the target circular image to generate a horizontal text image containing the text line. The technical solution provided by the present invention can quickly realize the conversion of arc-shaped text into horizontal rectangular text by mathematical calculation, and can be applied to various complex application scenarios, thereby improving the applicability and ease of use of text recognition in actual production and life. The calculation method is simple, and the efficiency of text image processing is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text processing, and in particular to a text image processing method, a text image processing system and a readable storage medium. Background Art

[0002] In related technologies, curved text is straightened mainly by using massive curved text samples and then adopting machine learning to straighten the text. In practical applications, a large amount of training data is required and it is difficult to construct it through simulated data. The lack of training samples leads to unsatisfactory final results. Summary of the invention

[0003] The present invention aims to solve at least one of the technical problems existing in the prior art or related art.

[0004] To this end, a first aspect of the present invention provides a text image processing method.

[0005] The second aspect of the present invention also provides a text image processing system.

[0006] The third aspect of the present invention also provides a readable storage medium.

[0007] In view of this, the first aspect of the present invention proposes a method for processing a text image, including: obtaining a text image to be processed, locating text lines in the text image, determining an arc-shaped text area containing the text lines, and generating a first circumscribed rectangle containing the arc-shaped text area; obtaining a first length and a first width of the first circumscribed rectangle; generating a target circular image containing the arc-shaped text area based on the first length, the first width and a preset circular image; and performing coordinate transformation on the target circular image to generate a horizontal text image containing the text lines.

[0008] The text image processing method provided by the present invention obtains the text image to be processed, locates the position of the text line in the text image to be processed, cuts out the arc text area containing the text line, generates the minimum circumscribed rectangle corresponding to the arc text area, measures the length and width of the circumscribed rectangle, uses the length and width of the circumscribed rectangle corresponding to the arc text area and a preset reference circle as cardinality data, adopts a mathematical calculation method, finds an approximate circle of the arc text, that is, a target circular image, and then converts the parameters of the found circle into polar coordinates and rectangular coordinates, so as to convert the arc text into a horizontal text image. The present application converts arc text into horizontal rectangular text by finding an approximate circle and performing coordinate transformation, and then performs text recognition on the rectangular text. Compared with the prior art of importing arc text into a machine learning model for text recognition through a large amount of training data, the present application is completed entirely through mathematical calculations. On the one hand, there is no need for a large number of training samples, which avoids the situation where the output results of the learning model are inaccurate due to incomplete training data, effectively improves the accuracy of text image processing, and can be applied to various complex application scenarios, improving the applicability and ease of use of text recognition in actual production and life. On the other hand, the calculation method is simple, and can quickly realize the conversion of arc text into horizontal rectangular text, effectively improving the efficiency of text image processing.

[0009] Specifically, the text images to be processed include seal images, official document images, bill images, and certificate images, etc., which are not limited in this application.

[0010] The text image processing method provided by the present invention may also have the following additional technical features:

[0011] In the above technical solution, further, before obtaining the text image to be processed, it also includes: horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided segmented images, generating a second circumscribed rectangle corresponding to each segmented image, using N as an equal division parameter, where N is an integer greater than 0; obtaining the second length and second width of each second circumscribed rectangle; and calculating a first ratio of the second length to the second width.

[0012] In this technical solution, for a preset reference circular image, the reference circle is horizontally divided from the vertical axis corresponding to the center of the circle into N equally divided segmented images, the circumscribed rectangle of each segmented image is determined, the length and width of the circumscribed rectangle of each segmented image are measured, and the ratio of the length and width of each circumscribed rectangle is calculated as the basic parameter for subsequent search for the approximate circle of the arc text, wherein N can be any integer greater than 0, and the larger N is, the more accurate the approximate circle of the arc text is found later. By calculating the aspect ratio of different segmented images within the reference circle, and then using the calculated aspect ratio and the equal division parameter N as the basic parameter, the approximate circle corresponding to the arc text is found. Compared with the method in the prior art of pre-training a machine learning model through a large amount of training data, and then importing the arc text into the learning model to convert it into horizontal text, this application uses a method for finding an approximate circle for any arc text to quickly realize the conversion of arc text into horizontal text. On the one hand, it does not require a large amount of training data, the algorithm is simple, and the conversion efficiency is effectively improved; on the other hand, it avoids inaccurate output results of the learning model due to incomplete training data, and effectively improves the accuracy of the conversion of arc text.

[0013] In any of the above technical solutions, further, the step of generating a target circular image containing an arc-shaped text area according to the first length, the first width and the preset circular image specifically includes: calculating a second ratio of the first length and the first width; comparing N first ratios with the second ratio, and determining a target ratio from the N first ratios, wherein the target ratio is a first ratio whose difference with the second ratio is less than or equal to a preset threshold; obtaining the nth second bounding rectangle corresponding to the target ratio among the N second bounding rectangles, and taking n as a segmentation parameter, wherein n is an integer greater than or equal to 1 and less than or equal to N; generating a first filled rectangle according to the first bounding rectangle and the segmentation parameter; generating a second filled rectangle according to the first bounding rectangle and the segmentation parameter; filling the first bounding rectangle according to the first filled rectangle and the second filled rectangle to generate a target bounding rectangle; generating a target circular image according to the target bounding rectangle.

[0014] In this technical solution, the ratio of the length and width of the circumscribed rectangle corresponding to the arc text is calculated, and the length-width ratio of the circumscribed rectangle of the N equally divided points in the reference circle is used to calculate the difference between the length-width ratio of the circumscribed rectangle corresponding to the arc text and the length-width ratio of the circumscribed rectangle of the N equally divided points in the reference circle. If the absolute value of the difference between the length-width ratio of the circumscribed rectangle of the arc text and the length-width ratio of the circumscribed rectangle of the nth equally divided point is less than the preset threshold, that is, the length-width ratio of the circumscribed rectangle corresponding to the arc text is closest to the length-width ratio of the circumscribed rectangle of the nth equally divided point, it can be approximated that the arc text is the first 1 to n equal parts of the N equal parts of the perfect circle. Further, the Nn parts of the perfect circle corresponding to the arc text, that is, the lower half and the left and right parts of the perfect circle are completed to obtain the target circular image corresponding to the arc text. By using a mathematical algorithm for any arc text to find an approximate circle, the algorithm is simple and does not require data training, which effectively reduces the difficulty of conversion and improves the conversion efficiency and accuracy.

[0015] Specifically, after determining that the circumscribed rectangle of the arc-shaped text corresponds to the circumscribed rectangle of the nth dividing line in the N-division reference circle, that is, after the arc-shaped text is the first 1 to n-division parts of the N-division perfect circle, the circumscribed rectangle of the arc-shaped text can be inferred, and the first 1 to n-division parts of the circumscribed rectangle of the approximate circle to be found are completed. After the Nn parts of the circumscribed rectangle of the approximate circle, that is, the lower half and the left and right parts of the circumscribed rectangle, are completed, the entire target circumscribed rectangle is obtained, and then the target circular image corresponding to the target circumscribed rectangle can be obtained, that is, the approximate circle of the arc-shaped text.

[0016] It should be understood that the pre-set threshold can be set according to the text recognition accuracy requirement, and this application does not limit this.

[0017] In any of the above technical solutions, further, the step of generating the first filling rectangle according to the first circumscribed rectangle and the second circumscribed rectangle coefficients specifically includes: calculating the third width of the first filling rectangle according to the first formula; generating the first filling rectangle according to the third width and the first length;

[0018] The first formula is:

[0019]

[0020] Wherein, W2 is the third width, W1 is the first width of the first circumscribed rectangle, n is the segmentation parameter, and N is the equal division parameter.

[0021] In this technical solution, the arc text is determined to be the first 1 to n equal parts of the N equal parts of the perfect circle, that is, the width W1 of the circumscribed rectangle of the arc text is only the height of the nth equal part of the N equal parts, and the length of the circumscribed rectangle of the rectangular text is the same as the length of the lower half of the target circumscribed rectangle to be filled. The first formula is used to calculate the width of the lower half of the target circumscribed rectangle to be filled corresponding to the approximate circle, that is, the width W2 of the first filling rectangle. The first filling rectangle is generated by the calculated W2 and the known length L1 to fill the lower half of the circumscribed rectangle corresponding to the approximate circle of the arc text. The part to be filled of the circumscribed rectangle of the approximate circle of the arc text is calculated by a simple mathematical method, which reduces the speed of finding the approximate circle of the arc text and greatly improves the efficiency of text image processing.

[0022] In any of the above technical solutions, further, the step of generating the second filling rectangle according to the first circumscribed rectangle and the second circumscribed rectangle coefficients specifically includes: calculating the fourth length of the second filling rectangle according to the second formula; calculating the fourth width of the second filling rectangle according to the third formula; generating the second filling rectangle according to the fourth length and the fourth width;

[0023] The second formula is:

[0024]

[0025] Wherein, L2 is the fourth length, W1 is the first width of the first circumscribed rectangle, and L1 is the first length of the first circumscribed rectangle;

[0026] The third formula is:

[0027]

[0028] Wherein, W3 is the fourth width, W1 is the first width of the first circumscribed rectangle, n is the segmentation parameter, and N is the equal division parameter.

[0029] In this technical solution, in practical applications, the text image to be processed is usually an elliptical image. If the circle corresponding to the arc text is directly completed based on the first 1 to n equal parts of the N equal parts of the arc text, only the lower half of the circle can be completed, resulting in the missing left and right side boundaries of the arc text in the perfect circle corresponding to the filled circumscribed rectangle, which leads to incomplete text information. To address this problem, the present application calculates the length and width of the left and right side rectangles of the circumscribed rectangle corresponding to the perfect circle to be filled through the third formula and the fourth formula. Based on the calculated length and width, a second filling rectangle is generated, and then the left and right sides of the target circumscribed rectangle are filled, which effectively improves the accuracy of the target circumscribed rectangle finally generated, thereby improving the accuracy of text image processing.

[0030] In any of the above technical solutions, further, the step of generating a target circular image according to the target circumscribed rectangle specifically includes: obtaining a fifth length of the target circumscribed rectangle; and generating the target circular image using the fifth length as a diameter.

[0031] In this technical solution, after the circumscribed rectangle of the arc text is completed, the length of the target circumscribed rectangle is measured, and the measured length is used as the diameter of the target circular image, thereby generating the target circular image of the arc text. By completing the circumscribed rectangle of the arc text and then drawing a circle based on the completed target circumscribed rectangle, the accuracy of the target circular image found is effectively improved. On the one hand, it avoids the diameter of the target circular image being too small, resulting in the target circular image not completely containing the arc text, thereby causing the text information to be lost; on the other hand, it avoids the diameter of the target circular image being too large, which reduces the conversion efficiency of the subsequent arc text.

[0032] In any of the above technical solutions, further, the step of performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines specifically includes: obtaining polar coordinate parameters of the arc-shaped text area within the target circular image; performing coordinate transformation on the arc-shaped text area according to the polar coordinate parameters to generate rectangular coordinate parameters corresponding to the polar coordinate parameters; and generating a horizontal text image according to the rectangular coordinate parameters.

[0033] In this technical solution, after generating a target circular image of arc text, the center point and radius of the target circular image are determined, and the target circular image is mapped to the polar coordinate space with the center point as the coordinate origin, and the polar coordinate parameters of the arc text area in the target circular image are obtained. According to the conversion relationship between polar coordinates and rectangular coordinates, the coordinate position of the arc text in the polar coordinate space is mapped to the position in the rectangular coordinate space, and the coordinate parameters of the arc in the rectangular coordinate are used as the output result to generate a horizontal text image corresponding to the arc text. By converting the polar coordinates and rectangular coordinates for the found circle parameters, compared with the prior art of importing arc text into a machine learning model to perform text recognition through a large amount of training data, this application uses a mathematical calculation method to quickly realize the conversion of arc text into horizontal text, without the need for a large amount of training data and complex algorithms, and effectively improves the efficiency and accuracy of text processing.

[0034] In any of the above technical solutions, further, after the target circular image is coordinate-converted to generate a horizontal text image containing text lines, the method further includes: recognizing the text lines in the horizontal text image to generate a text recognition result.

[0035] In this technical solution, the horizontal text image is processed by using text recognition technology to obtain the text recognition result. By converting the arc text into horizontal text by mathematical calculation, and then recognizing the text of the converted horizontal text image, on the one hand, it avoids the occurrence of text disorder caused by directly recognizing the text line content in the arc text area; on the other hand, it avoids a large amount of annotation work for the arc text, solves the problem of difficulty in obtaining training data, can be applied to complex application scenarios, has better robustness, and effectively improves the content recognition effect of the text line.

[0036] Specifically, the text in the horizontal text image may include Chinese characters, English characters, and special characters, which is not limited in this application.

[0037] Furthermore, the obtained text recognition result is sent to the terminal so that the terminal displays the text recognition result, so that the user can obtain the visualized text recognition result in time, and thus know the content of the text, such as the content of the seal text, in time.

[0038] According to the second aspect of the present invention, a text image processing system is proposed, comprising: a memory storing a program or instruction; a processor connected to the memory, and configured to implement the text image processing method proposed in the first aspect when executing the program or instruction. Therefore, the text image processing system has all the beneficial effects of the text image processing method proposed in the first aspect, which will not be described in detail here.

[0039] According to the third aspect of the present invention, a readable storage medium is provided, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the text image processing method provided in the first aspect is performed. Therefore, the readable storage medium has all the beneficial effects of the text image processing method provided in the first aspect, and in order to avoid repetition, it will not be described in detail.

[0040] Additional aspects and advantages of the present invention will become apparent in the following description or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0042] Figure 1 A flowchart of a text image processing method according to an embodiment of the present invention is shown;

[0043] Figure 2 A second flowchart of a text image processing method according to an embodiment of the present invention is shown;

[0044] Figure 3The third flowchart of the text image processing method according to an embodiment of the present invention is shown;

[0045] Figure 4 A fourth flowchart of a text image processing method according to an embodiment of the present invention is shown;

[0046] Figure 5 FIG5 shows a fifth flow chart of a method for processing text images according to an embodiment of the present invention;

[0047] Figure 6 A sixth flowchart of a text image processing method according to an embodiment of the present invention is shown;

[0048] Figure 7 FIG7 shows a flowchart of a text image processing method according to an embodiment of the present invention;

[0049] Figure 8 FIG8 is a flowchart of a text image processing method according to an embodiment of the present invention;

[0050] Fig. 9 A schematic diagram showing a text image processing method according to a specific embodiment of the present invention;

[0051] Fig.10 A schematic diagram showing a specific embodiment of the present invention for dividing a circle into equal parts horizontally is shown;

[0052] Fig.11 One of the schematic diagrams of the circumscribed rectangle at the equal division position according to a specific embodiment of the present invention is shown;

[0053] Fig.12 A second schematic diagram of a circumscribed rectangle at an equally divided position according to a specific embodiment of the present invention is shown;

[0054] Fig.13 A schematic diagram showing a circumscribed rectangle of an arc-shaped text area according to a specific embodiment of the present invention is shown;

[0055] Fig.14 A schematic diagram showing a first filling rectangle filling the lower half of a circumscribed rectangle according to a specific embodiment of the present invention is shown;

[0056] Fig.15 A schematic diagram showing a specific embodiment of the present invention in which a second filling rectangle fills the left and right sides of a circumscribed rectangle;

[0057] Fig.16 A schematic diagram showing a horizontal text image generated according to a specific embodiment of the present invention;

[0058] Fig.17 A schematic diagram showing the conversion between polar coordinates and rectangular coordinates according to a specific embodiment of the present invention is shown;

[0059] Fig.18 A schematic block diagram of a text image processing system of the present invention is shown.

[0060] in, Fig.18 The corresponding relationship between the reference numerals and the component names is as follows:

[0061] 1800: a text image processing system, 1802: a memory, and 1804: a processor. DETAILED DESCRIPTION

[0062] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0063] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0064] Refer to the following Figures 1 to 18 A text image processing method, a text image processing system and a readable storage medium according to some embodiments of the present invention are described.

[0065] Embodiment 1:

[0066] like Figure 1 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0067] Step 102, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0068] Step 104, obtaining a first length and a first width of a first circumscribed rectangle;

[0069] Step 106, generating a target circular image including an arc-shaped text area according to the first length, the first width and the preset circular image;

[0070] Step 108 , performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0071] In this embodiment, a text image to be processed is obtained, the position of the text line in the text image to be processed is located, the arc-shaped text area containing the text line is cut out, and the minimum circumscribed rectangle corresponding to the arc-shaped text area is generated. The length and width of the circumscribed rectangle are measured, and the length and width of the circumscribed rectangle corresponding to the arc-shaped text area and a preset reference circle are used as base data. A mathematical calculation method is used to find an approximate circle of the arc-shaped text, that is, a target circular image, and then the parameters of the found circle are converted into polar coordinates and rectangular coordinates to convert the arc-shaped text into a horizontal text image. The present application converts arc text into horizontal rectangular text by finding an approximate circle and performing coordinate transformation, and then performs text recognition on the rectangular text. Compared with the prior art of importing arc text into a machine learning model for text recognition through a large amount of training data, the present application is completed entirely through mathematical calculations. On the one hand, there is no need for a large number of training samples, which avoids the situation where the output results of the learning model are inaccurate due to incomplete training data, effectively improves the accuracy of text image processing, and can be applied to various complex application scenarios, improving the applicability and ease of use of text recognition in actual production and life. On the other hand, the calculation method is simple, and can quickly realize the conversion of arc text into horizontal rectangular text, effectively improving the efficiency of text image processing.

[0072] Specifically, the text images to be processed include seal images, official document images, bill images, and certificate images, etc., which are not limited in this application.

[0073] Embodiment 2:

[0074] like Figure 2 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0075] Step 202, horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided divided images, generating a second circumscribed rectangle corresponding to each divided image, and using N as an equally divided parameter, where N is an integer greater than 0;

[0076] Step 204, obtaining the second length and second width of each second circumscribed rectangle;

[0077] Step 206, calculating a first ratio of the second length to the second width;

[0078] Step 208, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0079] Step 210, obtaining a first length and a first width of a first circumscribed rectangle;

[0080] Step 212, generating a target circular image including an arc-shaped text area according to the first length, the first width and the preset circular image;

[0081] Step 214 , performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0082] In this embodiment, for a preset reference circular image, the reference circle is horizontally divided from the vertical axis corresponding to the center of the circle into N equally divided images, the circumscribed rectangle of each segmented image is determined, the length and width of the circumscribed rectangle of each segmented image are measured, and the ratio of the length and width of each circumscribed rectangle is calculated as the basic parameter for subsequent search for the approximate circle of the arc text, wherein N can be any integer greater than 0, and the larger N is, the more accurate the approximate circle of the arc text is found later. By calculating the aspect ratio of different segmented images within the reference circle, and then using the calculated aspect ratio and the equally divided parameter N as the basic parameters, the approximate circle corresponding to the arc text is found. Compared with the method in the prior art of pre-training a machine learning model with a large amount of training data, and then importing the arc text into the learning model to convert it into horizontal text, the present application uses a method for finding an approximate circle for any arc text to quickly realize the conversion of the arc text into horizontal text. On the one hand, it does not require a large amount of training data, the algorithm is simple, and the conversion efficiency is effectively improved; on the other hand, it avoids the inaccuracy of the output result of the learning model caused by incomplete training data, and effectively improves the accuracy of the conversion of the arc text.

[0083] In a specific embodiment, Fig.10 As shown, the reference circle is divided into N equally divided points, A and B are the first equally divided point horizontal line and the second equally divided point horizontal line, respectively. Fig.11 and Fig.12 As shown, they are the circumscribed rectangle at the A division and the circumscribed rectangle at the B division, respectively. By calculating the length-to-width ratio at the A division as the length-to-width ratio of the circumscribed rectangle, and the length-to-width ratio at the B division as the length-to-width ratio of the circumscribed rectangle, and so on, the length-to-width ratio of the circumscribed rectangle of any N equally divided points is calculated as the basic parameter for subsequent search for the approximate circle of the arc text.

[0084] Embodiment 3:

[0085] like Figure 3 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0086] Step 302, horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided divided images, generating a second circumscribed rectangle corresponding to each divided image, and using N as an equally divided parameter, where N is an integer greater than 0;

[0087] Step 304, obtaining the second length and second width of each second circumscribed rectangle;

[0088] Step 306, calculating a first ratio of the second length to the second width;

[0089] Step 308, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0090] Step 310, obtaining a first length and a first width of a first circumscribed rectangle;

[0091] Step 312, calculating a second ratio of the first length to the first width;

[0092] Step 314, comparing the N first ratios with the second ratio, and determining a target ratio from the N first ratios, where the target ratio is a first ratio whose difference with the second ratio is less than or equal to a preset threshold;

[0093] Step 316, obtaining the nth second circumscribed rectangle corresponding to the target ratio among the N second circumscribed rectangles, and taking n as a segmentation parameter, where n is an integer greater than or equal to 1 and less than or equal to N;

[0094] Step 318, generating a first filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0095] Step 320, generating a second filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0096] Step 322, filling the first circumscribed rectangle according to the first filling rectangle and the second filling rectangle to generate a target circumscribed rectangle;

[0097] Step 324, generating a target circular image according to the target circumscribed rectangle;

[0098] Step 326 , performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0099] In this embodiment, the ratio of the length and width of the circumscribed rectangle corresponding to the arc text is calculated, and the length-width ratio of the circumscribed rectangle of the N equally divided points in the reference circle is used to calculate the difference between the length-width ratio of the circumscribed rectangle corresponding to the arc text and the length-width ratio of the N circumscribed rectangles in the reference circle. If the absolute value of the difference between the length-width ratio of the circumscribed rectangle of the arc text and the length-width ratio of the circumscribed rectangle of the nth equally divided point is less than the preset threshold, that is, the length-width ratio of the circumscribed rectangle corresponding to the arc text is closest to the length-width ratio of the circumscribed rectangle of the nth equally divided point, it can be approximated that the arc text is the first 1 to n equal parts of the N equal parts of the perfect circle. Further, the Nn parts of the perfect circle corresponding to the arc text, that is, the lower half and the left and right parts of the perfect circle are completed to obtain the target circular image corresponding to the arc text. By using a mathematical algorithm for any arc text to find an approximate circle, the algorithm is simple and does not require data training, which effectively reduces the difficulty of conversion and improves the conversion efficiency and accuracy.

[0100] Specifically, after determining that the circumscribed rectangle of the arc-shaped text corresponds to the circumscribed rectangle of the nth dividing line in the N-division reference circle, that is, after the arc-shaped text is the first 1 to n-division parts of the N-division perfect circle, the circumscribed rectangle of the arc-shaped text can be inferred, and the first 1 to n-division parts of the circumscribed rectangle of the approximate circle to be found are completed. After the Nn parts of the circumscribed rectangle of the approximate circle, that is, the lower half and the left and right parts of the circumscribed rectangle, are completed, the entire target circumscribed rectangle is obtained, and then the target circular image corresponding to the target circumscribed rectangle can be obtained, that is, the approximate circle of the arc-shaped text.

[0101] Embodiment 4:

[0102] like Figure 4 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0103] Step 402, horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided divided images, generating a second circumscribed rectangle corresponding to each divided image, and using N as an equally divided parameter, where N is an integer greater than 0;

[0104] Step 404, obtaining the second length and second width of each second circumscribed rectangle;

[0105] Step 406, calculating a first ratio of the second length to the second width;

[0106] Step 408, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0107] Step 410, obtaining a first length and a first width of a first circumscribed rectangle;

[0108] Step 412, calculating a second ratio of the first length to the first width;

[0109] Step 414, comparing the N first ratios with the second ratio, and determining a target ratio from the N first ratios, the target ratio being a first ratio whose difference with the second ratio is less than or equal to a preset threshold;

[0110] Step 416, obtaining the nth second circumscribed rectangle corresponding to the target ratio among the N second circumscribed rectangles, and taking n as a segmentation parameter, where n is an integer greater than or equal to 1 and less than or equal to N;

[0111] Step 418, calculating the third width of the first filled rectangle according to the first formula;

[0112] Step 420, generating a first filling rectangle according to the third width and the first length;

[0113] Step 422, generating a second filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0114] Step 424, filling the first circumscribed rectangle according to the first filling rectangle and the second filling rectangle to generate a target circumscribed rectangle;

[0115] Step 426, generating a target circular image according to the target circumscribed rectangle;

[0116] Step 428, performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0117] In this embodiment, the arc text is determined to be the first 1 to n equal parts of the N equal parts of the perfect circle, that is, the width W1 of the circumscribed rectangle of the arc text is only the height of the nth equal part of the N equal parts, and the length of the circumscribed rectangle of the rectangular text is the same as the length of the lower half of the target circumscribed rectangle to be filled. The first formula is used to calculate the width of the lower half of the target circumscribed rectangle to be filled corresponding to the approximate circle, that is, the width W2 of the first filling rectangle. The first filling rectangle is generated by the calculated W2 and the known length L1 to fill the lower half of the circumscribed rectangle corresponding to the approximate circle of the arc text. The part to be filled of the circumscribed rectangle of the approximate circle of the arc text is calculated by a simple mathematical method, which reduces the speed of finding the approximate circle of the arc text and greatly improves the efficiency of text image processing.

[0118] Embodiment 5:

[0119] like Figure 5 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0120] Step 502, horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided divided images, generating a second circumscribed rectangle corresponding to each divided image, and using N as an equally divided parameter, where N is an integer greater than 0;

[0121] Step 504, obtaining the second length and second width of each second circumscribed rectangle;

[0122] Step 506, calculating a first ratio of the second length to the second width;

[0123] Step 508, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0124] Step 510, obtaining a first length and a first width of a first circumscribed rectangle;

[0125] Step 512, calculating a second ratio of the first length to the first width;

[0126] Step 514, comparing the N first ratios with the second ratio, and determining a target ratio from the N first ratios, where the target ratio is a first ratio whose difference with the second ratio is less than or equal to a preset threshold;

[0127] Step 516, obtaining the nth second circumscribed rectangle corresponding to the target ratio among the N second circumscribed rectangles, and taking n as a segmentation parameter, where n is an integer greater than or equal to 1 and less than or equal to N;

[0128] Step 518, generating a first filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0129] Step 520, calculating the fourth length of the second filled rectangle according to the second formula;

[0130] Step 522, calculating the fourth width of the second filled rectangle according to the third formula;

[0131] Step 524, generating a second filling rectangle according to the fourth length and the fourth width;

[0132] Step 526, filling the first circumscribed rectangle according to the first filling rectangle and the second filling rectangle to generate a target circumscribed rectangle;

[0133] Step 528, generating a target circular image according to the target circumscribed rectangle;

[0134] Step 530 , performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0135] In this embodiment, in this technical solution, in actual applications, the text image to be processed is usually an elliptical image. If the circle corresponding to the arc text is directly completed based on the first 1 to n equal parts of the N equal parts of the arc text, only the lower half of the circle can be completed, resulting in the missing left and right side boundaries of the arc text in the perfect circle corresponding to the filled circumscribed rectangle, which leads to incomplete text information. In response to this problem, the present application calculates the length and width of the left and right side rectangles of the circumscribed rectangle corresponding to the perfect circle to be filled by the third formula and the fourth formula. Based on the calculated length and width, a second filling rectangle is generated, and then the left and right sides of the target circumscribed rectangle are filled, which effectively improves the accuracy of the target circumscribed rectangle finally generated, thereby improving the accuracy of text image processing.

[0136] In a specific real-time example, if the length and width of the circumscribed rectangle of the arc-shaped text are the same, that is, the text image containing the arc-shaped text is a perfect circular image, and the arc-shaped text is 1 / 2 of a perfect circle, W3 is calculated to be 0 according to the third formula, that is, the length of the circumscribed rectangle of the arc-shaped text is the same as the length of the circumscribed rectangle of the approximate circle being sought, and there is no need to fill the left and right sides of the target circumscribed rectangle.

[0137] Embodiment 6:

[0138] like Figure 6 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0139] Step 602, horizontally dividing the preset circular image from the vertical axis corresponding to the center of the circle, determining N equally divided divided images, generating a second circumscribed rectangle corresponding to each divided image, and using N as an equally divided parameter, where N is an integer greater than 0;

[0140] Step 604, obtaining the second length and second width of each second circumscribed rectangle;

[0141] Step 606, calculating a first ratio of the second length to the second width;

[0142] Step 608, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0143] Step 610, obtaining a first length and a first width of a first circumscribed rectangle;

[0144] Step 612, calculating a second ratio of the first length to the first width;

[0145] Step 614, comparing the N first ratios with the second ratio, and determining a target ratio from the N first ratios, where the target ratio is a first ratio whose difference with the second ratio is less than or equal to a preset threshold;

[0146] Step 616, obtaining the nth second circumscribed rectangle corresponding to the target ratio among the N second circumscribed rectangles, and taking n as a segmentation parameter, where n is an integer greater than or equal to 1 and less than or equal to N;

[0147] Step 618, generating a first filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0148] Step 620, generating a second filling rectangle according to the first circumscribed rectangle and the segmentation parameters;

[0149] Step 622, filling the first circumscribed rectangle according to the first filling rectangle and the second filling rectangle to generate a target circumscribed rectangle;

[0150] Step 624, obtaining the fifth length of the target circumscribed rectangle;

[0151] Step 626, using the fifth length as the diameter, generating a target circular image;

[0152] Step 628, performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines.

[0153] In this embodiment, after the circumscribed rectangle of the arc text is completed, the length of the target circumscribed rectangle is measured, and the measured length is used as the diameter of the target circular image, thereby generating the target circular image of the arc text. By completing the circumscribed rectangle of the arc text and then drawing a circle based on the completed target circumscribed rectangle, the accuracy of the target circular image found is effectively improved. On the one hand, it avoids the diameter of the target circular image found being too small, resulting in the target circular image not completely containing the arc text, thereby causing the text information to be lost; on the other hand, it avoids the diameter of the target circular image found being too large, thereby reducing the conversion efficiency of the subsequent arc text.

[0154] Embodiment 7:

[0155] like Figure 7 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0156] Step 702, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0157] Step 704, obtaining a first length and a first width of a first circumscribed rectangle;

[0158] Step 706, generating a target circular image including an arc-shaped text area according to the first length, the first width and the preset circular image;

[0159] Step 708, obtaining polar coordinate parameters of the arc-shaped text area in the target circular image;

[0160] Step 710, performing coordinate transformation on the arc-shaped text area according to the polar coordinate parameters to generate rectangular coordinate parameters corresponding to the polar coordinate parameters;

[0161] Step 712, generating a horizontal text image according to the rectangular coordinate parameters.

[0162] In this embodiment, after generating a target circular image of arc text, the center point and radius of the target circular image are determined, and the target circular image is mapped to the polar coordinate space with the center point as the coordinate origin, and the polar coordinate parameters of the arc text area in the target circular image are obtained. According to the conversion relationship between polar coordinates and rectangular coordinates, the coordinate position of the arc text in the polar coordinate space is mapped to the position in the rectangular coordinate space, and the coordinate parameters of the arc in the rectangular coordinate are used as the output result to generate a horizontal text image corresponding to the arc text. By converting the polar coordinates and rectangular coordinates for the parameters of the found circle, compared with the prior art of importing the arc text into the machine learning model and performing text recognition through a large amount of training data, the present application uses a mathematical calculation method to quickly realize the conversion of arc text into horizontal text, without the need for a large number of training samples and complex algorithms, and effectively improves the efficiency and accuracy of text processing.

[0163] In a specific embodiment, Fig.17 As shown, the center O of the target circular image is determined, and the pixel coordinates of the arc-shaped text area at any angle θ are sampled as A(ρ,θ). The polar coordinate point is converted into the corresponding point A(x,y) in the rectangular coordinate system through the calculation method of x=ρcosθ; y=ρsinθ, and then the horizontal text image corresponding to the arc-shaped text is obtained.

[0164] Embodiment 8:

[0165] like Figure 8 As shown, according to an embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0166] Step 802, obtaining a text image to be processed, locating a text line in the text image, determining an arc-shaped text region containing the text line, and generating a first circumscribed rectangle containing the arc-shaped text region;

[0167] Step 804, obtaining a first length and a first width of a first circumscribed rectangle;

[0168] Step 806, generating a target circular image including an arc-shaped text area according to the first length, the first width and the preset circular image;

[0169] Step 808, performing coordinate transformation on the target circular image to generate a horizontal text image containing text lines;

[0170] Step 810, identifying text lines in the horizontal text image and generating text recognition results.

[0171] In this embodiment, the horizontal text image is processed by using text recognition technology to obtain the text recognition result. By converting the arc text into horizontal text by mathematical calculation, and then performing text recognition on the converted horizontal text image, on the one hand, it avoids the occurrence of text disorder caused by directly recognizing the text line content in the arc text area; on the other hand, it avoids a large amount of annotation work for the arc text, solves the problem of difficulty in obtaining training data, can be applied to complex application scenarios, has better robustness, and effectively improves the content recognition effect of the text line.

[0172] Specifically, the text in the horizontal text image may include Chinese characters, English characters, and special characters, which is not limited in this application.

[0173] Furthermore, the obtained text recognition result is sent to the terminal so that the terminal displays the text recognition result, so that the user can obtain the visualized text recognition result in time, and thus know the content of the text, such as the content of the seal text, in time.

[0174] Embodiment 9:

[0175] like Fig. 9 As shown, according to a specific embodiment of the present invention, a text image processing method is proposed, the method comprising:

[0176] Step 902, searching for an area corresponding to an approximately perfect circle according to the ratio of the length and width of the first circumscribed rectangle of the arc-shaped text area;

[0177] Step 904, completing the circle;

[0178] Step 906: Convert the completed circle into rectangular text according to the idea of ​​polar coordinate and Cartesian coordinate conversion.

[0179] In this embodiment, for the circular text on the official seal, or the effect text on the non-official seal, or any other circular text, the circumscribed rectangle of the text area is found, and the target circular image corresponding to the arc text is found and completed using the preset reference circular image. Fig.16As shown, according to the circular image found, polar coordinates and Cartesian coordinates are used to convert the text on the circular text box, so that the roughly straight text provides useful help for improving the text recognition results. The present application proposes a method for straightening circular text with arbitrary arcs. By finding an approximate circle for the arc text and converting the polar coordinates into Cartesian coordinates, the arc text is processed into straight, horizontal rectangular text, which provides good support for the recognition effect of the text.

[0180] Specifically, the first step is to define a reference circle and calculate the ratio of the length and width of different cross-section circles to the region as the basic parameters for finding an approximate circle. Fig.10 As shown, the circle is divided horizontally from the vertical axis corresponding to the center of the circle. It is assumed that there are N equal parts. A and B are the horizontal lines of the first and second dividing points respectively, with a total of N equal dividing points. Among them, N can be any integer greater than 0. The larger N is, the more accurate the circle found by the arc text later.

[0181] Furthermore, the ratio of the length and width of the circumscribed rectangle of any equally divided point is calculated. Fig.11 As shown, the aspect ratio of the A equal division is the aspect ratio of the circumscribed rectangle, such as Fig.12 As shown, the aspect ratio at the B-division point is the aspect ratio of the circumscribed rectangle, and so on, the aspect ratio of the circumscribed rectangle of any N-division points is calculated.

[0182] The second step is, Fig.13 As shown, the aspect ratio of the bounding rectangle of the target straightened arc text is calculated.

[0183] The third step is to match the aspect ratio parameters of the first and second steps to find the most approximate aspect ratio. Specifically, if the aspect ratio of the circumscribed rectangle of the arc text calculated in the second step is equal to the aspect ratio of the circumscribed rectangle of the nth dividing line in the N-division reference circle, then we can approximately draw the following conclusion: the target arc text is the first 1 to n-division parts of the N-division circle, so the goal of the circle filling is to fill the circle to Nn, that is, the lower half and the left and right parts of the circle.

[0184] The fourth step is to fill the circle according to the most approximate aspect ratio. Specifically, assume that the first width of the circumscribed rectangle of the target arc text is W1, the first length is L1, and W1 is just the height of the n equally divided rectangles. Therefore, Fig.14 As shown, the width W2 of the lower half of the supplementary circle is The length is L1. Further, if Fig.15 As shown, the left and right rectangles of the supplemented circle are the same in length and width, and the width W3 is The length L2 is

[0185] The fifth step is to convert polar coordinates and Cartesian coordinates according to the circle parameters found. Fig.17 As shown, for a point on the polar coordinate system, it can be converted into a corresponding point in the Cartesian coordinate system according to the fourth formula, the fourth formula: x = ρcosθ; y = ρsinθ.

[0186] This application quickly converts arc text into rectangular text by finding an approximate circle for any arc text. It does not require a large amount of data training and complex algorithms. It supports the processing of text with any arc, such as perfect circles and ellipses. It does not require massive samples and deep algorithms. All of it is completed through mathematical calculations, effectively improving the text recognition effect.

[0187] Embodiment 10:

[0188] like Fig.18 As shown, according to an embodiment of the second aspect of the present invention, a text image processing system 1800 is proposed, comprising: a memory 1802, the memory 1802 storing a program or instruction; a processor 1804, connected to the memory 1802, the processor 1804, being configured to implement the text image processing method proposed in the first aspect when executing the program or instruction. Therefore, the text image processing system has all the beneficial effects of the text image processing method proposed in the first aspect, which will not be described in detail here.

[0189] Embodiment 11:

[0190] According to the third aspect of the present invention, a readable storage medium is provided, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the text image processing method provided in the first aspect is performed. Therefore, the readable storage medium has all the beneficial effects of the text image processing method provided in the first aspect, and in order to avoid repetition, it will not be described in detail.

[0191] In the present invention, in this article, the term "comprises", "includes" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be noted that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0192] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0193] In the description of this specification, the description of the terms "one embodiment", "some embodiments", "specific embodiments", 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 representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0194] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A text image processing method, characterized in that: include: Acquire a text image to be processed, locate a text line in the text image, determine an arc-shaped text area containing the text line, and generate a first circumscribed rectangle containing the arc-shaped text area; Obtain a first length and a first width of the first circumscribed rectangle; Generate a target circular image including the arc-shaped text area according to the first length, the first width and a preset circular image; Performing coordinate transformation on the target circular image to generate a horizontal text image containing the text line; Performing recognition processing on the horizontal text image using a text recognition technology to obtain a text recognition result, and sending the obtained text recognition result to a terminal so that the terminal displays the text recognition result; Before obtaining the text image to be processed, the method further includes: The preset circular image is horizontally divided from the vertical axis corresponding to the center of the circle to determine N equally divided segmented images, and a second circumscribed rectangle corresponding to each segmented image is generated, and N is used as an equally divided parameter, wherein N is an integer greater than 0; Get the second length and second width of each of the second circumscribed rectangles; calculating a first ratio of the second length to the second width; The step of generating a target circular image including the arc-shaped text area according to the first length, the first width and a preset circular image specifically includes: calculating a second ratio of the first length to the first width; Compare the N first ratios with the second ratio, and determine a target ratio from the N first ratios, where the target ratio is a first ratio whose difference with the second ratio is less than or equal to a preset threshold; Among the N second circumscribed rectangles, obtain the nth second circumscribed rectangle corresponding to the target ratio, and use n as a segmentation parameter, where n is an integer greater than or equal to 1 and less than or equal to N; Generate a first filled rectangle according to the first circumscribed rectangle and the segmentation parameters; Generate a second filled rectangle according to the first circumscribed rectangle and the segmentation parameters; Filling the first circumscribed rectangle according to the first filling rectangle and the second filling rectangle to generate a target circumscribed rectangle; The target circular image is generated according to the target circumscribed rectangle.

2. The text image processing method according to claim 1, characterized in that: The step of generating a first filling rectangle according to the first circumscribed rectangle and the second circumscribed rectangle coefficient specifically includes: Calculate the third width of the first filled rectangle according to the first formula; Generate the first filling rectangle according to the third width and the first length; The first formula is: , Wherein, W2 is the third width, W1 is the first width of the first circumscribed rectangle, n is the segmentation parameter, and N is the equal division parameter.

3. The text image processing method according to claim 1, characterized in that: The step of generating a second filling rectangle according to the first circumscribed rectangle and the second circumscribed rectangle coefficient specifically includes: According to the second formula, calculating the fourth length of the second filled rectangle; According to the third formula, calculating the fourth width of the second filled rectangle; Generate the second filling rectangle according to the fourth length and the fourth width; The second formula is: , Wherein, L2 is the fourth length, W1 is the first width of the first circumscribed rectangle, and L1 is the first length of the first circumscribed rectangle; The third formula is: , Wherein, W3 is the fourth width, W1 is the first width of the first circumscribed rectangle, n is the segmentation parameter, and N is the equal division parameter.

4. The text image processing method according to claim 1, characterized in that: The step of generating the target circular image according to the target circumscribed rectangle specifically includes: Obtaining the fifth length of the target circumscribed rectangle; The target circular image is generated using the fifth length as the diameter.

5. The text image processing method according to claim 1, characterized in that: The step of performing coordinate transformation on the target circular image to generate a horizontal text image containing the text line specifically includes: Obtaining polar coordinate parameters of the arc-shaped text area in the target circular image; According to the polar coordinate parameters, coordinate transformation is performed on the arc-shaped text area to generate rectangular coordinate parameters corresponding to the polar coordinate parameters; The horizontal text image is generated according to the rectangular coordinate parameters.

6. The text image processing method according to claim 1, characterized in that: After the target circular image is subjected to coordinate transformation to generate a horizontal text image containing the text line, the method further includes: The text lines in the horizontal text image are recognized to generate text recognition results.

7. A text image processing system, characterized in that: include: A memory storing programs or instructions; A processor is connected to the memory, and when the processor executes the program or instruction, the text image processing method according to any one of claims 1 to 6 is implemented.

8. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the text image processing method according to any one of claims 1 to 6 are implemented.