Method for determining whether image text is curved, storage medium and product

By preprocessing the contract image and analyzing the number of polygon sides, combined with verification of the included angle of the straight line, the problem of OCR recognition difficulties caused by the curvature of the contract image was solved, and the efficiency and accuracy of text detection were improved.

CN114782939BActive Publication Date: 2025-11-18KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210313607.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-28
Publication Date
2025-11-18
Estimated Expiration
2042-03-28

AI Technical Summary

Technical Problem

In existing technologies, contract images are often curved during the photography process, making OCR recognition difficult, which affects the efficiency of text detection and recognition, and the correction process is time-consuming.

Method used

By preprocessing the original image, the detection area is determined and the number of sides of the text polygon is calculated to determine whether there is curved text in the image. The degree of curvature is verified by combining the angle between the horizontal and vertical lines.

Benefits of technology

It achieves efficient and accurate identification of whether text in an image is curved, reduces OCR recognition errors caused by curvature, and improves the efficiency and accuracy of text detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114782939B_ABST
    Figure CN114782939B_ABST
Patent Text Reader

Abstract

The embodiment of the disclosure discloses a method for judging whether text in an image is curved and a storage medium and product, and the method comprises the following steps: preprocessing an original image to determine at least one detection region in the original image; wherein the original image comprises at least one line of text; determining at least one text polygon in the original image based on the at least one detection region; and determining whether there is curved text in the original image based on the number of edges of the at least one text polygon. In the embodiment, a text polygon containing text content is determined by detection, and since the number of edges of the polygon increases relatively if there is a curve in the text, whether there is curved text in the original image is judged by the number of edges of the text polygon, so that efficient and accurate curved judgment of the text in the image is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image recognition technology, and in particular to a method and storage medium and product for determining whether text in an image is curved. Background Technology

[0002] Contracts, as the most numerous and complex documents involved in various transaction scenarios, require OCR recognition for digital processing. However, due to the significant curvature of contracts during the photographing process, OCR recognition is greatly interfered with, severely impacting text detection and recognition. If the OCR recognition stage discovers that the contract cannot be recognized due to curvature after it has been uploaded to the system, and then it needs to be sent back for processing, a lot of time will be wasted. Therefore, it is necessary to determine whether the contract text is curved in advance. Summary of the Invention

[0003] To address the aforementioned technical problems, this disclosure is proposed. Embodiments of this disclosure provide a method, storage medium, and product for determining whether text in an image is curved.

[0004] According to one aspect of the present disclosure, a method for determining whether text in an image is curved is provided, comprising:

[0005] The original image is preprocessed to determine at least one detection region in the original image; wherein the original image includes at least one line of text;

[0006] Based on the at least one detection region, at least one text polygon in the original image is determined;

[0007] Based on the number of sides of the at least one text polygon, determine whether there is curved text in the original image.

[0008] Optionally, the preprocessing of the original image to determine at least one detection region in the original image includes:

[0009] A first image with a single channel is obtained based on the original image;

[0010] The first image is binarized to obtain the second image;

[0011] The second image is subjected to multiple dilatational erosions based on morphological nuclei of different sizes to obtain the at least one detection region.

[0012] Optionally, obtaining a single-channel first image based on the original image includes:

[0013] The original image is scaled to obtain a scaled image of a set size;

[0014] A first image with a single channel is obtained based on the scaled image.

[0015] Optionally, determining at least one text polygon in the original image based on the at least one detection region includes:

[0016] Based on the connectivity of the at least one detection region, determine the minimum bounding polygon corresponding to the at least one detection region with connectivity;

[0017] The text polygon is determined based on the minimum bounding polygon.

[0018] Optionally, determining whether curved text exists in the original image based on the number of sides of the at least one text polygon includes:

[0019] In response to the fact that the number of edges of at least one text polygon in the at least one text polygon is greater than a set threshold;

[0020] It was determined that curved text existed in the original image.

[0021] Optionally, the method further includes:

[0022] In response to determining that curved text exists in the original image, a first predetermined number of horizontal straight lines and a second predetermined number of vertical straight lines are determined to be included in the original image;

[0023] Based on at least one included angle corresponding to the first set number of horizontal lines and the second set number of vertical lines, determine whether the conclusion that curved text exists in the original image is correct.

[0024] Optionally, determining the first predetermined number of horizontal lines and the second predetermined number of vertical lines included in the original image includes:

[0025] The original image is processed to obtain the gradient image corresponding to the original image;

[0026] Perform a Hough transform on the gradient image to obtain at least one straight line and its corresponding angle;

[0027] Based on the line angle, determine the first predetermined number of horizontal lines and the second predetermined number of vertical lines from the at least one line.

[0028] Optionally, determining the first predetermined number of horizontal lines and the second predetermined number of vertical lines from the at least one line based on the line angle includes:

[0029] The at least one straight line is sorted according to the difference between the corresponding straight line angle and the horizontal angle to obtain a first sequence;

[0030] The at least one execution is sorted according to the difference between the corresponding straight angle and vertical angle to obtain a second sequence;

[0031] Obtain the first predetermined number of horizontal lines from the first sequence, and obtain the second predetermined number of vertical lines from the second sequence.

[0032] Optionally, processing the original image to obtain the gradient image corresponding to the original image includes:

[0033] The original image is scaled to obtain a scaled image of a set size;

[0034] Perform grayscale conversion or channel separation processing on the scaled image to obtain a single-channel image;

[0035] The single-channel image is smoothed to obtain a smoothed image;

[0036] The gradient image is obtained based on the smoothed image.

[0037] Optionally, determining whether the conclusion that curved text exists in the original image is correct based on at least one angle corresponding to the first predetermined number of horizontal lines and the second predetermined number of vertical lines includes:

[0038] For each of the first set number of horizontal lines, based on the first vector corresponding to the horizontal line and the second vector corresponding to the at least one vertical line that intersects the horizontal line, the angle of at least one angle between the horizontal line and the at least one vertical line is determined.

[0039] Based on whether the angle of the at least one included angle meets the preset conditions, it is determined whether the conclusion that there is curved text in the original image is correct.

[0040] Optionally, determining whether the conclusion that curved text exists in the original image is correct based on whether the angle of the at least one included angle meets preset conditions includes:

[0041] If it is determined whether there is an angle in the at least one included angle that exceeds a set range by a set proportion, then the conclusion that there is curved text in the original image is correct; otherwise, the conclusion that there is curved text in the original image is incorrect.

[0042] According to another aspect of the embodiments of this disclosure, a device for determining whether text in an image is curved is provided, comprising:

[0043] A preprocessing module is used to preprocess the original image to determine at least one detection region in the original image; wherein the original image includes at least one line of text;

[0044] A polygon determination module is used to determine at least one text polygon in the original image based on the at least one detection region;

[0045] The first curvature recognition module is used to determine whether there is curved text in the original image based on the number of sides of the at least one text polygon.

[0046] Optionally, the preprocessing module includes:

[0047] A single-channel unit is used to obtain a first image in a single channel based on the original image;

[0048] A binarization unit is used to perform binarization processing on the first image to obtain a second image;

[0049] An expansion erosion unit is used to perform multiple expansion erosions on the second image based on morphological nuclei of different sizes to obtain the at least one detection region.

[0050] Optionally, the single-channel unit is specifically used to perform scaling processing on the original image to obtain a scaled image of a set size; and to obtain a single-channel first image based on the scaled image.

[0051] Optionally, the polygon determination module is specifically used to determine the minimum bounding polygon corresponding to the at least one detection region with connectivity based on the connectivity of the at least one detection region; and to determine the text polygon based on the minimum bounding polygon.

[0052] Optionally, the first curvature recognition module is specifically configured to determine that there is curved text in the original image in response to the fact that the number of sides of at least one text polygon in the at least one text polygon is greater than a set threshold.

[0053] Optionally, the device further includes:

[0054] The second curvature recognition module is used to determine, in response to determining that there is curved text in the original image, a first predetermined number of horizontal lines and a second predetermined number of vertical lines included in the original image; and to determine whether the conclusion that there is curved text in the original image is correct based on at least one included angle corresponding to the first predetermined number of horizontal lines and the second predetermined number of vertical lines.

[0055] Optionally, the second bending recognition module includes:

[0056] A gradient unit is used to process the original image to obtain a gradient image corresponding to the original image;

[0057] The Hough transform unit is used to perform a Hough transform on the gradient image to obtain at least one straight line and its corresponding straight line angle.

[0058] A straight line determination unit is used to determine, based on the straight line angle, a first predetermined number of horizontal straight lines and a second predetermined number of vertical straight lines from the at least one straight line.

[0059] Optionally, the line determination unit is specifically used to sort the at least one line according to the difference between the corresponding line angle and the horizontal angle to obtain a first sequence; sort the at least one line according to the difference between the corresponding line angle and the vertical angle to obtain a second sequence; obtain a first set number of horizontal lines from the first sequence, and obtain a second set number of vertical lines from the second sequence.

[0060] Optionally, the gradient unit is specifically used to perform scaling processing on the original image to obtain a scaled image of a set size; perform grayscale or channel separation processing on the scaled image to obtain a single-channel image; perform smoothing processing on the single-channel image to obtain a smoothed image; and obtain the gradient image based on the smoothed image.

[0061] Optionally, determining whether the conclusion that curved text exists in the original image is correct based on at least one angle corresponding to the first predetermined number of horizontal lines and the second predetermined number of vertical lines includes:

[0062] For each of the first set number of horizontal lines, based on the first vector corresponding to the horizontal line and the second vector corresponding to the at least one vertical line that intersects the horizontal line, the angle of at least one angle between the horizontal line and the at least one vertical line is determined.

[0063] Based on whether the angle of the at least one included angle meets the preset conditions, it is determined whether the conclusion that there is curved text in the original image is correct.

[0064] Optionally, the second curvature recognition module is further configured to determine whether there is a set proportion of the included angle that exceeds a set range. If so, the conclusion that there is curved text in the original image is correct; otherwise, the conclusion that there is curved text in the original image is incorrect.

[0065] According to another aspect of the present disclosure, a computer-readable storage medium is provided, the storage medium storing a computer program for executing the method for determining whether text in an image is curved as described in any of the above embodiments.

[0066] According to another aspect of the embodiments of this disclosure, an electronic device is provided, the electronic device comprising:

[0067] processor;

[0068] Memory used to store the processor's executable instructions;

[0069] The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for determining whether text in an image is curved as described in any of the above embodiments.

[0070] Based on the above embodiments of this disclosure, a method and storage medium / product for determining whether text in an image is curved are provided. The original image is preprocessed to determine at least one detection region in the original image; wherein the original image includes at least one line of text; at least one text polygon in the original image is determined based on the at least one detection region; and the presence of curved text in the original image is determined based on the number of sides of the at least one text polygon. This embodiment determines the text polygon containing the text content through detection. Furthermore, since the number of sides of the polygon increases relatively if the text is curved, determining whether curved text exists in the original image by the number of sides of the text polygon achieves efficient and accurate text curvature determination in an image.

[0071] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0072] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.

[0073] Figure 1 This is a flowchart illustrating a method for determining whether text in an image is curved, provided in an exemplary embodiment of this disclosure.

[0074] Figure 2 This is a public announcement Figure 1 A flowchart of step 102 in the illustrated embodiment is shown.

[0075] Figure 3a This is a schematic diagram of a scaled image provided as an optional example of this disclosure.

[0076] Figure 3b Yes Figure 3a A schematic diagram of the first image obtained through image scaling.

[0077] Figure 3c Yes Figure 3b A schematic diagram of the second image after binarization of the first image shown.

[0078] Figure 3d yes Figure 3c The diagram shows multiple detection regions in the second image obtained by dilatational erosion of the second image.

[0079] Figure 3e Based on Figure 3d The diagram shows multiple minimum bounding polygons obtained from multiple detection regions.

[0080] Figure 4 This is a flowchart illustrating a method for determining whether text in an image is curved, provided in another exemplary embodiment of this disclosure.

[0081] Figure 5 This is a public announcement Figure 4 A flowchart illustrating step 408 in the illustrated embodiment.

[0082] Figure 6a This is a schematic diagram of a scaled image provided as another optional example of this disclosure.

[0083] Figure 6b Yes Figure 6a The diagram shows a single-channel image obtained through image scaling.

[0084] Figure 6c Yes Figure 6b The diagram shows a gradient image obtained from single-channel image processing.

[0085] Figure 6d This is a schematic diagram of a straight line obtained after the Hough transform of a gradient image, provided as an optional example of this disclosure.

[0086] Figure 7 This is a schematic diagram of the structure of an image text bending determination device provided in an exemplary embodiment of the present disclosure.

[0087] Figure 8 This is a structural diagram of an electronic device provided in an exemplary embodiment of this disclosure. Detailed Implementation

[0088] Hereinafter, exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present disclosure, and not all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.

[0089] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of this disclosure.

[0090] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of this disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.

[0091] It should also be understood that in the embodiments disclosed herein, "a plurality of" may refer to two or more, and "at least one" may refer to one, two or more.

[0092] It should also be understood that any component, data or structure mentioned in the embodiments of this disclosure can generally be understood as one or more unless expressly defined or given to the contrary in the context.

[0093] Furthermore, the term "and / or" in this disclosure is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this disclosure generally indicates that the preceding and following related objects have an "or" relationship. The data referred to in this disclosure can include unstructured data such as text, images, and videos, as well as structured data.

[0094] It should also be understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.

[0095] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.

[0096] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.

[0097] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0098] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0099] The embodiments disclosed herein can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.

[0100] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.

[0101] Exemplary methods

[0102] Figure 1 This is a flowchart illustrating a method for determining whether text in an image is curved, provided in an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices, such as... Figure 1 As shown, it includes the following steps:

[0103] Step 102: Preprocess the original image to determine at least one detection region in the original image.

[0104] The original image includes at least one line of text.

[0105] Optionally, in order to determine whether the text in the original image is curved, the location of the text in the original image is identified, and the location corresponding to the text that is continuous in the original image (e.g., the interval is less than a set interval, etc. is determined to be continuous) is determined as a detection region.

[0106] Step 104: Determine at least one text polygon in the original image based on at least one detection region.

[0107] In one embodiment, the detection area is determined based on the text content and may be irregular. In order to better determine the curvature in the text content, the detection area can be regularized to obtain at least one text polygon.

[0108] Step 106: Determine whether there is curved text in the original image based on the number of sides of at least one text polygon.

[0109] When the text content in the original image is not curved, the number of sides or the area of ​​the text polygons, where each side is a straight line, should be within a certain range. For example, the polygons are mostly rectangles, meaning the number of sides should be 4, etc. In this case, if the number of sides of a text polygon is much greater than a set value or the average of all current text polygons, it can be considered that there is curved text.

[0110] The present disclosure provides a method for determining whether text in an image is curved, which involves preprocessing the original image to determine at least one detection region in the original image; wherein the original image includes at least one line of text; determining at least one text polygon in the original image based on the at least one detection region; and determining whether curved text exists in the original image based on the number of sides of the at least one text polygon. This embodiment determines the text polygon containing the text content by detection, and since the number of sides of the polygon increases if the text is curved, the method determines whether curved text exists in the original image by the number of sides of the text polygon, thus achieving efficient and accurate text curvature determination in the image.

[0111] like Figure 2 As shown above, in the above Figure 1 Based on the illustrated embodiment, step 102 may include the following steps:

[0112] Step 1021: Obtain a single-channel first image based on the original image.

[0113] In this embodiment, when the original image is a color image (e.g., including a red seal), it may affect recognition and make it impossible to accurately identify whether the text is complete. For example, when the original image is a contract image, the image usually includes a seal, and the seal usually has color. If it is not uniform, some text content in the image may be ignored. Therefore, in order to remove the influence of the seal and other curved text on recognition, this embodiment processes the original image into a single-channel image to make the text display in the image consistent, so as to facilitate subsequent recognition.

[0114] Step 1022: Binarize the first image to obtain the second image.

[0115] The first image after single-channel processing may be displayed as grayscale. However, the contrast between the text area and the non-text area is not maximized at this time. In this embodiment, binarization processing is used to maximize the difference between the area corresponding to the text and the area of ​​non-text in the image, so as to facilitate the detection of the area where the image is located. For example, the color value of the area corresponding to the text is set to 0, and the color value of the non-text area is set to 255, etc.

[0116] Step 1023: Perform multiple dilatational erosions on the second image based on morphological kernels of different sizes to obtain at least one detection region.

[0117] In this embodiment, with a convolution kernel of a preset size as the center, the edges of each continuous text segment in the second image are identified through existing dilation and erosion operations, and the detection area corresponding to each continuous text segment is obtained. In this embodiment, the regions corresponding to continuous text in all images are detected through dilation and erosion to determine whether these text segments are curved.

[0118] Optionally, based on the above embodiments, step 1021 may further include:

[0119] The original image is scaled to obtain a scaled image of a set size;

[0120] The first image of a single channel is obtained by scaling the image.

[0121] This embodiment performs resizing on the original image, processing each image into a scaled image of the same size, thus improving processing efficiency. For example, the original image is processed into a 512 pixel * 512 pixel image. The scaled image is then processed into a single-channel first image, which can be achieved through channel separation. For example, when the original image is an RGB image, the red channel of the scaled image is separated to obtain a single-channel first image, providing a foundation for subsequent dilation and erosion processing. For example, in an optional example, for such... Figure 3a The scaled image shown (the specific text content in this image is unrelated to this application and is only used to illustrate the position of the text) is subjected to red channel separation to obtain the following result: Figure 3b The first image shown, followed by... Figure 3b The first image shown is binarized to obtain the following result: Figure 3c The second image shown is then subjected to dilation and erosion to obtain the following result: Figure 3d The multiple detection regions shown in the second image.

[0122] Optionally, based on the above embodiments, step 104 may include the following steps:

[0123] Based on the connectivity of at least one detection region, determine the minimum bounding polygon corresponding to at least one detection region with connectivity.

[0124] Determine the text polygon based on the minimum bounding polygon.

[0125] In this embodiment, since each character in the text content may correspond to a different erosion shape, the shape of the obtained detection area is usually irregular. Optionally, a function provided in the prior art can be used to determine the minimum bounding polygon (which can be a convex polygon or a concave polygon, usually a convex polygon) for at least one detected detection area. The bounding polygon is a regular shape composed of multiple straight lines, for example, such as... Figure 3e As shown, it is based on Figure 3d The multiple detection regions shown yielded multiple minimum bounding polygons ( Figure 3a , 3b And the blacked-out parts in 3e and Figure 3c The white portion is used to obscure specific contract information and is unrelated to the method provided in this embodiment.

[0126] Optionally, based on the above embodiments, step 106 may include the following steps:

[0127] In response to the fact that the number of edges of at least one text polygon in at least one text polygon is greater than a set threshold;

[0128] Optionally, a threshold can be determined based on the average number of edges included in at least one text polygon; that is, the total number of edges corresponding to at least one text polygon included in the image is obtained, and the total number is divided by the number of text polygons to obtain the average number of edges, and the average value is used as the threshold.

[0129] The presence of curved text in the original image was identified.

[0130] In this embodiment, if the text in the image is curved, the number of sides of the corresponding text polygon will increase. This embodiment uses the number of sides as a criterion. When the number of sides is greater than the first threshold, it indicates that the text content in the text polygon is curved.

[0131] Figure 4 This is a flowchart illustrating a method for determining whether text in an image is curved, provided in another exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices, such as... Figure 4 As shown, it includes the following steps:

[0132] Step 402: Preprocess the original image to determine at least one detection region in the original image.

[0133] The original image includes at least one line of text.

[0134] The implementation process and technical effects of this step can be referred to Figure 1 Step 102 in the provided embodiments will not be repeated here.

[0135] Step 404: Determine at least one text polygon in the original image based on at least one detection region.

[0136] The implementation process and technical effects of this step can be referred to Figure 1 Step 104 in the provided embodiment will not be repeated here.

[0137] Step 406: Determine whether there is curved text in the original image based on the number of sides of at least one text polygon.

[0138] The implementation process and technical effects of this step can be referred to Figure 1 Step 106 in the provided embodiments will not be repeated here.

[0139] Step 408: In response to determining that curved text exists in the original image, determine that the original image includes a first set number of horizontal lines and a second set number of vertical lines.

[0140] This embodiment identifies whether the text content in the original image has been deformed by obtaining at least one horizontal and vertical orientation of the text included in the original image.

[0141] Step 410: Based on at least one included angle corresponding to the first set number of horizontal lines and the second set number of vertical lines, determine whether the conclusion that curved text exists in the original image is correct.

[0142] In this embodiment, in order to improve the accuracy of the detection results, when it is determined that there is curved text, further curvature verification can be performed on the original image, and the text can be determined by the angle value between the text orientations in at least one direction to determine whether the text is deformed during the shooting process. If the text content obtained is curved, this embodiment combines two methods for recognizing curved text to determine whether the text in the image is curved, thereby improving the accuracy of the determination results.

[0143] like Figure 5 As shown above, in the above Figure 4 Based on the illustrated embodiment, step 408 may include the following steps:

[0144] Step 4081: Process the original image to obtain the gradient image corresponding to the original image.

[0145] Optionally, the original image can be first converted to grayscale or extracted to obtain a single-channel image. Then, the Laplacian operator in the prior art can be used to process the single-channel image to obtain a gradient image. Using the gradient image to perform Hough transform makes it easier to determine the curved line.

[0146] Step 4082: Perform Hough transform on the gradient image to obtain at least one straight line and its corresponding angle.

[0147] The Hough transform indicates that a point in the original image coordinate system corresponds to a straight line in the parametric coordinate system, and similarly, a straight line in the parametric coordinate system corresponds to a point in the original coordinate system. All points that represent a straight line in the original coordinate system have the same slope and intercept, so they correspond to the same point in the parametric coordinate system. Therefore, after projecting all points in the original coordinate system onto the parametric coordinate system, we check for clustered points in the parametric coordinate system; these clustered points correspond to the straight lines in the original coordinate system. In other words, in the distance-angle parameter space, a point in the image becomes a sine curve, not a straight line in the kb parameter space. The intersections of these sine curves are the straight lines to be detected in the image space.

[0148] Step 4083: Determine a first set number of horizontal lines and a second set number of vertical lines from at least one line based on the line angle.

[0149] This embodiment uses Hough transform to obtain multiple straight lines representing the text orientation in the output original image and the direction corresponding to each line. The horizontal and vertical lines can be determined based on the output direction. In order to improve processing efficiency, this embodiment only judges a first set number of horizontal lines and a second set number of vertical lines. The first set number and the second set number can be set according to the actual application scenario. For example, for an image where the original image is rectangular, both the first set number and the second set number can be set to 2.

[0150] Optionally, based on the above embodiments, step 4083 may include:

[0151] Sort at least one straight line according to the difference between its corresponding straight line angle and horizontal angle to obtain the first sequence;

[0152] For at least one execution, sort them according to the difference between the corresponding straight line angle and the vertical angle to obtain the second sequence;

[0153] Obtain a first set number of horizontal lines from the first sequence, and obtain a second set number of vertical lines from the second sequence.

[0154] In this embodiment, to determine a first set number of horizontal lines and a second set number of vertical lines from multiple lines output by the Hough transform, the lines can be sorted according to their output angle values. The lines are sorted from smallest to largest by the difference between their angle and the horizontal angle to obtain a first sequence. The first set number of lines obtained in sequence are the horizontal lines closest to the horizontal angle. Correspondingly, the lines are sorted from smallest to largest by the difference between their angle and the vertical angle to obtain a second sequence. The second set number of lines obtained in sequence are the vertical lines closest to the vertical angle. This embodiment achieves rapid acquisition of a set number of lines through sorting, improving the efficiency of line filtering.

[0155] Optionally, based on the above embodiments, step 4081 may include:

[0156] The original image is scaled to obtain a scaled image of a set size;

[0157] Perform grayscale conversion or channel separation on the scaled image to obtain a single-channel image;

[0158] A smoothed image is obtained by smoothing a single-channel image;

[0159] Gradient images are obtained from smoothed images.

[0160] In this embodiment, the original image is resized, and each processed image is scaled to the same size, improving processing efficiency. For example, the original image is scaled to 512 pixels * 512 pixels. The scaled image is then processed into a single-channel image through grayscale conversion or channel separation. For example, when the original image is an RGB image, the red channel of the scaled image is separated to obtain a single-channel image, providing a basis for subsequent dilation and erosion processing. For example, in an optional example, for such... Figure 6a The scaled image shown (the specific text content in this image is unrelated to this application and is only used to illustrate the position of the text; the blackened parts in the image are to obscure specific contract information and are unrelated to the method provided in the embodiments of this disclosure) is then converted to grayscale to obtain the following result. Figure 6b The single-channel image shown, followed by... Figure 6b The single-channel image shown is smoothed using methods such as Gaussian filtering to remove interference. The resulting smoothed image is then processed by applying the Laplacian operator, yielding the image shown below. Figure 6c The gradient image shown.

[0161] Optionally, based on the above embodiments, step 410 may include:

[0162] For each horizontal line in the first set number of horizontal lines, based on the first vector corresponding to the horizontal line and the second vector corresponding to at least one vertical line that intersects the horizontal line, determine the angle of at least one angle between the horizontal line and at least one vertical line.

[0163] The conclusion that curved text exists in the original image is correct, based on whether at least one included angle meets the preset conditions.

[0164] In this embodiment, a directional straight line can be represented as a vector. The problem of calculating the angle between two straight lines is then transformed into calculating the angle between two vectors. Using the vector angle calculation formula, the angle between a horizontal line and a vertical line can be determined. Since the selected lines are a first predetermined number of horizontal lines closest to the horizontal text direction and a second predetermined number of vertical lines closest to the vertical text direction, multiple angles exist. For example, in an optional example, the Hough transform can be used to obtain... Figure 6d The two horizontal lines and two vertical lines shown define four included angles. The angles of these four included angles are used to determine whether the text in the image is curved.

[0165] Optionally, the conclusion that curved text exists in the original image is correct is determined based on whether the angle of at least one included angle meets preset conditions, including:

[0166] If at least one included angle is found to have an angle that exceeds a set range by a set proportion, then the conclusion that curved text exists in the original image is correct; otherwise, the conclusion that curved text exists in the original image is incorrect.

[0167] In this embodiment, since the horizontal line represents the horizontal orientation of the text in the image, and the vertical line represents the vertical orientation of the text in the image, when the text in the image is not curved, the horizontal and vertical lines should be perpendicular to each other (i.e., the angle between them is close to 90 degrees). This embodiment determines whether the horizontal and vertical lines are perpendicular by setting a set range. This set range can be set according to the actual situation, for example, it can be set to be greater than 70 degrees and less than 110 degrees. In addition, since there is at least one angle, the presence of curved text in the image can be determined by setting a ratio. For example, the set ratio is 1 / 2, etc. Different set ranges and set ratios can be set for different scenarios, so that the method of this embodiment can be flexibly configured and applicable to more application scenarios.

[0168] The method for determining whether text in an image is curved, provided in any of the embodiments of this disclosure, can be executed by any suitable device with data processing capabilities, including but not limited to: terminal devices and servers. Alternatively, the method for determining whether text in an image is curved, provided in any of the embodiments of this disclosure, can be executed by a processor, such as by a processor calling corresponding instructions stored in memory to execute any of the methods for determining whether text in an image is curved mentioned in the embodiments of this disclosure. Further details will not be elaborated below.

[0169] Exemplary device

[0170] Figure 7 This is a schematic diagram of the structure of a device for determining whether text in an image is curved, provided in an exemplary embodiment of this disclosure. Figure 7 As shown, the apparatus provided in this embodiment includes:

[0171] The preprocessing module 71 is used to preprocess the original image to determine at least one detection region in the original image.

[0172] The original image includes at least one line of text.

[0173] The polygon determination module 72 is used to determine at least one text polygon in the original image based on at least one detection region.

[0174] The first curvature recognition module 73 is used to determine whether there is curved text in the original image based on the number of sides of at least one text polygon.

[0175] The present disclosure provides a device for determining whether text in an image is curved, which preprocesses an original image to determine at least one detection region in the original image; wherein the original image includes at least one line of text; determines at least one text polygon in the original image based on the at least one detection region; and determines whether curved text exists in the original image based on the number of sides of the at least one text polygon. This embodiment determines the text polygon containing the text content by detection, and since the number of sides of the polygon increases if the text is curved, the device determines whether curved text exists in the original image by the number of sides of the text polygon, thus achieving efficient and accurate determination of text curvature in an image.

[0176] In some optional embodiments, the preprocessing module 71 includes:

[0177] A single-channel unit is used to obtain a first image with a single channel based on the original image;

[0178] A binarization unit is used to perform binarization processing on the first image to obtain the second image;

[0179] The dilatational erosion unit is used to perform multiple dilatational erosions on the second image based on morphological kernels of different sizes to obtain at least one detection area.

[0180] In some optional embodiments, a single-channel unit is specifically used to perform scaling processing on the original image to obtain a scaled image of a set size; and to obtain a first image of a single channel based on the scaled image.

[0181] In some optional embodiments, the polygon determination module 72 is specifically used to determine the minimum bounding polygon corresponding to at least one detection region with connectivity based on the connectivity of at least one detection region; and to determine the text polygon based on the minimum bounding polygon.

[0182] In some optional embodiments, the first curvature recognition module 73 is specifically configured to determine that curved text exists in the original image in response to the presence of at least one text polygon having a number of edges greater than a set threshold.

[0183] In some alternative embodiments, the first curvature recognition module 73 is further configured to determine a set threshold based on the average number of sides included in at least one text polygon.

[0184] In some optional embodiments, the apparatus provided in this embodiment further includes:

[0185] The second curvature recognition module is used to determine, in response to determining that there is curved text in the original image, a first predetermined number of horizontal lines and a second predetermined number of vertical lines included in the original image; and to determine whether the conclusion that there is curved text in the original image is correct based on at least one included angle corresponding to the first predetermined number of horizontal lines and the second predetermined number of vertical lines.

[0186] In some optional embodiments, the second bend recognition module includes:

[0187] The gradient unit is used to process the original image to obtain the gradient image corresponding to the original image;

[0188] The Hough transform unit is used to perform a Hough transform on a gradient image to obtain at least one straight line and its corresponding straight line angle.

[0189] A straight line determination unit is used to determine a first set number of horizontal straight lines and a second set number of vertical straight lines from at least one straight line based on the straight line angle.

[0190] Optionally, the line determination unit is specifically used to sort at least one line according to the difference between the corresponding line angle and the horizontal angle to obtain a first sequence; sort at least one line according to the difference between the corresponding line angle and the vertical angle to obtain a second sequence; obtain a first set number of horizontal lines from the first sequence, and obtain a second set number of vertical lines from the second sequence.

[0191] Optionally, the gradient unit is specifically used to perform scaling processing on the original image to obtain a scaled image of a set size; to perform grayscale or channel separation processing on the scaled image to obtain a single-channel image; to perform smoothing processing on the single-channel image to obtain a smoothed image; and to obtain a gradient image based on the smoothed image.

[0192] Optionally, based on at least one included angle between a first set number of horizontal lines and a second set number of vertical lines, it is determined whether the conclusion that curved text exists in the original image is correct, including:

[0193] For each horizontal line in the first set number of horizontal lines, based on the first vector corresponding to the horizontal line and the second vector corresponding to at least one vertical line that intersects the horizontal line, determine the angle of at least one angle between the horizontal line and at least one vertical line.

[0194] The conclusion that curved text exists in the original image is correct, based on whether at least one included angle meets the preset conditions.

[0195] Optionally, the second curvature recognition module is further configured to determine whether there is an angle in at least one included angle that exceeds a set range by a set proportion. If so, the conclusion that there is curved text in the original image is correct; otherwise, the conclusion that there is curved text in the original image is incorrect.

[0196] Exemplary electronic devices

[0197] Below, for reference Figure 8 This describes an electronic device according to embodiments of the present disclosure. The electronic device may be either or both of a first device 100 and a second device 200, or a standalone device independent of them, which may communicate with the first and second devices to receive acquired input signals from them.

[0198] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0199] like Figure 8 As shown, the electronic device 80 includes one or more processors 81 and memory 82.

[0200] The processor 81 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device 80 to perform desired functions.

[0201] The memory 82 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 81 may execute the program instructions to implement the methods for determining whether text in an image is curved, as described above in the various embodiments of this disclosure, and / or other desired functions. Various contents such as input signals, signal components, and noise components may also be stored in the computer-readable storage medium.

[0202] In one example, the electronic device 80 may also include an input device 83 and an output device 84, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).

[0203] For example, when the electronic device is a first device 100 or a second device 200, the input device 83 can be the aforementioned microphone or microphone array for capturing the input signal from the sound source. When the electronic device is a standalone device, the input device 83 can be a communication network connector for receiving the acquired input signals from the first device 100 and the second device 200.

[0204] In addition, the input device 83 may also include, for example, a keyboard, a mouse, etc.

[0205] The output device 84 can output various information to the outside, including determined distance information, direction information, etc. The output device 84 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.

[0206] Of course, for the sake of simplicity, Figure 8 Only some of the components of the electronic device 80 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 80 may include any other suitable components depending on the specific application.

[0207] Exemplary computer program products and computer-readable storage media

[0208] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods for determining whether text in an image is curved according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.

[0209] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0210] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform steps in the methods for determining whether text in an image is curved according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.

[0211] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0212] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.

[0213] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0214] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0215] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.

[0216] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions to this disclosure.

[0217] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.

[0218] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A method for determining whether text in an image is curved, characterized in that, include: The original image is preprocessed to determine at least one detection region in the original image; wherein the original image includes at least one line of text; Based on the at least one detection region, at least one text polygon in the original image is determined; Based on the number of sides of the at least one text polygon, determine whether there is curved text in the original image; In response to determining that curved text exists in the original image, a first predetermined number of horizontal straight lines and a second predetermined number of vertical straight lines are determined to be included in the original image; Based on at least one angle between the first set number of horizontal lines and the second set number of vertical lines, determine whether the conclusion that curved text exists in the original image is correct; for each of the first set number of horizontal lines, based on the first vector corresponding to the horizontal line and the second vector corresponding to at least one vertical line that intersects the horizontal line, determine the angle between the horizontal line and at least one vertical line; based on whether the angle of the at least one angle meets preset conditions, determine whether the conclusion that curved text exists in the original image is correct.

2. The method according to claim 1, characterized in that, The preprocessing of the original image to determine at least one detection region in the original image includes: A first image with a single channel is obtained based on the original image; The first image is binarized to obtain the second image; The second image is subjected to multiple dilatational erosions based on morphological nuclei of different sizes to obtain the at least one detection region.

3. The method according to claim 2, characterized in that, The process of obtaining a single-channel first image based on the original image includes: The original image is scaled to obtain a scaled image of a set size; A first image with a single channel is obtained based on the scaled image.

4. The method according to claim 1, characterized in that, Determining at least one text polygon in the original image based on the at least one detection region includes: Based on the connectivity of the at least one detection region, determine the minimum bounding polygon corresponding to the at least one detection region with connectivity; The text polygon is determined based on the minimum bounding polygon.

5. The method according to claim 1, characterized in that, Determining whether curved text exists in the original image based on the number of sides of the at least one text polygon includes: In response to the fact that the number of edges of at least one text polygon in the at least one text polygon is greater than a set threshold; It was determined that curved text existed in the original image.

6. The method according to any one of claims 1-5, characterized in that, Determining the first predetermined number of horizontal lines and the second predetermined number of vertical lines included in the original image includes: The original image is processed to obtain the gradient image corresponding to the original image; Perform a Hough transform on the gradient image to obtain at least one straight line and its corresponding angle; Based on the line angle, determine the first predetermined number of horizontal lines and the second predetermined number of vertical lines from the at least one line.

7. The method according to claim 6, characterized in that, The step of determining the first predetermined number of horizontal lines and the second predetermined number of vertical lines from the at least one line based on the line angle includes: The at least one straight line is sorted according to the difference between the corresponding straight line angle and the horizontal angle to obtain a first sequence; The at least one straight line is sorted according to the difference between the corresponding straight line angle and the vertical angle to obtain a second sequence; Obtain the first predetermined number of horizontal lines from the first sequence, and obtain the second predetermined number of vertical lines from the second sequence.

8. The method according to claim 7, characterized in that, The step of processing the original image to obtain the gradient image corresponding to the original image includes: The original image is scaled to obtain a scaled image of a set size; Perform grayscale conversion or channel separation processing on the scaled image to obtain a single-channel image; The single-channel image is smoothed to obtain a smoothed image; The gradient image is obtained based on the smoothed image.

9. The method according to any one of claims 1-5, characterized in that, The determination of whether the conclusion that curved text exists in the original image is correct based on whether the angle of the at least one included angle meets the preset conditions includes: If it is determined whether there is an angle in the at least one included angle that exceeds a set range by a set proportion, then the conclusion that there is curved text in the original image is correct; otherwise, the conclusion that there is curved text in the original image is incorrect.

10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program for executing the method for determining whether text in an image is curved, as described in any one of claims 1-9.

11. A computer program product, the computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for determining whether text in an image is curved as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Text detection method and device, electronic equipment and storage medium

    CN112200202A

  • Privacy protection method based on medical image

    CN113889232A

  • Text correction method and device, equipment and storage medium

    CN113920525A