A text recognition method and related equipment

By performing text detection and cutting processing on the image, the problem of low accuracy of overlapping text recognition in the prior art is solved, accurate recognition of overlapping text is achieved, and the accuracy of text recognition is improved.

CN113449728BActive Publication Date: 2024-09-10BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202110825075.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-21
Publication Date
2024-09-10
Estimated Expiration
2041-07-21

AI Technical Summary

Technical Problem

Existing text recognition technology, especially optical character recognition technology, has low recognition accuracy when there are overlapping texts in the image, and cannot effectively handle overlapping text.

Method used

By performing text detection on the image to be recognized, the first position and the second position are determined. If the preset overlap conditions are met, the image to be used is cut out from the image, including the first text and the second text, and the cut results are processed based on these positions. Perform text recognition on images to improve the recognition accuracy of overlapping text.

Benefits of technology

It achieves accurate recognition of overlapping text and improves the accuracy of text recognition, especially the recognition effect in overlapping text scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113449728B
    Figure CN113449728B
Patent Text Reader

Abstract

The present application discloses a text recognition method and related equipment, the method comprising: performing text detection on an image to be recognized, obtaining a first position and a second position, so that the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized, so that when it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, it is determined that the first text and the second text belong to a pair of overlapping texts, so firstly according to the first position and the second position, cutting out the image to be used from the image to be recognized, so that the image to be used includes the first text and the second text; then according to the first position and the second position, performing text recognition on the image to be used, obtaining the text recognition result of the first text and the text recognition result of the second text, so that the purpose of performing text recognition on the overlapping text in the image to be recognized can be achieved.
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 recognition method and related equipment. Background Art

[0002] With the development of text recognition technology, the application scope of text recognition technology is getting wider and wider. Among them, text recognition technology is used to recognize and process character information in an image.

[0003] However, due to defects in related text recognition technologies (such as optical character recognition (OCR) and other technologies), the recognition accuracy of these related text recognition technologies is low in some application scenarios (such as application scenarios where there is overlap between two texts in an image). Summary of the invention

[0004] In order to solve the above technical problems, the present application provides a text recognition method and related equipment, which can improve the accuracy of text recognition, especially the accuracy of text recognition of overlapping texts.

[0005] In order to achieve the above purpose, the technical solutions provided by the embodiments of the present application are as follows:

[0006] The present application provides a method for character recognition, the method comprising:

[0007] Performing text detection on the image to be recognized to obtain a first position and a second position; wherein the first position is used to describe the area where the first text is located in the image to be recognized; and the second position is used to describe the area where the second text is located in the image to be recognized;

[0008] If it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, cutting out an image to be used from the image to be recognized according to the first position and the second position, so that the image to be used includes the first text and the second text;

[0009] According to the first position and the second position, text recognition is performed on the image to be used to obtain a text recognition result of the first text and a text recognition result of the second text.

[0010] In a possible implementation, performing text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text includes:

[0011] According to the first position, performing text recognition on the image to be used to obtain a text recognition result of the first text;

[0012] According to the second position, text recognition is performed on the image to be used to obtain a text recognition result of the second text.

[0013] In a possible implementation, performing text recognition on the image to be used according to the first position to obtain a text recognition result of the first text includes:

[0014] Generate a first marked image according to the first position and the image to be used; input the first marked image into a pre-built text recognition model to obtain a text recognition result of the first text output by the text recognition model;

[0015] and / or,

[0016] The step of performing text recognition on the image to be used according to the second position to obtain a text recognition result of the second text includes:

[0017] A second marked image is generated according to the second position and the image to be used; the second marked image is input into the text recognition model to obtain a text recognition result of the second text output by the text recognition model.

[0018] In a possible implementation, the process of generating the first marked image includes:

[0019] Determine a mask image of the first text according to the first position; and splice the mask image of the first text with the image to be used to obtain the first marked image;

[0020] and / or,

[0021] The process of generating the second labeled image includes:

[0022] According to the second position, a mask image of the second text is determined; and the mask image of the second text is spliced ​​with the image to be used to obtain the second marked image.

[0023] In a possible implementation manner, cutting out the image to be used from the image to be recognized according to the first position and the second position includes:

[0024] Determining an image cutting position according to the first position and the second position;

[0025] According to the image cutting position, the image to be used is cut out from the image to be identified.

[0026] In a possible implementation manner, the process of determining the image cutting position includes:

[0027] Performing a region union process on the first position and the second position to obtain an initial cutting position;

[0028] According to a preset expansion coefficient, the initial cutting position is subjected to regional expansion processing to obtain the image cutting position.

[0029] In a possible implementation manner, performing text detection on the image to be recognized to obtain the first position and the second position includes:

[0030] The image to be recognized is input into a pre-constructed text detection model to obtain the first position and the second position output by the text detection model; wherein the text detection model is constructed based on a first sample image and the actual text position corresponding to the first sample image; and the first sample image includes at least one pair of overlapping texts.

[0031] The present application also provides a text recognition device, including:

[0032] A text detection unit, used to perform text detection on the image to be recognized, and obtain a first position and a second position; wherein the first position is used to describe the area where the first text is located in the image to be recognized; and the second position is used to describe the area where the second text is located in the image to be recognized;

[0033] an image cutting unit, configured to cut out an image to be used from the image to be recognized according to the first position and the second position, if it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, so that the image to be used includes the first text and the second text;

[0034] The text recognition unit is used to perform text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text.

[0035] The present application also provides a device, the device comprising a processor and a memory:

[0036] The memory is used to store computer programs;

[0037] The processor is used to execute any implementation of the text recognition method provided in the embodiments of the present application according to the computer program.

[0038] The embodiment of the present application also provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute any implementation of the text recognition method provided in the embodiment of the present application.

[0039] The embodiment of the present application also provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any implementation of the text recognition method provided in the embodiment of the present application.

[0040] Compared with the prior art, the embodiments of the present application have at least the following advantages:

[0041] In the text recognition method provided by the embodiment of the present application, after obtaining an image to be recognized including at least a pair of overlapping texts, text detection is performed on the image to be recognized to obtain a first position and a second position, so that the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized, so that when it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, it is determined that the first text and the second text belong to a pair of overlapping texts. Therefore, the image to be used is first cut out from the image to be recognized according to the first position and the second position, so that the image to be used includes the first text and the second text; then, text recognition is performed on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text, so that the purpose of text recognition for overlapping texts in the image to be recognized can be achieved.

[0042] Among them, because the text recognition result of the first text and the text recognition result of the second text are determined by comprehensively considering the first position, the second position and the image to be used, the text recognition result of the first text and the text recognition result of the second text are more accurate, which is beneficial to improving the accuracy of text recognition, especially to improving the accuracy of text recognition of overlapping texts. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application 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, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0044] Figure 1 A schematic diagram of an image including overlapping text provided in an embodiment of the present application;

[0045] Figure 2 A flowchart of a text recognition method provided in an embodiment of the present application;

[0046] Figure 3 A schematic diagram of a first position provided in an embodiment of the present application;

[0047] Figure 4A schematic diagram of a second position provided in an embodiment of the present application;

[0048] Figure 5 A schematic diagram of an image to be used provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of a mask image of a first text provided in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of a mask image of a second text provided in an embodiment of the present application;

[0051] Figure 8 A structural schematic diagram of a text recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] The inventors found in their research on text recognition technology that some related text recognition technologies (such as optical character recognition (OCR) and other technologies) have defects that make them unable to identify overlapping texts in an image (such as Figure 1 The overlapping text shown in the figure ("The number has decreased by 90% in the past 20 years" and "Swipe up to see more videos") cannot be accurately recognized, which results in poor text recognition accuracy of the overlapping text in the image.

[0053] Based on the above findings, in order to solve the technical problems in the background technology part, an embodiment of the present application provides a text recognition method, which includes: performing text detection on an image to be recognized to obtain a first position and a second position, so that the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized, so that when it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, firstly, according to the first position and the second position, the image to be used is cut out from the image to be recognized, so that the image to be used includes the first text and the second text; then, according to the first position and the second position, text recognition is performed on the image to be used to obtain a text recognition result of the first text and a text recognition result of the second text, so that the purpose of accurately recognizing overlapping texts in the image to be recognized can be achieved, thereby helping to improve the accuracy of text recognition (especially, the accuracy of text recognition of overlapping texts).

[0054] In addition, the embodiments of the present application do not limit the execution subject of the text recognition method. For example, the text recognition method provided in the embodiments of the present application can be applied to data processing devices such as terminal devices or servers. The terminal device can be a smart phone, a computer, a personal digital assistant (PDA) or a tablet computer. The server can be an independent server, a cluster server or a cloud server.

[0055] In order to enable those skilled in the art to better understand the solution of the present application, 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 only 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 creative work are within the scope of protection of this application.

[0056] Method Embodiment

[0057] See also Figure 2 , which is a flow chart of a text recognition method provided in an embodiment of the present application.

[0058] The text recognition method provided in the embodiment of the present application includes S1-S3:

[0059] S1: Perform text detection on the image to be recognized to obtain a first position and a second position.

[0060] The image to be recognized refers to an image that needs to be processed for text recognition. Figure 1 The image shown) may include at least one pair of overlapping texts.

[0061] It should be noted that if there is an overlap between the area occupied by one text and the area occupied by another text in the image to be recognized, the above-mentioned "one text" and the above-mentioned "another text" belong to a pair of overlapping texts, so that the image to be recognized includes at least one pair of overlapping texts.

[0062] The first position is used to describe the area where the first text is located in the image to be recognized. In addition, the embodiment of the present application does not limit the representation method of the first position. For example, if the first position is used to represent Figure 1 The first position can be used to Figure 3 The first mask image is shown.

[0063] The second position is used to describe the area where the second text is located in the image to be recognized. In addition, the embodiment of the present application does not limit the representation method of the second position. For example, if the second position is used to represent Figure 1In the area where the text "Swipe up to see more videos" is located in the middle and upper layers, the second position can be used Figure 4 The second mask image is shown.

[0064] In addition, the embodiments of the present application do not limit the implementation method of "text detection" in S1. For example, in one possible implementation method, S1 may specifically include: inputting the image to be recognized into a pre-built text detection model to obtain the first position and the second position output by the text detection model.

[0065] Among them, the text detection model is used to perform text detection on the input data of the text detection model (that is, to determine the location information of at least one text in the input data); moreover, the embodiments of the present application do not limit the text detection model. For example, the text detection model can be any deep learning model.

[0066] In addition, the text detection model can be constructed based on the first sample image and the actual text position corresponding to the first sample image.

[0067] The first sample image is used to represent an image required for building a text detection model; and there is at least one pair of overlapping texts in the first sample image. For example, the first sample image may include a first sample text and a second sample text, and there is an overlap between the area where the first sample text is located in the first sample image and the area where the second sample text is located in the first sample image. In addition, the embodiment of the present application does not limit the number of first sample images.

[0068] The actual text position corresponding to the first sample image is used to describe the area where each text in the first sample image is located. For example, if the first sample image includes a first sample text and a second sample text, the actual text position corresponding to the first sample image may include the actual text position of the first sample text and the actual text position of the second sample text. The actual text position of the first sample text is used to describe the area where the first sample text is actually located in the first sample image. The actual text position of the second sample text is used to describe the area where the second sample text is actually located in the first sample image.

[0069] In addition, the embodiment of the present application does not limit the construction process of the text detection model. For example, in a possible implementation, the construction process of the text detection model may include steps 11 to 14:

[0070] Step 11: Input the first sample image into the first model to obtain the text detection result of the first sample image output by the first model.

[0071] The first model is used to perform text detection on input data of the first model.

[0072] The text detection result of the first sample image is used to represent the predicted position of at least one text in the first sample image. That is, the text detection result of the first sample image may include the predicted position of at least one text in the first sample image.

[0073] Step 12: Determine whether the first stop condition is met, if so, execute step 14; if not, execute step 13.

[0074] Among them, the first stopping condition can be set in advance. For example, the first stopping condition can be that the loss value of the first model is lower than the first loss value threshold, or the change rate of the loss value of the first model is lower than the first change rate threshold (that is, the text detection performance of the first model is in a convergence state), or the number of updates of the first model reaches the first number threshold.

[0075] The loss value of the first model is used to characterize the text detection performance of the first model; and the embodiment of the present application does not limit the calculation method of the loss value of the first model.

[0076] In addition, the first loss value threshold, the first change rate threshold and the first number threshold can all be preset.

[0077] Step 13: Update the first model according to the text detection result of the first sample image and the actual text position corresponding to the first sample image, and return to execute step 11.

[0078] In an embodiment of the present application, after determining that the first model of the current round has not reached the first stop condition, it can be determined that the first model of the current round still has poor text detection performance. Therefore, the first model of the current round can be updated with reference to the difference between the text detection result of the first sample image and the actual text position corresponding to the first sample image, so that the updated first model has better text detection performance, so that the updated first model can be used to continue to execute step 11 and its subsequent steps.

[0079] Step 14: Determine a text detection model based on the first model.

[0080] In an embodiment of the present application, after determining that the first model of the current round has reached the first stop condition, it can be determined that the first model of the current round has good text detection performance, so the text detection model can be determined based on the first model of the current round (for example, the first model of the current round can be directly determined as the text detection model. For example, the model structure and model parameters of the text detection model can also be determined based on the model structure and model parameters of the first model of the current round, so that the model structure and model parameters of the text detection model are respectively consistent with the model structure and model parameters of the first model of the current round), so that the text detection model also has good text detection performance.

[0081] Based on the relevant contents of the above steps 11 to 14, it can be known that after obtaining the first sample image and its corresponding actual text position, the first model can be trained using the first sample image and its corresponding actual text position to obtain a trained first model, so that the trained first model has better text detection performance; then, based on the trained first model, a text detection model is determined so that the text detection model also has better text detection performance. Among them, because there are overlapping texts in the first sample image, the first model trained based on the first sample image can accurately detect the position information of each text in the overlapping text, so that the trained first model has better text detection performance for the position information of each text in the overlapping text, so that the text detection model determined based on the trained first model also has better text detection performance for the position information of each text in the overlapping text.

[0082] Based on the relevant content of S1 above, it can be known that for an image to be recognized that includes a first text and a second text, after acquiring the image to be recognized, text detection can be performed on the image to be recognized to obtain a text detection result corresponding to the image to be recognized, so that the text detection result corresponding to the image to be recognized includes a first position and a second position, so that the text detection result corresponding to the image to be recognized can be referred to later to perform text recognition on the image to be recognized. Among them, the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized.

[0083] S2: If it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, the image to be used is cut out from the image to be recognized according to the first position and the second position, so that the image to be used includes the first text and the second text.

[0084] Among them, the relative relationship between the first position and the second position is used to represent the relative position between the area where the first text is located and the area where the second text is located in the image to be recognized (for example, there is an overlap between the area where the first text is located and the area where the second text is located, or there is no overlap between the area where the first text is located and the area where the second text is located).

[0085] The preset overlapping condition is used to describe the condition reached by the relative position between a pair of overlapping texts. For example, the preset overlapping condition may be: there is an overlap between the area described by the first position and the area described by the second position.

[0086] The image to be used refers to an image cut out from the image to be recognized that only includes the first text and the second text. For example, if the image to be recognized is Figure 1 The image shown, the first text is Figure 1 The lower text in the middle layer is "the number has decreased by 90% in the past 20 years", and the second text is Figure 1 The text in the upper middle layer is "Swipe up to see more videos", then the image to be used can be Figure 5 Image shown.

[0087] In addition, the embodiment of the present application does not limit the process of determining the image to be used. For example, in a possible implementation, the process of determining the image to be used may include step 21-step 22:

[0088] Step 21: Determine the image cutting position according to the first position and the second position.

[0089] The image cutting position is used to indicate the position information required for cutting an image data (eg, the image to be identified, the first mask image, or the second mask image, etc.).

[0090] In addition, the embodiment of the present application does not limit the determination process of the image cutting position (that is, the implementation method of step 21). For example, step 21 may specifically include: directly performing a region union process on the first position and the second position to obtain the image cutting position. The "region union process" refers to performing a region union process on the region described by the first position and the region described by the second position.

[0091] It can be seen that after obtaining the first position and the second position, the area described by the first position and the area described by the second position can be firstly unioned to obtain a union area; then the position of the union area in the image to be identified is determined as the image cutting position, so that the area described by the image cutting position includes the area described by the first position and the area described by the second position, so that the image to be used determined based on the image cutting position includes the first text and the second text.

[0092] In addition, in order to avoid cutting the edge portion (such as the top and / or the bottom) of the text from the non-edge portion of the text during the image cutting process, the embodiment of the present application further provides another possible implementation of step 21, which may specifically include steps 211-212:

[0093] Step 211: performing a region union process on the first position and the second position to obtain an initial cutting position.

[0094] In an embodiment of the present application, after obtaining the first position and the second position, the area described by the first position and the area described by the second position can be firstly unioned to obtain a union area; then the position of the union area in the image to be identified is determined as the initial cutting position, so that the area described by the initial cutting position includes the area described by the first position and the area described by the second position.

[0095] Step 212: Performing regional expansion processing on the initial cutting position according to a preset expansion coefficient to obtain an image cutting position.

[0096] The preset expansion coefficient refers to a parameter value required to be used when expanding the area described by the initial cutting position; and the preset expansion coefficient can be preset.

[0097] In addition, the “region expansion process” in step 212 refers to the expansion process of the region described by the initial cutting position.

[0098] Based on the relevant contents of the above step 212, it can be known that after the initial cutting position is obtained, the area described by the initial cutting position can be expanded according to a preset expansion coefficient to obtain an expanded area; then the position of the expanded area in the image to be recognized is determined as the image cutting position, so that the area described by the image cutting position can cover the edge positions of each character in the first text and the second text as much as possible, so that the edge part (such as the top and / or bottom) of the character can be effectively avoided from being cut off from the non-edge part of the character during the image cutting process, thereby effectively ensuring the integrity of each character in the image to be used, which is beneficial to improving the accuracy of character recognition.

[0099] Based on the relevant content of the above step 21, it can be known that after determining that there is an overlap between the area described by the first position and the area described by the second position, the image cutting position can be determined based on the union of the area described by the first position and the area described by the second position, so that the area described by the image cutting position includes the area described by the first position and the area described by the second position, so that the image to be used determined based on the image cutting position includes the first text and the second text.

[0100] Step 22: Cut out the image to be used from the image to be identified according to the image cutting position.

[0101] In the embodiment of the present application, after the image cutting position is obtained, the portion of the image to be identified located at the image cutting position can be cut out, and the portion can be determined as the image to be used, so that the image to be used only includes the first text and the second text.

[0102] Based on the relevant content of S2 above, it can be known that after determining that there is an overlap between the area described by the first position and the area described by the second position, it can be determined that there is an overlap between the first text and the second text in the image to be recognized. Therefore, the union of the area described by the first position and the area described by the second position can be referred to, and the image to be used can be cut out from the image to be recognized so that the image to be used only includes the first text and the second text. This can effectively avoid the adverse effects of other texts in the image to be recognized except the first text and the second text on the text recognition process of the first text and the second text, which is conducive to improving the text recognition accuracy of overlapping texts.

[0103] S3: performing text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text.

[0104] The character recognition result of the first text is used to represent the characters predicted to exist in the first text.

[0105] The character recognition result of the second text is used to represent the characters predicted to exist in the second text.

[0106] In addition, the embodiment of the present application does not limit the implementation of S3. For example, S3 may specifically include S31-S32:

[0107] S31: performing text recognition on the image to be used according to the first position to obtain a text recognition result of the first text.

[0108] The embodiment of the present application does not limit the implementation of S31. For example, in a possible implementation, S31 may specifically include S311-S312:

[0109] S311: Generate a first marked image according to the first position and the image to be used.

[0110] The first marking image is used to represent the information carried by the first position and the information carried by the image to be used.

[0111] In addition, the embodiment of the present application does not limit the generation process of the first mark image (that is, the implementation of S311). For example, in a possible implementation, S311 may specifically include S3111-S3112:

[0112] S3111: Determine a mask image of the first text according to the first position.

[0113] The mask image of the first text is used to represent the area where the first text is located in the image to be used. For example, if the image to be used is Figure 5If the image is shown, and the first text is "the number has decreased by 90% in the past 20 years", the mask map of the first text can be Figure 6 Image shown.

[0114] In addition, the embodiments of the present application do not limit the implementation methods of S3111. For ease of understanding, two examples are provided below for illustration.

[0115] Example 1: If the first position is Figure 3 If the first mask image is represented by the first mask image shown, S3111 may specifically include: cutting out the mask image of the first text from the first mask image according to the image cutting position. For the relevant content of the “image cutting position”, please refer to the relevant content of the “image cutting position” in step 21 above.

[0116] Example 2: If the first position is represented by coordinates, S3111 may specifically include steps 31 and 32:

[0117] Step 31: Determine a mask position corresponding to the first position according to the relative position between the first position and the image cutting position.

[0118] The mask position corresponding to the first position refers to the position of the first text in the image to be used, so that the mask position corresponding to the first position is used to describe the area where the first text is located in the image to be used.

[0119] In addition, for the relevant content of "Image cutting position", please refer to the relevant content of "Image cutting position" in step 21 above.

[0120] Based on the relevant content of the above step 31, it can be known that after obtaining the first position and the image cutting position, the position of the first text in the image to be used can be calculated according to the relative position between the first position and the image cutting position, and the position of the first text in the image to be used can be determined as the mask position corresponding to the first position.

[0121] Step 32: performing mask processing on the image to be used according to the mask position corresponding to the first position to obtain a mask map of the first text.

[0122] It should be noted that the embodiment of the present application does not limit the implementation method of the "mask processing" in step 32.

[0123] Based on the relevant contents of the above steps 31 to 32, it can be known that the position of the first text in the image to be used can be determined according to the relative position between the first position (that is, the position of the first text in the image to be recognized) and the position of the image to be used in the image to be recognized; and then, according to the position of the first text in the image to be used, the image to be used is masked to obtain a mask map of the first text, so that the mask map of the first text can accurately represent the area where the first text is located in the image to be used.

[0124] S3112: Concatenate the mask image of the first text with the image to be used to obtain a first marked image.

[0125] In an embodiment of the present application, after obtaining the mask map of the first text, the mask map of the first text can be spliced ​​with the image to be used to obtain a first marked image (for example, the mask map of the first text can be added to the image to be used as the fourth channel image to obtain the first marked image, so that the first channel image to the third channel image in the first marked image are respectively the first channel image to the third channel image in the image to be used, and the fourth channel image in the first marked image is the mask map of the first text), so that the first marked image can accurately represent the information carried by the mask map of the first text and the information carried by the image to be used.

[0126] Based on the relevant content of S311 above, it can be known that after obtaining the image to be used, the information of the image to be used and the first position can be fused to obtain a first marked image, so that the first marked image can accurately represent the information carried by the image to be used and the information carried by the first position, so that the various characters existing in the first text can be accurately identified based on the first marked image later.

[0127] S312: Input the first marked image into a pre-built text recognition model to obtain a text recognition result of the first text output by the text recognition model.

[0128] Among them, the text recognition model is used to perform text recognition on the input data of the text recognition model; and the embodiment of the present application does not limit the text recognition model. For example, the text recognition model can be any deep learning model.

[0129] In addition, the text recognition model can be constructed based on the second sample image, the actual position corresponding to the second sample image, and the actual character corresponding to the second sample image.

[0130] The second sample image includes a pair of overlapping texts, the actual position corresponding to the second sample image includes the actual position of the pair of overlapping texts, and the actual characters corresponding to the second sample image include the actual characters of the pair of overlapping texts. For ease of understanding, the following is explained with examples.

[0131] As an example, if the second sample image includes the third sample text and the fourth sample text, and there is an overlap between the area where the third sample text is located in the second sample image and the area where the fourth sample text is located in the second sample image, then the actual position corresponding to the second sample image includes the actual position of the third sample text in the second sample image and the actual position of the fourth sample text in the second sample image, and the actual characters corresponding to the second sample image include the actual characters of the third sample text and the actual characters of the fourth sample text. The actual characters of the third sample text are used to represent the characters that actually exist in the third sample text. The actual characters of the fourth sample text are used to represent the characters that actually exist in the fourth sample text.

[0132] In addition, the embodiment of the present application does not limit the process of constructing the text recognition model. For example, in a possible implementation, based on the relevant content of the above example, it can be known that the process of constructing the text recognition model may include steps 41 to 46:

[0133] Step 41: Generate a third marked image according to the actual position of the third sample text in the second sample image and the second sample image.

[0134] It should be noted that step 41 can be implemented using any of the implementation methods of S311 above, by simply replacing the "first position" in any of the implementation methods of S3111 above with "the actual position of the third sample text in the second sample image", "the first text" with "the third sample text", "the image to be used" with "the second sample image", and "the first marked image" with "the third marked image".

[0135] Step 42: Generate a fourth marked image according to the actual position of the fourth sample text in the second sample image and the second sample image.

[0136] It should be noted that step 42 can be implemented using any of the implementation methods of S311 above, by simply replacing the "first position" in any of the implementation methods of S3111 above with "the actual position of the fourth sample text in the second sample image", "the first text" with "the fourth sample text", "the image to be used" with "the second sample image", and "the first marked image" with "the fourth marked image".

[0137] Step 43: Determine a text recognition result of the third sample text and a text recognition result of the fourth sample text according to the third marked image, the fourth marked image and the second model.

[0138] The second model is used to perform text recognition on the input data of the second model.

[0139] The character recognition result of the third sample text refers to the result obtained by performing character recognition on the third marked image by the second model, so that the character recognition result of the third sample text is used to represent the characters predicted to exist in the third sample text.

[0140] The character recognition result of the fourth sample text refers to the result obtained by performing character recognition on the fourth marked image by the second model, so that the character recognition result of the fourth sample text is used to represent the characters predicted to exist in the fourth sample text.

[0141] In addition, the embodiment of the present application does not limit step 43. For example, in one possible implementation, step 43 includes: inputting the third marked image into the second model to obtain the text recognition result of the third sample text output by the second model, and inputting the fourth marked image into the second model to obtain the text recognition result of the fourth sample text output by the second model.

[0142] Based on the relevant content of the above step 43, it can be known that after obtaining the third marked image and the fourth marked image, the third marked image and the fourth marked image can be respectively input into the second model, so that the second model can perform text recognition processing on the third marked image and the fourth marked image respectively, and obtain and output the text recognition result of the third sample text and the text recognition result of the fourth sample text, so that the text recognition performance of the second model can be determined in combination with the text recognition result of the third sample text and the text recognition result of the fourth sample text.

[0143] Step 44: Determine whether the second stop condition is met, if so, execute step 46; if not, execute step 45.

[0144] Among them, the second stopping condition can be set in advance. For example, the second stopping condition can be that the loss value of the second model is lower than the second loss value threshold, or the change rate of the loss value of the second model is lower than the second change rate threshold (that is, the text recognition performance of the second model is in a convergence state), or the number of updates of the second model reaches the second number threshold.

[0145] The loss value of the second model is used to characterize the text recognition performance of the second model; and the embodiment of the present application does not limit the calculation method of the loss value of the second model.

[0146] In addition, the second loss value threshold, the second change rate threshold and the second frequency threshold can all be preset.

[0147] Step 45: Update the second model according to the text recognition result of the third sample text, the actual characters of the third sample text, the text recognition result of the fourth sample text and the actual characters of the fourth sample text, and return to execute step 43.

[0148] In an embodiment of the present application, after determining that the second model of the current round has not reached the second stop condition, it can be determined that the second model of the current round still has poor text recognition performance. Therefore, the second model of the current round can be updated with reference to the difference between the text recognition result of the third sample text and the actual characters of the third sample text, and the difference between the text recognition result of the fourth sample text and the actual characters of the fourth sample text, so that the updated second model has better text recognition performance, so that the updated second model can be used to continue to execute step 43 and its subsequent steps.

[0149] Step 46: Determine a text recognition model based on the second model.

[0150] In an embodiment of the present application, after determining that the second model of the current round has reached the second stop condition, it can be determined that the second model of the current round has good text recognition performance, so the text recognition model can be determined based on the second model of the current round (for example, the second model of the current round can be directly determined as the text recognition model. For example, the model structure and model parameters of the text recognition model can be determined based on the model structure and model parameters of the second model of the current round, so that the model structure and model parameters of the text recognition model are respectively consistent with the model structure and model parameters of the second model of the current round), so that the text recognition model also has good text recognition performance.

[0151] Based on the relevant contents of the above steps 41 to 46, it can be known that after obtaining the second sample image, the actual position corresponding to the second sample image, and the actual character corresponding to the second sample image, the second model can be trained using the second sample image, the actual position corresponding to the second sample image, and the actual character corresponding to the second sample image to obtain a trained second model, so that the trained second model has better text recognition performance; then, based on the trained second model, a text recognition model is determined so that the text recognition model also has better text recognition performance. Among them, because there are overlapping texts in the second sample image, the second model trained based on the second sample image can accurately recognize the characters existing in each text in the overlapping text, so that the trained second model has better text recognition performance for overlapping texts, so that the text recognition model determined based on the trained second model also has better text recognition performance for overlapping texts.

[0152] Based on the relevant contents of S31 above, it can be known that after acquiring the image to be used, the first position can be referenced to perform text recognition on the image to be used to obtain the text recognition result of the first text, so that the text recognition result of the first text can accurately represent the characters existing in the first text. Among them, because the text recognition result of the first text is determined with reference to the first position, it is possible to focus on each character in the first text when performing text recognition on the image to be used, which can effectively reduce the adverse effects of each character in the second text on it, thereby effectively improving the text recognition accuracy of the first text, which is conducive to improving the text recognition accuracy of overlapping texts.

[0153] S32: performing text recognition on the image to be used according to the second position to obtain a text recognition result of the second text.

[0154] The embodiment of the present application does not limit the implementation of S32. For example, in a possible implementation, S32 may specifically include S321-S322:

[0155] S321: Generate a second marked image according to the second position and the image to be used.

[0156] The second marking image is used to represent the information carried by the second position and the information carried by the image to be used.

[0157] In addition, the embodiment of the present application does not limit the generation process of the second marked image (that is, the implementation of S321). For example, in a possible implementation, S321 may specifically include S3211-S3212:

[0158] S3211: Determine a mask image of the second text according to the second position.

[0159] The mask image of the second text is used to represent the area where the second text is located in the image to be used. For example, if the image to be used is Figure 5 If the image is shown, and the second text is "Swipe up to see more videos", the mask image of the second text can be Figure 7 Image shown.

[0160] In addition, the embodiments of the present application do not limit the implementation methods of S3211. For ease of understanding, two examples are provided below for illustration.

[0161] Example 1: If the second position uses Figure 4 If the second mask image is represented by the second mask image shown, S3211 may specifically include: cutting out the mask image of the second text from the second mask image according to the image cutting position. For the relevant content of the “image cutting position”, please refer to step 21 above.

[0162] Example 2: If the second position is represented by coordinates, S3211 may specifically include steps 51 and 52:

[0163] Step 51: Determine a mask position corresponding to the second position according to the relative position between the second position and the image cutting position.

[0164] The mask position corresponding to the second position refers to the position of the second text in the image to be used, so that the mask position corresponding to the second position is used to describe the area where the second text is located in the image to be used.

[0165] In addition, for the relevant content of "Image cutting position", please refer to the relevant content of "Image cutting position" in step 21 above.

[0166] Based on the relevant content of the above step 51, it can be known that after obtaining the second position and the image cutting position, the position of the second text in the image to be used can be calculated according to the relative position between the second position and the image cutting position, and the position of the second text in the image to be used can be determined as the mask position corresponding to the second position.

[0167] Step 52: performing mask processing on the image to be used according to the mask position corresponding to the second position to obtain a mask map of the second text.

[0168] It should be noted that the embodiment of the present application does not limit the implementation method of the “mask processing” in step 52.

[0169] Based on the relevant contents of the above steps 51 to 52, it can be known that the position of the second text in the image to be used can be determined based on the relative position between the second position (that is, the position of the second text in the image to be recognized) and the position of the image to be used in the image to be recognized; and then, according to the position of the second text in the image to be used, the image to be used is masked to obtain a mask map of the second text, so that the mask map of the second text can accurately represent the area where the second text is located in the image to be used.

[0170] S3212: splicing the mask image of the second text with the image to be used to obtain a second marked image.

[0171] In an embodiment of the present application, after obtaining the mask map of the second text, the mask map of the second text can be spliced ​​with the image to be used to obtain a second marked image (for example, the mask map of the second text can be added to the image to be used as the fourth channel image to obtain the second marked image, so that the first channel image to the third channel image in the second marked image are respectively the first channel image to the third channel image in the image to be used, and the fourth channel image in the second marked image is the mask map of the second text), so that the second marked image can accurately represent the information carried by the mask map of the second text and the information carried by the image to be used.

[0172] Based on the relevant content of S321 above, it can be known that after obtaining the image to be used, the information of the image to be used and the second position can be fused to obtain a second marked image, so that the second marked image can accurately represent the information carried by the image to be used and the information carried by the second position, so that the various characters existing in the second text can be accurately identified based on the second marked image later.

[0173] S322: Input the second marked image into a pre-built text recognition model to obtain a text recognition result of the second text output by the text recognition model. For the relevant content of the “text recognition model”, please refer to S312 above.

[0174] Based on the relevant contents of S32 above, it can be known that after acquiring the image to be used, the second position can be referenced to perform text recognition on the image to be used to obtain the text recognition result of the second text, so that the text recognition result of the second text can accurately represent the characters existing in the second text. Among them, because the text recognition result of the second text is determined with reference to the second position, it is possible to focus on each character in the second text when performing text recognition on the image to be used, which can effectively reduce the adverse effects of each character in the first text on it, thereby effectively improving the text recognition accuracy of the second text, which is conducive to improving the text recognition accuracy of overlapping texts.

[0175] Based on the relevant contents of S1 to S3 above, it can be known that for the text recognition method provided in the embodiment of the present application, after obtaining an image to be recognized including at least a pair of overlapping texts, text detection is performed on the image to be recognized to obtain a first position and a second position, so that the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized, so that when it is determined that the relative relationship between the first position and the second position satisfies the preset overlapping condition, it is determined that the first text and the second text belong to a pair of overlapping texts. Therefore, the image to be used is first cut out from the image to be recognized according to the first position and the second position, so that the image to be used includes the first text and the second text; then, text recognition is performed on the image to be used according to the first position and the second position to obtain the text recognition result of the first text and the text recognition result of the second text, so that the purpose of text recognition for overlapping texts in the image to be recognized can be achieved.

[0176] It can be seen that because the text recognition result of the first text and the text recognition result of the second text are determined by comprehensively considering the first position, the second position and the image to be used, the text recognition result of the first text and the text recognition result of the second text are more accurate, which is beneficial to improving the accuracy of text recognition, especially to improving the accuracy of text recognition of overlapping texts.

[0177] Based on the text recognition method provided by the above method embodiment, the embodiment of the present application also provides a text recognition device, which is explained and illustrated below in conjunction with the accompanying drawings.

[0178] Device Embodiment

[0179] For technical details of the text recognition device provided in the device embodiment, please refer to the above method embodiment.

[0180] See also Figure 8 , which is a structural schematic diagram of a text recognition device provided in an embodiment of the present application.

[0181] The text recognition device 800 provided in the embodiment of the present application includes:

[0182] The text detection unit 801 is used to perform text detection on the image to be recognized, and obtain a first position and a second position; wherein the first position is used to describe the area where the first text is located in the image to be recognized; and the second position is used to describe the area where the second text is located in the image to be recognized;

[0183] An image cutting unit 802 is configured to cut out an image to be used from the image to be recognized according to the first position and the second position if it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, so that the image to be used includes the first text and the second text;

[0184] The text recognition unit 803 is used to perform text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text.

[0185] In a possible implementation, the text recognition unit 803 includes:

[0186] A first recognition subunit is used to perform text recognition on the image to be used according to the first position to obtain a text recognition result of the first text;

[0187] The second recognition subunit is used to perform text recognition on the image to be used according to the second position to obtain a text recognition result of the second text.

[0188] In a possible implementation manner, the first identification subunit includes:

[0189] A first generating subunit, configured to generate a first marked image according to the first position and the image to be used;

[0190] A first prediction subunit, configured to input the first marked image into a pre-built text recognition model to obtain a text recognition result of the first text output by the text recognition model;

[0191] and / or,

[0192] The second identification subunit comprises:

[0193] A second generating subunit, configured to generate a second marked image according to the second position and the image to be used;

[0194] The second prediction subunit is used to input the second marked image into the text recognition model to obtain the text recognition result of the second text output by the text recognition model.

[0195] In a possible implementation manner, the first generating subunit is specifically configured to: determine a mask image of the first text according to the first position; and splice the mask image of the first text with the image to be used to obtain the first marked image;

[0196] and / or,

[0197] The second generating subunit is specifically used to: determine the mask image of the second text according to the second position; and splice the mask image of the second text with the image to be used to obtain the second marked image.

[0198] In a possible implementation, the image cutting unit 802 includes:

[0199] A first determining subunit, configured to determine an image cutting position according to the first position and the second position;

[0200] The image cutting subunit is used to cut out the image to be used from the image to be identified according to the image cutting position.

[0201] In a possible implementation manner, the first determining subunit is specifically configured to:

[0202] Performing a region union process on the first position and the second position to obtain an initial cutting position;

[0203] According to a preset expansion coefficient, the initial cutting position is subjected to regional expansion processing to obtain the image cutting position.

[0204] In a possible implementation, the text detection unit 801 is specifically configured to:

[0205] The image to be recognized is input into a pre-constructed text detection model to obtain the first position and the second position output by the text detection model; wherein the text detection model is constructed based on a first sample image and the actual text position corresponding to the first sample image; and the first sample image includes at least one pair of overlapping texts.

[0206] Based on the relevant content of the above-mentioned text recognition device 800, it can be known that for the text recognition device 800, after obtaining the image to be recognized including at least one pair of overlapping texts, text detection is performed on the image to be recognized to obtain a first position and a second position, so that the first position is used to describe the area where the first text is located in the image to be recognized, and the second position is used to describe the area where the second text is located in the image to be recognized, so that when it is determined that the relative relationship between the first position and the second position satisfies the preset overlapping condition, it is determined that the first text and the second text belong to a pair of overlapping texts. Therefore, first, according to the first position and the second position, the image to be used is cut out from the image to be recognized, so that the image to be used includes the first text and the second text; then, according to the first position and the second position, text recognition is performed on the image to be used to obtain the text recognition result of the first text and the text recognition result of the second text, so that the purpose of text recognition for overlapping texts in the image to be recognized can be achieved.

[0207] It can be seen that because the text recognition result of the first text and the text recognition result of the second text are determined by comprehensively considering the first position, the second position and the image to be used, the text recognition result of the first text and the text recognition result of the second text are more accurate, which is beneficial to improving the accuracy of text recognition, especially to improving the accuracy of text recognition of overlapping texts.

[0208] Furthermore, an embodiment of the present application also provides a device, the device comprising a processor and a memory:

[0209] The memory is used to store computer programs;

[0210] The processor is used to execute any implementation of the text recognition method provided in the embodiments of the present application according to the computer program.

[0211] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute any implementation of the text recognition method provided in the embodiment of the present application.

[0212] Furthermore, an embodiment of the present application also provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any implementation of the text recognition method provided in the embodiment of the present application.

[0213] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0214] The above is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as above in the preferred embodiment, it is not used to limit the present invention. Any technician familiar with the art can make many possible changes and modifications to the technical solution of the present invention by using the methods and technical contents disclosed above without departing from the scope of the technical solution of the present invention, or modify it into an equivalent embodiment of equivalent changes. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of protection of the technical solution of the present invention.

Claims

1. A method for character recognition, characterized in that: The method comprises: Performing text detection on the image to be recognized to obtain a first position and a second position; wherein the first position is used to describe the area where the first text is located in the image to be recognized; and the second position is used to describe the area where the second text is located in the image to be recognized; If it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, cutting out an image to be used from the image to be recognized according to the first position and the second position, so that the image to be used includes the first text and the second text; According to the first position and the second position, text recognition is performed on the image to be used to obtain a text recognition result of the first text and a text recognition result of the second text.

2. The method according to claim 1, characterized in that The step of performing text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text includes: According to the first position, performing text recognition on the image to be used to obtain a text recognition result of the first text; According to the second position, text recognition is performed on the image to be used to obtain a text recognition result of the second text.

3. The method according to claim 2, characterized in that The step of performing text recognition on the image to be used according to the first position to obtain a text recognition result of the first text includes: Generate a first marked image according to the first position and the image to be used; input the first marked image into a pre-built text recognition model to obtain a text recognition result of the first text output by the text recognition model; and / or, The step of performing text recognition on the image to be used according to the second position to obtain a text recognition result of the second text includes: A second marked image is generated according to the second position and the image to be used; the second marked image is input into the text recognition model to obtain a text recognition result of the second text output by the text recognition model.

4. The method according to claim 3, characterized in that The process of generating the first marked image includes: Determine a mask image of the first text according to the first position; and splice the mask image of the first text with the image to be used to obtain the first marked image; The process of generating the second labeled image includes: According to the second position, a mask image of the second text is determined; and the mask image of the second text is spliced ​​with the image to be used to obtain the second marked image.

5. The method according to claim 1, characterized in that The step of cutting out the image to be used from the image to be identified according to the first position and the second position includes: Determining an image cutting position according to the first position and the second position; According to the image cutting position, the image to be used is cut out from the image to be identified.

6. The method according to claim 5, characterized in that The process of determining the image cutting position includes: Performing a region union process on the first position and the second position to obtain an initial cutting position; According to a preset expansion coefficient, the initial cutting position is subjected to regional expansion processing to obtain the image cutting position.

7. The method according to claim 1, characterized in that The method of performing text detection on the image to be recognized to obtain the first position and the second position includes: The image to be recognized is input into a pre-constructed text detection model to obtain the first position and the second position output by the text detection model; wherein the text detection model is constructed based on a first sample image and the actual text position corresponding to the first sample image; and the first sample image includes at least one pair of overlapping texts.

8. A text recognition device, characterized in that: include: A text detection unit, used to perform text detection on the image to be recognized, and obtain a first position and a second position; wherein the first position is used to describe the area where the first text is located in the image to be recognized; and the second position is used to describe the area where the second text is located in the image to be recognized; an image cutting unit, configured to cut out an image to be used from the image to be recognized according to the first position and the second position, if it is determined that the relative relationship between the first position and the second position satisfies a preset overlapping condition, so that the image to be used includes the first text and the second text; The text recognition unit is used to perform text recognition on the image to be used according to the first position and the second position to obtain a text recognition result of the first text and a text recognition result of the second text.

9. A device, characterized in that: The device comprises a processor and a memory: The memory is used to store computer programs; The processor is configured to execute the method of any one of claims 1 to 7 according to the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 7.

11. A computer program product, characterized in that When the computer program product is executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • A Document Image Classification Method

    CN109344815A

  • Intelligent recognition method for text data in power industry complex scene

    CN110059694A

  • Ticket recognition training sample synthesis method and computer storage medium

    CN110163285A

  • Neural network model construction method and system for recognizing image superimposed character area

    CN110516665A

  • Image processing method and device, electronic equipment and readable storage medium

    CN110738602A