A paper invoice information extraction method and device
By combining the OCR model of YOLO4 and CRNN for full text recognition of paper invoices, the problem of low recognition accuracy and slow speed caused by rich Chinese characters and diverse fonts in the existing technology is solved, and more efficient invoice information extraction is achieved. Improved financial reimbursement efficiency.
Patent Information
- Application Number
- CN202111576816.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-12-22
AI Technical Summary
Existing automatic invoice recognition technology has low recognition accuracy and slow speed when dealing with rich Chinese characters, diverse fonts, image deformations, and similar characters, resulting in low efficiency in the financial reimbursement process.
An optical character recognition (OCR) model that combines the target detection model YOLO4 and the text recognition model CRNN is used to perform full-face text recognition on paper invoices. Through text detection and recognition, the recognition speed and accuracy are improved, and Hough straight line detection and correction are performed. The image is tilted to ensure the integrity of field information.
Significantly improves the speed and accuracy of paper invoice information extraction, reduces the workload of financial personnel, and improves financial reimbursement efficiency.
Smart Images

Figure CN114387604B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of bill recognition, and in particular to a method and device for extracting paper invoice information. Background Art
[0002] In the process of financial reimbursement, financial personnel need to manually process the reimbursement invoice documents, which not only consumes a lot of manpower and material resources, but also has very low work efficiency. Therefore, the automatic invoice recognition technology was introduced to batch collect information on invoice documents and output structured data. Compared with the traditional manual data entry, it greatly reduces the workload of financial personnel and improves work efficiency.
[0003] At present, for automatic invoice recognition, the text area of the invoice is first segmented. After segmentation, the text in the invoice is a separate entity to be recognized. Next, a strong character classifier such as template matching is used to recognize the segmented individual characters. Finally, the individual recognition results are connected as the recognized invoice elements. Among them, due to the huge number of Chinese characters, many types of fonts, image deformation, similar characters, rare characters and many other factors, the classifier has a weak ability to recognize individual Chinese characters, so the accuracy of extracting invoice image information is low and the speed is slow. Summary of the invention
[0004] The embodiment of the present invention provides a method and device for extracting paper invoice information, which are used to improve the speed and accuracy of extracting paper invoice information.
[0005] In a first aspect, a method for extracting paper invoice information is provided, the method comprising:
[0006] Get paper invoice images;
[0007] The paper invoice image is subjected to full-face text recognition by an optical character recognition (OCR) model to obtain a text recognition result; wherein the OCR model is obtained by combining an object detection model YOLO4 and a text recognition model CRNN, the YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model;
[0008] Export text information corresponding to the text recognition result.
[0009] Optionally, the performing full-face text recognition on the paper invoice image by using an optical character recognition (OCR) model includes:
[0010] Adjusting the size of the image to a target size to obtain a first image;
[0011] Performing straight line detection on the first image by using the Hough straight line detection method to obtain a tilt angle of the first image;
[0012] Correcting the first image according to the tilt angle to obtain a second image;
[0013] The second image is subjected to full-face text recognition using the OCR model.
[0014] Optionally, the exporting text information corresponding to the text recognition result includes:
[0015] Determining whether the text recognition result contains text information corresponding to all preset fields;
[0016] If the text recognition result contains text information corresponding to all preset fields, the text information corresponding to the text recognition result is exported.
[0017] Optionally, if the text recognition result does not include text information corresponding to the first field, the method further includes:
[0018] Determine whether the first field is a field corresponding to four elements; wherein the four elements include invoice code, invoice number, invoice date and pre-tax amount;
[0019] If the first field is not a field corresponding to the four elements, a verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
[0020] Optionally, the method further includes:
[0021] If the first field is a field corresponding to the four elements, obtaining the QR code information on the paper invoice image;
[0022] Scan the QR code information to obtain text information corresponding to the four elements;
[0023] The verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
[0024] Optionally, if the text recognition result does not include text information corresponding to the first field, the method further includes:
[0025] Determine whether the first field is a field corresponding to the password area;
[0026] If the first field is a field corresponding to the password area, the information extraction of the paper invoice is terminated.
[0027] In a second aspect, a paper invoice information extraction device is provided, the device comprising:
[0028] An acquisition module, used for acquiring a paper invoice image;
[0029] A processing module, used to control an optical character recognition (OCR) model to perform full-face text recognition on the paper invoice image to obtain a text recognition result; wherein the OCR model is obtained by combining an object detection model YOLO4 and a text recognition model CRNN, the YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model;
[0030] The processing module is also used to export text information corresponding to the text recognition result.
[0031] Optionally, the processing module is further used to:
[0032] Adjusting the size of the image to a target size to obtain a first image;
[0033] Performing straight line detection on the first image by using the Hough straight line detection method to obtain a tilt angle of the first image;
[0034] Correcting the first image according to the tilt angle to obtain a second image;
[0035] The OCR model is controlled to perform full-face text recognition on the second image.
[0036] Optionally, the processing module is specifically used to:
[0037] Determining whether the text recognition result contains text information corresponding to all preset fields;
[0038] When the text recognition result includes text information corresponding to all preset fields, the text information corresponding to the text recognition result is exported.
[0039] Optionally, if the text recognition result does not include text information corresponding to the first field, the processing module is further configured to:
[0040] Determine whether the first field is a field corresponding to four elements; wherein the four elements include invoice code, invoice number, invoice date and pre-tax amount;
[0041] When the first field is not a field corresponding to the four elements, the text information corresponding to the paper invoice is acquired by calling a verification interface according to the text information corresponding to the four elements.
[0042] Optionally, the acquisition module is further used to:
[0043] When the first field is a field corresponding to four elements, obtaining the QR code information on the paper invoice image;
[0044] Scan the QR code information to obtain text information corresponding to the four elements;
[0045] The verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
[0046] Optionally, if the text recognition result does not include text information corresponding to the first field, the processing module is further configured to:
[0047] Determine whether the first field is a field corresponding to the password area;
[0048] When the first field is a field corresponding to the password area, the information extraction of the paper invoice is finished.
[0049] According to a third aspect, an electronic device is provided, the electronic device comprising:
[0050] A memory for storing program instructions;
[0051] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods described in the first aspect according to the obtained program instructions.
[0052] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the steps included in any one of the methods described in the first aspect.
[0053] In a fifth aspect, a computer program product comprising instructions is provided. When the computer program product is run on a computer, the computer is enabled to execute the paper invoice information extraction method described in the above various possible implementations.
[0054] In an embodiment of the present application, a paper invoice image is obtained, and the full-face text recognition of the paper invoice image is performed through an optical character recognition (OCR) model to obtain a text recognition result, and the text information corresponding to the text recognition result is exported. Among them, the OCR model is obtained by combining the object detection model YOLO4 and the text recognition model CRNN. The YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model. In other words, the present application uses the latest object detection model YOLO4 model to perform text detection on the paper invoice image, and further uses the CRNN model to perform text recognition on the output result of the YOLO4 model, which effectively improves the speed and accuracy of text detection and recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application.
[0056] Figure 1 A flowchart of a method for extracting paper invoice information provided in an embodiment of the present application;
[0057] Figure 2 A flowchart of performing text detection using a YOLO4 model provided in an embodiment of the present application;
[0058] Figure 3 A structural block diagram of a paper invoice information extraction device provided in an embodiment of the present application;
[0059] Figure 4 Schematic diagram of the structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0061] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0062] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.
[0063] The following is an introduction to the paper invoice information extraction method provided by the embodiment of the present application in conjunction with the accompanying drawings. Figure 1 As shown, the process of the paper invoice information extraction method in the embodiment of the present application is described as follows:
[0064] Step 101: Acquire a paper invoice image;
[0065] Step 102: Perform full-face text recognition on the paper invoice image using an OCR model to obtain a text recognition result;
[0066] Among them, the optical character recognition (OCR) model is obtained by combining the target detection model YOLO4 and the text recognition model CRNN. The YOLO4 model is used to perform text detection on paper invoice images, and the CRNN model performs text recognition on the text detection results of the YOLO4 model.
[0067] In a possible implementation, after acquiring the paper invoice image, it is also possible to determine whether its size is a target size (for example, 416×416). If the size of the acquired paper invoice image is not the target size, the size of the paper invoice image is adjusted to the target size to obtain a first image, and then a Hough line detection method is used to perform line detection on the first image to obtain a tilt angle of the first image. The first image is corrected according to the tilt angle to obtain a second image, and the second image is subjected to full-face text recognition through an OCR model.
[0068] Specifically, the second image is subjected to text detection by using the YOLO4 model, the text detection result is input into the CRNN model, and the text recognition is performed based on the text detection result by using the CRNN model to obtain a text recognition result. For the process of performing text detection on the second image by using the YOLO4 model, please refer to Figure 2 As shown:
[0069] Before introducing the process of text detection by YOLO4 model, first Figure 2 Each module is introduced in.
[0070] DBL: represents the combination of convolutional layer, normalization layer, and activation function (relu) layer. In YOLO4, DBL components are basic units. YOLO4 is a neural network structure. The input and output data of each module are three-dimensional structures, such as (a, b, c), where a can be understood as the height of the image, b can be understood as the width of the image, and c is the channel, which can represent the number of feature maps. The number after DBL represents how many DBL modules are connected, for example, DBL5 represents 5 DBL modules.
[0071] Res: represents the residual connection unit in the neural network. The number after Res represents the number of residual connection units. For example, Res2 represents 2 residual connection units.
[0072] Conv: A normal convolutional layer.
[0073] Upsampling: The upsampling method is pooling, that is, the feature size is enlarged by element expansion, and there is no learning parameter. For example, a 10×10×5 feature map can be enlarged by upsampling to obtain a 20×20×5 feature map.
[0074] Concat: Channel concatenation. For example, a 20×20×5 feature map is concatenated with a 20×20×3 feature map to obtain a 20×20×8 feature map. Channel concatenation must ensure that the size of each concatenated feature map is consistent.
[0075] Anchor: A pre-selected box in object detection. Object detection requires predicting the position of an object. This position can be a rectangular marker box in the image. The marker box can be represented by the coordinates (x, y) of the upper left corner and the width and height of the marker box. By using the object detection algorithm to obtain the pre-selected box of each text, the position of the target text can be accurately known.
[0076] When the YOLO4 model is used to perform text detection on the second image, the second image is firstly channel-separated (for example, into three channels of blue, green and red) to obtain a 416×416×3 image (hereinafter referred to as the third image). The third image is firstly passed through the DBL, Res1, Res2 and Res3 modules to obtain the first output data. The first output data is passed through Res4, DBL5, DBL and CONV to obtain the first feature map (for example, 13×13×255). The first output data and the second output data (the output data obtained by passing the first output data through Res4 and DBL5) are spliced after DBL and upsampling to obtain To the first spliced data, the first spliced data is passed through DBL5, DBL, CONV to obtain a second feature map (for example, 26×26×255); and the second image data and the first spliced data are spliced through DBL5, DBL, upsampling to obtain the second spliced data, and the second spliced data is passed through DBL5, DBL, CONV to obtain a third feature map (for example, 52×52×255), and the best object pre-selection box is selected from the first feature map, the second feature map, and the third feature map to obtain the position of each font in the image. After obtaining the pre-selection box of each font on the image, the pre-selection boxes in a row are merged to obtain a text row, thereby realizing text detection of the second image. The text detection result is input into the CRNN model for text recognition to obtain a text recognition result.
[0077] Step 103: Export text information corresponding to the text recognition result.
[0078] In the embodiment of the present application, the text information corresponding to the text recognition result output by the OCR model can be directly exported to realize the information extraction of the paper invoice. In a possible implementation, it is also possible to judge whether the face information in the paper invoice image is complete according to the text recognition result. Specifically, it is determined whether the text recognition result contains the text information corresponding to all preset fields, such as whether it contains the name of the buyer and seller, taxpayer identification number, address, telephone number, bank and account number, goods or taxable services, service name, specification model, unit, quantity, unit price, amount, tax rate, tax amount, password area, invoice code, invoice number, invoice date and pre-tax amount and other fields on the face of the invoice. If the text information corresponding to all the preset fields is included, it means that the face information in the paper invoice image is complete (at this time, the paper invoice is not damaged, or the damaged area of the paper invoice is a blank area, which does not affect the extraction of the invoice information), and the text information corresponding to the text recognition result is directly exported.
[0079] If the text recognition result does not contain text information corresponding to a certain field (for example, the first field), it can be determined whether the first field is the field corresponding to the four elements, that is, the fields corresponding to the invoice code, invoice number, invoice date and pre-tax amount. If the first field is not the field corresponding to the four elements, the four-element information is obtained, and the verification interface is called through the text information corresponding to the four elements to obtain the full face value information corresponding to the paper invoice. For example, there is no text information corresponding to the purchaser's taxpayer identification number in the text recognition result. This text information does not belong to the four-element information. At this time, the four-element information of the paper invoice can be obtained, and the verification interface is called through the text information corresponding to the four elements to obtain the full face value information corresponding to the paper invoice, and the full face value information can be exported.
[0080] If the first field is a field corresponding to the four elements, the QR code information on the paper invoice image can also be obtained at this time, the QR code is scanned, the text information corresponding to the four elements is obtained, and the verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice. For example, there is no text information corresponding to the invoice date in the text recognition result. At this time, the full face information of the paper invoice cannot be directly obtained through the four elements. It is necessary to scan the QR code on the paper invoice image to obtain the four elements of the paper invoice, and the verification interface is called through the text information corresponding to the four elements to obtain the full face information of the paper invoice, and the full face information is exported. In some other implementations, if the QR code scanning fails, the information extraction of the paper invoice is directly exited, and an alarm message is issued to indicate that the paper invoice information extraction failed and the financial staff needs to manually enter it.
[0081] In some other embodiments, it is also possible to determine whether the first field is a field corresponding to the password area. If the first field is a field corresponding to the password area, the information extraction of the paper invoice is terminated, and an alarm message is issued to indicate that the password area is damaged and manual entry is required by the financial staff.
[0082] In the specific implementation process, after obtaining the paper invoice image, the image is first preprocessed, and then the YOLO4 model is called for text detection to obtain the images of each text line in the paper invoice image. Each text line image is input into the CRNN model for text recognition to obtain the information of each text line (i.e., text recognition result), thereby improving the speed and accuracy of paper invoice information extraction. Then, the obtained text line information is compared with the preset field to determine whether the face information contained in the paper invoice image is complete. If complete, it means that the invoice is intact, and the text line information is directly exported. If incomplete, it is further determined whether the four elements of invoice inspection in the incomplete information are complete. If complete, the inspection interface is called to obtain the full face information. If incomplete, it is determined whether the QR code in the paper invoice image is complete (i.e., whether it can be scanned successfully). If complete, the four elements are obtained by scanning the QR code, and the inspection interface is further called to obtain the full face information and export it, thereby realizing the information extraction of damaged paper invoices.
[0083] Based on the same inventive concept, the embodiment of the present application provides a paper invoice information extraction device, which can realize the functions corresponding to the aforementioned paper invoice information extraction method. The paper invoice information extraction device can be a hardware structure, a software module, or a hardware structure plus a software module. The paper invoice information extraction device can be implemented by a chip system, which can be composed of a chip or include a chip and other discrete devices. Please refer to Figure 3 As shown, the paper invoice information extraction device includes an acquisition module 301 and a processing module 302. Among them:
[0084] An acquisition module 301 is used to acquire a paper invoice image;
[0085] The processing module 302 is used to control the optical character recognition (OCR) model to perform full-face text recognition on the paper invoice image to obtain a text recognition result; wherein the OCR model is obtained by combining the object detection model YOLO4 and the text recognition model CRNN, the YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model;
[0086] The processing module 302 is further used to export text information corresponding to the text recognition result.
[0087] Optionally, the processing module 302 is further configured to:
[0088] Adjusting the size of the image to a target size to obtain a first image;
[0089] Performing straight line detection on the first image by using the Hough straight line detection method to obtain a tilt angle of the first image;
[0090] Correcting the first image according to the tilt angle to obtain a second image;
[0091] The OCR model is controlled to perform full-face text recognition on the second image.
[0092] Optionally, the processing module 302 is specifically configured to:
[0093] Determining whether the text recognition result contains text information corresponding to all preset fields;
[0094] When the text recognition result includes text information corresponding to all preset fields, the text information corresponding to the text recognition result is exported.
[0095] Optionally, if the text recognition result does not include text information corresponding to the first field, the processing module 302 is further configured to:
[0096] Determine whether the first field is a field corresponding to four elements; wherein the four elements include invoice code, invoice number, invoice date and pre-tax amount;
[0097] When the first field is not a field corresponding to the four elements, the text information corresponding to the paper invoice is acquired by calling a verification interface according to the text information corresponding to the four elements.
[0098] Optionally, the acquisition module 301 is further used to:
[0099] When the first field is a field corresponding to four elements, obtaining the QR code information on the paper invoice image;
[0100] Scan the QR code information to obtain text information corresponding to the four elements;
[0101] The verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
[0102] Optionally, if the text recognition result does not include text information corresponding to the first field, the processing module 302 is further configured to:
[0103] Determine whether the first field is a field corresponding to the password area;
[0104] When the first field is a field corresponding to the password area, the information extraction of the paper invoice is finished.
[0105] All relevant contents of each step involved in the embodiment of the aforementioned paper invoice information extraction method can be referred to the functional description of the functional module corresponding to the paper invoice information extraction device in the embodiment of the present application, and will not be repeated here.
[0106] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0107] Based on the same inventive concept, the present application embodiment provides an electronic device. Figure 4 As shown, the electronic device includes at least one processor 401 and a memory 402 connected to the at least one processor. The specific connection medium between the processor 401 and the memory 402 is not limited in the embodiment of the present application. Figure 4 In the example, the processor 401 and the memory 402 are connected via a bus 400. Figure 4 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 400 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0108] In the embodiment of the present application, the memory 402 stores instructions that can be executed by at least one processor 401. The at least one processor 401 can execute the steps included in the aforementioned paper invoice information extraction method by executing the instructions stored in the memory 402.
[0109] Among them, the processor 401 is the control center of the electronic device, which can use various interfaces and lines to connect various parts of the entire electronic device, and monitor the electronic device as a whole by running or executing instructions stored in the memory 402 and calling data stored in the memory 402, various functions of the electronic device and processing data. Optionally, the processor 401 may include one or more processing units, and the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes operating systems and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401. In some embodiments, the processor 401 and the memory 402 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0110] Processor 401 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the paper invoice information extraction method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0111] The memory 402 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 402 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 402 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 402 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0112] By designing and programming the processor 401, the code corresponding to the paper invoice information extraction method introduced in the above embodiment can be solidified into the chip, so that the chip can execute the steps of the above paper invoice information extraction method when running. How to design and program the processor 401 is a technology well known to those skilled in the art and will not be repeated here.
[0113] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes the steps of the aforementioned paper invoice information extraction method.
[0114] In some possible implementations, various aspects of the paper invoice information extraction method provided in the present application can also be implemented in the form of a program product, which includes a program code. When the program product is run on an electronic device, the program code is used to enable the detection device to execute the steps of the paper invoice information extraction method according to various exemplary embodiments of the present application described above in this specification.
[0115] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0116] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0117] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0119] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for extracting paper invoice information, characterized in that: The method comprises: Get paper invoice images; The paper invoice image is subjected to full-face text recognition by an optical character recognition (OCR) model to obtain a text recognition result; wherein the OCR model is obtained by combining an object detection model YOLO4 and a text recognition model CRNN, the YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model; Determining whether the text recognition result contains text information corresponding to all preset fields; If the text recognition result contains text information corresponding to all preset fields, exporting the text information corresponding to the text recognition result; If the text recognition result does not contain text information corresponding to the first field, determine whether the first field is a field corresponding to four elements; wherein the four elements include invoice code, invoice number, invoice date and pre-tax amount; if the first field is not a field corresponding to the four elements, call the verification interface according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
2. The method according to claim 1, characterized in that The step of performing full-face text recognition on the paper invoice image using an optical character recognition (OCR) model includes: Adjusting the size of the image to a target size to obtain a first image; Performing straight line detection on the first image by using the Hough straight line detection method to obtain a tilt angle of the first image; Correcting the first image according to the tilt angle to obtain a second image; The second image is subjected to full-face text recognition using the OCR model.
3. The method according to claim 1, characterized in that The method further comprises: If the first field is a field corresponding to the four elements, obtaining the QR code information on the paper invoice image; Scan the QR code information to obtain text information corresponding to the four elements; The verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
4. The method according to claim 1, characterized in that If the text recognition result does not include text information corresponding to the first field, the method further includes: Determine whether the first field is a field corresponding to the password area; If the first field is a field corresponding to the password area, the information extraction of the paper invoice is terminated.
5. A paper invoice information extraction device, characterized in that: The device comprises: An acquisition module, used for acquiring a paper invoice image; A processing module, used to control an optical character recognition (OCR) model to perform full-face text recognition on the paper invoice image to obtain a text recognition result; wherein the OCR model is obtained by combining an object detection model YOLO4 and a text recognition model CRNN, the YOLO4 model is used to perform text detection on the paper invoice image, and the CRNN model is used to perform text recognition on the text detection result of the YOLO4 model; The processing module is also used to determine whether the text recognition result contains text information corresponding to all preset fields; if the text recognition result contains text information corresponding to all preset fields, the text information corresponding to the text recognition result is exported; if the text recognition result does not contain text information corresponding to the first field, determine whether the first field is a field corresponding to four elements; wherein the four elements include invoice code, invoice number, invoice date and pre-tax amount; if the first field is not a field corresponding to the four elements, the verification interface is called according to the text information corresponding to the four elements to obtain the text information corresponding to the paper invoice.
6. The device according to claim 5, characterized in that The processing module is further used for: Adjusting the size of the image to a target size to obtain a first image; Performing straight line detection on the first image by using the Hough straight line detection method to obtain a tilt angle of the first image; Correcting the first image according to the tilt angle to obtain a second image; The OCR model is controlled to perform full-face text recognition on the second image.
7. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in the method according to any one of claims 1 to 4 according to the obtained program instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 4.
