Text tilt correction method, device, storage medium, and computer equipment

Through the pre-trained angle recognition model and rotation testing technology, the problem of processing text tilt in text images is solved, and high-precision correction of various text types is achieved, with a wide range of applications and strong anti-interference ability.

CN113128495BActive Publication Date: 2024-10-15GUANGZHOU HUIRUI SITONG INFORMATION SCI & TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911402303.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2024-10-15
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

It is difficult for the existing technology to effectively deal with the problem of text tilt in text images, especially the shortcomings of straight line detection due to the diversity of tilt angles, cumbersome training data, and image quality.

Method used

The pre-trained angle recognition model is used to identify the text image to be corrected, and the rotation angle is corrected and grayscaled and binarized, combined with rotation testing at different test angles, until the projection value of the pixel row in the vertical direction reaches zero. Tilt state to achieve text image correction.

Benefits of technology

It achieves high-precision correction of various text types, with a wide range of applications and strong anti-interference ability. It can handle complex documents such as handwritten text and seals, and the correction accuracy is highly customizable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113128495B_ABST
    Figure CN113128495B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, storage medium, and computer equipment for text tilt correction, which includes: identifying a text image to be corrected by a pre-trained angle recognition model to obtain a rotation angle; correcting the text image to be corrected according to the rotation angle to obtain a first text image; graying and binarizing the first text image to obtain a second text image; performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction is the target projection value, and using the test angle that makes the projection value of the pixel row of the second text image in the vertical direction the target projection value as the target test angle; rotating the first text image through the target test angle to obtain a target corrected text image. The present application accurately corrects the tilt of a text image based on the pixel projection method, and can be applied to various text images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a text tilt correction method, device, storage medium, and computer equipment. Background Art

[0002] Image processing and natural language processing and other fields of artificial intelligence are gradually being combined. The text in natural language processing may come from images, and the object of image processing is also very likely to be a text image. These two fields, which belong to artificial intelligence, are being closely combined. The mainstream artificial intelligence technology "deep learning" cannot solve the problem of text tilt in text images very well. First, there are many tilt angles; second, it is too cumbersome to generate training data; and finally, the document content in actual use is complex and changeable. There are also obvious disadvantages based on straight line detection or its evolution method. On the one hand, not all documents have straight lines to detect; on the other hand, due to image quality reasons, the straight lines have breakpoints or interference. Summary of the invention

[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present application provide a text tilt correction method, device, storage medium, and computer equipment.

[0004] In a first aspect, an embodiment of the present application provides a method for text tilt correction, the method comprising:

[0005] Obtain the text image to be corrected;

[0006] The text image to be corrected is identified by a pre-trained angle recognition model to obtain a rotation angle, which represents a rough estimated angle between the current state of the text image to be corrected and the upright state;

[0007] Correcting the text image to be corrected according to the rotation angle to obtain a first text image;

[0008] Preprocessing the first text image to obtain a second text image, wherein the preprocessing includes: grayscale processing and binarization processing;

[0009] Performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value, and taking the test angle that makes the projection value of the pixel row of the second text image in the vertical direction reach the target projection value as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction;

[0010] The text image obtained by rotating the first text image through the target test angle is used as the target corrected text image.

[0011] Optionally, the angle recognition model is trained based on a set of sample text images, and the roughly estimated angle between the current state and the upright state of each sample text image is known. The rotation angle is obtained by recognizing the text image to be corrected through the pre-trained angle recognition model, including:

[0012] Image feature extraction is performed on the text image to be corrected using a pre-trained angle recognition model;

[0013] The extracted image features are matched with the image features of each sample text image through the pre-trained angle recognition model to obtain the matching degree;

[0014] The roughly estimated angle corresponding to the sample text image with the highest matching degree is used as the rotation angle of the text image to be corrected.

[0015] Optionally, the coarse estimated angle includes 0 degree, 90 degrees, 180 degrees, and 270 degrees.

[0016] Optionally, the preprocessing further includes scaling.

[0017] Optionally, performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value, and taking the test angle that makes the projection value of the pixel row of the second text image in the vertical direction reach the target projection value as the target test angle, includes:

[0018] Performing rotation tests at different test angles on the second text image in succession;

[0019] By traversing the pixels, respectively obtaining the projection values ​​corresponding to the pixel rows of the second text image after the rotation test at each test angle in the vertical direction;

[0020] Matching each acquired projection value with the target projection value respectively, and taking a test angle that makes the projection value of the pixel row of the second text image in the vertical direction equal to the target projection value as the target test angle;

[0021] The target projection value is a projection value of a non-tilted text image in a vertical direction.

[0022] Optionally, the second text image is subjected to rotation tests at different test angles in sequence, including:

[0023] Different test angles are acquired in sequence within the preset angle range through a binary search method;

[0024] The second text image is subjected to rotation tests successively according to different acquired test angles.

[0025] In a second aspect, an embodiment of the present application provides a text tilt correction device, the device comprising:

[0026] An image acquisition module, used for acquiring the text image to be corrected;

[0027] A recognition module is used to recognize the text image to be corrected by using a pre-trained angle recognition model to obtain a rotation angle, where the rotation angle represents a rough estimated angle between the current state of the text image to be corrected and the upright state;

[0028] A correction module, used for correcting the text image to be corrected according to the rotation angle to obtain a first text image;

[0029] A processing module, used for preprocessing the first text image to obtain a second text image, wherein the preprocessing includes: grayscale processing and binarization processing;

[0030] A test module is used to perform rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value, and the test angle that makes the projection value of the pixel row of the second text image in the vertical direction reach the target projection value is used as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction;

[0031] The correction module is also used to use the text image obtained by rotating the first text image by a target test angle as the target corrected text image.

[0032] Optionally, the angle recognition model is obtained by training based on a set of sample text images, a roughly estimated angle between the current state and the upright state of each sample text image is known, and the recognition module includes:

[0033] An extraction module, used for extracting image features of the text image to be corrected by using a pre-trained angle recognition model;

[0034] A matching module is used to match the extracted image features with the image features of each sample text image through a pre-trained angle recognition model to obtain a matching degree;

[0035] The comparison module is used to use the roughly estimated angle corresponding to the sample text image with the highest matching degree as the rotation angle of the text image to be corrected.

[0036] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the steps of any of the methods described above.

[0037] In a fourth aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the steps of any of the methods described above when executing the program.

[0038] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0039] The scope of use is wider, regardless of whether the text type is Chinese, English or other languages. The use conditions are loose, and there is no requirement for straight lines, tables, etc. in the document, nor does it require high quality of text images. The anti-interference ability is strong, and handwritten text, seals, fingerprints, etc. in the document can be processed. The correction accuracy is high and the accuracy can be customized. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] Figure 1 A flowchart of a text tilt correction method provided by an embodiment;

[0043] Figure 2 A schematic diagram of the division of rotation angles provided in an embodiment;

[0044] Figure 3 A schematic diagram of projection values ​​at different test angles provided by an embodiment;

[0045] Figure 4 A structural block diagram of a text tilt correction device provided by an embodiment;

[0046] Figure 5 An internal structural diagram of a computer device provided for one embodiment. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0048] Figure 1 A flowchart of a text tilt correction method provided by an embodiment. Figure 1 , the method comprises the following steps:

[0049] S100: Acquire a text image to be corrected.

[0050] S200: The text image to be corrected is identified by a pre-trained angle recognition model to obtain a rotation angle.

[0051] Specifically, the rotation angle represents the roughly estimated angle between the current state and the upright state of the text image to be corrected. The angle recognition model is trained through a large number of sample text image sets, and the angle between the tilt state and the upright state of each sample text image is known. The text image to be corrected is input into the angle recognition model for recognition, and the sample text image with the highest matching degree with the text image to be corrected can be matched. The angle between the tilt state and the upright state of the sample text image can be used as the rotation angle of the text image to be corrected.

[0052] S300: Correcting the text image to be corrected according to the rotation angle to obtain a first text image.

[0053] Specifically, for example, if the rotation angle relative to the upright state is 90 degrees clockwise, the text image to be corrected needs to be rotated 90 degrees counterclockwise to obtain the first text image.

[0054] S400: Preprocess the first text image to obtain a second text image.

[0055] Specifically, the preprocessing includes: grayscale processing and binarization processing; the first text image is subjected to grayscale processing and binarization processing successively, so that the amount of data in the second text image after preprocessing is greatly reduced, and the outline of the target can be highlighted, thereby reducing the cost of subsequent data calculation and processing.

[0056] S500: Perform rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value, and use the test angle that makes the projection value of the pixel row of the second text image in the vertical direction reach the target projection value as the target test angle.

[0057] Specifically, the target projection value is the projection value of the non-tilted text image in the vertical direction. The angle between the tilt state and the upright state of the first text image or the second text image is unknown, so this angle can be tested through a rotation test. After the second text image is rotated by each test angle, the projection value of its pixel row in the vertical direction will be different. According to the fact that the projection value of the pixel row of the text image in the upright state is the smallest, the test angle at which the projection value of the pixel row of the second text image in the vertical direction is the smallest after the rotation of the test angle is the target test angle.

[0058] S600: The text image obtained by rotating the first text image by a target test angle is used as the target corrected text image.

[0059] Specifically, the first text image is the original text image, and the second text image is a text image that is preprocessed to obtain a target test angle. A rotation test is performed on the second text image to obtain the target test angle, and the calculation and processing overhead during the test is smaller. The obtained target test angle is applied to the first text image, so that the first text image is corrected after being rotated by the target test angle.

[0060] Rotation by rotation angle is a coarse adjustment, and rotation by target test angle is a more precise adjustment and correction.

[0061] The rotation angle acquisition is based on the local rotation changeability of the document image. The text image is regarded as a text matrix. Each row of the matrix corresponds to the pixel row of the text image, and each column of the matrix corresponds to the pixel column of the text image. Because the text is basically horizontal at present, the matrix row, that is, the pixel row of the image, is mainly operated. Secondly, the projection value of the pixel row in the vertical direction of the horizontal document is the smallest. When the document is tilted, the projection value will change, making the projection value of the pixel row in the vertical direction larger. Then, the angle between the second text image and the upright state is unknown, so it is necessary to try to rotate different test angles to find the target test angle with the smallest projection value of the pixel row in the vertical direction. Finally, after obtaining the target test angle, the image can be rotated back to achieve the purpose of correction. Corrective rotation is to rotate the text image to the upright state according to the obtained target test angle.

[0062] In one embodiment, the angle recognition model is trained and acquired based on a set of sample text images, and the roughly estimated angle between the current state and the upright state of each sample text image is known. Step S200 specifically includes the following steps:

[0063] Image feature extraction is performed on the text image to be corrected using a pre-trained angle recognition model;

[0064] The extracted image features are matched with the image features of each sample text image through the pre-trained angle recognition model to obtain the matching degree;

[0065] The roughly estimated angle corresponding to the sample text image with the highest matching degree is used as the rotation angle of the text image to be corrected.

[0066] Specifically, the angle recognition model is a deep learning model. After the text image to be corrected is matched with a sample text image in the angle recognition model, the roughly estimated angle corresponding to the sample text image is the rotation angle of the text image to be corrected.

[0067] In one embodiment, the coarse estimated angles include 0 degrees, 90 degrees, 180 degrees, and 270 degrees.

[0068] Figure 2 A schematic diagram of the division of rotation angles provided in an embodiment. Figure 2 , defining the positive y-axis direction as the upright state, it can be defined that the coarse estimated angle corresponding to the sample text image whose angle between the inclined state and the upright state is between -45 degrees and 45 degrees is 0 degrees; the coarse estimated angle corresponding to the sample text image whose angle between the inclined state and the upright state is between 45 degrees and 135 degrees is 90 degrees; the coarse estimated angle corresponding to the sample text image whose angle between the inclined state and the upright state is between 135 degrees and 225 degrees is 180 degrees; the coarse estimated angle corresponding to the sample text image whose angle between the inclined state and the upright state is between 225 degrees and 315 degrees is 270 degrees.

[0069] When the text image to be corrected matches any sample text image whose angle between the inclined state and the upright state is between -45 degrees and 45 degrees, the rotation angle of the text image to be corrected is 0 degrees; when the text image to be corrected matches any sample text image whose angle between the inclined state and the upright state is between 45 degrees and 135 degrees, the rotation angle of the text image to be corrected is 90 degrees; when the text image to be corrected matches any sample text image whose angle between the inclined state and the upright state is between 135 degrees and 225 degrees, the rotation angle of the text image to be corrected is 180 degrees; when the text image to be corrected matches any sample text image whose angle between the inclined state and the upright state is between 225 degrees and 315 degrees, the rotation angle of the text image to be corrected is 270 degrees.

[0070] Of course, each rough estimated angle may also be defined to correspond to other angle ranges.

[0071] In one embodiment, pre-processing also includes scaling.

[0072] Specifically, the second text image is used to obtain the target test angle through a rotation test. Therefore, the second text image will undergo multiple rotation tests at different test angles, and each rotation test requires a large amount of calculation and processing. Before the rotation test, proportional scaling of the second text image can make the data of the second text image smaller, consume less time during the rotation test, speed up the test process, and obtain the target test angle more quickly.

[0073] For example, the original text image to be corrected may be relatively large, about 2500*3500 in size, and the speed of traversing the second text image (binarized image) of this text image to be corrected will be very slow. The acceleration method is to scale the width and height of the text image to be corrected to smaller values, such as about 500*700, and then preprocess it to obtain the second text image.

[0074] In one embodiment, step S500 specifically includes:

[0075] Performing rotation tests at different test angles on the second text image in succession;

[0076] By traversing the pixels, respectively obtaining the projection values ​​corresponding to the pixel rows of the second text image after the rotation test at each test angle in the vertical direction;

[0077] Each acquired projection value is matched with the target projection value respectively, and a test angle that makes the projection value of the pixel row of the second text image in the vertical direction equal to the target projection value is used as the target test angle; wherein the target projection value is the projection value of the non-tilted text image in the vertical direction.

[0078] Specifically, refer to Figure 2 , the angle between the tilted state and the upright state of the second text image obtained after the correction text image is rotated by the rotation angle is between -45 degrees and 45 degrees. Taking the step size as 0.1, 900 test angles can be obtained in (-45, 45, 0.1), among which there is a test angle that can make the projection value of the pixel row of the second text image in the vertical direction after the rotation test of the test angle be the target projection value.

[0079] In one embodiment, only pixel rows are traversed. In the actual process, the value of each pixel needs to be judged, that is, each pixel row and each pixel column in each pixel row need to be judged. The accelerated method is to traverse only pixel rows.

[0080] In one embodiment, the second text image is subjected to rotation tests at different test angles in succession, including:

[0081] Different test angles are acquired in sequence within the preset angle range through a binary search method;

[0082] The second text image is subjected to rotation tests successively according to different acquired test angles.

[0083] Specifically, the binary search method means: divide n elements into two halves of roughly equal number, take a[n / 2] and compare it with the x to be found, if x = a[n / 2], then x is found and the algorithm operation terminates. Figure 2 , the angle between the tilted state and the upright state of the second text image obtained after the correction text image is rotated by the rotation angle is between -45 degrees and 45 degrees. Using the binary search method, each time you only need to determine the range of the test angle, for example, the test angle is in the range of (-45,0) or (0,45), and each judgment can reduce half of the attempts on this basis. Originally, about 900 angles needed to be tried, but using the binary search method, the target test angle can be obtained in no more than 10 times.

[0084] Figure 1 FIG. 1 is a flowchart of a text tilt correction method in an embodiment. It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0085] Figure 3 A schematic diagram of projection values ​​at different test angles provided by an embodiment. Figure 3 , the projection value corresponding to the second text image when it is rotated within the range of -45 to 45 degrees. The image in the upright state is basically symmetrical about the y-axis, and the tilted image will shift to the left or right on this basis. The horizontal coordinate of point a corresponds to the optimal rotation angle, that is, the target test angle, and the vertical coordinate corresponds to the smallest projection value.

[0086] Figure 4 A structural block diagram of a text tilt correction device provided by an embodiment. Figure 4 , the device comprises:

[0087] The image acquisition module 10 is used to acquire the text image to be corrected.

[0088] The recognition module 20 is used to recognize the text image to be corrected by using a pre-trained angle recognition model to obtain a rotation angle, where the rotation angle represents a roughly estimated angle between the current state of the text image to be corrected and the upright state.

[0089] The correction module 30 is used to correct the text image to be corrected according to the rotation angle to obtain a first text image.

[0090] The processing module 40 is used to pre-process the first text image to obtain a second text image, wherein the pre-processing includes grayscale processing and binarization processing.

[0091] The test module 50 is used to perform rotation tests on the second text image at different test angles until the projection value of the pixel row of the second text image in the vertical direction is the target projection value, and the test angle that makes the projection value of the pixel row of the second text image in the vertical direction the target projection value is used as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction.

[0092] The correction module 30 is further configured to use the text image obtained by rotating the first text image by a target test angle as a target corrected text image.

[0093] In one embodiment, the angle recognition model is trained and acquired based on a set of sample text images, and the roughly estimated angle between the current state and the upright state of each sample text image is known. The recognition module 20 includes:

[0094] The extraction module is used to extract image features of the text image to be corrected through a pre-trained angle recognition model.

[0095] The matching module is used to match the extracted image features with the image features of each sample text image through a pre-trained angle recognition model to obtain a matching degree.

[0096] The comparison module is used to use the roughly estimated angle corresponding to the sample text image with the highest matching degree as the rotation angle of the text image to be corrected.

[0097] In one embodiment, the coarse estimated angles include 0 degrees, 90 degrees, 180 degrees, and 270 degrees.

[0098] In one embodiment, pre-processing also includes scaling.

[0099] In one embodiment, the test module 50 is specifically used to: perform rotation tests at different test angles on the second text image in sequence; obtain the projection values ​​corresponding to the pixel rows of the second text image in the vertical direction after the rotation test at each test angle by traversing the pixels; match each obtained projection value with the target projection value, and use the test angle that makes the projection value of the pixel rows of the second text image in the vertical direction equal to the target projection value as the target test angle; wherein the target projection value is the projection value of the text image in the vertical direction without tilt.

[0100] Figure 5 An internal structure diagram of a computer device provided by an embodiment. Figure 5 , the computer device comprises a processor, a memory, a network interface, an input device and a display screen connected via a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program, which, when executed by the processor, enables the processor to implement a text tilt correction method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute a text tilt correction method. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.

[0101] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0102] In one embodiment, the text tilt correction device provided by the present application can be implemented in the form of a computer program. The computer program can be Figure 5 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the text tilt correction device, such as: Figure 5 The image acquisition module 10, the recognition module 20, the correction module 30, the processing module 40, and the test module 50 are shown. The computer program composed of the various program modules enables the processor to execute the steps of the text tilt correction method of each embodiment of the present application described in this specification.

[0103] For example, Figure 5 The computer device shown can be Figure 4The image acquisition module 10 in the text tilt correction device shown acquires the text image to be corrected. The computer device can perform recognition of the text image to be corrected through the pre-trained angle recognition model through the recognition module 20 to obtain the rotation angle, and the rotation angle represents the rough estimated angle between the current state of the text image to be corrected and the upright state. The computer device can perform correction of the text image to be corrected according to the rotation angle through the correction module 30 to obtain the first text image. The computer device can perform preprocessing of the first text image through the processing module 40 to obtain the second text image, and the preprocessing includes: grayscale processing and binarization processing. The computer device can perform rotation tests of the second text image at different test angles through the test module 50, until the projection value of the pixel row of the second text image in the vertical direction is the target projection value, and the test angle that makes the projection value of the pixel row of the second text image in the vertical direction the target projection value is used as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction. The computer device can also perform the text image obtained by rotating the first text image through the target test angle as the target corrected text image through the correction module 30.

[0104] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: obtaining a text image to be corrected; identifying the text image to be corrected by a pre-trained angle recognition model to obtain a rotation angle, wherein the rotation angle represents a rough estimated angle between the current state of the text image to be corrected and the upright state; correcting the text image to be corrected according to the rotation angle to obtain a first text image; preprocessing the first text image to obtain a second text image, wherein the preprocessing includes: grayscale processing and binarization processing; performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction is a target projection value, and taking the test angle that makes the projection value of the pixel row of the second text image in the vertical direction equal to the target projection value as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction; and taking the text image obtained after the first text image is rotated by the target test angle as the target corrected text image.

[0105] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining a text image to be corrected; identifying the text image to be corrected by a pre-trained angle recognition model to obtain a rotation angle, wherein the rotation angle represents a rough estimated angle between the current state of the text image to be corrected and the upright state; correcting the text image to be corrected according to the rotation angle to obtain a first text image; preprocessing the first text image to obtain a second text image, wherein the preprocessing includes: grayscale processing and binarization processing; performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction is the target projection value, and taking the test angle that makes the projection value of the pixel row of the second text image in the vertical direction the target projection value as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction; and taking the text image obtained after the first text image is rotated by the target test angle as the target corrected text image.

[0106] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0107] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also 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 "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0108] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for text tilt correction, It is characterized in that The method comprises: Obtain the text image to be corrected; The text image to be corrected is identified by a pre-trained angle recognition model to obtain a rotation angle, wherein the rotation angle represents a rough estimated angle between a current state of the text image to be corrected and an upright state, wherein the rough estimated angle includes 0 degrees, 90 degrees, 180 degrees or 270 degrees; Correcting the text image to be corrected according to the rotation angle to obtain a first text image; Preprocessing the first text image to obtain a second text image, wherein the preprocessing includes: grayscale processing and binarization processing, and the preprocessing also includes proportional scaling, wherein the proportional scaling makes the data of the second text image smaller than that of the first text image; Performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction is the target projection value, and taking the test angle that makes the projection value of the pixel row of the second text image in the vertical direction the target projection value as the target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction; The text image obtained by rotating the first text image by the target test angle is used as the target corrected text image; The performing rotation tests at different test angles on the second text image respectively includes: Different test angles are acquired in sequence within the preset angle range through a binary search method; The second text image is subjected to rotation tests successively according to the different test angles obtained.

2. The method according to claim 1, It is characterized in that The angle recognition model is obtained by training a set of sample text images, and the roughly estimated angle between the current state and the upright state of each sample text image is known. The rotation angle is obtained by recognizing the text image to be corrected by the pre-trained angle recognition model, including: Performing image feature extraction on the text image to be corrected by using a pre-trained angle recognition model; The extracted image features are matched with the image features of each sample text image by the pre-trained angle recognition model to obtain a matching degree; The roughly estimated angle corresponding to the sample text image with the highest matching degree is used as the rotation angle of the text image to be corrected.

3. The method according to claim 2, It is characterized in that The step of performing rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value, and taking the test angle at which the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value as the target test angle, comprises: Performing rotation tests at different test angles on the second text image in succession; By traversing the pixels, respectively obtaining the projection values ​​corresponding to the pixel rows of the second text image after the rotation test at each test angle in the vertical direction; Matching each acquired projection value with the target projection value respectively, and taking a test angle at which the projection value of a pixel row of the second text image in a vertical direction is equal to the target projection value as a target test angle; The target projection value is a projection value of a non-tilted text image in a vertical direction.

4. A text tilt correction device, It is characterized in that The device comprises: An image acquisition module, used for acquiring the text image to be corrected; A recognition module, used for recognizing the text image to be corrected by using a pre-trained angle recognition model to obtain a rotation angle, wherein the rotation angle represents a rough estimated angle between the current state of the text image to be corrected and the upright state, wherein the rough estimated angle includes 0 degrees, 90 degrees, 180 degrees or 270 degrees; A correction module, used for correcting the text image to be corrected according to the rotation angle to obtain a first text image; A processing module, configured to preprocess the first text image to obtain a second text image, wherein the preprocessing includes grayscale processing and binarization processing, and the preprocessing also includes proportional scaling, wherein the proportional scaling makes the data of the second text image smaller than that of the first text image; a test module, configured to perform rotation tests at different test angles on the second text image until the projection value of the pixel row of the second text image in the vertical direction reaches a target projection value, and to use the test angle at which the projection value of the pixel row of the second text image in the vertical direction reaches the target projection value as a target test angle, wherein the target projection value is the projection value of the text image without tilt in the vertical direction; The correction module is further used to use the text image obtained by rotating the first text image by the target test angle as the target corrected text image; The test module is further used to successively acquire different test angles within a preset angle range by a binary search method; and to successively perform rotation tests on the second text image according to the acquired different test angles.

5. The device according to claim 4, It is characterized in that The angle recognition model is obtained by training a set of sample text images, and the roughly estimated angle between the current state and the upright state of each sample text image is known. The recognition module includes: An extraction module, used for extracting image features of the text image to be corrected by using a pre-trained angle recognition model; A matching module, used to match the extracted image features with the image features of each sample text image through the pre-trained angle recognition model to obtain a matching degree; The comparison module is used to use the roughly estimated angle corresponding to the sample text image with the highest matching degree as the rotation angle of the text image to be corrected.

6. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 3.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the method according to any one of claims 1 to 3 are performed.