An OCR character recognition method and system based on an attention mechanism

By employing an attention-based OCR text recognition method, which utilizes residual backbone networks and attention feature fusion technology, the problems of missed text detection and poor bounding box detection performance are solved, achieving efficient and accurate text recognition.

CN115497095BActive Publication Date: 2026-03-17JIANGMEN POWER SUPPLY BUREAU OF GUANGDONG POWER GRID CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing OCR text recognition technology suffers from problems such as missed text detection and poor bounding box detection performance, especially in cases of multi-scale text and complex backgrounds, resulting in long detection times and low accuracy.

Method used

An attention-based OCR text recognition method is adopted. A vocabulary is constructed through image preprocessing, text features are extracted using residual backbone network and attention feature fusion technology, bounding box detection is performed by combining coordinate attention, and CNN and RNN are used in the text recognition network for text prediction and recognition.

Benefits of technology

It improves the accuracy and inference speed of text detection, reduces text false negatives, and improves the detection performance of multi-scale text, especially the accuracy of bounding box detection for long text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115497095B_ABST
    Figure CN115497095B_ABST
Patent Text Reader

Abstract

The application provides an OCR character recognition method and system based on an attention mechanism, wherein more text features can be retained by using a multi-scale feature fusion method with the attention mechanism, so that the missing detection condition of the text is improved. In addition, when a final feature map is obtained, a coordinate attention is used to capture long-distance feature correlation, which is more conducive to long text detection. Meanwhile, simple post-processing is adopted, so that the accuracy and reasoning speed of text detection are improved, and thus the text recognition result is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of text recognition technology, specifically relating to an OCR text recognition method and system based on an attention mechanism. Background Technology

[0002] Currently, users upload their business licenses as a means of obtaining authentication. Generally, they need to fill in the contents of the business license. For texts with a lot of content, the filling process is time-consuming and labor-intensive, and it is easy to make mistakes. In addition, the existing technology for text recognition of business licenses is relatively complicated and computationally intensive, which reduces the efficiency of text recognition.

[0003] OCR (Optical Character Recognition) technology refers to the process by which electronic devices (such as scanners or digital cameras) examine characters printed on paper and then translate the shapes into computer text using character recognition methods. Most existing OCR-based recognition methods are based on traditional models. Traditional models often consume significant detection time, perform poorly on long texts, frequently miss detections of small-scale text, or suffer from low accuracy in complex backgrounds, such as when the image is blurry.

[0004] When detecting text in images, previous techniques often missed detections for small-scale text, and when the text lines were long, they usually detected multiple bounding boxes. Furthermore, the detection performance was poor when the image clarity was insufficient, the robustness of the model was poor, and the inference time was too long. Summary of the Invention

[0005] In view of this, the present invention aims to solve the problems of text omission and poor bounding box detection in traditional OCR text recognition technology.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:

[0007] In a first aspect, the present invention provides an OCR text recognition method based on an attention mechanism, comprising the following steps:

[0008] The input image to be recognized is preprocessed, and the required vocabulary is constructed.

[0009] The processed image is fed into a text detection network to obtain the coordinates of the text bounding box. The text detection network performs text feature detection on the processed image based on an attention mechanism.

[0010] The input image is cropped based on the coordinates of the text bounding box to obtain a series of images containing only one line of text.

[0011] The cropped images are sequentially fed into a text recognition network, and the final text recognition result is obtained after comparison with the dictionary.

[0012] Furthermore, the input image to be recognized undergoes image preprocessing, and the required vocabulary is constructed, specifically including:

[0013] Read the input image and decode it into an image matrix in RGB format;

[0014] Maintain the aspect ratio of the image, and scale the shorter side of the image to 736 pixels;

[0015] Normalize the image matrix;

[0016] Build a corresponding dictionary for the text to be recognized.

[0017] Furthermore, the processed image is fed into a text detection network to obtain the coordinates of the text bounding boxes. The text detection network performs text feature detection on the processed image based on an attention mechanism, specifically including:

[0018] The processed image is fed into the residual backbone network for preliminary feature extraction;

[0019] The residual network has four residual modules. The last layer feature map of each residual module is extracted and constructed into a feature pyramid, which is labeled as layer 1, 2, 3 and 4 from top to bottom.

[0020] First, attention feature fusion is performed on the features of layers 1 and 2, followed by convolution operation, to obtain the corrected feature maps of layers 1 and 2;

[0021] The corrected second-layer feature map and the third-layer feature map are subjected to the above attention feature fusion operation. Then, the corrected third-layer feature map and the fourth-layer feature map are subjected to the attention feature fusion operation.

[0022] The upsampled features of each layer of the corrected feature pyramid are stitched together at the scale of the lower-level feature maps.

[0023] The resulting spliced ​​feature map undergoes secondary feature re-correction through coordinate attention.

[0024] Set the pixel threshold to 0.2, set values ​​greater than 0.2 to 1 and values ​​less than or equal to 0.2 to 0 in the final feature map to obtain a binarized image;

[0025] In the binarized image, 1 represents the text region and 0 represents the non-text region. The text outline is obtained using functions in OpenCV. The text box with the highest confidence is selected as the final text outline, thus obtaining the coordinates of the text bounding box.

[0026] Furthermore, the input image is cropped based on the coordinates of the text bounding box to obtain a series of images containing only one line of text, specifically including:

[0027] Cropping of the input image based on the coordinates of the text bounding box;

[0028] Arrange the cropped images in a top-to-bottom, left-to-right order;

[0029] These images were scaled down to 32x100 pixels.

[0030] Furthermore, the cropped images are sequentially fed into a text recognition network, and the final text recognition result is obtained after comparison with the vocabulary database, specifically including:

[0031] The cropped images are sequentially fed into the text recognition network;

[0032] Text features are extracted using a CNN network, and the feature maps are converted into feature sequences.

[0033] The text is fed into an RNN recurrent network for text prediction and recognition.

[0034] The predicted recognition results are input into the CTC algorithm network, and the final recognition result is obtained after comparison with the word library.

[0035] Secondly, the present invention provides an OCR text recognition system based on an attention mechanism, comprising:

[0036] The preprocessing unit is used to preprocess the input image to be recognized and to build the required vocabulary.

[0037] The first processing unit is used to send the processed image into the text detection network to obtain the text bounding box coordinates. The text detection network performs text feature detection on the processed image based on the attention mechanism.

[0038] The second processing unit is used to crop the input image according to the coordinates of the text bounding box to obtain a series of images containing only one line of text.

[0039] The recognition unit is used to feed the cropped images into the text recognition network sequentially, and obtain the final text recognition result after comparison with the dictionary.

[0040] Furthermore, in the preprocessing unit, the input image to be recognized is preprocessed, and the required vocabulary is constructed, specifically including:

[0041] Read the input image and decode it into an image matrix in RGB format;

[0042] Maintain the aspect ratio of the image, and scale the shorter side of the image to 736 pixels;

[0043] Normalize the image matrix;

[0044] Build a corresponding dictionary for the text to be recognized.

[0045] Furthermore, in the first processing unit, the processed image is fed into a text detection network to obtain the coordinates of the text bounding boxes. The text detection network performs text feature detection on the processed image based on an attention mechanism, specifically including:

[0046] The processed image is fed into the residual backbone network for preliminary feature extraction;

[0047] The residual network has four residual modules. The last layer feature map of each residual module is extracted and constructed into a feature pyramid, which is labeled as layer 1, 2, 3 and 4 from top to bottom.

[0048] First, attention feature fusion is performed on the features of layers 1 and 2, followed by convolution operation, to obtain the corrected feature maps of layers 1 and 2;

[0049] The corrected second-layer feature map and the third-layer feature map are subjected to the above attention feature fusion operation. Then, the corrected third-layer feature map and the fourth-layer feature map are subjected to the attention feature fusion operation.

[0050] The upsampled features of each layer of the corrected feature pyramid are stitched together at the scale of the lower-level feature maps.

[0051] The resulting spliced ​​feature map undergoes secondary feature re-correction through coordinate attention.

[0052] Set the pixel threshold to 0.2, set values ​​greater than 0.2 to 1 and values ​​less than or equal to 0.2 to 0 in the final feature map to obtain a binarized image;

[0053] In the binarized image, 1 represents the text region and 0 represents the non-text region. The text outline is obtained using functions in OpenCV. The text box with the highest confidence is selected as the final text outline, thus obtaining the coordinates of the text bounding box.

[0054] Furthermore, in the second processing unit, the input image is cropped based on the coordinates of the text bounding box to obtain a series of images containing only one line of text, specifically including:

[0055] Cropping of the input image based on the coordinates of the text bounding box;

[0056] Arrange the cropped images in a top-to-bottom, left-to-right order;

[0057] These images were scaled down to 32x100 pixels.

[0058] Furthermore, in the recognition unit, the cropped images are sequentially fed into the text recognition network, and the final text recognition result is obtained after comparison with the dictionary, specifically including:

[0059] The cropped images are sequentially fed into the text recognition network;

[0060] Text features are extracted using a CNN network, and the feature maps are converted into feature sequences.

[0061] The text is fed into an RNN recurrent network for text prediction and recognition.

[0062] The predicted recognition results are input into the CTC algorithm network, and the final recognition result is obtained after comparison with the word library.

[0063] In summary, this invention provides an OCR text recognition method and system based on an attention mechanism. By using a multi-scale feature fusion method with an attention mechanism, more text features can be retained, thereby improving the rate of missed detections. Furthermore, using coordinate attention to capture long-distance feature correlations when obtaining the final feature map is more beneficial for detecting long texts. Simultaneously, simple post-processing is employed to improve the accuracy and inference speed of text detection, resulting in more accurate text recognition results. Attached Figure Description

[0064] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0065] Figure 1 A flowchart illustrating an attention-based OCR text recognition method provided in an embodiment of the present invention;

[0066] Figure 2 This is a schematic diagram of the structure of a text detection network provided in an embodiment of the present invention;

[0067] Figure 3 Attention feature fusion structure diagram provided in the embodiments of the present invention;

[0068] Figure 4 A schematic diagram of a convolution operation provided in an embodiment of the present invention;

[0069] Figure 5 The coordinate attention structure diagram provided for embodiments of the present invention. Detailed Implementation

[0070] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0071] Currently, users upload their business licenses as a means of obtaining authentication. Generally, they need to fill in the contents of the business license. For texts with a lot of content, the filling process is time-consuming and labor-intensive, and it is easy to make mistakes. In addition, the existing technology for text recognition of business licenses is relatively complicated and computationally intensive, which reduces the efficiency of text recognition.

[0072] OCR (Optical Character Recognition) technology refers to the process by which electronic devices (such as scanners or digital cameras) examine characters printed on paper and then translate the shapes into computer text using character recognition methods. Most existing OCR-based recognition methods are based on traditional models. Traditional models often consume significant detection time, perform poorly on long texts, frequently miss detections of small-scale text, or suffer from low accuracy in complex backgrounds, such as when the image is blurry.

[0073] When detecting text in images, previous techniques often missed detections for small-scale text, and when the text lines were long, they usually detected multiple bounding boxes. Furthermore, the detection performance was poor when the image clarity was insufficient, the robustness of the model was poor, and the inference time was too long.

[0074] Based on this, the present invention provides an OCR text recognition method and system based on an attention mechanism.

[0075] The following is a detailed description of an embodiment of the OCR text recognition method based on the attention mechanism of the present invention.

[0076] Please see Figure 1 This embodiment provides an OCR text recognition method based on an attention mechanism, including:

[0077] Step 1: Perform image preprocessing on the input image to be recognized and build the required vocabulary.

[0078] Step 2: Feed the processed image into the text detection network to obtain the text bounding box coordinates. The text detection network performs text feature detection on the processed image based on the attention mechanism.

[0079] Step 3: Crop the input image based on the coordinates of the text bounding box to obtain a series of images containing only one line of text.

[0080] Step 4: The cropped images are fed into the text recognition network in sequence, and the final text recognition result is obtained after comparison with the dictionary.

[0081] In an optional embodiment, the preprocessing and lexicon construction in step 1 includes:

[0082] 1.1: Read the input image and decode it into an image matrix in RGB format.

[0083] 1.2: Maintain the aspect ratio of the image and scale the shorter side of the image to 736 pixels.

[0084] 1.3: Normalize the image matrix.

[0085] 1.4: Construct a dictionary for the text to be recognized.

[0086] In an optional embodiment, the text detection network structure described in step 2 is as follows: Figure 2 As shown. The process of further processing using this text detection network is as follows:

[0087] 2.1: The processed image is fed into the residual backbone network for preliminary feature extraction.

[0088] 2.2: The residual network has four residual modules. The last layer feature map of each residual module is extracted and constructed into a feature pyramid, which is labeled as layer 1, 2, 3 and 4 from top to bottom.

[0089] 2.3: First, attention feature fusion is performed on the features of layers 1 and 2. The fused structure is as follows: Figure 3 As shown.

[0090] The feature map of layer 1 is upsampled so that its width and height are the same as those of layer 2, and then pixel-wise summed. After that, it is processed through two branches. One branch first compresses the spatial pixels to 1 through global pooling before performing convolution module operations, and the other branch directly performs convolution module operations.

[0091] Convolution operations such as Figure 4 As shown: First, a 1x1 convolution is performed to compress the channels to reduce memory consumption. After normalization, an activation function is applied to increase the non-linear relationship between features. Then, another 1x1 convolution is performed to expand the channels to the original number of channels, and normalization is performed again.

[0092] The feature maps obtained after passing through the two branches are added pixel by pixel, and the attention weights are calculated using the Sigmoid activation function. Then, these weights are multiplied pixel by pixel by the feature maps of the first and second layers to obtain the corrected feature maps of the first and second layers.

[0093] 2.4: Perform the above attention feature fusion operation on the corrected second layer feature map and the third layer feature map, and then perform attention feature fusion operation on the obtained corrected third layer feature map and the fourth layer feature map.

[0094] 2.5: The scale of upsampling from each layer of the corrected feature pyramid to the lower-level feature map is stitched together.

[0095] 2.6: The resulting concatenated feature map undergoes secondary feature re-correction using coordinate attention. Coordinate attention is as follows... Figure 5 As shown:

[0096] The feature map is globally pooled along the X and Y axes, then reshaped and stitched along the spatial dimensions. After that, it is passed through a convolutional module to increase its non-linearity. Then, it is split into two paths using a split operation. After another convolution operation and a sigmoid activation function, the attention weights for the X and Y axes are obtained. Then, the weights are multiplied pixel by pixel to obtain the second-corrected feature map.

[0097] 2.7: Set the pixel threshold to 0.2, set values ​​greater than 0.2 to 1 and values ​​less than or equal to 0.2 to 0 in the final feature map to obtain a binarized image.

[0098] 2.8: In the binary image, 1 represents a text region and 0 represents a non-text region. Using functions in OpenCV, the text outline is obtained, and the text box with the highest confidence level is selected as the final text outline. This allows the determination of the coordinates of the text bounding box.

[0099] In an optional embodiment, the specific process of step 3 is as follows:

[0100] 3.1: Crop the input image based on the coordinate points obtained in step 2.

[0101] 3.2: Arrange the cropped images in order from top to bottom and from left to right.

[0102] 3.3: Scale these images to a size of 32x100 pixels.

[0103] In an optional embodiment, the specific process of step 4 is as follows:

[0104] 4.1: Feed the images from step 3 into the text recognition network in sequence.

[0105] 4.2: Text features are extracted using a CNN network, and the feature maps are converted into feature sequences.

[0106] 4.3: The text is fed into an RNN recurrent network for prediction and recognition.

[0107] This embodiment provides an OCR text recognition method based on an attention mechanism. By using a multi-scale feature fusion method with an attention mechanism, more text features can be retained, thereby improving the rate of missed detections. Furthermore, coordinate attention is used when obtaining the final feature map to capture long-distance feature correlations, which is more beneficial for the detection of long texts. Simultaneously, simple post-processing is employed to improve the accuracy and inference speed of text detection, thus making the text recognition results more accurate.

[0108] Compared with existing technologies, the text recognition method provided in this embodiment has the following advantages:

[0109] 1. A new deep learning model is adopted, which is more efficient, takes less time, requires less training data, and has higher text recognition accuracy than the traditional optical character recognition method.

[0110] 2. By embedding fusion attention into the multi-scale feature pyramid, the attention mechanism corrects scale inconsistencies during feature fusion, preserving more scale information and thus achieving better text detection results at different scales.

[0111] 3. Finally, coordinate attention is used to obtain the final feature map. This attention can capture the correlation between features at a greater distance, especially for long texts, and can reduce detection errors at boundaries. Therefore, it has a better detection effect for texts of different lengths.

[0112] 4. Simple binarization post-processing operations were used, which improved the model's inference time.

[0113] The above is a detailed description of an embodiment of an attention-based OCR text recognition method of the present invention. The following will provide a detailed description of an embodiment of an attention-based OCR text recognition system of the present invention.

[0114] This embodiment provides an OCR text recognition system based on an attention mechanism, including: a preprocessing unit, a first processing unit, a second processing unit, and a recognition unit.

[0115] In this embodiment, the preprocessing unit is used to preprocess the input image to be recognized and to build the required vocabulary.

[0116] Specifically, in the preprocessing unit, the input image to be recognized undergoes image preprocessing, and the required vocabulary is constructed, including:

[0117] Read the input image and decode it into an image matrix in RGB format;

[0118] Maintain the aspect ratio of the image, and scale the shorter side of the image to 736 pixels;

[0119] Normalize the image matrix;

[0120] Build a corresponding dictionary for the text to be recognized.

[0121] In this embodiment, the first processing unit is used to send the processed image into the text detection network to obtain the text bounding box coordinates. The text detection network performs text feature detection on the processed image based on an attention mechanism.

[0122] Specifically, in the first processing unit, the processed image is fed into the text detection network to obtain the text bounding box coordinates, including:

[0123] The processed image is fed into the residual backbone network for preliminary feature extraction;

[0124] The residual network has four residual modules. The last layer feature map of each residual module is extracted and constructed into a feature pyramid, which is labeled as layer 1, 2, 3 and 4 from top to bottom.

[0125] First, attention feature fusion is performed on the features of layers 1 and 2, followed by convolution operation, to obtain the corrected feature maps of layers 1 and 2;

[0126] The corrected second-layer feature map and the third-layer feature map are subjected to the above attention feature fusion operation. Then, the corrected third-layer feature map and the fourth-layer feature map are subjected to the attention feature fusion operation.

[0127] The upsampled features of each layer of the corrected feature pyramid are stitched together at the scale of the lower-level feature maps.

[0128] The resulting spliced ​​feature map undergoes secondary feature re-correction through coordinate attention.

[0129] Set the pixel threshold to 0.2, set values ​​greater than 0.2 to 1 and values ​​less than or equal to 0.2 to 0 in the final feature map to obtain a binarized image;

[0130] In the binarized image, 1 represents the text region and 0 represents the non-text region. The text outline is obtained using functions in OpenCV. The text box with the highest confidence is selected as the final text outline, thus obtaining the coordinates of the text bounding box.

[0131] In this embodiment, the second processing unit is used to crop the input image according to the coordinates of the text bounding box to obtain a series of images containing only one line of text.

[0132] Specifically, in the second processing unit, the input image is cropped based on the coordinates of the text bounding box to obtain a series of images containing only one line of text, including:

[0133] Cropping of the input image based on the coordinates of the text bounding box;

[0134] Arrange the cropped images in a top-to-bottom, left-to-right order;

[0135] These images were scaled down to 32x100 pixels.

[0136] In this embodiment, the recognition unit is used to sequentially send the cropped images into the text recognition network, and obtain the final text recognition result after comparison with the dictionary.

[0137] Specifically, in the recognition unit, the cropped images are sequentially fed into the text recognition network, and the final text recognition result is obtained after comparison with the dictionary, including:

[0138] The cropped images are sequentially fed into the text recognition network;

[0139] Text features are extracted using a CNN network, and the feature maps are converted into feature sequences.

[0140] The text is fed into an RNN recurrent network for text prediction and recognition.

[0141] The predicted recognition results are input into the CTC algorithm network, and the final recognition result is obtained after comparison with the word library.

[0142] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An OCR character recognition method based on an attention mechanism, characterized in that, The method comprises the following steps: performing image preprocessing on an input picture to be recognized, and constructing a required vocabulary; sending the processed picture into a text detection network to obtain text bounding box coordinates, the text detection network performing text feature detection on the processed picture based on an attention mechanism; cropping the input image according to the coordinates of the text bounding box to obtain a series of pictures each containing only one line of text; sending the cropped pictures into a text recognition network in sequence, and obtaining a final text recognition result after comparison with the vocabulary; sending the processed picture into a text detection network to obtain text bounding box coordinates, the text detection network performing text feature detection on the processed picture based on an attention mechanism, specifically comprising: sending the processed image into a residual backbone network to preliminarily extract features; the residual network has four residual modules, the last layer feature map of each residual module is extracted, and a feature pyramid is constructed, which is denoted as the 1st, 2nd, 3rd and 4th layers from top to bottom; firstly, the features of the 1st and 2nd layers are subjected to attention feature fusion and convolution operation to obtain corrected 1st and 2nd layer feature maps; the 2nd layer feature map after correction and the 3rd layer feature map are subjected to the above attention feature fusion operation, and then the corrected 3rd layer feature map and the 4th layer feature map are subjected to attention feature fusion operation; the up-sampling of each layer of the corrected feature pyramid to the scale of the low layer feature map is spliced; the spliced feature map is subjected to coordinate attention for secondary correction of the features; a pixel threshold of 0.2 is set, values greater than 0.2 in the final feature map are set to 1, and values less than or equal to 0.2 are set to 0, to obtain a binary image; in the binary image, 1 represents a text region and 0 represents a non-text region, a text contour is obtained using a function in opencv, the text box with the largest confidence is selected as the final text contour, and thus the coordinates of the text bounding box are obtained.

2. The attention mechanism based OCR text recognition method according to claim 1, wherein, performing image preprocessing on an input picture to be recognized, and constructing a required vocabulary, specifically comprising: reading the input image and decoding it into an image matrix with an RGB format; keeping the width-height ratio of the image, and scaling the short side of the image to 736 pixels; normalizing the image matrix; constructing a corresponding vocabulary for the text to be recognized. 3.The attention mechanism based OCR text recognition method of claim 1, wherein, cropping the input image according to the coordinates of the text bounding box to obtain a series of pictures each containing only one line of text, specifically comprising: cropping the input image according to the coordinates of the text bounding box; arranging the cropped images in the order from top to bottom and from left to right; scaling these pictures to a size of 32 x 100 pixels.

4. The attention mechanism based OCR text recognition method according to claim 3, characterized in that, sending the cropped pictures into a text recognition network in sequence, and obtaining a final text recognition result after comparison with the vocabulary, specifically comprising: sending the cropped pictures into a text recognition network in sequence; extracting text features through a CNN network, and converting the feature map into a feature sequence; sending the feature sequence into an RNN recurrent network for text prediction and recognition; inputting the prediction and recognition result into a CTC algorithm network, and obtaining a final recognition result after comparison with the vocabulary.

5. An OCR text recognition system based on attention mechanism, characterized in that, comprising: A preprocessing unit is configured to perform image preprocessing on an input image to be recognized and construct a required vocabulary; A first processing unit is configured to send the processed image to a text detection network to obtain text bounding box coordinates, the text detection network being configured to detect text features of the processed image based on an attention mechanism; A second processing unit is configured to crop the input image according to the coordinates of the text bounding box to obtain a series of images each containing only one line of text; An identification unit is configured to send the cropped images to a text recognition network one by one, and obtain a final text recognition result after comparison with the vocabulary. In the first processing unit, the processed image is sent to a text detection network, the text detection network being configured to detect text features of the processed image based on an attention mechanism to obtain text bounding box coordinates, and the text detection network includes the following steps: The processed image is sent to a residual backbone network to perform preliminary extraction of features; The residual network has four residual modules, and the last layer feature map of each residual module is extracted to construct a feature pyramid, which is denoted as the 1st, 2nd, 3rd and 4th layers from top to bottom; The features of the 1st and 2nd layers are subjected to attention feature fusion and convolution to obtain corrected 1st and 2nd layer feature maps; The 2nd layer feature map after correction is subjected to the above attention feature fusion operation with the 3rd layer feature map, and the corrected 3rd layer feature map obtained is subjected to attention feature fusion operation with the 4th layer feature map; The up-sampling of each layer of the corrected feature pyramid to the scale of the low layer feature map is performed to splice the feature maps; The spliced feature map is subjected to coordinate attention to perform secondary correction of features; A pixel threshold of 0.2 is set, and values greater than 0.2 in the final feature map are set to 1, and values less than or equal to 0.2 are set to 0 to obtain a binary image; In the binary image, 1 represents a text region, and 0 represents a non-text region, a text contour is obtained using a function in opencv, the text box with the largest confidence is selected as the final text contour, and thus the coordinates of the text bounding box are obtained.

6. The attention mechanism based OCR text recognition system according to claim 5, wherein, In the preprocessing unit, the input image to be recognized is subjected to image preprocessing, and a required vocabulary is constructed, and the preprocessing unit includes the following steps: The input image is read and decoded into an image matrix having an RGB format; The width-to-height ratio of the image is maintained, and the short side of the image is scaled to 736 pixels; The image matrix is normalized; A corresponding vocabulary is constructed for the text to be recognized.

7. The attention mechanism based OCR text recognition system according to claim 5, wherein, In the second processing unit, the input image is cropped according to the coordinates of the text bounding box to obtain a series of images each containing only one line of text, and the second processing unit includes the following steps: The input image is cropped according to the coordinates of the text bounding box; The cropped images are arranged in the order from top to bottom and from left to right; The images are scaled to a size of 32 x 100 pixels.

8. The attention mechanism based OCR text recognition system according to claim 7, wherein, In the identification unit, the cropped images are sent to a text recognition network one by one, and a final text recognition result is obtained after comparison with the vocabulary, and the identification unit includes the following steps: The cropped images are sent to a text recognition network one by one; Text features are extracted through a CNN network, and the feature map is converted into a feature sequence; The predicted recognition result is input into a CTC algorithm network, and a final recognition result is obtained after comparison with the word library. The predicted recognition result is input into a CTC algorithm network, and a final recognition result is obtained after comparison with the word library.

Citation Information

Patent Citations

  • Terminal strip image detection and identification method

    CN114550153A