A coarse-fine dual-model OCR recognition method for import and export cargo application forms
Through the coarse and fine dual model method, the coarse model and the fine model are combined to perform OCR recognition on the import and export goods application form, which solves the problem of incorrect recognition of form frame lines, achieves more efficient form content recognition and archiving, and improves the efficiency of financial personnel. Work efficiency.
Patent Information
- Application Number
- CN202210087400.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-01-25
AI Technical Summary
In the existing OCR recognition of import and export goods application forms, the rule-based method of table frame line detection has the defect of mistakenly identifying foreign text as table text, making it difficult to identify the actual form, resulting in a recognition effect that does not meet the needs.
The coarse and fine dual model method is used to match and locate the table header content through the coarse model, image preprocessing and combined with the fine model to identify table content blocks, using the improved TE-Efficient and CRNN lightweight detection network structure, combining PAN and TE- The CODE module extracts table content block features for final identification and archiving.
It effectively improves the accuracy and efficiency of OCR recognition of import and export goods application forms, reduces misidentifications, meets practical application needs, and improves the work efficiency of financial personnel.
Smart Images

Figure CN114565748B
Abstract
Description
Technical Field
[0001] The invention relates to an ORC recognition method for a form, in particular to an OCR recognition method for an import and export goods application form using a coarse and fine dual model. Background Art
[0002] In the daily office work of import and export companies, the import and export goods application form is an important voucher for warehouse management, and it is also a type of data that back-end management personnel often need to deal with. In particular, the information loss of the scanned application form file is serious. This kind of task is often heavy and intensive. The early data entry staff is very easy to make mistakes due to fatigue under high-intensity repetitive work. In addition, the low efficiency of basic data collection leads to the lag of comprehensive statistical data, which greatly reduces the performance of the company's other business information management systems (such as ERP, CRM), thus affecting the correct decision-making of the enterprise. The common method is to increase the number of recorders and computer equipment, but these all lead to increased office costs. With the development of deep learning technology, the emergence of optical character recognition (OCR) technology has effectively solved such problems. For example, to convert a table in a PDF document into an Excel table, you can first identify the boundary position coordinates of the text block contained in the table in the PDF document, and divide the table in the PDF document into rows and columns according to the boundary position coordinates of the text block to obtain multiple divided areas, determine the divided area to which each text block belongs, and write the text blocks in the divided areas into the corresponding Excel table, thereby achieving the purpose of converting a table in a PDF document without a border line or with an incomplete border line into an Excel table without relying on the border line of the table in the PDF document. The disadvantage of this scheme is that the detection of table frame lines is a traditional rule-based table segmentation method. When identifying the boundary position coordinates of the text block contained in the table, there must be no other text outside the table, otherwise the external text will be mistakenly identified as the text in the table. In the actual layout documents, there are often many logical blocks (such as illustrations, titles, and text) outside the table. Many tables are not visually distinguishable from the text segments, and the table styles vary. It is difficult to identify the boundary between the table and other logical blocks using the rule method. It is easy to mistake the logical block outside the table for a part of the table, and it is difficult to locate the actual table as a whole. The recognition effect cannot meet the actual needs. Therefore, a new recognition method is urgently needed for the OCR recognition of import and export goods application forms. Summary of the invention
[0003] Purpose of the invention: The technical problem to be solved by the present invention is to provide a coarse-fine dual-model OCR recognition method for import and export goods application forms in view of the shortcomings of the prior art.
[0004] In order to solve the above technical problems, the present invention discloses a coarse-fine dual-model import and export goods application form OCR recognition method, comprising the following steps:
[0005] Step 1: Use a coarse model to match and locate the header content;
[0006] Step 2, performing image preprocessing on the table content;
[0007] Step 3: Use a refined model to identify the cell content of the table content block;
[0008] Step 4: Get the OCR recognition result of the import and export goods application form and perform subsequent processing.
[0009] The method for matching, locating and identifying the header content using a coarse model described in step 1 of the present invention includes: training a header content recognition model according to the header part of the import and export goods application form, and quickly matching the template information in the tabulation database; the recognition model uses the Tesseract-OCR algorithm to obtain the basic content information of the entire import and export goods application form through matching, including the number of rows and columns and the corresponding field content information.
[0010] The method for image preprocessing of table contents described in step 2 of the present invention comprises: performing rotation correction on the outer envelope slice area of the table contents of the import and export goods application form based on Hough line detection, filtering the image noise information through median filtering and image sharpening operations, and removing the red seal information in combination with the threshold segmentation method.
[0011] The method for identifying the content of a table content block cell using a fine model described in step 3 of the present invention includes: for the table image that has undergone the image preprocessing described in step 2, constructing a fine model to identify the content of a small target in each table content block cell; the fine model uses an improved TE-Efficient and CRNN lightweight detection network structure, which is based on the Efficient network structure, and uses a model composite scaling method to uniformly scale the network depth, width and resolution, and adds PAN and TE-CODE modules to increase the feature extraction and recognition performance of the small target in the table content block cell, and combines the CRNN model to finally identify the content of each table content block cell to obtain the text content position and results.
[0012] The subsequent processing method described in step 4 of the present invention includes: the text content position and results identified in step 3 are combined with the application form field content information identified in step 1, and are synchronously written into the database to complete the identification and archiving of the import and export goods application form data.
[0013] Step 1 in the present invention comprises:
[0014] Step 1-1, perform Hough line detection on the input import and export goods application form image to obtain the outer envelope of the form content;
[0015] Step 1-2, select the upper or left half of the outer envelope as the header of the import and export goods application form;
[0016] Step 1-3: Use Tensseract-OCR algorithm to recognize the header content of the import and export goods application form;
[0017] Steps 1-4, match the template information in the background table database to obtain the number of rows and columns of the entire application form and the corresponding field content information.
[0018] Step 2 in the present invention comprises:
[0019] Step 2-1, based on Hough line detection, rotation correction is performed on the outer envelope slice area of the import and export goods application form;
[0020] Step 2-2, perform image median filtering and sharpening operations on the import and export goods application form to remove some noise information;
[0021] Step 3-3, separate the RGB channels of the processed image, and remove the red seal information from the R channel image by combining threshold segmentation to obtain a preprocessed table image.
[0022] The rotation correction method described in step 2-1 of the present invention includes:
[0023] By rotation angle Correct the regional image to the horizontal direction and rotate the angle The calculation method is as follows:
[0024]
[0025] Among them, (x1, y1) and (x2, y2) are the vertex coordinates of the outer envelope slice area of the table content detected by the Hough line.
[0026] In step 3 of the present invention, a refined network is constructed based on the improved TE-Efficient and CRNN lightweight detection network structure to identify the small target content of the table content block cell; wherein, the core network of the network detection part adopts Efficientnet, and output detection heads are constructed based on the PAN+TE-CODE module at its 1 / 32, 1 / 16, and 1 / 8 layers. Different weight allocations are used for the three output detection heads. The lower the layer, the more effective information, and the greater the allocated weight. The detection of small target objects is increased through the above-mentioned network detection structure, and finally the entire image is divided into independent table content block cell units to be identified. Subsequently, combined with the existing CRNN model, the segmented grid image blocks are respectively identified to obtain the final recognition result of the entire image.
[0027] Step 4 of the present invention includes: constructing an index and matching the text content position and results identified in step 3, combined with the application form field content information identified in step 1, and finally completing the accurate identification of the entire import and export goods application form content, and synchronously writing it into the database to complete the identification and archiving of the data.
[0028] Beneficial effects: This method can effectively solve the import and export goods application form recognition task and greatly improve the work efficiency of financial personnel. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0030] Figure 1 It is a schematic diagram of the overall process framework of the present invention.
[0031] Figure 2 This is a schematic diagram of the coarse model matching, identification and positioning of the present invention.
[0032] Figure 3 This is a schematic diagram of image preprocessing according to the present invention.
[0033] Figure 4 This is a schematic diagram of the fine identification network structure in the present invention.
[0034] Figure 5 This is a schematic diagram of the PAN network structure in the present invention.
[0035] Figure 6 This is a schematic diagram of the TE-code network structure in the present invention. DETAILED DESCRIPTION
[0036] like Figure 1As shown, this implementation example provides a coarse-fine dual-model OCR recognition method for import and export goods application forms, including: coarse model header content matching positioning recognition, form content image preprocessing, form cell content recognition and recognition post-processing.
[0037] like Figure 2 As shown, the open source TesseractOCR open source library is used for the matching and positioning of the header content based on the coarse model (Tesseract is an OCR library. Tesseract is currently recognized as the best and most accurate open source OCR system. In addition to its extremely high accuracy, Tesseract is also very flexible. It can recognize any font and any Unicode character through training.). Before the header recognition and matching, a different inbound and outbound cargo application tabulation library is first constructed, which mainly contains information such as headers, rows, columns, and main fields. Then, a header content recognition model is trained based on the Tessact-OCR model according to the header part of the application form, which can quickly match the template information in the tabulation database. For the input application form image, Hough line detection is first performed to obtain the outer envelope of the table content. The upper half or left half of the outer envelope is taken as the header part of the application form. By recognizing the header, it is matched with the template information in the background table database to obtain the number of rows and columns of the entire application form and the corresponding field content and other information.
[0038] The image preprocessing module, such as Figure 3 As shown, based on Hough line detection, the outer envelope slice area of the table content is rotated and corrected. The rotation angle can be calculated by the following formula Correct the regional image to the horizontal direction. In actual situation, the average of the two groups of vertices can be calculated.
[0039]
[0040] Among them, (x1, y1) and (x2, y2) are the vertex coordinates of the outer envelope slice area of the table content detected by the Hough line, and the rotation angle is calculated by the above formula. Then the image is subjected to median filtering and sharpening operations to remove some noise information, and the processed image is separated into RGB channels. The R channel image is combined with threshold segmentation to remove information such as red seals, and the preprocessed image sample is obtained.
[0041] like Figure 4As shown in the figure, for the preprocessed table image, a fine model is constructed to identify the small target content of each table cell. The fine model adopts the improved TE-Efficient+CRNN lightweight detection network structure (TE-Efficient is a new detection network structure proposed in this patent, which is a targeted improvement model based on the Efficient structure combined with the characteristics of table content detection, and CRNN is a general recognition network). It is aimed at the reasons that the font size of the table content area to be identified is small and it is difficult to extract effective features, such as Figure 4 As shown in the figure, the core network of the network detection part adopts Efficientnet (see the paper EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks). The output detection head is constructed based on PAN+TE-code (where PAN can be understood as a symmetric pyramid structure and TE-CODE belongs to an improved attention mechanism module) modules at its 1 / 32, 1 / 16, and 1 / 8 layers. Different weights are assigned to the three output heads. The lower the layer, the more effective information there is, and the greater the weight assigned. Figure 5 The symmetrical image pyramid structure shown in Figure 1 can effectively increase the extraction of image semantic information. Figure 6The network structure TE-code shown in the figure integrates the multi-head structure of transformer, where the transformer structure comes from the paper "Attention is All You Need". In order to adapt to the recognition of the table cell content, when segmenting and position encoding (Embeddingpatches), the segmentation is preferably 6*10, 8*16 in size. In order to better fit the distribution of table content, the position encoding constructs a corresponding adjacency matrix to mark the connection between adjacent segmented blocks, which is initialized with random values, and then connected to the Encoder module of Transformer, that is, the multi-head attention mechanism (multi-head Attention). Each sub-layer cooperates with the multi-layer perceptron (MLP) and adopts residual connection to finally obtain the output head part. This structure can improve the extraction of the relevance of table content and effectively increase the detection and recognition of small target information. The above structure is used to increase the detection of small target objects, and finally the entire image is divided into independent cell units to be identified. Subsequently, the CRNN model of "An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition" is combined to perform content recognition on each cell unit to obtain the final recognition result of the entire image.
[0042] The post-recognition processing refers to synchronously writing the recognized text content position and results, combined with the application form field information obtained by rough recognition, into the database to complete the recognition and archiving of the data.
[0043] The present invention provides a coarse-fine dual-model import and export cargo application form OCR recognition method and method. There are many methods and ways to implement the technical solution. The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A coarse-fine dual-model OCR recognition method for import and export cargo application forms, It is characterized in that The following steps are involved: Step 1: Use a coarse model to match and locate the header content; Step 2, performing image preprocessing on the table content; Step 3: Use a refined model to identify the cell content of the table content block; Step 4: Get the OCR recognition result of the import and export goods application form and perform subsequent processing; The method for matching, locating and identifying the header content using a coarse model in step 1 includes: training a header content recognition model based on the header part of the import and export goods application form to quickly match the template information in the tabulation database; the recognition model uses the Tesseract-OCR algorithm to obtain the basic content information of the entire import and export goods application form through matching, including the number of rows and columns and the corresponding field content information; The method for identifying the content of the cell of the table content block by using a fine model described in step 3 includes: for the table image that has undergone the image preprocessing described in step 2, constructing a fine model to identify the content of the small target of each cell of the table content block; the fine model adopts an improved TE-Efficient and CRNN lightweight detection network structure, which is based on the Efficient network structure, adopts a model composite scaling method to uniformly scale the network depth, width and resolution, adds PAN and TE-CODE modules to increase the feature extraction and recognition performance of the small target of the cell of the table content block, and finally identifies the content of each cell of the table content block in combination with the CRNN model to obtain the text content position and result; In step 3, a refined network is constructed based on the improved TE-Efficient and CRNN lightweight detection network structure to identify the small target content of the table content block cell; wherein, the core network of the network detection part adopts Efficientnet, and the output detection head is constructed based on the PAN+TE-CODE module at its 1 / 32, 1 / 16, and 1 / 8 layers. Different weights are assigned to the output detection head. The lower the layer, the more effective information, and the greater the assigned weight. The detection of small target objects is increased through the above-mentioned network detection part, and finally the entire image is divided into independent table content block cell units to be identified. Subsequently, combined with the existing CRNN model, the segmented grid image blocks are identified separately to obtain the final recognition result of the entire image.
2. According to the coarse-fine dual-model OCR recognition method for import and export goods application form of claim 1, It is characterized in that The image preprocessing method for the table content described in step 2 includes: rotating and correcting the outer envelope slice area of the table content of the import and export goods application form based on Hough line detection, filtering the noise information of the image through median filtering and image sharpening operations, and removing the red seal information in combination with the threshold segmentation method.
3. According to the coarse-fine dual-model OCR recognition method for import and export goods application form of claim 2, It is characterized in that The subsequent processing method described in step 4 includes: the text content position and results identified in step 3 are combined with the application form field content information identified in step 1, and are synchronously written into the database to complete the identification and archiving of the import and export goods application form data.
4. According to claim 3, a coarse and fine dual model OCR recognition method for import and export goods application form, It is characterized in that Step 1 includes: Step 1-1, perform Hough line detection on the input import and export goods application form image to obtain the outer envelope of the form content; Step 1-2, select the upper or left half of the outer envelope as the header of the import and export goods application form; Step 1-3: Use Tensseract-OCR algorithm to recognize the header content of the import and export goods application form; Steps 1-4, match the template information in the background table database to obtain the number of rows and columns of the entire application form and the corresponding field content information.
5. According to claim 4, a coarse and fine dual model OCR recognition method for import and export goods application form, It is characterized in that Step 2 includes: Step 2-1, based on Hough line detection, rotation correction is performed on the outer envelope slice area of the import and export goods application form; Step 2-2, perform image median filtering and sharpening operations on the import and export goods application form to remove some noise information; Step 3-3, separate the RGB channels of the processed image, and remove the red seal information from the R channel image by combining threshold segmentation to obtain a preprocessed table image.
6. A coarse and fine dual model OCR recognition method for import and export goods application form according to claim 5, It is characterized in that The rotation correction method in step 2-1 includes: By rotation angle Correct the regional image to the horizontal direction and rotate the angle The calculation method is as follows: Among them, (x 1 ,y 1 ) and (x 2 ,y 2 ) are the vertex coordinates of the outer envelope slice area of the table content detected by the Hough line.
7. A coarse and fine dual model OCR recognition method for import and export goods application form according to claim 6, It is characterized in that Step 4 includes: building an index and matching the text content position and results obtained in step 3 in combination with the application form field content information obtained in step 1, and finally completing the accurate recognition of the entire import and export goods application form content, and synchronously writing it into the database to complete the recognition and archiving of the data.
Citation Information
Patent Citations
OCR identification method and device based on template matching, and storage medium
CN110008944A
Character recognition method and device
CN110555441A
Information extraction method and device
CN113961685A
Method and device for parsing table in document image
US20190266394A1
