A text recognition method, model training method, device and equipment

By training the image recognition model and the angle recognition model, identifying and correcting the text in the tilted image, the problem of difficulty in tilted image recognition is solved, and the accurate recognition of the tilted image text is achieved.

CN111914840BActive Publication Date: 2024-12-27CHINA CONSTRUCTION BANK
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202010760060.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-31
Publication Date
2024-12-27
Estimated Expiration
2040-07-31

AI Technical Summary

Technical Problem

The prior art is difficult to accurately identify text in skewed images, resulting in increased character recognition difficulty and text paragraph construction errors.

Method used

By training the image recognition model and the angle recognition model, the image template category and tilt angle are identified respectively, the image is adjusted for text recognition, and the tilt image is recognized and corrected using the pre-constructed model.

Benefits of technology

The accuracy of text recognition in tilted images is achieved, meaningless paragraph problems caused by tilting are avoided, and the accuracy and reliability of text recognition are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111914840B_ABST
    Figure CN111914840B_ABST
Patent Text Reader

Abstract

The embodiments of this specification provide a text recognition method, model training method, device and equipment. The method includes: receiving an image to be processed; the image to be processed contains text to be recognized; obtaining the image template category corresponding to the image to be processed; cutting out the template image to be processed corresponding to the image template category in the image to be processed; determining the tilt angle corresponding to the template image to be processed; and recognizing the text to be recognized in the template image to be processed based on the tilt angle. Through the above method, by determining the template image to be processed corresponding to a certain image template category, and then identifying the tilt angle of the template image to be processed, it is possible to correct the image based on the tilt angle and further realize the recognition of the text in the image, thereby solving the problem of not being able to accurately recognize the text in the tilted image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a text recognition method, a model training method, a device and equipment. Background Art

[0002] With the advancement of science and technology and the development of society, the recognition of text in images is increasingly used in work and life. When recognizing text in an image, the characters in the image are first obtained, and a complete field is constructed based on the recognized characters.

[0003] However, in practical applications, the acquired image may be an inclined image with a certain tilt angle. Directly recognizing text in an inclined image is not only difficult in character recognition, but also may not be able to construct a correct paragraph based on the inclined text, thus failing to accurately recognize the text in the image. Therefore, a technical solution for recognizing text in an inclined image is urgently needed. Summary of the invention

[0004] The purpose of the embodiments of this specification is to provide a text recognition method, a model training method, an apparatus and a device to solve the problem of how to recognize text in tilted images.

[0005] In order to solve the above technical problems, the embodiment of the present application also provides an image recognition model training method, including:

[0006] Receive a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character;

[0007] Acquire the character position of the first positioning character in the first sample image;

[0008] A pre-built image recognition model is trained based on the character positions and the image module categories; the image recognition model is used to recognize the image template category corresponding to the image.

[0009] The embodiment of this specification also proposes an image recognition model training device, including:

[0010] A first sample image receiving module is used to receive a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character;

[0011] A character position acquisition module, used for acquiring the character position of the first positioning character in the first sample image;

[0012] The image recognition model training module is used to train a pre-built image recognition model based on the character position and the image module category; the image recognition model is used to identify the image template category corresponding to the image.

[0013] The embodiments of the present specification also propose an image recognition model training device, comprising a memory and a processor; the memory stores computer program instructions; the processor is used to execute the computer program instructions to implement the following steps: receiving a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character; obtaining the character position of the first positioning character in the first sample image; training a pre-constructed image recognition model based on the character position and the image module category; the image recognition model is used to identify the image template category corresponding to the image.

[0014] In order to solve the above technical problems, the embodiment of this specification also proposes an angle recognition model training method, including:

[0015] receiving a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category;

[0016] A pre-built angle recognition model is trained based on the image template category and the rotation angle; the angle recognition model is used to recognize the tilt angle of the image.

[0017] The embodiment of this specification also proposes an angle recognition model training device, including:

[0018] A second sample image receiving module, used for receiving a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category;

[0019] The angle recognition model training module is used to train a pre-built angle recognition model based on the image template category and the rotation angle; the angle recognition model is used to recognize the tilt angle of the image.

[0020] The embodiments of this specification also propose an angle recognition model training device, including a memory and a processor; the memory is used to store computer program instructions; the processor is used to execute the computer program instructions to implement the following steps: receiving a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category; training a pre-constructed angle recognition model based on the image template category and the rotation angle; the angle recognition model is used to identify the tilt angle of the image.

[0021] In order to solve the above technical problems, the present specification also proposes a text recognition method, including:

[0022] Receiving an image to be processed; the image to be processed contains text to be recognized;

[0023] Obtaining the image template category corresponding to the image to be processed;

[0024] Extracting a template image to be processed corresponding to the image template category from the image to be processed;

[0025] Determining a tilt angle corresponding to the template image to be processed;

[0026] The text to be recognized in the template image to be processed is recognized based on the tilt angle.

[0027] The embodiment of this specification also provides a text recognition device, including:

[0028] The to-be-processed image receiving module is used to receive the to-be-processed image; the to-be-processed image contains text to be recognized;

[0029] An image template category acquisition module, used to acquire the image template category corresponding to the image to be processed;

[0030] A template image to be processed interception module, used to intercept the template image to be processed corresponding to the image template category from the image to be processed;

[0031] An inclination angle determination module, used to determine the inclination angle corresponding to the template image to be processed;

[0032] The text recognition module is used to recognize the text to be recognized in the template image to be processed based on the tilt angle.

[0033] The embodiments of the present specification also propose a text recognition device, including a memory and a processor; the memory is used to store computer program instructions; the processor is used to execute the computer program instructions to implement the following steps: receiving an image to be processed; the image to be processed contains text to be recognized; obtaining an image template category corresponding to the image to be processed; cutting out a template image to be processed corresponding to the image template category in the image to be processed; determining an inclination angle corresponding to the template image to be processed; and recognizing the text to be recognized in the template image to be processed based on the inclination angle.

[0034] It can be seen from the technical solution provided by the above embodiment of this specification that the embodiment of this specification first trains the image recognition model according to the first sample image marked with positioning characters and the image template category corresponding to the first sample image, so that after the image recognition model recognizes the image, it can determine the image template category corresponding to the image according to the distribution of characters in the image. Secondly, the angle recognition model is trained according to the second sample image corresponding to the image template category marked with the rotation angle, so that the angle recognition model can determine the tilt angle of the image corresponding to the image template category. After the model training is completed, when the image to be processed is received, the image to be processed is input into the image recognition model to identify the image template category corresponding to the image to be processed, and then the template image to be processed is intercepted from the image to be processed according to the image template category, and the template image to be processed is identified by the angle recognition model to determine the tilt angle of the template image to be processed, so that the tilt angle adjustment and text recognition can be performed on the text to be recognized based on the tilt angle. Through the above method, text recognition of the image to be recognized with a certain tilt angle is realized, the recognition accuracy of the text in the tilted image is ensured, and the problem of recognizing meaningless paragraphs based on the tilted image is avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of this specification 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 this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 This is a flowchart of an image recognition model training method according to an embodiment of this specification;

[0037] Figure 2 This is a flow chart of an angle recognition model training method according to an embodiment of this specification;

[0038] Figure 3 This is a flowchart of a text recognition method according to an embodiment of this specification;

[0039] Figure 4 This is a module diagram of an image recognition model training device according to an embodiment of this specification;

[0040] Figure 5 This is a module diagram of an angle recognition model training device according to an embodiment of this specification;

[0041] Figure 6 This is a module diagram of a text recognition device according to an embodiment of this specification;

[0042] Figure 7 This is a structural diagram of an image recognition model training device according to an embodiment of this specification;

[0043] Figure 8 This is a structural diagram of an angle recognition model training device according to an embodiment of this specification;

[0044] Fig. 9 This is a structural diagram of a text recognition device according to an embodiment of this specification. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0046] The following is combined with Figure 1 The present specification describes an image recognition model training method. The method is performed by an image recognition model training device, which includes but is not limited to a server, an industrial computer, a PC, etc. The image recognition model training method includes the following specific implementation steps.

[0047] S110: Receive a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character.

[0048] The first sample image is a sample image used to train a pre-built image recognition model. The first sample image may be any image containing text. The first sample image may have a certain tilt angle. The first sample image may be an image obtained by shooting, an image obtained by screenshot, or an image generated by a computer program, and there is no restriction on the method for obtaining the first sample image.

[0049] The first sample image corresponds to a certain image template category. The image template category is used to represent a fixed arrangement of characters in the image. The image template category corresponds to a positioning character distribution method. According to the image template category, the corresponding positioning character can be obtained at a fixed position of the image, so as to determine the positioning character in the image and obtain the tilt angle of the image in the subsequent text recognition process.

[0050] In real life, images that require text recognition often have fixed categories, such as copies of certificates, photos of signboards, screenshots of terminal devices, etc. The text in these images that require text recognition often has a fixed text arrangement. For example, in an identity document, the certificate information is arranged in a fixed style. After the characters in the identity document are identified, the image template category corresponding to the currently identified image can be determined as an identity document based on the arrangement of the characters. Specifically, the image template category can also be the front or side of an identity card. In actual applications, the image template category can be expanded according to the needs of the actual situation, and is not limited to the above examples, so it will not be repeated here.

[0051] Since the degree of rotation of the image will not affect the image template category of the first sample image, and the technical problem solved by the embodiments of this specification includes the recognition of text in an inclined image, the first sample image may be an image with different inclination angles.

[0052] The first sample image may be marked with at least one first positioning character. The first positioning character is used to determine the style corresponding to the sample image. For example, when the first sample image is a signboard, the first positioning character may be each word in the signboard.

[0053] The first positioning character may be text, or a symbol or logo inherent in the image. For example, when the first sample image is a copy of the front side of an ID card, the national emblem in the first sample image may also be marked as the first positioning character. If the national emblem is identified in the subsequent text recognition process, the image template category corresponding to the image may also be determined based on the identified national emblem and other positioning characters.

[0054] In practical applications, the first positioning characters may be all characters in the first sample image, or may be part of the characters in the first sample image. In some cases, some characters in the image template category corresponding to the first sample image may not be fixed characters, and marking such characters may affect the accuracy of the trained image recognition model. Therefore, in practical applications, the corresponding first positioning characters may be marked in the first sample image according to the specific requirements of the image template category.

[0055] S120: Obtain the character position of the first positioned character in the first sample image.

[0056] The character position is the position of the first positioning character in the first sample image. The image template category corresponding to the first sample image can be determined based on the distribution position of the first positioning character. For example, when the first sample image is a copy of an ID card, the characters in the first sample image have a fixed distribution position. When recognizing another ID card copy, if it is determined that the positioning characters in the ID card copy meet the character distribution characteristics of the ID card copy, it can be determined that the image template category corresponding to the currently recognized image is the front of the ID card or the back of the ID card.

[0057] The character position can be the position of the first positioning character compared to a coordinate system independent of the first sample image, or can be the relative position between different first positioning characters. The character position can be adjusted based on actual application requirements and is not limited to the above examples, which will not be repeated here.

[0058] Since the sizes of different first sample images obtained when training the image recognition model may be quite different, the first positioning characters corresponding to the same image template category may have different relative positions. In the above situation, if the first sample image is not adjusted, the relative position relationship between the positioning characters in the same image template category cannot be accurately determined when training the image recognition model, thereby affecting the accuracy of the trained image recognition model.

[0059] Therefore, in some embodiments, in order to ensure that the positions of the locating characters corresponding to the same image template category are distributed in the same manner, before obtaining the character position of the first locating character, the size of the first sample image can be adjusted to a preset standard size. The preset standard size can be a pre-set image size. After the first sample images of the same image template category are adjusted to the same size, the first locating characters therein also have a fixed interval, thereby ensuring the accuracy of the trained image recognition model.

[0060] Since the first sample image may be an inclined image, if the length and width of the first sample image itself are directly adjusted to a fixed size, the pictures corresponding to the image template category in the first sample image may have different sizes. Therefore, in practical applications, the first sample image needs to be resized according to the inclination of the image.

[0061] In some embodiments, when obtaining the character position of the first positioning character, the first sample image can be set in a preset coordinate system, and the coordinates of the first positioning character in the preset coordinate system are used as the character position corresponding to the first positioning character. By setting the preset coordinate system to obtain the character position corresponding to the first positioning character, the position of the first positioning character can be quantitatively and accurately obtained.

[0062] S130: training a pre-built image recognition model based on the character position and the image module category; the image recognition model is used to recognize the image template category corresponding to the image.

[0063] After obtaining the character position, the image recognition model can be trained based on the character position and the image template category corresponding to the first sample image. Since the first sample image is marked with the first positioning character, that is, the first sample image is labeled data, the image recognition model can be trained by supervised learning.

[0064] In the embodiments of the present specification, the image recognition model may be a mathematical model for classifying unclassified images into known image template categories. The image recognition model may be a Bayesian classification model, a support vector machine classification model (SVM), or a convolutional neural network classification model (CNN).

[0065] In some embodiments, the image recognition model may be a yolo model. The yolo model is a target detection model based on a convolutional neural network. The Yolo model includes a convolutional layer and a fully connected layer, which extracts features from an image through a convolutional layer, and then outputs corresponding probabilities according to the extracted image features through a fully connected layer to complete the recognition of image categories.

[0066] In the specific application process, the yolo model can divide the image into multiple units, and divide the image category by judging whether there is a target object in each unit. Applied to the embodiment of this specification, the corresponding units can be divided for the first sample image, and the corresponding units in the first sample image can be marked as having corresponding positioning characters according to the character position. The image template category of the corresponding first sample image is determined according to the distribution of units in the image where the first positioning character exists.

[0067] The above implementation is only an introduction to a specific example of an image recognition model. In practical applications, any machine learning model that identifies an image to determine the classification corresponding to the image can be used as the image recognition model for training, which will not be described in detail.

[0068] Through the above-mentioned image recognition model training method, the image recognition model can be trained based on the first sample image marked with positioning characters and the image template category corresponding to the first sample image, so that after the image recognition model recognizes the image, it can determine the image template category corresponding to the image according to the distribution of characters in the image. Therefore, the above-mentioned image recognition model training method can train an image recognition model that recognizes the image template category corresponding to the image, which is conducive to the recognition of text in the image using the text recognition method in the subsequent steps.

[0069] The following is combined with Figure 2 The present specification describes an angle recognition model training method. The method is performed by an angle recognition model training device, which includes but is not limited to a server, an industrial computer, a PC, etc. The angle recognition model training method includes the following specific implementation steps.

[0070] S210: receiving a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category.

[0071] The first sample image is a sample image used to train the pre-built angle recognition model. The first sample image may be any image containing text. The first sample image may have a certain tilt angle. The first sample image may be an image obtained by shooting, an image obtained by screenshot, or an image generated by a computer program, and there is no restriction on the method for obtaining the first sample image.

[0072] Since the trained angle recognition model needs to recognize the tilt angle of the image, the second sample image can be an image with a certain tilt angle. Accordingly, the second sample image is annotated with a corresponding rotation angle. The rotation angle is used to indicate the offset angle of the second sample image compared to the normal placement. For example, when the second sample image is inverted, the rotation angle of the second sample image is 180 degrees.

[0073] In some embodiments, in order to ensure the accuracy of the marked rotation angle, the second sample image can be obtained by adjusting the candidate sample image. The candidate sample images have different tilt angles, and corresponding second positioning characters are marked in the candidate sample images, and the second positioning characters are constructed as corresponding text lines. Based on the deflection angle of the text line relative to the horizontal axis, the tilt angle of the second sample image can be corrected. The adjusted candidate sample image may be an image without a deflection angle, or it may be an image rotated 180 degrees. In this case, the corrected candidate sample image can be adjusted to a standard image according to the correction instruction input by the user, and the standard image is an image with a tilt angle of 0 degrees. After all candidate sample images are adjusted to standard images without a deflection angle, the standard image can be rotated to an angle between 0 degrees and 359 degrees by the rotation angle input by the user again, and the rotated angle is used as the rotation angle corresponding to the rotated second sample image to ensure the correctness of the marked rotation angle.

[0074] The second positioning characters may be words, or symbols or logos inherent in the image, etc. The tilt angle of the second sample image may be determined by the positions of the second positioning characters and the positional relationship between the second positioning characters.

[0075] S220: Training a pre-built angle recognition model based on the rotation angle; the angle recognition model is used to recognize the tilt angle of the image.

[0076] After obtaining the second sample image with the rotation angle marked, the angle recognition model can be trained based on the rotation angle. Since the rotation angle is marked in the second sample image, that is, the second sample image is labeled data, the angle recognition model can be trained by supervised learning.

[0077] In the embodiment of the present specification, the angle recognition model can also be a mathematical model for determining the tilt angle of the image according to the positioning characters in the image. The image recognition model can be a Bayesian classification model, a support vector machine classification model (SVM), or a convolutional neural network classification model (CNN).

[0078] In some embodiments, the angle recognition model can be a vgg neural network model. The vgg neural network model includes a convolution layer, a fully connected layer and a softmax layer. The convolution layer is used to convolve the image to extract image features; the fully connected layer is used to reduce the dimension of the image features, thereby achieving image classification. The softmax layer is used to convert the output of the fully connected layer into a probability for output. By training the vgg neural network model, the vgg neural network model can classify the image according to the distribution of the positioning characters to determine the tilt angle of the image.

[0079] The above implementation is an introduction to a specific example of the angle recognition model. In practical applications, any machine learning model that identifies and classifies images to determine the tilt angle corresponding to the image can be trained as the angle recognition model, which will not be described in detail.

[0080] Through the above-mentioned angle recognition model training method, the angle recognition model can be trained according to the second sample image corresponding to the image template category marked with the rotation angle, so that the angle recognition model can determine the tilt angle of the image corresponding to the image template category. Therefore, the above-mentioned angle recognition model training method can train an angle recognition model for identifying the tilt angle of an image, which is beneficial to the recognition of text in the tilted image in the subsequent steps.

[0081] The following is combined with Figure 3 A text recognition method according to an embodiment of this specification is introduced. The execution subject of the method is a text recognition device, which includes but is not limited to a server, an industrial computer, a PC, etc. The text recognition method includes the following specific implementation steps.

[0082] S310: receiving an image to be processed; the image to be processed contains text to be recognized.

[0083] The image to be processed is an image that needs to be subjected to text recognition. The image to be processed may be an image with a certain tilt angle. The image to be processed may also be an image obtained by combining multiple small images corresponding to corresponding image template categories. When performing text recognition on the image to be processed, the texts in these small images may be recognized respectively.

[0084] The image to be processed contains text to be recognized, that is, text to be recognized. However, when the image to be processed may have a certain tilt angle, the characters in the image to be processed cannot be accurately recognized. Even if the characters in the image to be processed are recognized, it may not be possible to construct an accurate text paragraph based on the recognized characters. Therefore, when recognizing the text to be recognized in the image to be processed, it is necessary to first perform correction processing on the tilt angle of the image to be processed.

[0085] S320: Obtain an image template category corresponding to the image to be processed.

[0086] Since the image to be processed may have a variety of different tilt angles, the method of directly identifying the characters in the image to be processed and determining the text lines corresponding to the characters for correction may cause errors in character recognition due to the tilt angle of the characters themselves. Even if the characters are recognized, when the image to be processed is tilted, the characters in different lines may be distributed in the same line, resulting in confusion in the recognized text and inability to obtain the correct text from the image. Therefore, it is necessary to correct the image to be processed based on the tilt angle of the image to be processed.

[0087] Since the tilt angle of an image needs to be identified based on the corresponding positioning marks in the image, while directly identifying the image can obtain the characters in it, it is impossible to determine whether the identified characters are used as positioning characters, nor is it possible to determine the relative position relationship between the corresponding positioning characters. Therefore, in the case where some image template categories are set for the image in advance, the image template category corresponding to the image to be processed can be determined by identifying the image to be processed.

[0088] For the introduction of the image template category, please refer to the introduction in step S110, which will not be repeated here.

[0089] In some embodiments, the image to be processed may be input into an image recognition model to obtain the image template category corresponding to the image to be processed. The image recognition model may be used to identify the image template category corresponding to the image. The image recognition model may be based on Figure 1 The model obtained by training the corresponding image recognition model training method. For an introduction to the image recognition model, please refer to Figure 1 The description in the corresponding embodiment will not be repeated here.

[0090] In a specific example, the image template category corresponding to the image to be processed can be identified by using the image recognition model by first identifying corresponding characters in the image to be processed. The characters can be pre-set recognizable characters, such as Chinese characters, English letters, specific patterns, etc. After identifying these characters, the image category template corresponding to the image to be processed can be determined based on the positions of these characters in the image and the relative positional relationship between the characters.

[0091] In some embodiments, the image to be processed may be composed of more than two small images, and the small images may correspond to different image template categories. In these embodiments, when the image to be processed is recognized by the image recognition model, the corresponding small images can be respectively cut out from the image to be processed according to the characteristics of the image to be processed, and the image template categories corresponding to these small images can be determined, so that the determination of each image in the image to be processed and the corresponding text recognition can be realized when the image to be processed is composed of multiple images.

[0092] In some embodiments, the image to be processed includes an ID card image. Accordingly, when the image to be processed is identified using an image recognition model, it can be determined that the image template category corresponding to the image to be processed includes an ID card image front template and an ID card back template. In practical applications, the content included in the image to be processed and the image template category to which the image to be processed belongs are not limited to the above examples and will not be described in detail.

[0093] S330: extracting a template image to be processed corresponding to the image template category from the image to be processed.

[0094] After determining the image template category corresponding to the image to be processed, the template image to be processed can be cut out from the image to be processed based on the image template category. The template image to be processed is an image corresponding to the image template category. The template image to be processed can be smaller than the image to be processed, or it can be the same size as the image to be processed. The image to be processed can contain only one template image to be processed, or it can contain two or more template images to be processed. After cutting out the template image to be processed, in the subsequent steps, the template image to be processed can be directly input into the angle recognition model to obtain the corresponding tilt angle.

[0095] By cutting out the template image to be processed for text recognition, the interference of redundant parts in the image to be processed on text recognition can be removed, which is beneficial to improving the accuracy of text recognition.

[0096] S340: Determine the tilt angle corresponding to the template image to be processed.

[0097] After obtaining the positioning character, the template image to be processed can be input into the angle recognition model to complete the acquisition of the tilt angle of the template image to be processed. The angle recognition model can obtain the tilt angle of the image corresponding to a certain image template category. The angle recognition model can be based on Figure 2 The model obtained by training the corresponding angle recognition model training method. For an introduction to the angle recognition model, please refer to Figure 2 The description in the corresponding embodiment will not be repeated here.

[0098] In some embodiments, the use of the angle recognition model to determine the tilt angle corresponding to the image to be processed may include first convolving the image to be processed to obtain image features corresponding to the image to be processed, then reducing the dimension of the image features, and calculating the output value corresponding to the image to be processed based on the image features after the dimension reduction. Then, the tilt angle corresponding to the output value is determined according to a preset classification standard corresponding to the output value, so that the tilt angle corresponding to the image to be processed can be determined.

[0099] By acquiring the tilt angle corresponding to the image to be processed, accurate recognition of text in the image to be processed can be achieved when the angle of the image to be processed is adjusted.

[0100] S350: Recognize the text to be recognized in the template image to be processed based on the tilt angle.

[0101] After the tilt angle corresponding to the image to be processed is acquired, the image to be processed may be corrected based on the tilt angle, and then text recognition may be performed on the corrected image to be processed.

[0102] In some embodiments, performing text recognition on the image to be processed based on the rotation angle may be to rotate the image to be processed based on the tilt angle, and recognize the text to be recognized in the rotated image to be processed. Since there is no tilt angle in the rotated image to be processed, that is, the texts in the corresponding rows and columns therein are distributed in the correct rows and columns, the corresponding text can be directly recognized in the image to be processed.

[0103] The method of performing text recognition on the corrected image to be processed can be selected based on actual needs. For example, the text in the corrected image to be processed can be recognized by OCR technology. The above example is only an exemplary introduction to image text recognition. It can be adjusted according to needs in actual applications and will not be repeated here.

[0104] By using the above-mentioned text recognition method, after inputting the image to be processed into the image recognition model, the image template category corresponding to the image to be processed can be identified, and then the template image to be processed is cut out from the image to be processed according to the image template category, and the template image to be processed is identified by using the angle recognition model to determine the inclination angle of the template image to be processed, so that the inclination angle of the text to be recognized can be adjusted and the text recognized based on the inclination angle. Therefore, the above-mentioned text recognition method realizes text recognition for images to be recognized with a certain inclination angle, ensures the recognition accuracy of text in the inclined image, and avoids the situation of recognizing meaningless paragraphs based on the inclined image, which is beneficial to the application in real life.

[0105] based on Figure 1 The corresponding image recognition model training method introduces an image recognition model training device in the embodiment of this specification. The image recognition model training device is set in the image recognition model training device. Figure 4 As shown, the image recognition model training device includes the following modules.

[0106] The first sample image receiving module 410 is used to receive a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character;

[0107] A character position acquisition module 420, configured to acquire the character position of the first positioning character in the first sample image;

[0108] The image recognition model training module 430 is used to train a pre-built image recognition model based on the character position and the image module category; the image recognition model is used to identify the image template category corresponding to the image.

[0109] based on Figure 2 The corresponding angle recognition model training method introduces an angle recognition model training device in the embodiment of this specification. The angle recognition model training device is set in the angle recognition model training device. Figure 5 As shown, the angle recognition model training device includes the following modules.

[0110] The second sample image receiving module 510 is used to receive a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category;

[0111] The angle recognition model training module 520 is used to train a pre-built angle recognition model based on the rotation angle; the angle recognition model is used to recognize the tilt angle of the image.

[0112] based on Figure 3The corresponding text recognition method introduces a text recognition device in the embodiment of this specification. The text recognition device is set in the text recognition device. Figure 6 As shown, the text recognition device includes the following modules.

[0113] The to-be-processed image receiving module 610 is used to receive an to-be-processed image; the to-be-processed image contains text to be recognized;

[0114] An image template category acquisition module 620 is used to acquire the image template category corresponding to the image to be processed;

[0115] A template image to be processed intercepting module 630, used to intercept a template image to be processed corresponding to the image template category from the image to be processed;

[0116] The tilt angle determination module 640 is used to determine the tilt angle corresponding to the template image to be processed;

[0117] The text recognition module 650 is used to recognize the text to be recognized in the template image to be processed based on the tilt angle.

[0118] based on Figure 1 Corresponding to the image recognition model training method, this specification embodiment provides an image recognition model training device. Figure 7 As shown, the image recognition model training device may include a memory and a processor.

[0119] In this embodiment, the memory may be implemented in any appropriate manner. For example, the memory may be a read-only memory, a mechanical hard disk, a solid-state hard disk, or a USB flash drive, etc. The memory may be used to store computer instructions.

[0120] In this embodiment, the processor can be implemented in any appropriate manner. For example, the processor can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. The processor can execute the computer instructions to implement the following steps: receiving a first sample image; the first sample image corresponds to an image template category; the sample image is marked with at least one first positioning character; obtaining the character position of the first positioning character in the first sample image; training a pre-constructed image recognition model based on the character position and the image module category; the image recognition model is used to identify the image template category corresponding to the image.

[0121] based on Figure 2 Corresponding to the angle recognition model training method, the embodiment of this specification provides an angle recognition model training device. Figure 8 As shown, the angle recognition model training device may include a memory and a processor.

[0122] In this embodiment, the memory may be implemented in any appropriate manner. For example, the memory may be a read-only memory, a mechanical hard disk, a solid-state hard disk, or a USB flash drive, etc. The memory may be used to store computer instructions.

[0123] In this embodiment, the processor can be implemented in any appropriate manner. For example, the processor can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. The processor can execute the computer instructions to implement the following steps: receiving a second sample image; the second sample image corresponds to a rotation angle; the second sample image corresponds to an image template category; training a pre-built angle recognition model based on the rotation angle; the angle recognition model is used to recognize the tilt angle of the image.

[0124] based on Figure 3 Corresponding to the text recognition method, this specification embodiment provides a text recognition device. Fig. 9 As shown, the text recognition device may include a memory and a processor.

[0125] In this embodiment, the memory may be implemented in any appropriate manner. For example, the memory may be a read-only memory, a mechanical hard disk, a solid-state hard disk, or a USB flash drive, etc. The memory may be used to store computer instructions.

[0126] In this embodiment, the processor can be implemented in any appropriate manner. For example, the processor can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. The processor can execute the computer instructions to implement the following steps: receiving an image to be processed; the image to be processed contains text to be recognized; obtaining the image template category corresponding to the image to be processed; cutting out the template image to be processed corresponding to the image template category in the image to be processed; determining the tilt angle corresponding to the template image to be processed; and recognizing the text to be recognized in the template image to be processed based on the tilt angle.

[0127] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip2. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog2. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0128] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0129] It can be known from the above description of the implementation mode that the technicians in this field can clearly understand that the present specification can be implemented by means of software plus the necessary first hardware platform. Based on such an understanding, the technical solution of the present specification can be essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present specification or some parts of the embodiments.

[0130] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0131] This specification can be used in many first or special computer system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0132] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0133] Although the present specification is described through embodiments, those skilled in the art will appreciate that there are many modifications and changes to the present specification without departing from the spirit of the present specification, and it is intended that the appended claims include these modifications and changes without departing from the spirit of the present specification.

Claims

1. A text recognition method, characterized in that: include: Receiving an image to be processed; the image to be processed contains text to be recognized; Obtaining the image template category corresponding to the image to be processed; wherein the image template category is used to represent a fixed arrangement of characters in the image, corresponding to a positioning character distribution method; the obtaining the image template category corresponding to the image to be processed comprises: identifying corresponding characters in the image to be processed; determining the image template category corresponding to the image to be processed according to the positions of the characters in the image to be processed and the relative positional relationship between the characters; Cutting out a template image to be processed corresponding to the image template category from the image to be processed; wherein the template image to be processed is smaller than the image to be processed; Determining the tilt angle corresponding to the template image to be processed; comprising: inputting the template image to be processed into an angle recognition model to obtain the tilt angle corresponding to the template image to be processed; the angle recognition model is used to recognize the tilt angle of the image; Recognize the text to be recognized in the template image to be processed based on the tilt angle; Among them, the angle recognition model includes a vgg neural network model, which includes a convolution layer, a fully connected layer and a softmax layer; accordingly, the template image to be processed is input into the angle recognition model to obtain the tilt angle corresponding to the template image to be processed, including: using the convolution layer to convolve the template image to be processed to extract image features; using the fully connected layer to reduce the dimension of the template image to be processed to achieve classification of the template image to be processed; using the softmax layer to convert the output of the fully connected layer into corresponding probabilities to determine the tilt angle corresponding to the template image to be processed.

2. The method according to claim 1, characterized in that The image to be processed includes an ID card image; accordingly, the image template category includes an ID card image front template and an ID card image back template.

3. The method according to claim 1, characterized in that The step of recognizing the text to be recognized in the image to be processed based on the tilt angle includes: Rotating the image to be processed based on the tilt angle; Recognize the text to be recognized in the rotated template image to be processed.

4. A text recognition device, characterized in that: include: The to-be-processed image receiving module is used to receive the to-be-processed image; the to-be-processed image contains text to be recognized; An image template category acquisition module is used to acquire the image template category corresponding to the image to be processed; wherein the image template category is used to represent a fixed arrangement of characters in an image, corresponding to a positioning character distribution method; the acquisition of the image template category corresponding to the image to be processed includes: identifying corresponding characters in the image to be processed; determining the image template category corresponding to the image to be processed according to the position of the characters in the image to be processed and the relative position relationship between the characters; A template image interception module to be processed, used to intercept a template image to be processed corresponding to the image template category from the image to be processed; wherein the template image to be processed is smaller than the image to be processed; The tilt angle determination module is used to determine the tilt angle corresponding to the template image to be processed; the tilt angle determination module is specifically used to input the template image to be processed into an angle recognition model to obtain the tilt angle corresponding to the template image to be processed; the angle recognition model is used to identify the tilt angle of the image; A text recognition module, used for recognizing the text to be recognized in the template image to be processed based on the tilt angle; Among them, the angle recognition model includes a vgg neural network model, which includes a convolution layer, a fully connected layer and a softmax layer; accordingly, the template image to be processed is input into the angle recognition model to obtain the tilt angle corresponding to the template image to be processed, including: using the convolution layer to convolve the template image to be processed to extract image features; using the fully connected layer to reduce the dimension of the template image to be processed to achieve classification of the template image to be processed; using the softmax layer to convert the output of the fully connected layer into corresponding probabilities to determine the tilt angle corresponding to the template image to be processed.

5. A text recognition device comprising a memory and a processor; The memory is used to store computer program instructions; The processor is used to execute the computer program instructions to implement the following steps: receiving an image to be processed; the image to be processed contains text to be recognized; obtaining an image template category corresponding to the image to be processed; wherein, The image template category is used to represent a fixed arrangement of characters in an image, corresponding to a positioning character distribution method; the acquisition of the image template category corresponding to the image to be processed includes: identifying corresponding characters in the image to be processed; determining the image template category corresponding to the image to be processed according to the position of the characters in the image to be processed and the relative position relationship between the characters; cutting out the template image to be processed corresponding to the image template category in the image to be processed; wherein the template image to be processed is smaller than the image to be processed; determining the inclination angle corresponding to the template image to be processed; including: inputting the template image to be processed into an angle recognition model to obtain the inclination angle corresponding to the template image to be processed; the angle recognition model type, used to identify the tilt angle of an image; based on the tilt angle, identify the text to be identified in the template image to be processed; wherein the angle recognition model includes a vgg neural network model, and the vgg neural network model includes a convolution layer, a fully connected layer and a softmax layer; accordingly, the template image to be processed is input into the angle recognition model to obtain the tilt angle corresponding to the template image to be processed, including: using the convolution layer to convolve the template image to be processed to extract image features; using the fully connected layer to reduce the dimension of the template image to be processed to achieve classification of the template image to be processed; using the softmax layer to convert the output of the fully connected layer into a corresponding probability to determine the tilt angle corresponding to the template image to be processed.

Citation Information

Patent Citations

  • An image information extraction method and device

    CN109034159A

  • Card information identification method and device and terminal

    CN110516672A

  • Certificate image capturing method, storage medium and certificate image capturing device

    CN110929732A

  • Target text extraction method and device in certificate, equipment and readable storage medium

    CN111126125A

  • Text detection and recognition method and system and computer equipment

    CN111401371A