A tobacco document OCR recognition method and system capable of eliminating misplacement and overlap of characters
By employing OCR methods involving image correction, gridded segmentation, positional encoding, and semantic segmentation, the problem of text misalignment and overlap in tobacco documents was solved, achieving efficient and accurate text recognition.
Patent Information
- Application Number
- CN202311294968.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-08
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-10-08
AI Technical Summary
Existing OCR technology struggles to accurately identify complex overlaps between text and background content in tobacco electronic contracts caused by printing errors and operational deviations.
By employing OCR recognition methods that include image correction, gridded segmentation, positional encoding, foreground and background separation, horizontal correction, and semantic segmentation, text misalignment and overlap are eliminated, enabling accurate recognition of tobacco documents.
It improves the accuracy of OCR recognition of tobacco receipts, solves the problem of inaccurate recognition caused by text misalignment and overlap, simplifies the processing flow, and improves recognition efficiency.
Smart Images

Figure CN117333877B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of computer technology, and in particular to a method and system for OCR recognition of tobacco receipts that eliminates text misalignment and overlap. Background Technology
[0002] Optical Character Recognition (OCR) is a technology that uses computers to recognize and extract printed or handwritten text. OCR is widely used in many fields, including document management, automated data entry, library science, robotics, and many others. It uses image processing, pattern recognition, and machine learning techniques to analyze and interpret the shapes and features of characters in images, converting them into text information that computers can understand and process. With the increasing maturity of OCR technology and the growing demand for structured information extraction, OCR form recognition technology has also received increasing attention and research. OCR technology automatically recognizes and extracts text and data from forms. Traditional form processing requires manual input or scanning of forms and manual processing, while OCR form recognition can automate these tasks, saving time and labor costs. Therefore, OCR form recognition is widely used in various industries and fields. In typical form recognition tasks, the form content is generated in a single printout, with no text overlap. Existing models and algorithms can achieve high-accuracy text recognition. However, for some special business documents, such as tobacco electronic contracts, the corresponding text content is usually printed on pre-printed documents. Due to factors such as the accuracy of the printing program and possible deviations in the placement of the documents by operators, various complex overlap problems may occur between the printed text content and the background content of the printed documents. In such cases, current OCR methods struggle to accurately identify the various text information in the documents. Summary of the Invention
[0003] The purpose of this invention is to provide a method and system for OCR recognition of tobacco receipts that eliminates text misalignment and overlap, thereby solving the aforementioned problems in the prior art.
[0004] This invention provides an OCR recognition method for tobacco receipts that eliminates text misalignment and overlap, comprising:
[0005] The uploaded tobacco receipt image is obtained, the image is corrected, the corrected receipt image is divided into grid blocks, and the block-shaped receipt image is encoded with position.
[0006] The foreground and background images of the segmented document images are obtained by separating them through the location encoding, and the foreground and background images of the segmented document images are stitched together to obtain the foreground and background images of the complete document image.
[0007] The foreground and background images of the complete document image are horizontally corrected respectively, and the text field offset is calculated based on the field positions of the foreground and background images of the horizontally corrected complete document image. The foreground image of the horizontally corrected complete document image is offset corrected using the text field offset.
[0008] The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. A semantic segmentation-based OCR recognition method is then used to perform text recognition on the tobacco receipt image.
[0009] This invention provides an OCR recognition system for tobacco receipts that eliminates text misalignment and overlap, comprising:
[0010] The encoding module is used to acquire the uploaded tobacco document image, perform image correction on the document image, divide the corrected document image into grid blocks, and perform position encoding on the block-based document image;
[0011] The separation module is used to separate the segmented document image by the location code to obtain its foreground image and background image, and to stitch the foreground image and background image of the segmented document image to obtain the foreground image and background image of the complete document image.
[0012] The correction module is used to perform horizontal correction on the foreground and background images of the complete document image, and calculate the text field offset based on the field positions of the foreground and background images of the horizontally corrected complete document image. The foreground image of the horizontally corrected complete document image is then offset using the text field offset.
[0013] The recognition module is used to fuse the corrected foreground image and background image to obtain a complete tobacco receipt image, and to perform text recognition on the tobacco receipt image using an OCR recognition method based on semantic segmentation.
[0014] This invention also provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps of the above-described method for eliminating text misalignment and overlap in tobacco document OCR recognition.
[0015] This invention also provides a computer-readable storage medium storing an information transmission implementation program. When the program is executed by a processor, it implements the steps of the above-described method for eliminating text misalignment and overlap in tobacco document OCR recognition.
[0016] The embodiments of the present invention can include the following beneficial effects: The embodiments of the present invention use text image reconstruction technology to solve the problem of text content recognition when there are various complex overlaps between the printed text content and the background content of the printed document in tobacco documents, thereby improving the OCR recognition accuracy of special business documents. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in one or more embodiments of this specification or in 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 recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of the OCR recognition method for tobacco receipts that eliminates text misalignment and overlap according to an embodiment of the present invention;
[0019] Figure 2 This is a flowchart illustrating the specific implementation of the OCR recognition method for tobacco receipts that eliminates text misalignment and overlap according to an embodiment of the present invention.
[0020] Figure 3 This is a schematic diagram of the gridded tobacco document according to an embodiment of the present invention;
[0021] Figure 4 This is a schematic diagram of the gridded blocks according to an embodiment of the present invention;
[0022] Figure 5 This is a diagram showing the overlapping of different characters in a tobacco receipt according to an embodiment of the present invention;
[0023] Figure 6 This is a diagram illustrating the expected effect of separating overlapping text in an embodiment of the present invention.
[0024] Figure 7 This is a schematic diagram of the background image after horizontal correction according to an embodiment of the present invention;
[0025] Figure 8 This is a schematic diagram of the foreground image after offset correction according to an embodiment of the present invention;
[0026] Figure 9 This is a complete tobacco document rendering of an embodiment of the present invention, showing that the foreground and background are blended without misalignment or overlap.
[0027] Figure 10 This is an OCR recognition result image of an embodiment of the present invention;
[0028] Figure 11 This is a schematic diagram of an OCR recognition system for tobacco receipts that eliminates text misalignment and overlap, according to an embodiment of the present invention. Detailed Implementation
[0029] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this document.
[0030] Method Implementation Examples
[0031] According to embodiments of the present invention, a method for OCR recognition of tobacco receipts that eliminates text misalignment and overlap is provided. Figure 1 This is a flowchart of the OCR recognition method for tobacco receipts to eliminate text misalignment and overlap according to an embodiment of the present invention. Figure 1 As shown, the OCR recognition method for eliminating text misalignment and overlap in tobacco receipts according to an embodiment of the present invention specifically includes:
[0032] Step S101: Obtain the uploaded tobacco receipt image, perform image correction on the receipt image, divide the corrected receipt image into grid blocks, and perform position encoding on the block-based receipt image, specifically including:
[0033] The uploaded tobacco receipt image is obtained, and the receipt image is subjected to deformation correction, blank removal and image enhancement processing. The corrected receipt image is divided into grid blocks and the block-shaped receipt image is encoded with position.
[0034] Step S102 involves separating the segmented document image using the location encoding to obtain its foreground and background images, and then stitching the foreground and background images of the segmented document image together to obtain the foreground and background images of the complete document image. Specifically, this includes:
[0035] A deep encoder-based image reconstruction network model is used to obtain model weights that can separate the foreground and background text information of the document image. The model weights and the position encoding are used as parameters to input into the pre-trained foreground text separation network and background separation network to separate the segmented document image to obtain its foreground image and background image. The foreground image and background image of the segmented document image are then stitched together to obtain the foreground image and background image of the complete document image.
[0036] Step S103 involves horizontally correcting the foreground and background images of the complete document image, calculating text field offsets based on the field positions of the foreground and background images after horizontal correction, and then offsetting the foreground image of the horizontally corrected complete document image using the text field offsets. Specifically, this includes:
[0037] The foreground and background images of the complete document image are horizontally corrected respectively. The position of the text field in the background image of the corrected complete document image is calculated as the expected position of the text field in the foreground image of the complete document image in the document image. The text field offset is calculated based on the actual position of the text field in the foreground image of the horizontally corrected complete document image and the expected position. The foreground image of the horizontally corrected complete document image is offset corrected using the text field offset.
[0038] Step S104: The corrected foreground image and background image are fused to obtain a complete tobacco receipt image. A semantic segmentation-based OCR recognition method is then used to perform text recognition on the tobacco receipt image, specifically including:
[0039] The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. The tobacco receipt image is then segmented using a semantic segmentation model. The segmented tobacco receipt image is then used as an OCR processing unit and input into a convolutional neural network. Combined with post-processing methods, the tobacco receipt image is used for text recognition.
[0040] The following describes the specific implementation process of the OCR recognition method for tobacco receipts that eliminates text misalignment and overlap, based on an embodiment of the present invention. Figure 2 As shown, the above technical solutions of the embodiments of the present invention will be described in detail.
[0041] Step S1: Obtain the uploaded tobacco receipt image;
[0042] Step S2: Image Correction: Correct the tilted shooting angle and image distortion of the document image, remove blank boundaries, and then enhance the image to reduce the impact of light intensity.
[0043] Step S3: Grid-based segmentation and location coding: The document image is gridded, segmented into blocks according to the grid area, and the segmented document area image is then coded in two dimensions for location.
[0044] Step S4: Separate and reconstruct document images: Use a deep encoder-based image reconstruction network to separate the foreground and background of each encoded region block. Here, the foreground refers to the printed content of the document, and the background refers to the printed content of the document. Separate two images, the foreground and background, for each region block.
[0045] Step S5: Foreground and background document image block stitching: According to the position code in step S3, the separated foreground image block and background image block are stitched together to obtain the complete document foreground and background images;
[0046] Step S6: Horizontal Correction of Background Image: For the background image obtained in Step S5, the text area in the background image is horizontally corrected to eliminate the text tilt angle offset.
[0047] Step S7: Horizontal and positional correction of the foreground image: Based on the foreground image obtained in step S5, the text area in the foreground image is horizontally corrected to eliminate the text tilt angle offset; based on the positional information of the text area in the background image obtained in step S6, the offset is calculated, and the overall positional offset of the foreground text area is corrected to eliminate the positional offset of the foreground text area, thereby eliminating the printing misalignment of the foreground text.
[0048] Step S8: Foreground and background image fusion: The background image and foreground image obtained in steps S6 and S7 are fused together to obtain a complete document image that is not misaligned or overlapping;
[0049] Step S9: OCR document recognition: Use a semantic segmentation-based OCR algorithm to recognize document text.
[0050] Furthermore, in step S2, the specific steps of image correction are as follows:
[0051] Step S21: Correct any issues with the shooting angle or image distortion in the document images;
[0052] Step S22: Remove the blank areas between the text area boundary and the document area boundary;
[0053] Step S23: Enhance the image of the document to reduce the impact of varying lighting intensity;
[0054] Furthermore, in step S3, the specific steps for performing gridded segmentation and location encoding on the document are as follows:
[0055] Step S31: Grid the document image, and divide it into blocks according to the gridded area location to form multiple document text area images. The resulting image is shown below. Figure 3 As shown;
[0056] Step S32: Perform two-dimensional location encoding on the segmented document image from step S31, recording the relative position of each area block within the entire document. The resulting image is shown below. Figure 4 As shown;
[0057] Furthermore, in step S4, the specific steps for separating and reconstructing the document image are as follows:
[0058] Step S41: Create a dataset for image separation and reconstruction; the dataset is divided into two sets. Dataset A includes a set of images of document areas with overlapping characters and a separate set of foreground images. Dataset B includes a set of images of document areas with overlapping characters and a separate set of background images. The document area images with overlapping characters include two types: text-to-text character overlap and number-to-text character overlap. Figure 5 As shown in (a) and (b), they are used to train the foreground text separation network and the background separation network, respectively;
[0059] Step S42: The foreground text separation network structure adopts a deep encoder image reconstruction network, and the model is trained using dataset A to obtain model weights that can well separate the foreground text information of document area images.
[0060] Step S43: The background text separation network structure also adopts a deep encoder image reconstruction network. The model is trained using dataset B to obtain model weights that can effectively separate the background text information of document area images.
[0061] Step S44: Input the document area images containing location codes obtained in step S32 into the models trained in steps S42 and S43 respectively, to separate the foreground text information images and background text information images of the document area images, such as... Figure 6 As shown;
[0062] Furthermore, the specific steps for stitching together the foreground and background document image blocks in step S5 are as follows:
[0063] Step S51: Based on the two-dimensional position code in step S32, the foreground text document image area block and the background document image area obtained in step S44 are spliced together to obtain a complete image containing only foreground text information and a complete image containing only background text information.
[0064] Further, in step S6, the specific steps for horizontal correction of the background image are as follows:
[0065] Step S61: Perform correction processing on the complete image containing only background text information obtained in step S51; eliminate the angle between the horizontal line of the text area and the horizontal line of the entire document, realize the horizontal correction of the text area in the background image, and obtain the horizontally corrected background image, such as... Figure 7 As shown;
[0066] Further, in step S7, the specific steps for leveling and correcting the position of the foreground image are as follows:
[0067] Step S71: Correct the complete image containing only foreground text information obtained in step S51; eliminate the angle between the horizontal line of the text area and the horizontal line of the entire document, realize the horizontal correction of the text area in the foreground image, and obtain the horizontally corrected foreground image;
[0068] Step S72: Calculate the position of a field of printed text (e.g., contract number) in the background image obtained in step S61 in the document image, and then calculate the starting position of the printed content corresponding to the field, which is the expected position of the foreground text field in the document image.
[0069] Step S73: Using the expected position of the foreground text field obtained in step S72, compare it with the actual position of the field after image correction in step S71, and calculate the text offset.
[0070] Step S74: Based on the text offset obtained in step S73, perform overall text region offset processing on the horizontally corrected image obtained in step S71. Then, according to the text offset obtained in step S73, perform offset correction on the foreground image obtained in step S71 based on the relative position of its text region on the document paper to eliminate the offset. This avoids the problem of text characters overlapping again when subsequently merging with the separated background image; the resulting foreground image after position offset correction is shown in the image. Figure 8 As shown;
[0071] Further, in step S8, the specific steps for foreground and background image fusion are as follows:
[0072] Step S81: Merge the document image containing only background text information obtained in step S61 with the document image containing only foreground text information obtained in step S74 to obtain a complete tobacco document image with non-overlapping and misaligned text characters, such as... Figure 9 As shown;
[0073] Further, in step S9, the specific steps for OCR document recognition are as follows:
[0074] Step S91: Use the document images obtained in step S81 to create a dataset for the semantic segmentation model, and annotate the text regions in the document images at the pixel level.
[0075] Step S92: Use a semantic segmentation model to classify the image at the pixel level, determine whether each pixel belongs to a text target, obtain the probability map of the text region, and obtain the bounding curve of the text segmentation region through post-processing.
[0076] Step S93: Based on the text region segmentation results of step S92, further segment the text line, separating the characters in the text region as OCR processing units to improve accuracy;
[0077] Step S94: Use a convolutional neural network-based method to perform character recognition on each text line, enabling it to map the characters in the image to the corresponding text labels;
[0078] Step S95: Post-process the character recognition results to remove erroneous recognition results and correct typos. The resulting image is shown below. Figure 10 As shown.
[0079] In step S91, the text area in the document is labeled. The purpose of the labeling is to add a label to each pixel to indicate whether it belongs to the text area, which is used for classification in step S92.
[0080] In step S92, the probability map of the text region refers to the probability value output by the semantic segmentation model for each pixel in the input image, representing the likelihood that the pixel belongs to a text region. This probability map can be obtained by performing forward propagation of the semantic segmentation model on the image. The probability map is used to determine whether pixels in a document image belong to text regions; based on the obtained pixel probability map, lines are drawn connecting pixel regions with higher probabilities to select the text region, resulting in a bounding curve. The function of the bounding curve is:
[0081] (1) Accurately identify the text region in the image, thereby helping the recognition system to locate the specific location of the text;
[0082] (2) Enclosing curves can segment text from the background of an image, providing clear input for subsequent text recognition tasks;
[0083] (3) By using the enclosing curve, non-text areas in the image can be excluded, thereby reducing the computational load of the recognizer and improving performance;
[0084] (4) By applying the enclosing curve to the text recognition stage, the focus of recognition can be concentrated on the text area, reducing interference and improving the accuracy of recognition;
[0085] (5) Enclosing curves can be used as input for subsequent processing steps, such as error detection and correction in the recognized character sequence, to further improve the accuracy of recognition.
[0086] In step S92, after obtaining the enclosing curve, only the area within the enclosing curve is sent to the text recognition task, and the image content outside the enclosing curve does not need to be processed to reduce the amount of computation.
[0087] In step S94, after segmenting individual character regions, it is necessary to identify the content within each individual character region. The purpose of the label is to tell the network what character the text image corresponds to during network training. In the text recognition task, the input is the segmented individual character region image, and the output is the label corresponding to that image, that is, what character is in the image.
[0088] In summary, traditional publicly available methods for OCR form recognition directly preprocess the form image before performing text region detection and text recognition. However, if misalignment exists within the detected form content, relation extraction tasks often fail to accurately identify the corresponding relationships. Furthermore, in specific form recognition tasks, if overlapping characters exist, general OCR form recognition models exhibit low accuracy and cannot achieve satisfactory results. This invention addresses the issues of text misalignment and overlapping characters in tobacco form images by employing text image reconstruction technology: The entire tobacco document image is corrected and then processed into gridded blocks for encoding. Foreground and background images are reconstructed separately to resolve text character overlap. Horizontal angle correction is then applied to the reconstructed foreground and background images, and the expected location of corresponding fields in the foreground is inferred from the background text fields to correct the foreground text region position, eliminating offsets and resolving text misalignment in the tobacco document image. Finally, a semantic segmentation-based OCR text recognition algorithm is used to accurately recognize the reconstructed and fused tobacco document without text character misalignment or overlap. Specific results are as follows:
[0089] ① The embodiments of the present invention utilize a gridding method to perform gridded block encoding on the entire document image, which helps to reduce the propagation of error information in each region block during the foreground and background separation and reconstruction of subsequent images, thereby improving the image separation and reconstruction effect and processing speed and simplifying subsequent processing;
[0090] ② In this embodiment of the invention, a neural network model structure based on a deep encoder is used to separate the foreground and background images of images where the foreground and background text images overlap, thus solving the problem of inaccurate recognition in subsequent OCR recognition tasks caused by overlapping text characters in the secondary printing images of tobacco documents.
[0091] ③ In this embodiment of the invention, a horizontal correction method is used to correct the text area in the image containing only background information, thereby eliminating the offset of its printing tilt angle. Horizontal correction and position correction methods are used to correct the text area in the image containing only foreground information, thereby eliminating the offset of its secondary printing tilt angle and position misalignment. The above two points solve the problem of misaligned text information in the tobacco document image printed twice.
[0092] System Implementation Examples
[0093] According to embodiments of the present invention, a tobacco document OCR recognition system is provided to eliminate text misalignment and overlap. Figure 11 This is a schematic diagram of a tobacco receipt OCR recognition system for eliminating text misalignment and overlap according to an embodiment of the present invention, as shown below. Figure 11 As shown, the tobacco document OCR recognition system for eliminating text misalignment and overlap according to an embodiment of the present invention specifically includes:
[0094] Encoding module 1100 is used to acquire uploaded tobacco document images, perform image correction on the document images, divide the corrected document images into grid blocks, and perform position encoding on the block-based document images. Specifically, it is used for:
[0095] The uploaded tobacco receipt image is obtained, and the image is subjected to deformation correction, blank removal and image enhancement processing. The corrected receipt image is then divided into grid blocks and the block-shaped receipt image is then encoded in terms of location.
[0096] The separation module 1102 is used to separate the segmented document image into its foreground and background images through the location encoding, and to stitch the foreground and background images of the segmented document image together to obtain the foreground and background images of the complete document image. Specifically, it is used for:
[0097] A deep encoder-based image reconstruction network model is used to obtain model weights that can separate the foreground and background text information of the document image. The model weights and the position encoding are used as parameters to input into the pre-trained foreground text separation network and background separation network to separate the segmented document image to obtain its foreground image and background image. The foreground image and background image of the segmented document image are then stitched together to obtain the foreground image and background image of the complete document image.
[0098] The correction module 1104 is used to perform horizontal correction on the foreground and background images of the complete document image, and calculate the text field offset based on the field positions of the foreground and background images of the horizontally corrected complete document image. The foreground image of the horizontally corrected complete document image is then offset using the text field offset. Specifically, it is used for:
[0099] The foreground and background images of the complete document image are horizontally corrected respectively. The position of the text field in the background image of the corrected complete document image is calculated as the expected position of the text field in the foreground image of the complete document image in the document image. The text field offset is calculated based on the actual position of the text field in the foreground image of the horizontally corrected complete document image and the expected position. The foreground image of the horizontally corrected complete document image is offset corrected using the text field offset.
[0100] The recognition module 1106 is used to fuse the corrected foreground image and background image to obtain a complete tobacco receipt image, and to perform text recognition on the tobacco receipt image using a semantic segmentation-based OCR recognition method. Specifically, it is used for:
[0101] The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. The tobacco receipt image is then segmented using a semantic segmentation model. The segmented tobacco receipt image is then used as an OCR processing unit and input into a convolutional neural network. Combined with post-processing methods, the tobacco receipt image is used for text recognition.
[0102] The embodiments of the present invention are system embodiments corresponding to the above method embodiments. The specific operation of each module can be understood by referring to the description of the method embodiments, and will not be repeated here.
[0103] In summary, the embodiments of the present invention have the following beneficial effects:
[0104] ① In this embodiment of the invention, the entire document is processed by gridded block encoding. After gridded block encoding, the foreground and background of the image are separated and reconstructed. Errors in the reconstruction network will only affect the current block and will not spread to the entire document. This can reduce the overall error rate during network reconstruction and improve the reconstruction network effect. At the same time, block recognition allows multiple blocks to be processed at the same time, thereby improving the processing speed and simplifying subsequent processing.
[0105] ② In this embodiment of the invention, a neural network model structure based on a deep encoder is used to separate the foreground and background images of images where the foreground and background text images overlap, thus solving the problem of inaccurate recognition in subsequent OCR recognition tasks caused by overlapping text characters in the secondary printing images of tobacco documents.
[0106] ③ This embodiment of the invention utilizes two images reconstructed from a neural network based on a depth encoder, separating the foreground and background. The text region is horizontally corrected based on the angle between the water direction in the two images and the horizontal direction of the text region. The expected position of the corresponding field in the foreground text image is inferred from the position of a field in the background text image. This is then compared with the actual corresponding field position in the separated foreground text image to calculate the offset. This offset is then applied to the entire text information region of the foreground image, achieving position correction of the text region in the foreground document image and eliminating the offset. This embodiment of the invention utilizes the aforementioned horizontal and positional corrections to solve the problem of text region misalignment in reprinted document images.
[0107] Device Example 1
[0108] This invention provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, performs the steps described in the method embodiment.
[0109] Device Example 2
[0110] This invention provides a computer-readable storage medium storing an information transmission implementation program, which, when executed by a processor, performs the steps described in the method embodiment.
[0111] The computer-readable storage media described in this embodiment include, but are not limited to, ROM, RAM, disk, or optical disk.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; 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 or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for OCR recognition of tobacco receipts to eliminate misalignment and overlap of text blocks, characterized in that, include: The process includes: acquiring the uploaded tobacco receipt image; performing image correction on the receipt image; dividing the corrected receipt image into grid blocks; and performing position encoding on the block-based receipt image; specifically, this includes: The uploaded tobacco receipt image is obtained, and the receipt image is subjected to deformation correction, blank removal and image enhancement processing. The corrected receipt image is divided into grid blocks and the block-shaped receipt image is encoded with position. The foreground and background images of the segmented document images are obtained by separating them through the location encoding, and the foreground and background images of the segmented document images are stitched together to obtain the foreground and background images of the complete document image. The process involves: horizontally correcting the foreground and background images of the complete document image; calculating the text field offset based on the field positions of the foreground and background images after horizontal correction; and then correcting the offset of the foreground image of the horizontally corrected complete document image using the text field offset. Specifically, this includes: horizontally correcting the foreground and background images of the complete document image; calculating the position of the text field in the background image of the corrected complete document image as the expected position of the text field in the foreground image of the complete document image; calculating the text field offset based on the actual position of the text field in the foreground image of the horizontally corrected complete document image and the expected position; and then correcting the offset of the foreground image of the horizontally corrected complete document image using the text field offset. The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. A semantic segmentation-based OCR recognition method is then used to perform text recognition on the tobacco receipt image.
2. The method according to claim 1, characterized in that, The step of separating the segmented document image using the location encoding to obtain its foreground and background images, and then stitching the foreground and background images of the segmented document image together to obtain the foreground and background images of the complete document image specifically includes: A deep encoder-based image reconstruction network model is used to obtain model weights that can separate the foreground and background text information of the document image. The model weights and the positional encoding are used as parameters to input into the pre-trained foreground text separation network and background separation network to separate the segmented document image to obtain its foreground image and background image. The foreground image and background image of the segmented document image are then stitched together to obtain the foreground image and background image of the complete document image.
3. The method according to claim 1, characterized in that, The fused and corrected foreground and background images yield a complete tobacco receipt image. Text recognition of this tobacco receipt image is performed using a semantic segmentation-based OCR method, specifically including: The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. The tobacco receipt image is then segmented using a semantic segmentation model. The segmented tobacco receipt image is then used as an OCR processing unit and input into a convolutional neural network. Combined with post-processing methods, the tobacco receipt image is used for text recognition.
4. A tobacco receipt OCR recognition system for eliminating text misalignment and overlap, characterized in that, include: The encoding module is used to acquire uploaded tobacco receipt images, perform image correction on the receipt images, divide the corrected receipt images into grid blocks, and perform position encoding on the divided receipt images; specifically, it is used to: acquire uploaded tobacco receipt images, perform deformation correction, remove blanks, and enhance the image on the receipt images, divide the corrected receipt images into grid blocks, and perform position encoding on the divided receipt images; The separation module is used to separate the segmented document image by the location code to obtain its foreground image and background image, and to stitch the foreground image and background image of the segmented document image to obtain the foreground image and background image of the complete document image. The correction module is used to horizontally correct the foreground and background images of the complete document image, and calculate the text field offset based on the field positions of the foreground and background images of the horizontally corrected complete document image. The foreground image of the horizontally corrected complete document image is then offset using the text field offset. Specifically, it is used for: The foreground and background images of the complete document image are horizontally corrected respectively. The position of the text field in the background image of the corrected complete document image is calculated as the expected position of the text field in the foreground image of the complete document image in the document image. The text field offset is calculated based on the actual position of the text field in the foreground image of the horizontally corrected complete document image and the expected position. The foreground image of the horizontally corrected complete document image is offset corrected using the text field offset. The recognition module is used to fuse the corrected foreground image and background image to obtain a complete tobacco receipt image, and to perform text recognition on the tobacco receipt image using an OCR recognition method based on semantic segmentation.
5. The system according to claim 4, characterized in that, The separation module is specifically used for: A deep encoder-based image reconstruction network model is trained to obtain model weights that can separate the foreground and background text information of a document image. The model weights and the positional encoding are then input as parameters into a pre-trained foreground text separation network and a background separation network to separate the segmented document image into its foreground and background images. The foreground and background images of the segmented document images are then stitched together to obtain the foreground and background images of the complete document image.
6. The system according to claim 4, characterized in that, The identification module is specifically used for: The foreground and background images are fused and corrected to obtain a complete tobacco receipt image. The tobacco receipt image is then segmented using a semantic segmentation model. The segmented tobacco receipt image is then used as an OCR processing unit and input into a convolutional neural network. Combined with post-processing methods, the tobacco receipt image is used for text recognition.
7. An electronic device, characterized in that, include: The memory, the processor, and the computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the tobacco document OCR recognition method for eliminating text misalignment and overlap as described in any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an information transmission implementation program, which, when executed by a processor, implements the steps of the tobacco document OCR recognition method for eliminating text misalignment and overlap as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Invoice information extraction method and device, computer equipment and storage medium
CN112541443A
Image foreground and background segmentation method and system based on sparse decomposition and image Laplacian regularization
CN115546245A
