Data field extraction method and device, storage medium and computer equipment

By setting anchor points in standard document images and calibrating actual document images, the problem of extraction errors caused by image displacement was solved, achieving higher accuracy and stability in data field extraction and improving the automation level of OCR applications.

CN121527770APending Publication Date: 2026-02-13YGSOFT INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511634101.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing technologies are prone to errors in extracting structured data fields from invoices due to image displacement, especially in OCR applications where it is difficult to accurately extract dynamic field content.

Method used

By setting anchor points in a standard invoice image to determine a standard rectangle, and calibrating parameters in an actual invoice image, a calibration image is generated, thereby stabilizing the extraction of dynamic fields.

Benefits of technology

It improves the accuracy and stability of data field extraction, reduces the strict requirements on the placement and angle of documents, and enhances the automation level and processing efficiency of OCR applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121527770A_ABST
    Figure CN121527770A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of information processing, in particular to a data field extraction method and device, a storage medium and computer equipment. The method comprises the following steps: acquiring a standard bill image and an actual bill image belonging to the same pixel coordinate system; determining an actual rectangle in the actual bill image based on the actual position of the anchor point in the actual bill image; comparing the standard rectangle with the actual rectangle, and determining an image calibration parameter; performing calibration processing on the actual bill image based on the image calibration parameter to obtain a calibration image; and based on the standard bill image, extracting a data field belonging to the second preset field type from the calibration image. Under the condition that the actual bill image shifts or rotates relative to the standard bill image, the dynamic field with the changed text content in the actual bill image can still be reliably positioned and extracted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information processing technology, and in particular to a method, apparatus, storage medium, and computer device for extracting data fields. Background Technology

[0002] Currently, while OCR (Optical Character Recognition) technology can accurately recognize text in images, in practical applications of extracting structured data fields such as invoices, text parsing-based methods are prone to confusion when field content is similar, leading to extraction errors. Furthermore, methods based on fixed coordinate positions cannot handle image displacement caused by manual placement or shooting angles, resulting in inaccurate extraction positions and thus field parsing errors. These factors collectively limit the accuracy and reliability of data field extraction in real-world scenarios. Summary of the Invention

[0003] In view of this, this application provides a data field extraction method, apparatus, storage medium, and computer equipment that can reliably locate and extract dynamic fields of text content changes in the actual invoice image even when the actual invoice image is shifted or rotated relative to the standard invoice image.

[0004] According to one aspect of this application, a method for extracting data fields is provided, comprising: Obtain a standard ticket image and an actual ticket image belonging to the same pixel coordinate system. The standard ticket image includes multiple anchor points and a standard rectangle in the standard ticket image determined according to the anchor points. The anchor points are determined according to the area where the data field of the first preset field type is located in the standard ticket image. Based on the actual position of the anchor point in the actual ticket image, determine the actual rectangle in the actual ticket image; By comparing the standard rectangle with the actual rectangle, the image calibration parameters are determined; The actual ticket image is calibrated based on the image calibration parameters to obtain a calibrated image. Based on the standard ticket image, data fields belonging to the second preset field type are extracted from the calibration image.

[0005] According to another aspect of this application, a data field extraction apparatus is provided, comprising: The acquisition module is used to acquire a standard ticket image and an actual ticket image belonging to the same pixel coordinate system. The standard ticket image includes multiple anchor points and a standard rectangle in the standard ticket image determined according to the anchor points. The anchor points are determined according to the area where the data field of the first preset field type is located in the standard ticket image. The calibration module is used to determine the actual rectangle in the actual ticket image based on the actual position of the anchor point in the actual ticket image; and to determine image calibration parameters by comparing the standard rectangle with the actual rectangle; and to perform calibration processing on the actual ticket image based on the image calibration parameters to obtain a calibrated image. The extraction module is used to extract data fields belonging to a second preset field type from the calibration image based on the standard ticket image.

[0006] According to another aspect of this application, a readable storage medium is provided, on which a program or instructions are stored, which, when executed by a processor, implement the steps of the above-described data field extraction method.

[0007] According to another aspect of this application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the steps of the above-described data field extraction method.

[0008] By employing the above technical solution, this application provides a data field extraction method, apparatus, storage medium, and computer equipment. Anchor points are pre-set in a standard ticket image to obtain a standard rectangle representing the posture of the standard ticket image and an actual rectangle representing the posture of the actual ticket image in a pixel coordinate system. The standard rectangle and the actual rectangle are then used to calibrate the actual ticket image, resulting in a calibration image that coincides with the standard ticket image. Dynamic fields representing changes in text content are then stably located and extracted from the calibration image. This application significantly reduces the stringent requirements on the placement and angle of the ticket. Even if the actual ticket image undergoes translation, rotation, or scaling relative to the standard ticket image, dynamic fields can still be stably located and extracted through automatic calibration, improving the accuracy and stability of data field extraction. This achieves a higher level of automation and processing efficiency in OCR applications such as ticket recognition.

[0009] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description

[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart illustrating the data field extraction method provided in an embodiment of this application is shown; Figure 2 A flowchart illustrating a data field extraction method according to another embodiment of this application is shown; Figure 3 An image of a standard invoice provided in yet another embodiment of this application is shown; Figure 4 An actual invoice image provided in yet another embodiment of this application is shown; Figure 5 A calibration image provided in yet another embodiment of this application is shown; Figure 6 An image showing the recognition and extraction results provided in another embodiment of this application is illustrated; Figure 7 A structural block diagram of the data field extraction device provided in an embodiment of this application is shown. Detailed Implementation

[0011] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present application can be combined with each other.

[0012] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0013] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “attached” to another element, it can be directly connected or attached to the other element, or there may be intermediate elements. Furthermore, “connected” or “attached” as used herein can include wireless connections or wireless interconnections. The term “and / or” as used herein includes all or any unit and all combinations of one or more associated listed items.

[0014] Exemplary embodiments according to this application will now be described in more detail with reference to the accompanying drawings. However, these exemplary embodiments may be implemented in many different forms and should not be construed as being limited to the embodiments set forth herein. It should be understood that these embodiments are provided so that the disclosure of this application is thorough and complete, and that the concept of these exemplary embodiments is fully conveyed to those skilled in the art.

[0015] Currently, OCR technology is very mature, making text recognition very easy. However, after acquiring the text, accurately extracting data fields becomes a crucial step in the application. This is especially true in invoice processing, where text is typically divided into two types: static fields and dynamic fields. For example, the invoice header is usually a static field with fixed text content, while the invoice amount is a dynamic field with changing text content. This necessitates accurately extracting the relevant dynamic field content from the static fields in practical applications.

[0016] In related technologies, OCR technology is used to first identify all text in the invoice image, obtaining a text list. Then, the identified text list is parsed using logical rules to accurately extract related dynamic fields by recognizing static fields. For example, by recognizing the static field of invoice amount, the dynamic field representing the actual amount is extracted. However, if the text in the dynamic field contains similar text to the static field, errors may occur during the parsing process. Furthermore, related technologies also employ position-based text extraction methods. If the actual invoice image is displaced, the extracted position may be inaccurate, leading to errors in the parsing of dynamic fields.

[0017] In view of this, this application provides a method for extracting data fields, such as... Figure 1 As shown, the method includes: Step 101: Obtain the standard ticket image and the actual ticket image, which belong to the same pixel coordinate system.

[0018] The standard document image includes multiple anchor points and a standard rectangle in the standard document image determined by the anchor points. The anchor points are determined based on the area where the data field of the first preset field type is located in the standard document image.

[0019] The data field extraction method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the data field extraction method, but is not limited to the above forms.

[0020] This embodiment establishes a stable image acquisition environment using fixed image acquisition equipment. In this environment, all acquired images share the same coordinate system, allowing for precise measurement and correction of differences between images.

[0021] Specifically, a standard invoice is one with clear text, a neat format, and no damage. An actual invoice is one from which data fields need to be extracted in a real-world application scenario. The image acquisition device is fixed in physical space; its position, angle, and field of view are all constant, therefore its physical acquisition area is also fixed. This step uses a pre-configured image acquisition device to acquire images of the standard invoice within its physical acquisition area to obtain a standard, upright, and undistorted image. In a real-world application scenario, the same image acquisition device is used to acquire images of the actual invoice within its physical acquisition area to obtain the actual invoice image. It can be understood that the standard invoice and the actual invoice are mapped into digital images by the same image acquisition device within the same physical acquisition area; therefore, the standard invoice image and the actual invoice image produced within this physical acquisition area share the same pixel coordinate system.

[0022] In this step, anchor points are manually selected in the standard invoice image based on the regions containing data fields belonging to the first preset field type. Then, based on the anchor points, data fields belonging to the second preset field type are determined in the standard invoice image, and the regions containing these data fields are also manually selected.

[0023] It should be noted that a data field refers to any independent unit of information on a document that needs to be identified and extracted. For example, on an invoice, the invoice code, invoice date, buyer's name, invoice amount, and tax rate are all data fields. The first preset field type refers to fields that are unique, easily identifiable by text, have a fixed position, and whose text content remains unchanged. In this embodiment, data fields belonging to the first preset field type are treated as static fields. Static fields refer to labels or descriptive text on the document. For example, the invoice code, invoice date, and invoice amount are all static fields. Corresponding to the first preset field type, the second preset field type refers to fields whose text content changes each time. In this embodiment, data fields belonging to the second preset field type are treated as dynamic fields. Dynamic fields are the actual data values ​​on the document that need to be accurately extracted and are related to static fields. For example, the specific string of numbers following the static field "invoice code" is the dynamic field corresponding to the static field "invoice code". Similarly, the specific date following the static field "invoice date" is the dynamic field corresponding to the static field "invoice date".

[0024] Next, OCR technology is used to recognize the standard invoice image to obtain the location information of the anchor point and dynamic field in the standard invoice image and the corresponding data field.

[0025] Furthermore, multiple scattered anchor points are aggregated into a global, quantified spatial attitude reference to obtain the standard rectangle of the standard ticket image, thus providing a unified comparison basis for subsequent accurate calculation of image calibration parameters.

[0026] Step 102: Determine the actual rectangle in the actual ticket image based on the actual position of the anchor point in the actual ticket image.

[0027] In this step, the actual position of the anchor point is located in the actual document image, and the process of obtaining the standard rectangle is repeated. Based on the actual position of the anchor point in the actual document image, the actual rectangle in the actual document image is calculated. The actual rectangle records the spatial pose information of the actual document image, such as its size and angle.

[0028] Step 103: Compare the standard rectangle with the actual rectangle to determine the image calibration parameters.

[0029] In this step, the actual rectangle in the actual ticket image is compared with the standard rectangle in the standard ticket image. Using a geometric transformation algorithm, the transformation parameters required to transform the actual rectangle to perfectly overlap with the standard rectangle are precisely calculated, and these transformation parameters are used as image calibration parameters. The image calibration parameters include at least one of the following: translation parameters, rotation parameters, and scaling parameters.

[0030] Step 104: Perform calibration processing on the actual ticket image based on the image calibration parameters to obtain a calibrated image.

[0031] In this step, the calculated image calibration parameters are used to perform a geometric transformation (translation, rotation, scaling) on ​​the entire original actual ticket image. This process generates a completely new, calibrated image. Ideally, the content of this calibrated image should be perfectly aligned with the position and orientation of its anchor points to match the standard ticket image.

[0032] Step 105: Based on the standard ticket image, extract the data fields belonging to the second preset field type from the calibration image.

[0033] In this step, since the image has already been calibrated, the location information of the dynamic fields previously defined on the standard ticket image can now be directly and accurately applied to this calibration image. Simply crop the corresponding target image regions from the calibration image based on the location information of these dynamic field regions. Perform OCR recognition on these small, aligned target image regions to obtain the accurate dynamic field content.

[0034] This embodiment pre-sets anchor points in a standard invoice image to consistently restore the actual invoice image, obtaining a calibration image that coincides with the standard invoice image. This provides accurate positioning for recognition, and allows for the stable location and extraction of dynamic fields with changing text content from the calibration image. This solves the problem of incorrect field extraction caused by manual placement offsets during invoice scanning, and addresses the issue of inaccurate data field extraction due to scaling caused by possible changes in camera focal length during invoice recognition. This application significantly reduces the stringent requirements on the placement and angle of the invoice. Even if the actual invoice image is shifted, rotated, or scaled relative to the standard invoice image, dynamic fields can still be stably located and extracted through automatic calibration, improving the accuracy and stability of data field extraction. This achieves a higher level of automation and processing efficiency in OCR applications such as invoice recognition.

[0035] Another embodiment of this application provides a method for extracting data fields, such as... Figure 2 As shown, the method includes: Step 201: Acquire standard ticket images and actual ticket images of standard tickets belonging to the same pixel coordinate system using an image acquisition device.

[0036] This embodiment establishes a stable image acquisition environment using fixed image acquisition equipment. In this environment, all acquired images share the same coordinate system, allowing for precise measurement and correction of differences between images.

[0037] Specifically, a standard invoice is one with clear text, a neat format, and no damage. An actual invoice is one from which data fields need to be extracted in a real-world application scenario. The image acquisition device is fixed in physical space; its position, angle, and field of view are all constant, therefore its physical acquisition area is also fixed. This step uses a pre-configured image acquisition device to acquire images of the standard invoice within its physical acquisition area to obtain a standard, upright, and undistorted image. In a real-world application scenario, the same image acquisition device is used to acquire images of the actual invoice within its physical acquisition area to obtain the actual invoice image. It can be understood that the standard invoice and the actual invoice are mapped into digital images by the same image acquisition device within the same physical acquisition area; therefore, the standard invoice image and the actual invoice image produced within this physical acquisition area share the same pixel coordinate system.

[0038] Here, the image acquisition device is a device with image acquisition function, such as a camera or scanner, and this embodiment does not impose specific limitations.

[0039] For example, the physical acquisition area is a perfectly rectangular region. In the pixel coordinate system shared by the standard ticket image and the actual ticket image, the horizontal axis corresponds to the horizontal direction of the physical acquisition area, and the vertical axis corresponds to the vertical direction of the physical acquisition area. It should be noted that because the position of the ticket within the physical acquisition area may change during actual photography or scanning, the acquired actual ticket image may also be displaced relative to the standard ticket image, such as by offset, rotation, or scaling.

[0040] Step 202: In the pixel coordinate system, determine the standard coordinates of the center point of the anchor point in the standard document image; based on the standard coordinates, determine the smallest bounding rectangle that can enclose the center points of all anchor points in the standard document image, and use the smallest bounding rectangle as the standard rectangle.

[0041] In this embodiment, anchor points are manually selected in the standard invoice image based on the regions where data fields belonging to a first preset field type are located. Furthermore, based on the anchor points, data fields belonging to a second preset field type are determined in the standard invoice image, and regions where data fields belonging to the second preset field type are located are manually selected in the standard invoice image.

[0042] It should be noted that a data field refers to any independent unit of information on a document that needs to be identified and extracted. For example, on an invoice, the invoice code, invoice date, buyer's name, invoice amount, and tax rate are all data fields. The first preset field type refers to fields that are unique, easily identifiable by text, have a fixed position, and whose text content remains unchanged. In this embodiment, data fields belonging to the first preset field type are treated as static fields. Static fields refer to labels or descriptive text on the document. For example, the invoice code, invoice date, and invoice amount are all static fields. Corresponding to the first preset field type, the second preset field type refers to fields whose text content changes each time. In this embodiment, data fields belonging to the second preset field type are treated as dynamic fields. Dynamic fields are the actual data values ​​on the document that need to be accurately extracted and are related to static fields. For example, the specific string of numbers following the static field "invoice code" is the dynamic field corresponding to the static field "invoice code". Similarly, the specific date following the static field "invoice date" is the dynamic field corresponding to the static field "invoice date".

[0043] Specifically, at least three anchor points are manually selected on the standard invoice image. These anchor points are used to determine the areas containing static fields on the standard invoice image. More anchor points can increase robustness but reduce efficiency. The number of anchor points is set according to the actual application scenario; this embodiment does not impose a specific limit. For example, the areas containing static fields such as invoice code, invoice date, payee, and invoice amount in the standard invoice image are selected as anchor points. Furthermore, in addition to anchor points, dynamic fields corresponding to the static fields that need to be extracted need to be defined on the standard invoice image, and the areas containing these dynamic fields are manually selected. For example, the specific amount value following the static field "Invoice Amount" in the standard invoice image is the dynamic field corresponding to the static field "Invoice Amount." The area containing this dynamic field is then manually selected, which is the area containing the dynamic field to be extracted corresponding to "Invoice Amount."

[0044] Understandably, in a standard invoice image, an anchor point is a specific pixel region, and the text content within this region happens to be a static field. Similarly, the region containing dynamic fields in a standard invoice image is also a specific pixel region, and the text content within this region happens to be a dynamic field.

[0045] In practical applications, the shapes of the selected anchor points and the areas containing dynamic fields in a standard invoice image can be irregular.

[0046] In this step, after selecting the anchor points and the area where the dynamic field is located in the standard ticket image, multiple scattered anchor points are aggregated into a global, quantized spatial attitude reference to obtain the standard rectangle of the standard ticket image, thus providing a unified comparison basis for subsequent accurate calculation of image calibration parameters.

[0047] Furthermore, as a refinement and extension of the specific implementation of the above embodiments, in order to fully illustrate the specific implementation process of this embodiment, in the pixel coordinate system, the standard coordinates of the center point of the anchor point in the standard ticket image are determined; based on the standard coordinates, the minimum bounding rectangle that can enclose the center points of all anchor points in the standard ticket image is determined, specifically including: performing optical character recognition on the standard ticket image to represent the anchor points in the standard ticket image by a first bounding box; calculating the standard coordinates of the center point of the anchor point in the standard ticket image based on the vertex coordinates of the first bounding box; traversing the standard coordinates of the center points of the anchor points to determine the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinates; determining the coordinates of the vertices of the minimum bounding rectangle based on the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinates; and obtaining the minimum bounding rectangle based on the coordinates of the vertices of the minimum bounding rectangle.

[0048] In this step, OCR technology is used to recognize the standard invoice image (hereinafter referred to as "OCR recognition" for ease of description). Anchor points in the standard invoice image are represented by a first bounding box, and their positional information is obtained through the first bounding box. Simultaneously, the region containing dynamic fields in the standard invoice image is represented by a second bounding box, and its positional information is obtained through the second bounding box. Furthermore, the text content within the first and second bounding boxes can also be recognized, i.e., the static fields corresponding to the anchor points in the standard invoice image and the dynamic fields corresponding to the regions containing the dynamic fields. Specifically, the positional information of the anchor points in the standard invoice image includes the precise coordinates of the top-left corner (i.e., the top-left vertex) of the first bounding box to which the anchor point belongs, as well as the width and height of the first bounding box. The positional information of the regions containing the dynamic fields in the standard invoice image includes the precise coordinates of the top-left corner of the second bounding box to which the dynamic field region belongs, as well as the width and height of the second bounding box.

[0049] Here, the bounding box is the smallest bounding rectangle of the region. Specifically, the first bounding box is the smallest bounding rectangle of the region represented by the anchor point in the standard document image, and the second bounding box is the smallest bounding rectangle of the region where the dynamic field is located in the standard document image. Therefore, in this step, a rectangle with a slightly larger volume and simpler characteristics is used to approximate the complex geometric objects corresponding to the regions represented by the anchor point and the regions where the dynamic field is located.

[0050] It should be noted that the coordinates mentioned in this embodiment are all pixel coordinates in the pixel coordinate system corresponding to the physical acquisition area.

[0051] Furthermore, for any anchor point in the standard document image, its center point is the geometric center of the first bounding box to which the anchor point belongs. For example, the x-coordinate of the anchor point's center point in the standard document image = x-coordinate of the top-left corner of the first bounding box + width of the first bounding box / 2; the y-coordinate of the anchor point's center point in the standard document image = y-coordinate of the top-left corner of the first bounding box + height of the first bounding box / 2. Thus, the standard coordinates of the anchor point's center point in the standard document image are calculated (x-coordinate and y-coordinate of the anchor point's center point in the standard document image). Here, using the center point is more stable and representative than using a corner point of the first bounding box, and can better represent the true position of the anchor point.

[0052] Next, based on the standard coordinates of the center points of all anchor points, a minimum bounding rectangle that can enclose them is calculated, and this rectangle is used as the standard rectangle. The standard rectangle records the standard orientation of the standard ticket image, representing its position, size, and rotation angle. Understandably, if the standard ticket is upright within the physical acquisition area, the standard rectangle of the standard ticket image should be horizontal; therefore, the rotation angle of the standard ticket image is zero degrees. Specifically, the maximum and minimum values ​​of the x and y coordinates of the center points of all anchor points are found to determine a rectangle that can enclose all center points as small as possible.

[0053] For example, two variables, `min_x` and `min_y`, are defined and initialized, for example, to positive infinity or to the standard coordinates of the center point of the first anchor point. Simultaneously, two variables, `max_x` and `max_y`, are defined and initialized, for example, to negative infinity or to the standard coordinates of the center point of the first anchor point. Then, the standard coordinates of the center points of all anchor points are iterated: for each anchor point... i Standard coordinates of the center point ,like Then update min_x to To find the leftmost x-coordinate of the standard rectangle; if Then update min_y to To find the ordinate of the top edge of the standard rectangle; if Then update max_x to To find the rightmost x-coordinate of the standard rectangle; if If y, then update max_y to The goal is to find the bottom ordinate of the standard rectangle. After iterating through the standard coordinates of the center points of all anchor points, four values ​​required to form the standard rectangle are obtained: min_x, min_y, max_x, and max_y. Therefore, the top-left corner coordinates are (min_x, min_y), the bottom-right corner coordinates are (max_x, max_y), the width is max_x - min_x, and the height is max_y - min_y. This precisely finds the smallest standard rectangle that can enclose the center points of all anchor points in the standard document image.

[0054] Step 203: Perform optical character recognition on the actual ticket image to obtain the text data in the actual ticket image and the text coordinates of the text data in the pixel coordinate system; match the data field corresponding to the anchor point with the text data; determine the actual position of the anchor point in the actual ticket image based on the target text coordinates of the target text data matched by the data field corresponding to the anchor point, so as to determine the actual rectangle in the actual ticket image based on the actual position of the anchor point in the actual ticket image.

[0055] In this step, OCR recognition is performed on the actual invoice image to identify all text data and the text coordinates of the text data in the pixel coordinate system. The static field corresponding to the anchor point is matched with the text data to search for the static field corresponding to the anchor point in the text data of the actual invoice image recognized by OCR. Therefore, based on the target text coordinates of the target text data matched with the static field corresponding to the anchor point, the actual area where the static field corresponding to the anchor point is located in the actual invoice image is determined. Thus, based on the actual area where the static field corresponding to the anchor point is located in the actual invoice image, the actual position of the anchor point in the actual invoice image is determined. Next, the process of step 202 is repeated. Based on the actual position of the anchor point in the actual invoice image, the actual center point of the anchor point in the actual invoice image is calculated. Based on these actual center points, a new minimum bounding rectangle is calculated, which is the actual rectangle of the actual invoice image. The actual rectangle records the spatial pose information of the actual invoice image, such as its size and angle. The process of obtaining the actual rectangle is the same as the process of obtaining the standard rectangle, and will not be described again in this embodiment.

[0056] Step 204: Compare the standard rectangle with the actual rectangle to determine the image calibration parameters.

[0057] In this step, the actual rectangle in the actual ticket image is compared with the standard rectangle in the standard ticket image in the pixel coordinate system. Using a geometric transformation algorithm, the transformation parameters required to transform the actual rectangle to perfectly overlap with the standard rectangle are precisely calculated, and these transformation parameters are used as image calibration parameters. The image calibration parameters include at least one of the following: translation parameters, rotation parameters, and scaling parameters.

[0058] Specifically, the translation parameter indicates how many pixels the actual ticket image needs to be moved along the horizontal and vertical axes of the pixel coordinate system, thus obtaining the translation amount of the actual ticket image. The rotation parameter indicates how many degrees the actual ticket image needs to be rotated. The scaling parameter indicates how many times the actual ticket image needs to be enlarged or reduced along the horizontal and vertical axes of the pixel coordinate system.

[0059] It should be noted that the geometric transformation algorithm can be any existing algorithm in related technologies, such as the affine transformation algorithm, as long as it can obtain the image calibration parameters. This embodiment does not impose any specific restrictions.

[0060] Step 205: The actual ticket image is calibrated based on the image calibration parameters to obtain a calibrated image.

[0061] In this step, the calculated image calibration parameters are used to perform a geometric transformation (translation, rotation, scaling) on ​​the entire original actual ticket image. This process generates a completely new, calibrated image. Ideally, the content of this calibrated image should be perfectly aligned with the position and orientation of its anchor points to match the standard ticket image.

[0062] Step 206: Based on the location information of the area where the data field of the second preset field type is located in the standard ticket image under the pixel coordinate system, determine the target image area in the calibration image; perform optical character recognition on the target image area to obtain the data field of the second preset field type within the target image area.

[0063] In this step, a calibration image aligned with the standard ticket image has been obtained, along with the location information of the dynamic field regions predefined in step 202. Since the image has been calibrated, the location information of the dynamic field regions previously defined on the standard ticket image can now be directly and accurately applied to this calibration image. Simply crop the corresponding target image regions precisely from the calibration image based on the location information of these dynamic field regions. Perform OCR recognition on these small, aligned target image regions to ultimately obtain the accurate dynamic field content.

[0064] This embodiment ensures stable data field extraction even when the image is moved or rotated, improving the accuracy and reliability of document recognition in OCR applications.

[0065] In another embodiment of this application, a standard ticket image with anchor points set is shown below. Figure 3 As shown, the simulated image of the actual ticket undergoing displacement is as follows: Figure 4 As shown, the calibration image is as follows Figure 5 As shown, the content of the dynamic field extracted from the calibration image is as follows: Figure 6 As shown.

[0066] It should be noted that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0067] Furthermore, such as Figure 7 As shown, as a specific implementation of the above data field extraction method, this application embodiment provides a data field extraction device 700, which includes: an acquisition module 701, a calibration module 702, and an extraction module 703.

[0068] Among them, the acquisition module 701 is used to acquire a standard ticket image and an actual ticket image belonging to the same pixel coordinate system. The standard ticket image includes multiple anchor points and a standard rectangle in the standard ticket image determined according to the anchor points. The anchor points are determined according to the area where the data field belonging to the first preset field type is located in the standard ticket image. The calibration module 702 is used to determine the actual rectangle in the actual ticket image based on the actual position of the anchor point in the actual ticket image; and to determine the image calibration parameters by comparing the standard rectangle with the actual rectangle; and to perform calibration processing on the actual ticket image based on the image calibration parameters to obtain a calibrated image. Extraction module 703 is used to extract data fields belonging to a second preset field type from a calibration image based on a standard invoice image.

[0069] Optionally, the data field extraction device 700 further includes: The first determining module is used to determine the standard coordinates of the center point of the anchor point in the standard document image in the pixel coordinate system; based on the standard coordinates, it determines the smallest bounding rectangle that can enclose the center points of all anchor points in the standard document image, and uses the smallest bounding rectangle as the standard rectangle.

[0070] The first determining module is specifically used to perform optical character recognition on the standard ticket image, so that the anchor point in the standard ticket image is represented by the first bounding box; and to calculate the standard coordinates of the center point of the anchor point in the standard ticket image based on the vertex coordinates of the first bounding box.

[0071] The first determining module is specifically used to traverse the standard coordinates of the center point of the anchor point, determine the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinates; determine the coordinates of the vertices of the minimum bounding rectangle based on the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinates; and obtain the minimum bounding rectangle based on the coordinates of the vertices of the minimum bounding rectangle.

[0072] Optionally, the data field extraction device 700 further includes: The second determining module is used to perform optical character recognition on the actual ticket image to obtain the text data in the actual ticket image and the text coordinates of the text data in the pixel coordinate system; match the data field corresponding to the anchor point with the text data; and determine the actual position of the anchor point in the actual ticket image based on the target text coordinates of the target text data matched by the data field corresponding to the anchor point.

[0073] The calibration module 702 is specifically used for image calibration parameters, which include at least one of the following: translation parameters, rotation parameters, and scaling parameters.

[0074] The extraction module 703 is specifically used to determine the target image region in the calibration image based on the location information of the data field belonging to the second preset field type in the standard ticket image under the pixel coordinate system; and to perform optical character recognition on the target image region to obtain the data field belonging to the second preset field type within the target image region.

[0075] Specific limitations regarding the data field extraction device can be found in the limitations of the data field extraction method described above, and will not be repeated here. Each module in the aforementioned data field extraction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0076] Based on the above, Figures 1 to 2 Accordingly, embodiments of this application also provide a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method. Figures 1 to 2 The data field extraction method shown.

[0077] Based on this understanding, the technical solution of this application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, or portable hard drive), and includes several instructions to cause a computer device (such as a personal computer, server, or network device) to execute the methods described in the various implementation scenarios of this application.

[0078] Based on the above, Figures 1 to 2 The method shown, and Figure 7 To achieve the above objectives, the present application also provides a computer device, specifically a personal computer, server, network device, etc., as shown in the virtual device embodiment. This computer device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described objectives. Figures 1 to 2 The data field extraction method shown.

[0079] Optionally, the computer device may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB ports, card reader ports, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Bluetooth interfaces, Wi-Fi interfaces), etc.

[0080] Those skilled in the art will understand that the computer device structure provided in this embodiment does not constitute a limitation on the computer device, and may include more or fewer components, or combine certain components, or have different component arrangements.

[0081] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages and stores the hardware and software resources of a computer device, supporting the operation of information processing programs and other software and / or programs. The network communication module is used to enable communication between the various components within the storage medium, as well as communication with other hardware and software within the physical device.

[0082] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platform, or the embodiments of this application can be implemented by hardware.

[0083] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing this application. Those skilled in the art will understand that the modules in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or can be modified to be located in one or more apparatuses different from this embodiment. The modules of the above-described embodiment can be combined into one module, or further divided into multiple sub-modules.

[0084] The serial numbers in this application are for descriptive purposes only and do not represent the superiority or inferiority of any particular implementation scenario. The above disclosures are merely a few specific implementation scenarios of this application; however, this application is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of this application.

Claims

1. A method for extracting data fields, characterized in that, The method includes: Obtain a standard ticket image and an actual ticket image belonging to the same pixel coordinate system. The standard ticket image includes multiple anchor points and a standard rectangle in the standard ticket image determined according to the anchor points. The anchor points are determined according to the area where the data field of the first preset field type is located in the standard ticket image. Based on the actual position of the anchor point in the actual ticket image, determine the actual rectangle in the actual ticket image; By comparing the standard rectangle with the actual rectangle, the image calibration parameters are determined; The actual ticket image is calibrated based on the image calibration parameters to obtain a calibrated image. Based on the standard ticket image, data fields belonging to the second preset field type are extracted from the calibration image.

2. The data field extraction method according to claim 1, characterized in that, Before obtaining the standard ticket image and the actual ticket image belonging to the same pixel coordinate system, the method further includes: In the pixel coordinate system, determine the standard coordinates of the center point of the anchor point in the standard ticket image; Based on the standard coordinates, determine the smallest bounding rectangle that can enclose the center point of all the anchor points in the standard ticket image, and use the smallest bounding rectangle as the standard rectangle.

3. The data field extraction method according to claim 2, characterized in that, Determining the standard coordinates of the center point of the anchor point in the standard document image specifically includes: Optical character recognition is performed on the standard ticket image so that the anchor point in the standard ticket image is represented by a first bounding box; Based on the vertex coordinates of the first bounding box, calculate the standard coordinates of the center point of the anchor point in the standard ticket image.

4. The data field extraction method according to claim 2, characterized in that, The step of determining the smallest bounding rectangle that can enclose the center point of all the anchor points in the standard document image based on the standard coordinates specifically includes: Iterate through the standard coordinates of the center point of the anchor point to determine the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinates. Based on the maximum x-coordinate, minimum x-coordinate, maximum y-coordinate, and minimum x-coordinate in the standard coordinate system, determine the coordinates of the vertices of the minimum bounding rectangle; The minimum bounding rectangle is obtained based on the coordinates of its vertices.

5. The data field extraction method according to claim 1, characterized in that, Before the step of basing the anchor point on the actual position in the actual ticket image, the method further includes: Optical character recognition is performed on the actual ticket image to obtain the text data in the actual ticket image and the text coordinates of the text data in the pixel coordinate system; Match the data field corresponding to the anchor point with the text data; The actual position of the anchor point in the actual ticket image is determined based on the target text coordinates of the target text data matched by the data field corresponding to the anchor point.

6. The data field extraction method according to claim 1, characterized in that, The image calibration parameters include at least one of the following: translation parameters, rotation parameters, and scaling parameters.

7. The data field extraction method according to claim 1, characterized in that, The step of extracting data fields belonging to the second preset field type from the calibration image based on the standard invoice image specifically includes: Based on the location information of the data field belonging to the second preset field type in the standard ticket image under the pixel coordinate system, the target image region is determined in the calibration image; Optical character recognition is performed on the target image region to obtain a data field belonging to the second preset field type within the target image region.

8. A data field extraction device, characterized in that, The device includes: The acquisition module is used to acquire a standard ticket image and an actual ticket image belonging to the same pixel coordinate system. The standard ticket image includes multiple anchor points and a standard rectangle in the standard ticket image determined according to the anchor points. The anchor points are determined according to the area where the data field of the first preset field type is located in the standard ticket image. The calibration module is used to determine the actual rectangle in the actual ticket image based on the actual position of the anchor point in the actual ticket image; and to determine image calibration parameters by comparing the standard rectangle with the actual rectangle; and to perform calibration processing on the actual ticket image based on the image calibration parameters to obtain a calibrated image. The extraction module is used to extract data fields belonging to a second preset field type from the calibration image based on the standard ticket image.

9. A readable storage medium having a program or instructions stored thereon, characterized in that, When the program or instructions are executed by the processor, they implement the steps of the data field extraction method as described in any one of claims 1 to 7.

10. A computer device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the program, it implements the data field extraction method as described in any one of claims 1 to 7.