Text recognition method and device, electronic equipment, medium and product
By preset recognition template data, preprocessing and cropping of the recognized image, the problem of high text recognition cost and difficult to guarantee accuracy in the image is solved, and the effect of reducing costs and improving accuracy is achieved.
Patent Information
- Application Number
- CN202310765991.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-26
- Publication Date
- 2024-12-27
AI Technical Summary
In the prior art, text recognition in images is high and the accuracy is difficult to guarantee, mainly because the text recognition model requires a lot of training to recognize the association relationship in the entire image.
By presetting the template image size and associated area information in the template data, the recognized image is preprocessed and cropped, standard images are generated and cropped into multiple cropped images, and text recognition is performed separately to avoid directly identifying the entire image. .
This reduces the recognition cost and ensures the accuracy of text recognition, avoiding the training requirement for the entire image association relationship recognition model.
Smart Images

Figure CN119206691A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a text recognition method, device, electronic device, medium and product. Background Art
[0002] With the continuous development of science and technology and the gradual improvement of automation, a large amount of text processing work in images has gradually shifted from being done manually to being done automatically by machines.
[0003] In the prior art, a machine takes a picture of an image to be recognized, and inputs the entire image into a pre-trained text recognition model, and uses the output result of the text recognition model as the entire text content in the image to be recognized, and then performs corresponding text processing work based on the entire text content in the image to be recognized.
[0004] However, there is a strict correlation between the texts in the entire image to be recognized. If the text recognition model of the prior art cannot accurately recognize the correlation between the texts in the entire image to be recognized, the subsequent text processing work will not be able to proceed normally. In order to ensure that the text recognition model of the prior art can accurately distinguish the correlation between the texts in the entire image to be recognized, a large amount of training of the text recognition model is required in the early stage, which will lead to high costs and the final recognition accuracy is difficult to guarantee. In other words, the prior art has problems such as high cost of text recognition in images and difficulty in ensuring recognition accuracy. Summary of the invention
[0005] The present application provides a text recognition method, device, electronic device, medium and product to solve the problems of high cost of text recognition in images and difficulty in ensuring recognition accuracy.
[0006] In a first aspect, the present application provides a text recognition method, comprising:
[0007] Acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified;
[0008] Preprocessing the image to be identified according to the template image size to obtain a standard image;
[0009] Performing cropping processing on the standard image according to the preset associated area information to be identified, to obtain at least one cropped image;
[0010] Perform text recognition processing on at least one of the cropped images, and generate text recognition information of the image to be recognized based on the text recognition processing result of at least one of the cropped images.
[0011] Optionally, preprocessing the image to be identified according to the template image size to obtain a standard image includes:
[0012] Using a preset image parameter recognition algorithm to determine current parameters of the image to be recognized, the current parameters including a current inclination angle, a current size, and a current center point;
[0013] Performing angle correction processing on the image to be identified according to the current inclination angle and the current center point to obtain an angle-corrected image;
[0014] Performing size correction processing on the angle-corrected image according to the current size and the template image size to obtain a size-corrected image;
[0015] The standard image is determined according to the size-corrected image.
[0016] Optionally, performing angle correction processing on the image to be identified according to the current inclination angle and the current center point to obtain an angle-corrected image includes:
[0017] In response to the current inclination being a positive value, the image to be identified is rotated counterclockwise by the current inclination with the current center point as the rotation center to obtain the angle-corrected image;
[0018] In response to the current inclination being a negative value, the image to be identified is rotated clockwise by the absolute value of the current inclination with the current center point as the rotation center to obtain the angle-corrected image;
[0019] In response to the current tilt angle being 0°, the image to be recognized is determined to be the angle-corrected image.
[0020] Optionally, determining the standard image according to the size-corrected image includes:
[0021] Pre-cropping the size-corrected image according to the preset associated area information to be identified to obtain a cropped image;
[0022] Performing text pre-recognition processing on the one cropped image;
[0023] In response to a failure in the text pre-recognition process, rotating the size-corrected image by 180°, and determining the rotated size-corrected image as the standard image;
[0024] In response to the text pre-recognition process being successful, the size-corrected image is directly determined as the standard image.
[0025] Optionally, performing size correction processing on the angle-corrected image according to the current size and the template image size to obtain the size-corrected image includes:
[0026] Determine a horizontal scaling ratio and a vertical scaling ratio of the current size to the template image size;
[0027] Performing decimation or supplementation processing on the pixels in the horizontal direction of the angle-corrected image according to the horizontal scaling ratio to obtain a horizontally corrected image, and performing decimation or supplementation processing on the pixels in the vertical direction of the horizontally corrected image according to the vertical scaling ratio to obtain the standard image; or
[0028] The pixel points in the vertical direction of the angle-corrected image are removed or supplemented according to the vertical scaling ratio to obtain the vertically corrected image, and the pixel points in the horizontal direction of the vertically corrected image are removed or supplemented according to the horizontal scaling ratio to obtain the standard image.
[0029] Optionally, the preset associated area information to be identified includes the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be identified;
[0030] The step of performing cropping processing on the standard image according to the preset associated area information to be identified to obtain at least one cropped image includes:
[0031] Determine at least one rectangular area in the standard image according to the upper left corner coordinates and the lower right corner coordinates of the at least one associated area to be identified;
[0032] An image within at least one rectangular area in the standard image is cropped to obtain at least one cropped image.
[0033] Optionally, performing text recognition processing on at least one of the cropped images includes:
[0034] Inputting at least one of the cropped images into a pre-trained text recognition model, performing text recognition processing on at least one of the cropped images, and obtaining an output result of the text recognition model;
[0035] The output result of the text recognition model is used as a text recognition processing result of at least one of the cropped images.
[0036] Optionally, the preset associated area information to be identified includes at least one associated area identifier to be identified;
[0037] Generating text recognition information of the image to be recognized according to a text recognition processing result of at least one of the cropped images includes:
[0038] Determine the text that is identical to the associated region identifier to be identified in the text recognition processing result of at least one of the cropped images as a target text identifier;
[0039] Determining the text other than the target text mark in the text recognition processing result of at least one of the cropped images as the target text content;
[0040] The target text identifier is used as a key and the target text content is used as a value to generate text recognition information of the image to be recognized.
[0041] In a second aspect, the present application provides a text recognition device, the text recognition device comprising:
[0042] An acquisition module, used to acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified;
[0043] A preprocessing module, used for preprocessing the image to be identified according to the size of the template image to obtain a standard image;
[0044] A cropping module, used for cropping the standard image according to the preset associated area information to be identified, to obtain at least one cropped image;
[0045] The generating module is used to perform text recognition processing on at least one of the cropped images, and generate text recognition information of the image to be recognized according to the text recognition processing result of at least one of the cropped images.
[0046] In a third aspect, the present application provides an electronic device, the electronic device comprising: a processor, and a memory communicatively connected to the processor;
[0047] The memory stores computer-executable instructions;
[0048] The processor executes the computer-executable instructions stored in the memory to implement the text recognition method according to any one of the first aspects.
[0049] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the text recognition method described in any one of the first aspects.
[0050] In a fifth aspect, the present application provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the text recognition method described in any one of the first aspects is implemented.
[0051] The text recognition method, device, electronic device, medium and product provided by the present application, the text recognition method includes: obtaining an image to be recognized and preset recognition template data, the preset recognition template data includes template image size and preset associated area information to be recognized; preprocessing the image to be recognized according to the template image size to obtain a standard image; cropping the standard image according to the preset associated area information to be recognized to obtain at least one cropped image; performing text recognition processing on at least one cropped image, and generating text recognition information of the image to be recognized according to the text recognition processing result of at least one cropped image. Through the above scheme, the image to be recognized is transformed into a standard image according to the template image size in the preset recognition template data, and then the standard image is cropped into at least one cropped image according to the preset associated area information to be recognized in the preset recognition template data, so that text recognition processing is performed on at least one cropped image respectively, and text recognition information of the image to be recognized is generated according to the text recognition processing result of at least one cropped image. Since text recognition is not performed directly on the entire image to be recognized, it is no longer necessary to train a text recognition model that can accurately recognize the association relationship between texts in the entire image to be recognized, thereby reducing the recognition cost and ensuring the recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0053] Figure 1 A schematic diagram of a scenario of a text recognition method provided in an embodiment of the present application;
[0054] Figure 2 A flowchart of a text recognition method provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of an example of the current inclination angle of an image to be recognized in the text recognition method provided in an embodiment of the present application;
[0056] Figure 4 Another exemplary schematic diagram of the current inclination angle of the image to be recognized in the text recognition method provided in the embodiment of the present application;
[0057] Figure 5 Another exemplary schematic diagram of the current inclination angle of the image to be recognized in the text recognition method provided in the embodiment of the present application;
[0058] Figure 6 Another exemplary schematic diagram of the current inclination angle of the image to be recognized in the text recognition method provided in the embodiment of the present application;
[0059] Figure 7An example schematic diagram of the angle correction of the text orientation in an image provided by the text recognition method according to an embodiment of the present application;
[0060] Figure 8 Another exemplary schematic diagram of the angle correction of the text orientation in the image provided by the text recognition method according to the embodiment of the present application;
[0061] Fig. 9 An example schematic diagram of a cropped image of a text recognition method provided in an embodiment of the present application;
[0062] Fig.10 A schematic diagram of the structure of a text recognition device provided in an embodiment of the present application;
[0063] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0064] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0065] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0066] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0067] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0068] In the prior art, a machine takes a picture of an image to be recognized, and inputs the entire image into a pre-trained text recognition model, and uses the output result of the text recognition model as the entire text content in the image to be recognized, and then performs corresponding text processing work based on the entire text content in the image to be recognized.
[0069] However, there is a strict correlation between the texts in the entire image to be recognized. If the text recognition model in the prior art cannot accurately recognize the correlation between the texts in the entire image to be recognized, the output result of the text recognition model will be a string of messy texts. For example, the image to be recognized includes the associated first text A1B1 and the second text a1b1, and the associated third text A2B2 and the fourth text a2b2, where A1B1 and A2B2 are on one horizontal line of the image to be recognized, and a1b1 and a2b2 are on another horizontal line of the image to be recognized. If If the text recognition model cannot accurately identify the relationship between the texts in the entire image to be recognized, the output result of the text recognition model may be A1B1A2B2a1b1a2b2, rather than A1B1:a1b1 and A2B2:a2b2, which will cause the subsequent text processing work to be unable to proceed normally. In order to ensure that the text recognition model of the prior art can accurately distinguish the relationship between the texts in the entire image to be recognized, the text recognition model needs to be trained a lot in the early stage, which will lead to high costs and the final recognition accuracy is difficult to guarantee. In other words, the prior art has problems such as high cost of text recognition in images and difficulty in ensuring recognition accuracy.
[0070] In view of the problem that the cost of text recognition in the above-mentioned image is high and the recognition accuracy is difficult to guarantee, the inventors found in the research that in order to solve this problem, it is not necessary to use the text recognition model to perform text recognition on the entire image to be recognized at one time, but to solve the problem of the association relationship between the texts in the image to be recognized by using the preset recognition template data, that is, the preset association area information to be recognized is stored in advance in the preset recognition template data, and the preset association area information to be recognized can locate the associated text in the image to be recognized, and then the associated area to be recognized in the image to be recognized is cropped into at least one cropped image according to the preset association area information to be recognized, that is, the associated text is in the same cropped image, and then each cropped image is input into the text recognition model that does not need to recognize the association relationship between the texts, and the text recognition is performed on each cropped image to obtain the associated text. In addition, since the text recognition is not directly performed on the entire image to be recognized, it is no longer necessary to train a text recognition model that can accurately recognize the association relationship between the texts in the entire image to be recognized, thereby reducing the recognition cost and ensuring the recognition accuracy.
[0071] Based on the above creative findings, the inventor proposed the technical solution of the present application.
[0072] The text recognition method provided by the embodiment of the present invention can be applied in passport review scenarios, identity card review scenarios, or other scenarios related to text recognition.
[0073] like Figure 1As shown, if applied in a passport review scenario, it may include a client 100 and a server 200. The client 100 can take a photo of a passport, generate a passport image to be identified, and send the passport image to be identified and a passport review request to the server 200. The server 200 pre-stores preset recognition template data, which includes the template passport image size and preset associated area information to be identified. After receiving the passport image to be identified and the passport review request, the server 200 pre-processes the passport image to be identified according to the template passport image size to obtain a standard passport image, which has the same size and angle as the template passport image used when generating the preset recognition template data, then crops the standard passport image according to the preset associated area information to be identified to obtain at least one cropped passport image, and then performs text recognition processing on at least one cropped passport image, and generates text recognition information of the passport image to be identified according to the text recognition processing result of at least one cropped image, and uses a preset passport review algorithm to review the text recognition information of the passport image to be identified, and sends the review result to the client 100.
[0074] It is understandable that the text recognition method provided in the embodiment of the present invention can also be applied in other scenarios. The specific application methods are similar to the passport review scenario and will not be described in detail here.
[0075] The technical solutions shown in the present application are described in detail below through specific embodiments. Optionally, the following embodiments may exist alone or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.
[0076] Figure 2 Flow chart of the text recognition method provided in the embodiment of the present application. The execution subject of the text recognition method provided in the embodiment of the present application may be a text recognition device, which may be integrated in an electronic device, such as Figure 2 As shown, the text recognition method provided in the embodiment of the present application includes:
[0077] S10: Acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified.
[0078] In some embodiments, an image acquisition device acquires an image to be recognized and sends the acquired image to be recognized to an electronic device, thereby acquiring the image to be recognized. The image acquisition device includes but is not limited to a camera, a mobile phone, a tablet computer, or other devices with a camera function. The types of images to be recognized include but are not limited to passports, ID cards, student ID cards, bank cards, etc.
[0079] In some embodiments, the template image size and preset associated area information to be identified input by relevant personnel are obtained in advance, preset identification template data is generated, and the preset identification template data is stored in a storage medium or a database, so that the preset identification template data can be obtained by accessing the storage medium or the database. The type of template image used when generating the preset identification template data is the same as the type of the image to be identified.
[0080] Exemplarily, the template image size may include length*width. In one example, the template image size is 780*540.
[0081] Exemplarily, the preset information of the associated region to be identified may include the position information of at least one associated region to be identified and at least one identifier of the associated region to be identified. It can be understood that the preset information of the associated region to be identified is determined according to the template image, that is, the position information of at least one associated region to be identified in the preset information of the associated region to be identified is the position information of at least one associated region to be identified in the template image.
[0082] Exemplarily, an associated region to be identified may include at least two associated parts of text. The associated region to be identified may be the minimum image area occupied by the at least two associated parts of text. The minimum image area may be a rectangle, an irregular shape, or other shapes, which are not limited here.
[0083] Exemplarily, preset recognition template data of multiple images are pre-stored. After the image to be recognized is acquired, the type of the currently acquired image to be recognized is first determined, and then the preset recognition template data of the same type as the currently acquired image to be recognized is acquired. For example, if the type of the currently acquired image to be recognized is a passport, the preset recognition template data of the passport is acquired; if the type of the currently acquired image to be recognized is an ID card, the preset recognition template data of the ID card is acquired.
[0084] S20: Preprocess the image to be identified according to the template image size to obtain a standard image.
[0085] It is understandable that due to the difference in actual shooting angle and actual shooting distance, the angle and size of the image to be identified may be different from the template image, and the preset associated area information to be identified is determined based on the template image. If the image to be identified is directly cropped based on the preset associated area information to be identified, it may cause the text that should have been in the same cropped image to be split into two cropped images, and the text that should have been in the two cropped images to be cropped into the same cropped image, that is, the cropping result is inaccurate. Therefore, after obtaining the image to be identified, the image to be identified can be preprocessed according to the size of the template image to obtain a standard image with the same angle and size as the template image, and then the standard image can be cropped based on the preset associated area information to avoid inaccurate cropping results.
[0086] S30: Crop the standard image according to preset information of the associated region to be identified to obtain at least one cropped image.
[0087] Since the standard image and the template image have the same angle and size, after obtaining the standard image, the standard image can be directly cropped according to the preset associated area information to be identified, and at least one cropped image can be cropped from the standard image.
[0088] It can be understood that the number of cropped images is the same as the number of associated regions to be identified, one associated region to be identified corresponds to one cropped image, and different associated regions to be identified correspond to different cropped images.
[0089] Optionally, the preset information of the associated region to be identified includes the upper left corner coordinates and the lower right corner coordinates of at least one associated region to be identified. Accordingly, step S30 includes: determining at least one rectangular region in the standard image according to the upper left corner coordinates and the lower right corner coordinates of at least one associated region to be identified; and cropping the image within the at least one rectangular region in the standard image to obtain at least one cropped image.
[0090] In the text recognition method of the above embodiment, at least one rectangular area in the standard image is determined according to the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be recognized; and the image within the at least one rectangular area in the standard image is cropped to obtain at least one cropped image. In this way, the associated areas to be recognized in the standard image can be accurately cropped into separate cropped images, which is convenient for subsequent text recognition processing.
[0091] S40: Performing text recognition processing on at least one cropped image, and generating text recognition information of the image to be recognized according to the text recognition processing result of at least one cropped image.
[0092] Exemplarily, a pre-trained text recognition model is used to perform text recognition processing on at least one cropped image, and after obtaining the text recognition processing result output by the text recognition model, text recognition information of the image to be recognized is generated according to the text recognition processing result.
[0093] The text recognition method provided by the embodiment of the present application obtains an image to be recognized and preset recognition template data, wherein the preset recognition template data includes a template image size and preset information of associated regions to be recognized; pre-processes the image to be recognized according to the template image size to obtain a standard image; crops the standard image according to the preset information of associated regions to be recognized to obtain at least one cropped image; performs text recognition processing on at least one cropped image, and generates text recognition information of the image to be recognized according to the text recognition processing result of at least one cropped image. In this way, the image to be recognized is transformed into a standard image according to the template image size in the preset recognition template data, and then the standard image is cropped into at least one cropped image according to the preset information of associated regions to be recognized in the preset recognition template data, so that text recognition processing is performed on at least one cropped image respectively, and text recognition information of the image to be recognized is generated according to the text recognition processing result of at least one cropped image. Since text recognition is not performed directly on the entire image to be recognized, it is no longer necessary to train a text recognition model that can accurately recognize the association relationship between texts in the entire image to be recognized, thereby reducing the recognition cost and ensuring the recognition accuracy.
[0094] Optionally, step S20 includes:
[0095] S21: using a preset image parameter recognition algorithm to determine current parameters of the image to be recognized, where the current parameters include a current inclination angle, a current size, and a current center point.
[0096] Exemplarily, the cv2 library function in OpenCV is used to automatically determine the current inclination angle, current size and current center point of the image to be recognized. The current size may include length*width.
[0097] S22: Perform angle correction processing on the image to be recognized according to the current inclination angle and the current center point to obtain an angle-corrected image.
[0098] Exemplarily, after determining the current inclination angle, if the current inclination angle is 0°, the image to be identified can be directly determined as an angle-corrected image; if the current inclination angle is not 0°, the image to be identified is angle-corrected to obtain an angle-corrected image.
[0099] As a possible implementation, the template image used when generating the preset recognition template data is a horizontally placed image, and the angle between the long side of the template image and the horizontal axis is 0°. The current inclination angle is the angle between the long side of the image to be recognized and the horizontal axis. Therefore, after determining the current inclination angle of the image to be recognized, the image to be recognized can be rotated so that the long side is parallel to the horizontal axis with the current center point as the rotation center, thereby obtaining an angle-corrected image.
[0100] As another possible implementation, the current inclination angle is the angle required to rotate the image to be identified to be consistent with the text orientation of the template image. Therefore, after determining the current inclination angle of the image to be identified, the image to be identified can be rotated by the current inclination angle according to a preset rotation direction with the current center point as the rotation center, thereby obtaining an angle-corrected image.
[0101] S23: Performing size correction processing on the angle-corrected image according to the current size and the template image size to obtain a size-corrected image.
[0102] Exemplarily, after determining the current size, if the current size is consistent with the template image size, the angle-corrected image is directly determined as the size-corrected image; if the current size is inconsistent with the template image size, the angle-corrected image is size-corrected to obtain the size-corrected image.
[0103] S24: Determine a standard image based on the size-corrected image.
[0104] Exemplarily, after obtaining the size-corrected image, the angle and size of the size-corrected image may be checked. If the check passes, the size-corrected image is directly determined as the standard image; if the check fails, the size-corrected image is corrected and the corrected image is determined as the standard image.
[0105] The text recognition method of the above embodiment adopts a preset image parameter recognition algorithm to determine the current parameters of the image to be recognized, and the current parameters include the current inclination angle, the current size and the current center point; the image to be recognized is subjected to angle correction processing according to the current inclination angle and the current center point to obtain an angle-corrected image; the angle-corrected image is subjected to size correction processing according to the current size and the template image size to obtain a size-corrected image; and the standard image is determined according to the size-corrected image. In this way, the image to be recognized is first subjected to angle correction processing, and then subjected to size correction processing, so that a standard image with the same angle and size as the template image used when generating the preset recognition template data can be obtained.
[0106] It should be pointed out that in other embodiments, the image to be identified can be first size-corrected, and then the image to be identified after the size correction can be angle-corrected, and a standard image can be determined based on the image to be identified after the size correction and the angle correction, wherein the image to be identified after the size correction and the angle correction is the same as the size-corrected image in step S24.
[0107] Optionally, step S22 includes:
[0108] S221: In response to the current inclination being a positive value, the image to be identified is rotated counterclockwise by the current inclination with the current center point as the rotation center to obtain an angle-corrected image;
[0109] S222: In response to the current inclination being a negative value, the image to be recognized is rotated clockwise by the absolute value of the current inclination with the current center point as the rotation center to obtain an angle-corrected image;
[0110] S223: In response to the current tilt angle being 0°, determining the image to be recognized as an angle-corrected image.
[0111] In this embodiment, the template image used when generating the preset recognition template data is a horizontally placed image, and the angle between the long side of the template image and the horizontal axis is 0°. When the current inclination angle is the angle between the long side of the image to be recognized and the horizontal axis, the value range of the current inclination angle α is -90°≤α<90°. If the horizontal axis is rotated counterclockwise to coincide with the long side of the image to be recognized, then α<0°. Figure 3 As shown; if the horizontal axis is rotated clockwise to coincide with the long side of the image to be identified, then α>0°, as Figure 4 As shown; if the horizontal axis is parallel to the long side of the image to be identified, then α=0°, as Figure 5 As shown; if the horizontal axis is perpendicular to the long side of the image to be identified, then α = -90°, as Figure 6 As shown. Further, when it is determined that the current inclination of the image to be identified is a positive value, the image to be identified is rotated counterclockwise by the current inclination with the current center point as the rotation center to obtain an angle-corrected image; when it is determined that the current inclination of the image to be identified is a negative value, the image to be identified is rotated clockwise by the absolute value of the current inclination with the current center point as the rotation center to obtain an angle-corrected image; when it is determined that the current inclination of the image to be identified is 0°, the image to be identified is directly determined as an angle-corrected image.
[0112] In the text recognition method of the above embodiment, in response to the current inclination being a positive value, the image to be recognized is rotated counterclockwise by the current inclination with the current center point as the rotation center to obtain an angle-corrected image; in response to the current inclination being a negative value, the image to be recognized is rotated clockwise by the absolute value of the current inclination with the current center point as the rotation center to obtain an angle-corrected image; in response to the current inclination being 0°, the image to be recognized is determined to be an angle-corrected image. In this way, the long side of the angle-corrected image is ensured to be parallel to the horizontal axis, thereby facilitating the smooth execution of the subsequent text recognition steps.
[0113] Optionally, based on the previous embodiment, step S24 includes:
[0114] S241: Pre-cropping the size-corrected image according to preset information of the associated region to be identified to obtain a cropped image.
[0115] Exemplarily, the preset information of the associated area to be identified includes the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be identified, and a rectangular area in the size-corrected image is determined based on the upper left corner coordinates and the lower right corner coordinates of any associated area to be identified, and then the image within the rectangular area in the size-corrected image is cropped to obtain a cropped image.
[0116] S242: Perform text pre-recognition processing on a cropped image.
[0117] Exemplarily, a cropped image obtained in step S241 is input into a pre-trained text recognition model, and text pre-recognition processing is performed on the cropped image.
[0118] S243: In response to the text pre-recognition process failing, the size-corrected image is rotated by 180°, and the rotated size-corrected image is determined as the standard image.
[0119] S244: In response to the text pre-recognition process being successful, directly determining the size-corrected image as the standard image.
[0120] For example, when the current inclination angle is the angle between the long side of the image to be recognized and the horizontal axis, the orientation of the characters in the angle-corrected image obtained after the image to be recognized is angle-corrected according to the current inclination angle and the current center point may be exactly the same as the orientation of the characters in the template image (e.g. Figure 7 ), or it may be exactly opposite to the text direction in the template image (such as Figure 8As shown), when the orientation is opposite to that of the text in the template image, it may cause subsequent text recognition failure. Therefore, in order to avoid affecting the processing progress of subsequent text recognition, the size-corrected image is pre-cropped and text pre-recognized in advance, and then the text pre-recognition result is used to determine whether the orientation of the text in the size-corrected image is consistent with that in the template image. If the text pre-recognition result can be obtained, that is, the text pre-recognition process is successful, it means that the orientation of the text in the size-corrected image is consistent with that in the template image. Therefore, the size-corrected image is directly determined as the standard image; if the text pre-recognition result cannot be obtained, that is, the text pre-recognition process fails, it means that the orientation of the text in the size-corrected image is opposite to that in the template image. Therefore, the size-corrected image is rotated 180°, and the rotated size-corrected image is determined as the standard image.
[0121] The text recognition method of the above embodiment performs pre-cropping processing on the size-corrected image according to the preset information of the associated area to be recognized to obtain a cropped image; performs text pre-recognition processing on the cropped image; in response to the failure of the text pre-recognition processing, the size-corrected image is rotated 180°, and the rotated size-corrected image is determined as the standard image; in response to the success of the text pre-recognition processing, the size-corrected image is directly determined as the standard image. In this way, it is ensured that the text orientation in the standard image is consistent with the text orientation in the template image, thereby avoiding delays in the subsequent text processing progress and ensuring the accuracy of the text recognition processing results.
[0122] Optionally, step S23 includes:
[0123] S231: Determine the horizontal scaling ratio and the vertical scaling ratio of the current size to the template image size;
[0124] S232: performing decimation or supplementation processing on the pixels in the horizontal direction of the angle-corrected image according to the horizontal scaling ratio to obtain a horizontally-corrected image, and performing decimation or supplementation processing on the pixels in the vertical direction of the horizontally-corrected image according to the vertical scaling ratio to obtain a standard image; or
[0125] S233: decimating or supplementing the pixels in the vertical direction of the angle-corrected image according to the vertical scaling ratio to obtain a vertically corrected image, and decimating or supplementing the pixels in the horizontal direction of the vertically corrected image according to the horizontal scaling ratio to obtain a standard image.
[0126] It can be understood that, in some embodiments, step S23 includes step S231 and step S232; in some embodiments, step S23 includes step S231 and step S233, which is not limited here.
[0127] The specific implementation of this embodiment is explained below by taking step S23 including step S231 and step S232 as an example:
[0128] In one example, the value obtained by dividing the length of the current size by the length of the template image size is used as the horizontal scaling ratio; the value obtained by dividing the width of the current size by the width of the template image size is used as the vertical scaling ratio. Furthermore, if the horizontal scaling ratio is greater than 1, the pixels in the horizontal direction of the angle correction image are decimated, and the angle correction image after the decimation is used as the horizontal correction image; if the horizontal scaling ratio is less than 1, the pixels in the horizontal direction of the angle correction image are supplemented, and the angle correction image after the supplementation is used as the horizontal correction image; if the horizontal scaling ratio is 1, the angle correction image is directly used as the horizontal correction image, wherein the length of the horizontal correction image is the same as the length of the template image. Furthermore, if the vertical scaling ratio is greater than 1, the pixels in the vertical direction of the horizontally corrected image are decimated, and the horizontally corrected image after the decimation is used as the standard image; if the vertical scaling ratio is less than 1, the pixels in the vertical direction of the horizontally corrected image are supplemented, and the horizontally corrected image after the supplementation is used as the standard image; if the vertical scaling ratio is 1, the horizontally corrected image is directly used as the standard image, wherein the length of the standard image is the same as the length of the template image, and the width of the standard image is the same as the width of the template image.
[0129] It should be noted that when step S23 includes step S231 and step S233, its specific implementation is similar to the specific implementation in the above example, and will not be described in detail here.
[0130] In an example, the horizontal scaling ratio and the vertical scaling ratio are both 2, that is, the size of the angle-corrected image is twice the size of the template image. Therefore, one pixel is extracted at every interval in the horizontal direction of the angle-corrected image to evenly reduce the number of pixels in the horizontal direction of the angle-corrected image, and ensure that the length of the extracted image in the horizontal direction is the same as the length of the template image; one pixel is extracted at every interval in the vertical direction of the angle-corrected image to evenly reduce the number of pixels in the vertical direction of the angle-corrected image, and ensure that the width of the extracted image in the vertical direction is the same as the width of the template image, so that the image after the corresponding pixels are extracted in both the horizontal and vertical directions is used as the standard image.
[0131] In an example, the horizontal scaling ratio and the vertical scaling ratio are both 0.5, that is, the size of the angle-corrected image is 0.5 times the size of the template image. Therefore, a blank pixel is added for every pixel in the horizontal direction of the angle-corrected image to evenly increase the number of pixels in the horizontal direction of the angle-corrected image, and ensure that the length of the expanded image in the horizontal direction is the same as the length of the template image; a blank pixel is added for every pixel in the vertical direction of the angle-corrected image to evenly increase the number of pixels in the vertical direction of the angle-corrected image, and ensure that the width of the expanded image in the vertical direction is the same as the width of the template image, so that the image after the corresponding pixels are expanded in both the horizontal and vertical directions is used as the standard image.
[0132] The text recognition method of the above embodiment determines the horizontal scaling ratio and vertical scaling ratio of the current size to the template image size; performs extraction or supplementation processing on the pixels in the horizontal direction of the angle-corrected image according to the horizontal scaling ratio to obtain a horizontally corrected image, and performs extraction or supplementation processing on the pixels in the vertical direction of the horizontally corrected image according to the vertical scaling ratio to obtain a standard image; or performs extraction or supplementation processing on the pixels in the vertical direction of the angle-corrected image according to the vertical scaling ratio to obtain a vertically corrected image, and performs extraction or supplementation processing on the pixels in the horizontal direction of the vertically corrected image according to the horizontal scaling ratio to obtain a standard image. In this way, the size of the obtained standard image is ensured to be consistent with the size of the template image through extraction or supplementation processing, thereby facilitating the smooth execution of the subsequent text recognition steps.
[0133] Optionally, step S40 includes:
[0134] S41: inputting at least one cropped image into a pre-trained text recognition model, performing text recognition processing on the at least one cropped image, and obtaining an output result of the text recognition model;
[0135] S42: Using the output result of the text recognition model as the text recognition processing result of at least one cropped image.
[0136] Specifically, a cropped image is input into a pre-trained text recognition model. After performing text recognition processing on the cropped image and obtaining an output result of the text recognition model corresponding to the cropped image, the output result of the text recognition model is used as the text recognition processing result of the cropped image. Then, the next cropped image is input into the text recognition model. After performing text recognition processing on the next cropped image and obtaining the output result of the text recognition model corresponding to the next cropped image, the output result of the text recognition model is used as the text recognition processing result of the next cropped image, and so on, until the text recognition processing results of all cropped images are obtained.
[0137] The text recognition method of the above embodiment inputs at least one cropped image into a pre-trained text recognition model, performs text recognition processing on the at least one cropped image, obtains the output result of the text recognition model, and uses the output result of the text recognition model as the text recognition processing result of the at least one cropped image. In this way, text recognition can be accurately performed on each cropped image based on the pre-trained text recognition model, and the text recognition cost is saved.
[0138] Optionally, the preset associated area to be identified information includes at least one associated area to be identified identifier.
[0139] Accordingly, step S40 includes:
[0140] S43: determining the text in the text recognition processing result of at least one cropped image that is identical to the associated region identifier to be recognized as the target text identifier;
[0141] S44: determining the text other than the target text mark in the text recognition processing result of at least one cropped image as the target text content;
[0142] S45: Generate text recognition information of the image to be recognized by taking the target text identifier as a key and the target text content as a value.
[0143] Specifically, the text recognition processing result may include at least two associated parts of text, wherein at least one part of the text is a target text identifier that is the same as the associated region identifier to be recognized, and the remaining part of the text is the target text content.
[0144] After respectively determining the target text identifier and target text content in the text recognition processing results of each cropped image, the target text identifier in the text recognition processing results of the same cropped image is used as the key, and the target text content in the text recognition processing results of the same cropped image is used as the value to generate a key-value pair corresponding to the same cropped image, and then the key-value pairs corresponding to all the cropped images are determined as the text recognition information of the image to be recognized.
[0145] In one example, the standard image, the first cropped image, the second cropped image, and the third cropped image obtained after cropping the standard image according to the preset associated area information to be identified are as follows: Fig. 9As shown in the figure, the identification area to be recognized corresponding to the first cropped image is marked as "Name", the identification area to be recognized corresponding to the second cropped image is marked as "Place of issue", and the identification area to be recognized corresponding to the third cropped image is marked as "Date of expiry". Text recognition processing is performed on the first cropped image, the second cropped image, and the third cropped image respectively. The text recognition processing result of the first cropped image is "Name Zhang San ZHANGSAN". Furthermore, it can be determined that the target text identifier in the text recognition processing result of the first cropped image is "Name", the target text content is "Zhang San ZHANGSAN", and the first key-value pair "Name": "Zhang San ZHANGSAN" is generated; the text recognition processing result of the second cropped image is "Place of issue Guangdong / GUANGDONG". Furthermore, it can be determined that the target text identifier in the text recognition processing result of the second cropped image is "Place of issue", the target text content is "Guangdong / GUANGDONG", and the second key-value pair "Place of issue": "Guangdong / GUANGDONG" is generated; the text recognition processing result of the third cropped image is "Date of expiry 17 Jan / JAN 2029". Furthermore, it can be determined that the target text identifier in the text recognition processing result of the third cropped image is "Date of expiry", the target text content is "17 Jan / JAN 2029", and the third key-value pair "Date of expiry": "17 Jan / JAN 2029" is generated. Finally, the first key-value pair, the second key-value pair, and the third key-value pair are determined as the text recognition information of the image to be recognized.
[0146] In the text recognition method of the above embodiment, the text with the same identifier as the identification area to be recognized in the text recognition processing result of at least one cropped image is determined as the target text identifier; the text other than the target text identifier in the text recognition processing result of at least one cropped image is determined as the target text content; with the target text identifier as the key and the target text content as the value, the text recognition information of the image to be recognized is generated. In this way, the text recognition information of the image to be recognized can be obtained simply and accurately, and the correct association relationship between texts is ensured.
[0147] Fig.10 The following is a schematic structural diagram of the text recognition device provided by the embodiment of the present application. As Fig.10 shown, the text recognition device 300 provided by the embodiment of the present application includes an acquisition module 301, a preprocessing module 302, a cropping module 303, and a generation module 304.
[0148] Among them, the acquisition module 301 is used to obtain the image to be identified and the preset identification template data, and the preset identification template data includes the template image size and the preset associated area information to be identified. The pre-processing module 302 is used to pre-process the image to be identified according to the template image size to obtain a standard image. The cropping module 303 is used to crop the standard image according to the preset associated area information to be identified to obtain at least one cropped image. The generation module 304 is used to perform text recognition processing on at least one cropped image, and generate text recognition information of the image to be identified according to the text recognition processing result of at least one cropped image.
[0149] Optionally, the preprocessing module 302 is specifically used to: use a preset image parameter recognition algorithm to determine the current parameters of the image to be recognized, the current parameters including the current inclination angle, the current size and the current center point; perform angle correction processing on the image to be recognized according to the current inclination angle and the current center point to obtain an angle-corrected image; perform size correction processing on the angle-corrected image according to the current size and the template image size to obtain a size-corrected image; and determine the standard image based on the size-corrected image.
[0150] Optionally, the preprocessing module 302 is specifically used to: in response to the current inclination angle being a positive value, with the current center point as the rotation center, rotate the image to be identified counterclockwise by the current inclination angle to obtain an angle-corrected image; in response to the current inclination angle being a negative value, with the current center point as the rotation center, rotate the image to be identified clockwise by the absolute value of the current inclination angle to obtain an angle-corrected image; in response to the current inclination angle being 0°, determine the image to be identified as an angle-corrected image.
[0151] Optionally, the preprocessing module 302 is specifically used to: pre-crop the size-corrected image according to preset associated area information to be identified to obtain a cropped image; perform text pre-recognition on the cropped image; in response to failure of the text pre-recognition, rotate the size-corrected image 180° and determine the rotated size-corrected image as a standard image; in response to success of the text pre-recognition, directly determine the size-corrected image as a standard image.
[0152] Optionally, the preprocessing module 302 is specifically used to: determine the horizontal scaling ratio and the vertical scaling ratio of the current size to the template image size; perform a subtracting or supplementing process on the pixels in the horizontal direction of the angle-corrected image according to the horizontal scaling ratio to obtain a horizontally corrected image, and perform a subtracting or supplementing process on the pixels in the vertical direction of the horizontally corrected image according to the vertical scaling ratio to obtain a standard image; or perform a subtracting or supplementing process on the pixels in the vertical direction of the angle-corrected image according to the vertical scaling ratio to obtain a vertically corrected image, and perform a subtracting or supplementing process on the pixels in the horizontal direction of the vertically corrected image according to the horizontal scaling ratio to obtain a standard image.
[0153] Optionally, the preset information of the associated area to be identified includes the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be identified; the cropping module 303 is specifically used to: determine at least one rectangular area in the standard image according to the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be identified; crop the image within at least one rectangular area in the standard image to obtain at least one cropped image.
[0154] Optionally, the generation module 304 is specifically used to: input at least one cropped image into a pre-trained text recognition model, perform text recognition processing on at least one cropped image, and obtain an output result of the text recognition model; and use the output result of the text recognition model as the text recognition processing result of at least one cropped image.
[0155] Optionally, the preset associated area information to be identified includes at least one associated area identifier to be identified; the generation module 304 is specifically used to: determine the text that is the same as the associated area identifier to be identified in the text recognition processing result of at least one cropped image as the target text identifier; determine the text other than the target text identifier in the text recognition processing result of at least one cropped image as the target text content; and generate the text recognition information of the image to be identified using the target text identifier as the key and the target text content as the value.
[0156] The text recognition device 300 provided in the embodiment of the present application can execute the technical solution shown in the above-mentioned text recognition method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0157] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig.11 As shown, the electronic device 500 provided in the embodiment of the present application includes: a processor 501, and a memory 502 communicatively connected to the processor 501; the memory 502 stores computer-executable instructions; the processor 501 executes the computer-executable instructions stored in the memory 502 to implement the text recognition method of any of the above embodiments.
[0158] For example, when the processor 501 executes the computer-executable instructions stored in the memory 502, the following steps of the text recognition method are implemented:
[0159] S10: Acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified;
[0160] S20: preprocessing the image to be identified according to the size of the template image to obtain a standard image;
[0161] S30: performing cropping processing on the standard image according to preset information of the associated region to be identified, to obtain at least one cropped image;
[0162] S40: Performing text recognition processing on at least one cropped image, and generating text recognition information of the image to be recognized according to the text recognition processing result of at least one cropped image.
[0163] exist Fig.11 In the corresponding embodiment, the program may include a program code, and the program code includes computer-executable instructions. The processor 501 may be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it may also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The memory 502 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.
[0164] The memory 502 and the processor 501 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0165] Exemplarily, the electronic device 500 includes but is not limited to a server, a personal computer, a laptop computer, a tablet computer, etc.
[0166] The electronic device 500 provided in the embodiment of the present application can execute the technical solution shown in the above-mentioned text recognition method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0167] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the text recognition method of any of the above embodiments.
[0168] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the text recognition method of any of the above embodiments is implemented.
[0169] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0170] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0171] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0172] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0173] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0174] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0175] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A text recognition method, characterized in that: include: Acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified; Preprocessing the image to be identified according to the template image size to obtain a standard image; Performing cropping processing on the standard image according to the preset associated area information to be identified, to obtain at least one cropped image; Perform text recognition processing on at least one of the cropped images, and generate text recognition information of the image to be recognized based on the text recognition processing result of at least one of the cropped images.
2. The method according to claim 1, characterized in that The preprocessing of the image to be identified according to the template image size to obtain a standard image includes: Using a preset image parameter recognition algorithm to determine current parameters of the image to be recognized, the current parameters including a current inclination angle, a current size, and a current center point; Performing angle correction processing on the image to be identified according to the current inclination angle and the current center point to obtain an angle-corrected image; Performing size correction processing on the angle-corrected image according to the current size and the template image size to obtain a size-corrected image; The standard image is determined according to the size-corrected image.
3. The method according to claim 2, characterized in that The step of performing angle correction processing on the image to be identified according to the current inclination angle and the current center point to obtain an angle-corrected image includes: In response to the current inclination being a positive value, the image to be identified is rotated counterclockwise by the current inclination with the current center point as the rotation center to obtain the angle-corrected image; In response to the current inclination being a negative value, the image to be identified is rotated clockwise by the absolute value of the current inclination with the current center point as the rotation center to obtain the angle-corrected image; In response to the current tilt angle being 0°, the image to be recognized is determined to be the angle-corrected image.
4. The method according to claim 3, characterized in that The step of determining the standard image according to the size-corrected image comprises: Pre-cropping the size-corrected image according to the preset associated area information to be identified to obtain a cropped image; Performing text pre-recognition processing on the one cropped image; In response to a failure in the text pre-recognition process, rotating the size-corrected image by 180°, and determining the rotated size-corrected image as the standard image; In response to the text pre-recognition process being successful, the size-corrected image is directly determined as the standard image.
5. The method according to claim 2, characterized in that: The step of performing size correction processing on the angle-corrected image according to the current size and the template image size to obtain the size-corrected image includes: Determine a horizontal scaling ratio and a vertical scaling ratio of the current size to the template image size; Performing decimation or supplementation processing on the pixels in the horizontal direction of the angle-corrected image according to the horizontal scaling ratio to obtain a horizontally corrected image, and performing decimation or supplementation processing on the pixels in the vertical direction of the horizontally corrected image according to the vertical scaling ratio to obtain the standard image; or The pixel points in the vertical direction of the angle-corrected image are removed or supplemented according to the vertical scaling ratio to obtain the vertically corrected image, and the pixel points in the horizontal direction of the vertically corrected image are removed or supplemented according to the horizontal scaling ratio to obtain the standard image.
6. The method according to claim 1, characterized in that The preset associated area information to be identified includes the upper left corner coordinates and the lower right corner coordinates of at least one associated area to be identified; The step of performing cropping processing on the standard image according to the preset associated area information to be identified to obtain at least one cropped image includes: Determine at least one rectangular area in the standard image according to the upper left corner coordinates and the lower right corner coordinates of the at least one associated area to be identified; An image within at least one rectangular area in the standard image is cropped to obtain at least one cropped image.
7. The method according to claim 1, characterized in that The performing text recognition processing on at least one of the cropped images comprises: Inputting at least one of the cropped images into a pre-trained text recognition model, performing text recognition processing on at least one of the cropped images, and obtaining an output result of the text recognition model; The output result of the text recognition model is used as a text recognition processing result of at least one of the cropped images.
8. The method according to claim 1, characterized in that The preset associated area information to be identified includes at least one associated area identifier to be identified; Generating text recognition information of the image to be recognized according to a text recognition processing result of at least one of the cropped images includes: Determine the text that is identical to the associated region identifier to be identified in the text recognition processing result of at least one of the cropped images as a target text identifier; Determining the text other than the target text mark in the text recognition processing result of at least one of the cropped images as the target text content; The target text identifier is used as a key and the target text content is used as a value to generate text recognition information of the image to be recognized.
9. A text recognition device, characterized in that: include: An acquisition module, used to acquire an image to be identified and preset identification template data, wherein the preset identification template data includes template image size and preset associated area information to be identified; A preprocessing module, used for preprocessing the image to be identified according to the size of the template image to obtain a standard image; A cropping module, used for cropping the standard image according to the preset associated area information to be identified, to obtain at least one cropped image; The generating module is used to perform text recognition processing on at least one of the cropped images, and generate text recognition information of the image to be recognized according to the text recognition processing result of at least one of the cropped images.
10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the text recognition method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the text recognition method according to any one of claims 1 to 8.
12. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the text recognition method according to any one of claims 1 to 8.
