OCR method and system, and storage medium and electronic device

Through the multi-task neural network structure, combined with target positioning and pixel-level classification network to obtain the text box area, and combined with Seq2Seq and CTC neural network to recognize the text, it solves the problems of inaccurate coordinate position and invalid CTC recognition in the existing OCR system, and achieves More accurate OCR recognition and wider application scenarios.

WO2024212485A1PCT designated stage expired Publication Date: 2024-10-17SHANGHAI MIDU INFORMATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/128095
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-10
Filing Date
2023-10-31
Publication Date
2024-10-17

AI Technical Summary

Technical Problem

The existing OCR system uses a neural network structure designed for a single task in the two steps of obtaining text boxes and recognizing text, resulting in inaccurate coordinate positions and ineffective CTC algorithms. It cannot complement the shortcomings of the respective tasks, limiting the accuracy and application of recognition. scene.

Method used

It adopts a multi-task neural network structure, combines target positioning and pixel-level classification networks to obtain the text box area, and combines Seq2Seq and CTC neural networks to identify text. It uses multi-task methods to make up for their respective shortcomings and achieve more accurate OCR recognition.

Benefits of technology

Through the multi-task neural network structure, the accuracy and application scenarios of OCR recognition are improved, the problems of inaccurate coordinate positions and invalid CTC recognition are solved, and the application scope of OCR recognition is expanded.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023128095_17102024_PF_FP_ABST
    Figure CN2023128095_17102024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present invention are an OCR recognition method and system, and a storage medium and an electronic device. The method comprises the following steps: acquiring an image to be subjected to recognition, which includes text; acquiring a first text box region of said image on the basis of an objective localization neural network, acquiring a second text box region of said image on the basis of a pixel-level classification neural network, and acquiring a final text box region of said image on the basis of the first text box region and the second text box region; intercepting from said image a text box image corresponding to the final textbox region; and when the number of frame pixels of the text box image is less than a preset number of pixels, performing recognition on text in the text box image on the basis of a Seq2Seq neural network, otherwise, performing recognition on the text in the text box image on the basis of a CTC neural network. The OCR method and system, and the storage medium and the electronic device in the present invention realize accurate OCR by using a multi-task neural network.
Need to check novelty before this filing date? Find Prior Art

Description

OCR recognition method, system, storage medium and electronic device Technical Field

[0001] The present invention belongs to the technical field of text recognition, and in particular relates to an OCR recognition method, system, storage medium and electronic equipment. Background Art

[0002] Optical Character Recognition (OCR) is the process by which an electronic device (such as a scanner or digital camera) examines printed characters, determines their shape by detecting patterns of light and dark, and then uses character recognition methods to translate these shapes into computer text. Specifically, for printed characters, the text in a paper document is optically converted into a black and white dot matrix image file. Recognition software then converts the text in the image into text format for further editing and processing with word processing software. Key metrics for measuring the performance of an OCR system include rejection rate, false recognition rate, recognition speed, user interface friendliness, product stability, ease of use, and feasibility.

[0003] In the prior art, OCR tasks generally include the following two steps:

[0004] (1) Get the text box;

[0005] (2) Identify the text that appears in the text box image.

[0006] Each of the above steps is usually designed using only a single task. For example, when acquiring a text box, a regression coordinate frame is used (i.e., a target positioning task). When recognizing the text appearing in the text box image, the CTC (Connectionist Temporal Classification) algorithm is used for decoding. However, the regression coordinate frame format results in inaccurate coordinate positions, requiring post-processing for adjustment. The CTC algorithm will be ineffective when the width of the text box image is too short. Therefore, a neural network structure designed for only one task cannot complement the shortcomings of each task.

[0007] Summary of the Invention

[0008] In view of the above-mentioned shortcomings of the prior art, the object of the present invention is to provide an OCR recognition method, system, storage medium and electronic device, which can achieve accurate OCR recognition by adopting a multi-task neural network.

[0009] In a first aspect, the present invention provides an OCR recognition method, which includes the following steps: obtaining an image to be recognized containing text; obtaining a first text box area of ​​the image to be recognized based on a target positioning neural network, obtaining a second text box area of ​​the image to be recognized based on a pixel-level classification neural network, and obtaining a final text box area of ​​the image to be recognized based on the first text block area and the second text box area; intercepting a text box image corresponding to the final text box area on the image to be recognized; when the number of border pixels of the text box image is less than a preset number of pixels, recognizing the text in the text box image based on a Seq2Seq neural network; otherwise, recognizing the text in the text box image based on a CTC neural network.

[0010] In an implementation of the first aspect, acquiring a first text box area of ​​the image to be recognized based on a target positioning neural network includes the following steps:

[0011] Constructing the target positioning neural network, the target positioning neural network includes a 2-layer CNN, a 2-layer feature extraction network, a 1-layer CNN and a non-maximum suppression CNN connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence;

[0012] The image to be recognized is input into the target positioning neural network to obtain the first text box area as output.

[0013] In an implementation of the first aspect, acquiring the second text box area of ​​the image to be recognized based on a pixel-level classification neural network includes the following steps:

[0014] Constructing the pixel-level classification neural network, the pixel-level classification neural network includes a 2-layer CNN, a 2-layer feature extraction network, a 1-layer CNN, a 1-layer transposed convolution, a 3-layer CNN and a softmax layer connected in sequence; the feature extraction network includes a Self-Attention, a LayerNorm and a Relu connected in sequence;

[0015] The image to be identified is input into the pixel-level classification neural network to obtain the output second text box area.

[0016] In an implementation of the first aspect, obtaining a final text box area of ​​the image to be recognized based on the first text block area and the second text box area includes the following steps:

[0017] Obtaining the maximum horizontal coordinate value and the minimum horizontal coordinate value of the first text box area on the image to be recognized;

[0018] Obtaining the maximum value and the minimum value of the longitudinal coordinate of the second text box area on the image to be recognized;

[0019] The rectangle enclosed by the two vertical lines where the maximum value of the horizontal coordinate and the minimum value of the horizontal coordinate are located, and the two horizontal lines where the maximum value of the vertical coordinate and the minimum value of the vertical coordinate are located is used as the final text box area.

[0020] In an implementation of the first aspect, recognizing text in the text box image based on a Seq2Seq neural network includes the following steps:

[0021] Constructing the Seq2Seq neural network, the Seq2Seq neural network includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network, a global average pooling layer, and a 4-layer LSTM connected in sequence; the feature extraction network includes a Self-Attention, a LayerNorm, and a Relu connected in sequence;

[0022] The text box image is input into the Seq2Seq neural network to obtain output text.

[0023] In an implementation of the first aspect, recognizing text in the text box image based on a CTC neural network includes the following steps:

[0024] Constructing the CTC neural network, the CTC neural network includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network and a CTC decoder connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence;

[0025] The text box image is input into the CTC neural network to obtain the output text.

[0026] In an implementation manner of the first aspect, the preset number of pixels is 20.

[0027] In a second aspect, the present invention provides an OCR recognition system, the system comprising an acquisition module, a region recognition module, a interception module and a text recognition module;

[0028] The acquisition module is used to acquire an image to be recognized containing text;

[0029] The region recognition module is used to obtain a first text box region of the image to be recognized based on a target positioning neural network, obtain a second text box region of the image to be recognized based on a pixel-level classification neural network, and obtain a final text box region of the image to be recognized based on the first text block region and the second text box region;

[0030] The interception module is used to intercept the text box image corresponding to the final text box area on the image to be recognized;

[0031] The text recognition module is used to recognize the text in the text box image based on a Seq2Seq neural network when the number of pixels of the border of the text box image is less than a preset number of pixels; otherwise, the text in the text box image is recognized based on a CTC neural network.

[0032] In a third aspect, the present invention provides an electronic device, comprising: a processor and a memory.

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

[0034] The processor is configured to execute the computer program stored in the memory, so as to enable the electronic device to perform the above-mentioned OCR recognition method.

[0035] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program implements the above-mentioned OCR recognition method when executed by an electronic device.

[0036] As described above, the OCR recognition method, system, storage medium, and electronic device of the present invention have the following beneficial effects:

[0037] The OCR recognition method, system, storage medium, and electronic device described in the present invention achieve accurate OCR recognition by adopting a multi-task neural network. The combination of target positioning and pixel-level classification compensates for the defect of inaccurate coordinate position; the combination of CTC recognition and Seq2Seq recognition compensates for the defect of invalid CTC recognition, thereby greatly expanding the application scenarios of OCR recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] FIG1 is a schematic diagram showing a scenario of an electronic device in an embodiment of the present invention;

[0039] FIG2 is a flow chart of an OCR recognition method according to an embodiment of the present invention;

[0040] FIG3 is a schematic diagram showing the structure of an OCR recognition system according to an embodiment of the present invention;

[0041] FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

[0042] Component number description

[0043] 11. Cell Phone

[0044] 12 tablets

[0045] 13 laptops

[0046] 31 Get Module

[0047] 32 Region Identification Module

[0048] 33 Interception module

[0049] 34 Text Recognition Module

[0050] 41 processing units

[0051] 42 Memory

[0052] 421 Random Access Memory

[0053] 422 Cache Memory

[0054] 423 Storage System

[0055] 424 Programs / Utilities

[0056] 4241 Program Module

[0057] 43 bus

[0058] 44 Input / Output Interfaces

[0059] 45 Network Adapter DETAILED DESCRIPTION

[0060] The following describes the embodiments of the present invention through specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.

[0061] It should be noted that the illustrations provided in the following embodiments are merely schematic illustrations of the basic concept of the present invention. Therefore, the illustrations only show components related to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the type, quantity, and proportion of each component may be changed arbitrarily, and the component layout may also be more complex.

[0062] The following embodiments of the present invention provide an OCR recognition method, which can be applied to the electronic device shown in Figure 1. The electronic device described in the present invention may include a mobile phone 11 with a wireless charging function, a tablet computer 12, a laptop computer 13, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiments of the present invention do not impose any restrictions on the specific type of electronic device.

[0063] For example, the electronic device may be a station (STAION, ST) in a WLAN with a wireless charging function, a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA) device, a handheld device with a wireless charging function, a computing device or other processing device, a computer, a laptop computer, a handheld communication device, a handheld computing device, and / or other devices for communicating on a wireless system and a next-generation communication system, such as a mobile terminal in a 5G network, a mobile terminal in a future-evolved Public Land Mobile Network (PLMN), or a mobile terminal in a future-evolved Non-terrestrial Network (NTN).

[0064] For example, the electronic device can communicate with a network and other devices via wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS can include Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), BeiDou navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS) and / or Satellite Based Augmentation Systems (SBAS).

[0065] The technical solutions in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings in the embodiments of the present invention.

[0066] As shown in FIG1 , in one embodiment, the OCR recognition method of the present invention includes the following steps:

[0067] Step S1: Obtain an image to be recognized containing text.

[0068] Specifically, the electronic device of the present invention obtains an image containing text to be recognized from an image acquisition device, a network, etc. The image acquisition device and the electronic device may be connected to each other in a wired or wireless manner.

[0069] Step S2: obtaining a first text box area of ​​the image to be identified based on a target positioning neural network, obtaining a second text box area of ​​the image to be identified based on a pixel-level classification neural network, and obtaining a final text box area of ​​the image to be identified based on the first text block area and the second text box area.

[0070] Specifically, the present invention combines a target positioning neural network and a pixel-level classification neural network to identify the text box area in the image to be identified, thereby combining the advantages of both and ensuring the accuracy of the text box area.

[0071] In one embodiment, obtaining the first text box area of ​​the image to be recognized based on the target positioning neural network includes the following steps:

[0072] 211) Constructing the target positioning neural network, the target positioning neural network includes a 2-layer CNN, a 2-layer feature extraction network, a 1-layer CNN and a non-maximum suppressed CNN connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0073] The convolution kernel size of the two-layer CNN is equal to the stride of movement, ensuring that regions do not overlap when convolutionally extracting image features. The two-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm, and Relu, which are connected in sequence. The single-layer CNN is used to perform double downsampling, thereby reducing the input image size to half of its original size. The non-maximum suppressed CNN obtains the text box coordinate values ​​after non-maximum suppression as the target positioning branch result.

[0074] 212) Inputting the image to be identified into the target positioning neural network to obtain the first text box area as output.

[0075] In one embodiment, obtaining the second text box area of ​​the image to be recognized based on a pixel-level classification neural network includes the following steps:

[0076] 221) Construct the pixel-level classification neural network, which includes 2 layers of CNN, 2 layers of feature extraction network, 1 layer of CNN, 1 layer of transposed convolution, 3 layers of CNN and softmax layer connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0077] Among them, the convolution kernel size of the two-layer CNN is equal to the moving stride, so as to ensure that the areas do not overlap when the convolution extracts image features. The two-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence. The one-layer CNN is used to perform one-fold downsampling, thereby reducing the input image size to half of the original. The one-layer transposed convolution (Transposed CNN) is used to perform one-fold upsampling, thereby enlarging the input feature map to the size of the original input image. The output channel of the three-layer CNN is 2, and the softmax layer is connected to the output of the three-layer CNN, normalizing all values ​​to between 0 and 1, and treating pixels greater than 0.6 as text box areas, thereby obtaining pixel-level classification branch results.

[0078] 222) Inputting the image to be identified into the pixel-level classification neural network to obtain the output second text box area.

[0079] Preferably, the target localization neural network and the pixel-level classification neural network can share some structures. For example, they can share a 2-layer CNN, a 2-layer feature extraction network, and a 1-layer CNN, thereby saving system overhead.

[0080] In one embodiment, obtaining a final text box area of ​​the image to be recognized based on the first text block area and the second text box area includes the following steps:

[0081] 231) Obtain the maximum horizontal coordinate value and the minimum horizontal coordinate value of the first text box area on the image to be recognized.

[0082] 232) Obtain the maximum value and the minimum value of the longitudinal coordinate of the second text box area on the image to be recognized.

[0083] 233) The rectangle enclosed by the two vertical lines where the maximum value of the horizontal coordinate and the minimum value of the horizontal coordinate are located, and the two horizontal lines where the maximum value of the vertical coordinate and the minimum value of the vertical coordinate are located is used as the final text box area.

[0084] Step S3: intercepting a text box image corresponding to the final text box area on the image to be recognized.

[0085] Specifically, a corresponding text box image is captured on the image to be recognized according to the coordinate information of the final text box area, thereby obtaining a text box image containing text.

[0086] Step S4: When the number of pixels in the border of the text box image is less than a preset number of pixels, the text in the text box image is recognized based on a Seq2Seq neural network; otherwise, the text in the text box image is recognized based on a CTC neural network.

[0087] Specifically, the present invention combines the Seq2Seq neural network and the CTC neural network to recognize the text in the text box image, thereby combining the advantages of both and avoiding invalid text recognition. Preferably, the preset number of pixels is 20.

[0088] In one embodiment, recognizing text in the text box image based on a Seq2Seq neural network includes the following steps:

[0089] 411) Construct the Seq2Seq neural network, which includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network, a global average pooling layer and a 4-layer LSTM connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0090] Among them, the 2-layer CNN is used to perform 2x downsampling, thereby reducing the size of the text box image to one-quarter of its original size. The 3-layer BiLSTM is used to fuse time series information. The 2-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence. The global average pooling layer (Global Average Pooling) converts the input two-dimensional matrix into a vector with a length of 768 values. The 4-layer LSTM will continue to output in a loop, and each input is the previous output until it encounters the EOS special character and stops. Finally, each output is merged together to obtain the text recognition result of the Seq2Seq neural network.

[0091] 412) Input the text box image into the Seq2Seq neural network to obtain output text.

[0092] In one embodiment, recognizing text in the text box image based on a CTC neural network includes the following steps:

[0093] 421) Construct the CTC neural network, which includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network and a CTC decoder connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0094] The two-layer CNN is used to downsample by a factor of 2, reducing the size of the text box image to one-quarter its original size. The three-layer BiLSTM is used to integrate temporal information. The two-layer feature extraction network is used to extract features. Each layer of the feature extraction network includes a Self-Attention, LayerNorm, and ReLU layer connected in sequence. The CTC decoder decodes the output of the two-layer feature extraction network to obtain the text recognition results of the CTC neural network.

[0095] 422) Input the text box image into the CTC neural network to obtain output text.

[0096] Preferably, the Seq2Seq neural network and the CTC neural network can share some structures. For example, they can share a 2-layer CNN, a 3-layer BiLSTM, and a 2-layer feature extraction network, thereby reducing system overhead.

[0097] The protection scope of the OCR recognition method described in the embodiment of the present invention is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, subtracting, or replacing steps in the prior art based on the principles of the present invention are included in the protection scope of the present invention.

[0098] An embodiment of the present invention further provides an OCR recognition system, which can implement the OCR recognition method described in the present invention. However, the implementation device of the OCR recognition system described in the present invention includes but is not limited to the structure of the OCR recognition system listed in this embodiment. Any structural deformation and replacement of the existing technology made according to the principles of the present invention are included in the protection scope of the present invention.

[0099] As shown in FIG. 3 , in one embodiment, the OCR recognition system of the present invention includes an acquisition module 31 , a region recognition module 32 , a clipping module 33 and a text recognition module 34 .

[0100] The acquisition module 31 is used to acquire an image to be recognized containing text.

[0101] Specifically, the electronic device of the present invention obtains an image containing text to be recognized from an image acquisition device, a network, etc. The image acquisition device and the electronic device may be connected to each other in a wired or wireless manner.

[0102] The region recognition module 32 is connected to the acquisition module 31, and is used to obtain the first text box area of ​​the image to be recognized based on the target positioning neural network, obtain the second text box area of ​​the image to be recognized based on the pixel-level classification neural network, and obtain the final text box area of ​​the image to be recognized based on the first text block area and the second text box area.

[0103] Specifically, the present invention combines a target positioning neural network and a pixel-level classification neural network to identify the text box area in the image to be identified, thereby combining the advantages of both and ensuring the accuracy of the text box area.

[0104] In one embodiment, obtaining the first text box area of ​​the image to be recognized based on the target positioning neural network includes the following steps:

[0105] 211) Constructing the target positioning neural network, the target positioning neural network includes a 2-layer CNN, a 2-layer feature extraction network, a 1-layer CNN and a non-maximum suppressed CNN connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0106] The convolution kernel size of the two-layer CNN is equal to the stride of movement, ensuring that regions do not overlap when convolutionally extracting image features. The two-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm, and Relu, which are connected in sequence. The single-layer CNN is used to perform double downsampling, thereby reducing the input image size to half of its original size. The non-maximum suppressed CNN obtains the text box coordinate values ​​after non-maximum suppression as the target positioning branch result.

[0107] 212) Inputting the image to be identified into the target positioning neural network to obtain the first text box area as output.

[0108] In one embodiment, obtaining the second text box area of ​​the image to be recognized based on a pixel-level classification neural network includes the following steps:

[0109] 221) Construct the pixel-level classification neural network, which includes 2 layers of CNN, 2 layers of feature extraction network, 1 layer of CNN, 1 layer of transposed convolution, 3 layers of CNN and softmax layer connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0110] Among them, the convolution kernel size of the two-layer CNN is equal to the moving stride, so as to ensure that the areas do not overlap when the convolution extracts image features. The two-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence. The one-layer CNN is used to perform one-fold downsampling, thereby reducing the input image size to half of the original. The one-layer transposed convolution (Transposed CNN) is used to perform one-fold upsampling, thereby enlarging the input feature map to the size of the original input image. The output channel of the three-layer CNN is 2, and the softmax layer is connected to the output of the three-layer CNN, normalizing all values ​​to between 0 and 1, and treating pixels greater than 0.6 as text box areas, thereby obtaining pixel-level classification branch results.

[0111] 222) Inputting the image to be identified into the pixel-level classification neural network to obtain the output second text box area.

[0112] Preferably, the target localization neural network and the pixel-level classification neural network can share some structures. For example, they can share a 2-layer CNN, a 2-layer feature extraction network, and a 1-layer CNN, thereby saving system overhead.

[0113] In one embodiment, obtaining a final text box area of ​​the image to be recognized based on the first text block area and the second text box area includes the following steps:

[0114] 231) Obtain the first upper left corner coordinates and the first lower right corner coordinates of the first text box area on the image to be recognized.

[0115] 232) Obtain the second upper left corner coordinates and the second lower right corner coordinates of the second text box area on the image to be recognized.

[0116] 233) The final text box area is composed of the minimum value of the first upper left corner coordinate and the second upper left corner coordinate, and the maximum value of the first lower right corner coordinate and the second lower right corner coordinate.

[0117] The interception module 33 is connected to the area recognition module 32 and is used to intercept the text box image corresponding to the final text box area on the image to be recognized.

[0118] Specifically, a corresponding text box image is captured on the image to be recognized according to the coordinate information of the final text box area, thereby obtaining a text box image containing text.

[0119] The text recognition module 34 is connected to the interception module 33 and is used to recognize the text in the text box image based on the Seq2Seq neural network when the number of border pixels of the text box image is less than the preset number of pixels; otherwise, the text in the text box image is recognized based on the CTC neural network.

[0120] Specifically, the present invention combines the Seq2Seq neural network and the CTC neural network to recognize the text in the text box image, thereby combining the advantages of both and avoiding invalid text recognition. Preferably, the preset number of pixels is 20.

[0121] In one embodiment, recognizing text in the text box image based on a Seq2Seq neural network includes the following steps:

[0122] 411) Construct the Seq2Seq neural network, which includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network, a global average pooling layer and a 4-layer LSTM connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0123] Among them, the 2-layer CNN is used to perform 2x downsampling, thereby reducing the size of the text box image to one-quarter of its original size. The 3-layer BiLSTM is used to fuse time series information. The 2-layer feature extraction network is used to extract features, and each layer of the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence. The global average pooling layer (Global Average Pooling) converts the input two-dimensional matrix into a vector with a length of 768 values. The 4-layer LSTM will continue to output in a loop, and each input is the previous output until it encounters the EOS special character and stops. Finally, each output is merged together to obtain the text recognition result of the Seq2Seq neural network.

[0124] 412) Input the text box image into the Seq2Seq neural network to obtain output text.

[0125] In one embodiment, recognizing text in the text box image based on a CTC neural network includes the following steps:

[0126] 421) Construct the CTC neural network, which includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network and a CTC decoder connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence.

[0127] The two-layer CNN is used to downsample by a factor of 2, reducing the size of the text box image to one-quarter its original size. The three-layer BiLSTM is used to integrate temporal information. The two-layer feature extraction network is used to extract features. Each layer of the feature extraction network includes a Self-Attention, LayerNorm, and ReLU layer connected in sequence. The CTC decoder decodes the output of the two-layer feature extraction network to obtain the text recognition results of the CTC neural network.

[0128] 422) Input the text box image into the CTC neural network to obtain output text.

[0129] Preferably, the Seq2Seq neural network and the CTC neural network can share some structures. For example, they can share a 2-layer CNN, a 3-layer BiLSTM, and a 2-layer feature extraction network, thereby reducing system overhead.

[0130] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices or methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules / units is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules or units, which can be electrical, mechanical or other forms.

[0131] Modules / units described as separate components may or may not be physically separate, and components displayed as modules / units may or may not be physical modules, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules / units may be selected based on actual needs to achieve the objectives of the embodiments of the present invention. For example, the functional modules / units in various embodiments of the present invention may be integrated into a single processing module, each module / unit may exist physically separately, or two or more modules / units may be integrated into a single module / unit.

[0132] Those skilled in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0133] The embodiment of the present invention also provides a computer-readable storage medium. A person skilled in the art will understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing a processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state drive, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0134] An embodiment of the present invention further provides an electronic device comprising a processor and a memory.

[0135] The memory is used to store computer programs.

[0136] The memory includes various media that can store program codes, such as ROM, RAM, magnetic disk, USB flash drive, memory card or optical disk.

[0137] The processor is connected to the memory and is used to execute the computer program stored in the memory, so that the electronic device executes the above-mentioned OCR recognition method.

[0138] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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 gate or transistor logic devices, discrete hardware components.

[0139] As shown in Figure 4, the electronic device of the present invention is implemented as a general-purpose computing device. Components of the electronic device may include, but are not limited to, one or more processors or processing units 41, a memory 42, and a bus 43 connecting various system components (including the memory 42 and the processing unit 41).

[0140] Bus 43 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0141] Electronic devices typically include a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device, including volatile and non-volatile media, removable and non-removable media.

[0142] The memory 42 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 421 and / or cache memory 422. The electronic device may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 423 may be used to read and write to a non-removable, non-volatile magnetic medium (not shown in FIG. 4 , commonly referred to as a “hard drive”). Although not shown in FIG. 4 , a magnetic disk drive for reading and writing to a removable non-volatile magnetic disk (e.g., a “floppy disk”) and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to the bus 43 via one or more data medium interfaces. The memory 42 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.

[0143] A program / utility 424 having a set (at least one) of program modules 4241 may be stored, for example, in memory 42. Such program modules 4241 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 4241 generally implement the functions and / or methods of the embodiments described herein.

[0144] The electronic device may also communicate with one or more external devices (e.g., a keyboard, a pointing device, a display, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may occur via an input / output (I / O) interface 44. Furthermore, the electronic device may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 45. As shown in FIG4 , the network adapter 45 communicates with other modules of the electronic device via a bus 43. It should be understood that, although not shown in the figures, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0145] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.

Claims

1. An OCR recognition method, characterized in that: The method comprises the following steps: Get the image to be recognized containing text; Acquire a first text box area of ​​the image to be recognized based on a target positioning neural network, acquire a second text box area of ​​the image to be recognized based on a pixel-level classification neural network, and acquire a final text box area of ​​the image to be recognized based on the first text block area and the second text box area; intercepting a text box image corresponding to the final text box area on the image to be recognized; When the number of border pixels of the text box image is less than a preset number of pixels, the text in the text box image is recognized based on a Seq2Seq neural network; otherwise, the text in the text box image is recognized based on a CTC neural network.

2. The OCR recognition method according to claim 1, characterized in that: Acquiring the first text box area of ​​the image to be recognized based on the target positioning neural network includes the following steps: Constructing the target positioning neural network, the target positioning neural network includes a 2-layer CNN, a 2-layer feature extraction network, a 1-layer CNN and a non-maximum suppressed CNN connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence; The image to be recognized is input into the target positioning neural network to obtain the first text box area as output.

3. The OCR recognition method according to claim 1, characterized in that: Acquiring the second text box area of ​​the image to be recognized based on the pixel-level classification neural network includes the following steps: Constructing the pixel-level classification neural network, the pixel-level classification neural network includes two layers of CNN, two layers of feature extraction network, one layer of CNN, one layer of transposed convolution, three layers of CNN and a softmax layer connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence; The image to be recognized is input into the pixel-level classification neural network to obtain the output second text box area.

4. The OCR recognition method according to claim 1, characterized in that: Acquiring a final text box area of ​​the image to be recognized based on the first text block area and the second text box area comprises the following steps: Obtaining a maximum horizontal coordinate value and a minimum horizontal coordinate value of the first text box area on the image to be recognized; Obtaining a maximum longitudinal coordinate value and a minimum longitudinal coordinate value of the second text box area on the image to be recognized; The rectangle enclosed by the two longitudinal lines where the maximum value of the horizontal coordinate and the minimum value of the horizontal coordinate are located, and the two transverse lines where the maximum value of the vertical coordinate and the minimum value of the vertical coordinate are located is taken as the final text box area.

5. The OCR recognition method according to claim 1, characterized in that: Recognizing the text in the text box image based on the Seq2Seq neural network includes the following steps: Constructing the Seq2Seq neural network, the Seq2Seq neural network includes 2 layers of CNN, 3 layers of BiLSTM, 2 layers of feature extraction network, global average pooling layer and 4 layers of LSTM connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence; The text box image is input into the Seq2Seq neural network to obtain output text.

6. The OCR recognition method according to claim 1, characterized in that: Recognizing the text in the text box image based on the CTC neural network includes the following steps: Constructing the CTC neural network, the CTC neural network includes a 2-layer CNN, a 3-layer BiLSTM, a 2-layer feature extraction network and a CTC decoder connected in sequence; the feature extraction network includes Self-Attention, LayerNorm and Relu connected in sequence; The text box image is input into the CTC neural network to obtain output text.

7. The OCR recognition method according to claim 1, characterized in that: The preset number of pixels is 20.

8. An OCR recognition system, characterized in that: The system includes an acquisition module, a region recognition module, a capture module and a text recognition module; The acquisition module is used to acquire an image to be recognized containing text; The region recognition module is used to obtain a first text box region of the image to be recognized based on a target positioning neural network, obtain a second text box region of the image to be recognized based on a pixel-level classification neural network, and obtain a final text box region of the image to be recognized based on the first text block region and the second text box region; The interception module is used to intercept the text box image corresponding to the final text box area on the image to be recognized; The text recognition module is used to recognize the text in the text box image based on a Seq2Seq neural network when the number of border pixels of the text box image is less than a preset number of pixels; otherwise, recognize the text in the text box image based on a CTC neural network.

9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory so that the electronic device executes the claim Find any one of the OCR recognition methods described in 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by an electronic device, the OCR recognition method according to claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Image-based text recognition method and device and storage medium

    CN111291753A

  • Medical bill image processing method and device, electronic device and storage medium

    CN113705733A

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

    CN115527023A

  • OCR (Optical Character Recognition) method and system, storage medium and electronic equipment

    CN116092087A

  • Systems and methods for automatic unit selection and target decomposition for sequence labelling

    US20180247639A1