CN-115188016-B - Table document comparison and identification method and device
Abstract
The invention discloses a table document comparison and identification method and device, wherein the method comprises the steps of positioning a paper table document to be compared through a table document positioning model, optimizing the background of the image to be compared through a table image enhancement model, obtaining a table region picture through a table detection model, identifying the table region picture through a table structure identification model and a text identification model, finally sending the identified result to a difference comparison model, and outputting a comparison identification result of table cells and texts.
Inventors
- CHEN PENGFEI
- LIN JIAN
- Yi Qiuchen
Assignees
- 东云睿连(武汉)计算技术有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20220706
Claims (10)
- 1. A method for table document alignment identification, the method comprising the steps of: receiving paper form document pictures to be compared and corresponding standard electronic form documents, and converting the standard electronic form documents into standard form document pictures; Inputting the paper form document picture to be compared into a form document positioning model to obtain a paper form document picture with corrected position; Inputting the paper form document picture with the corrected position into a form image enhancement model to obtain a paper form document picture to be compared with optimized background; Inputting the background optimized paper form document picture to be compared into a form detection model to obtain a form region picture to be compared; inputting the to-be-compared table area picture into a table structure identification model to obtain to-be-compared cell intersection point coordinates; inputting the standard table region picture into the table structure identification model to obtain standard cell intersection point coordinates; Inputting the to-be-compared table area picture into a character recognition model to obtain rectangular frame coordinates and text of the to-be-compared characters; inputting the standard table area picture into a character recognition model to obtain standard rectangular character frame coordinates and a text; and inputting the rectangular text frame coordinates and the text to be compared into a difference comparison model, and simultaneously inputting the standard rectangular text frame coordinates and the text into the difference comparison model to obtain a comparison and identification result of the table cells and the text.
- 2. The method for comparing and identifying form documents according to claim 1, wherein the form document positioning model adopts a form document positioning model based on semantic segmentation to position and correct paper form document areas; Correspondingly, the specific step of inputting the paper form document picture to be compared to a form document positioning model to obtain the paper form document picture with corrected position comprises the following steps: S11, dividing pixel areas of the paper form document pictures to be compared to obtain mask images of the paper form document to be compared; Step S12, calculating four corner coordinates of the mask chart of the paper form document to be compared; And S13, performing perspective transformation on the four document corner coordinates, and cutting out a document area to obtain a paper form document picture with corrected positions.
- 3. The method for comparing and identifying form documents according to claim 1, wherein the form image enhancement model adopts a method based on illumination removal to enhance the image of the corrected paper form document picture; Correspondingly, the specific step of inputting the paper form document picture with corrected position into a form image enhancement model to obtain the paper form document picture to be compared with optimized background comprises the following steps: S21, carrying out Gaussian blur on the paper form document picture corrected in the position to obtain a background picture with uniform illumination; S22, dividing the paper form document picture with the corrected position and the background picture to obtain a weight picture; S23, scaling the weight graph to obtain a paper form document picture without illumination; And step S24, carrying out contrast enhancement and sharpening treatment on the illumination-removed paper form document picture to obtain an image-enhanced paper form document picture, and taking the image-enhanced paper form document picture as a background-optimized paper form document picture to be compared.
- 4. The method for comparing and identifying form documents according to claim 3, wherein the form detection model locates form areas by using a form detection model based on deep learning; Correspondingly, the step of inputting the background optimized paper form document picture to be compared into a form detection model to obtain a form region picture to be compared, and inputting the standard form document picture into the form detection model to obtain a standard form region picture specifically comprises the following steps: step S31, carrying out table detection on the image-reinforced paper table document picture to obtain rectangular coordinates of a table area, and cutting out the table area picture to be compared; step S32, carrying out table detection on the standard table document picture to obtain rectangular coordinates of a table area, and cutting out the standard table area picture; and step S33, obtaining a matching pair corresponding to the table to be compared and the standard table through table coordinate matching.
- 5. The method of comparing and identifying form documents according to claim 4, wherein in the step S33, the step of obtaining the matched pair corresponding to the form to be compared and the standard form by form coordinate matching specifically includes: step S311, selecting one rectangular coordinate of the table to be compared and all rectangular coordinates of the standard table, performing cross-comparison calculation, selecting the rectangular coordinate of the standard table with the maximum cross-comparison and meeting a set threshold value, and matching to the current rectangular coordinate of the table to be compared; step S312, carrying out matching calculation on the rectangular coordinates of the follow-up table to be compared to obtain a coordinate matching relation between the table to be compared and the standard table; step S313, marking the unmatched rectangular coordinates in the table to be compared as newly added table coordinates, and marking the unmatched rectangular coordinates in the standard table as missing table coordinates; Step S314, cutting out a table picture according to the detected rectangular coordinates, and constructing a table picture pair by the cut table picture through a matching relation, wherein the picture pair is the table region picture to be compared and the standard table region picture.
- 6. The method for comparing and identifying table documents according to claim 5, wherein the table structure identification model adopts a semantic segmentation model to obtain table frame lines, and the table cells are obtained through frame line intersection points, and the specific steps include: Step 41, segmenting the table picture pairs in the step 314 by using a semantic segmentation model to obtain table frame wires of the table picture pairs, wherein the table frame wires of the table picture pairs comprise the table frame wires of the table region pictures to be compared and the table frame wires of the standard table region pictures; step S42, detecting intersection points of table frame wires of the table picture pairs to obtain table cell coordinates; And S43, performing four-side verification on the obtained table cells, and filtering out the unclosed table cells.
- 7. The method for comparing and identifying table documents according to claim 6, wherein in the step S43, the method for performing four-side verification on the table cells comprises the following specific steps: step S51, obtaining a cell with the minimum side length for the table cell obtained in the step S52; step S52, setting the minimum side length as the sampling minimum interval length; step S53, setting sampling points on four sides of the table cell obtained in the step S52 through a minimum sampling interval; Step S54, judging whether the sampling point is in the form frame line obtained in the step S41 or not, and checking whether a closed cell exists or not.
- 8. The method for comparing and identifying form documents according to any one of claims 5 to 7, wherein the step of inputting the form region picture to be compared to a text recognition model to obtain rectangular text frame coordinates and text to be compared, and inputting the standard form region picture to the text recognition model to obtain standard rectangular text frame coordinates and text comprises the following specific steps: and identifying the table picture pair belonging to the step S314 through the OCR model to obtain the text content and the text coordinates of the table picture pair.
- 9. The method for comparative identification of a tabular document according to claim 8, the method is characterized in that the method for comparing and identifying the form document further comprises the following steps: And correlating the text content and the text coordinates of the obtained table picture pairs to corresponding table cells by calculating the intersection ratio of the text coordinates and the cell coordinates to obtain a table to be compared and a standard table, and obtaining the difference cell coordinates and the corresponding difference text content by comparing the differences of the text content in the cells, wherein the specific steps comprise: step S61, calculating the cross ratio of the table cell coordinates obtained in the step S43 and the text coordinates obtained in the step S54; Step S62, when the intersection ratio is larger than a set threshold value, the text content is associated to the cell; Step S63, when the intersection ratio is smaller than a set threshold value, calculating the distance from the central point of the character coordinates to the central points of all the cell coordinates, and associating the character content to the cell with the minimum distance; And S64, comparing the corresponding cell text contents of the table to be compared with the corresponding cell text contents of the standard table one by one to obtain cell coordinates with content differences and corresponding difference text contents.
- 10. The device for comparing and identifying the table documents is characterized by comprising a comparison data acquisition unit, a document positioning unit, a document image enhancement unit, a table detection unit, a table structure identification unit, a table text identification unit, a table difference comparison unit and a comparison identification display unit; the comparison data acquisition unit is used for acquiring paper form document pictures and standard electronic form documents to be compared and converting the standard electronic form documents into standard form document pictures; the document positioning unit is used for positioning and cutting out paper form document pictures; The document image enhancement unit is used for removing the problem of uneven background of the paper form document picture with corrected position; The table detection unit is used for detecting the table positions in the paper table document pictures and the standard table document pictures and the association relation between the tables, and constructing a table picture pair according to the association relation; the table structure identification unit is used for identifying the table cell structure of the table picture pair; the table text recognition unit is used for recognizing text content and position coordinates of the table picture pairs; the table difference comparison unit is used for identifying difference content and position coordinates between the paper table document picture to be compared and the standard table document picture; The comparison and identification display unit is used for displaying the difference content existing in the table to be compared and the standard table.
Description
Table document comparison and identification method and device Technical Field The embodiment of the invention relates to the technical field of artificial intelligence, in particular to a table document comparison and identification method and device. Background When comparing and checking electronic documents, such as pdf files, pictures and other table documents incapable of being edited in text, the table contents need to be checked manually, and huge manpower and material resources are consumed when a large amount of table document data are compared. The traditional automatic difference comparison method solves the problem of partial comparison. The traditional method based on pixel difference comparison can accurately position the difference position, but the method for comparing and identifying the pixel difference document generally has higher requirements for two table documents, and the typesetting of the two table documents must be ensured to be unchanged. When the paper form document and the electronic form document are compared, the position of the form is offset due to the collection of the paper form document, the consistency of typesetting cannot be ensured, and a larger error is generated in the pixel-based comparison method. At present, the OCR technology is relatively mature, and the table documents are recognized by adopting OCR, and then difference comparison is carried out through the recognized text content. When the OCR technology recognizes the table contents, the coordinate positions of the characters and the corresponding character contents can be output, the texts corresponding to the two tables are associated through the character coordinates, and then the difference comparison is carried out by comparing the text contents. The form comparison based on the OCR technology has the same problems as the pixel comparison method, and in the acquisition process of the paper form document, the form is distorted, so that the coordinate position recognized by OCR cannot be accurately matched to the corresponding text of the electronic document, and incorrect matching is caused, thereby causing larger comparison errors. The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present invention and is not intended to represent an admission that the foregoing is prior art. Disclosure of Invention The invention provides a method and a device for comparing and identifying form documents, which are used for solving the problem that the existing method based on pixel difference comparison and single OCR identification can generate larger comparison error aiming at the situation of pixel deviation and form distortion in the acquisition process of paper form document comparison. The invention provides a table document comparison and identification method which comprises the following steps: receiving paper form document pictures to be compared and corresponding standard electronic form documents, and converting the standard electronic form documents into standard form document pictures; Inputting the paper form document picture to be compared into a form document positioning model to obtain a paper form document picture with corrected position; Inputting the paper form document picture with the corrected position into a form image enhancement model to obtain a paper form document picture to be compared with optimized background; Inputting the background optimized paper form document picture to be compared into a form detection model to obtain a form region picture to be compared; inputting the to-be-compared table area picture into a table structure identification model to obtain to-be-compared cell intersection point coordinates; inputting the standard table region picture into the table structure identification model to obtain standard cell intersection point coordinates; Inputting the to-be-compared table area picture into a character recognition model to obtain rectangular frame coordinates and text of the to-be-compared characters; inputting the standard table area picture into a character recognition model to obtain standard rectangular character frame coordinates and a text; and inputting the rectangular text frame coordinates and the text to be compared into a difference comparison model, and simultaneously inputting the standard rectangular text frame coordinates and the text into the difference comparison model to obtain a comparison and identification result of the table cells and the text. Preferably, the form document positioning model adopts a form document positioning model based on semantic segmentation to position and correct a paper form document area; Correspondingly, the specific step of inputting the paper form document picture to be compared to a form document positioning model to obtain the paper form document picture with corrected position comprises the following steps: S11, dividing pixel areas of the paper form docu