Chart table content extraction method based on OCR engine

By using an OCR engine-based method in document chart table content extraction, the table is identified using object detection and line segment detection algorithms, and the text information is extracted using OCR recognition technology, the problem of extraction accuracy and inefficiency in the existing technology is solved, and the problem of extraction accuracy and inefficiency is realized. Automatic, efficient and accurate table content extraction.

CN119418341AInactive Publication Date: 2025-02-11CHINA YANGTZE POWER
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411264814.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-02-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art has low accuracy and low efficiency in document chart content extraction, and requires manual annotation or rule matching, resulting in insufficient efficiency and accuracy.

Method used

The OCR engine-based chart table content extraction method is used to convert the PDF file into an image, and the table is identified using object detection and line segment detection algorithms. Then, the text information in the table is extracted using OCR recognition technology and filled in the complete table according to the table structure. Table content.

Benefits of technology

It realizes automated and efficient table content extraction, reduces manual intervention, improves the accuracy and stability of the extraction, and is suitable for various types of documents and table data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119418341A_ABST
    Figure CN119418341A_ABST
Patent Text Reader

Abstract

The invention discloses a chart table content extraction method based on an OCR engine. The method comprises the steps that a bidding document file in a pdf format is converted into an image file; identifying a table in the bidding document image file through target detection; detecting and identifying rows and columns in the table through a yov5 line segment detection algorithm, and recording initial positions of the rows and the columns; performing table cell discovery through row and column line segments, intercepting the position of a cell, and storing a cell picture of the cell; performing character recognition on the cell picture by using OCR (Optical Character Recognition) to obtain cell text information; performing table header discovery according to a table structure, and filling a cell text into a corresponding table cell; according to the method, the problems of low accuracy and low efficiency in the prior art are solved, the advantages of the OCR technology are utilized, the automatic and efficient extraction process is achieved, manual intervention is reduced, and the extraction accuracy and stability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of table content extraction, and in particular relates to a method for extracting chart table content based on an OCR engine. Background Art

[0002] In the current information processing technology field, there is a demand for extracting document chart and table content. The extraction methods in the existing technology usually rely on manual annotation or rule matching, and each type of table requires extraction rules, which has problems of low accuracy and low efficiency. Therefore, it is necessary to design a chart and table content extraction method based on OCR engine to solve the above problems. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide a method for extracting the content of charts and tables based on an OCR engine, which is used to solve the problems of low accuracy and low efficiency in the prior art. It has the advantages of utilizing OCR technology, realizing an automated and efficient extraction process, reducing manual intervention, and improving the accuracy and stability of extraction.

[0004] In order to achieve the above technical effects, the technical solution adopted by the present invention is: A method for extracting content from a chart or table based on an OCR engine comprises the following steps: S1, convert the tender document file in pdf format into an image file; S2, identifying the table in the tender image file through object detection; S3, detect and identify the rows and columns in the table through the yolov5 line segment detection algorithm, and record their starting positions; S4, discover the table cell through the row and column segments, and intercept the cell position and save the cell image; S5, use OCR recognition to perform text recognition on the cell image to obtain cell text information; S6, find the table header according to the table structure, and fill the cell text into the corresponding table cell.

[0005] Preferably, in step S1, the ffmpeg tool is used to convert the tender document file in pdf format into an image file; and the pdf file is converted into an image format by inputting an appropriate command in a command line interface.

[0006] Preferably, in step S2, the table in the tender document image file is identified using the yolov5 target detection method; the table in the image is identified using the yolov5 target detection model to determine the position and boundary of the table.

[0007] Preferably, in step S3, the yolov5 line segment detection algorithm is used to detect the row and column line segments in the table, and the starting positions of the row and column line segments in the table are recorded and recorded for subsequent processing.

[0008] Preferably, in step S4, discovering table cells through row and column segments, and intercepting the cell positions and saving the cell images include: Based on the detected row and column segments, the cells in the table are found, and the cell positions are captured and saved as separate image files for subsequent processing.

[0009] Preferably, in step S5, using OCR recognition to perform text recognition on the cell image, and obtaining the cell text information includes using OCR recognition to perform text recognition on the image of each cell, and extracting the text information in the cell.

[0010] Preferably, in step S6, discovering the table header according to the table structure and filling the cell text into the corresponding table cell includes: According to the table structure and text content, the table header is found, and the identified cell text information is filled into the corresponding table cell to complete the sorting and filling of the table content. The specific method is as follows: The table header content dictionary is constructed by manually or by analyzing the table header data in the historical table to obtain the approximate character content of the table header; Table format analysis: analyze the upper and lower structures and left and right structures of the table format; obtain the table format by classifying and analyzing the contents of the first few rows of the table and comparing the table header contents with the dictionary; Get the header information, and get the header content of the table based on the table format content and the dictionary comparison of the header content; Supplement the content across rows and columns of the table. According to the table constructed by row and column segments, calculate the position of the table across rows and columns and position it, and fill the content from top to bottom and from left to right. Structural data is sorted according to table format content and header information.

[0011] The beneficial effects of the present invention are as follows: 1. Accuracy of extraction results: Using the OCR engine for text recognition can accurately identify the content in documents and tables, avoiding errors caused by manual annotation and rule matching.

[0012] 2. Improve extraction efficiency: The automated extraction process reduces manual intervention, saves time and labor costs, and improves extraction efficiency.

[0013] 3. Wide applicability: This method is applicable to various types of documents and tabular data, has strong versatility, and can meet the extraction needs of different fields.

[0014] 4. Significant economic benefits: reducing labor costs and improving work efficiency, which helps to reduce the operating costs of enterprises and improve work efficiency and competitiveness. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a flowchart of this application; Figure 2 It is the flow chart of structured extraction of charts and tables in this application; Figure 3 is a schematic diagram of a table to be extracted in an embodiment of the present application; Figure 4 It is a position diagram of each cell after the row and column line segments of the table in the embodiment of the present application are detected; Figure 5 is a document table recognition result diagram based on OCR recognition in an embodiment of the present application; Figure 6 It is a schematic diagram of the system architecture in an embodiment of the present application. DETAILED DESCRIPTION

[0016] Embodiment 1: like Figure 1 As shown, a method for extracting content from a chart or table based on an OCR engine comprises the following steps: S1, convert the tender document file in pdf format into an image file; S2, identifying the table in the tender image file through object detection; S3, detect and identify the rows and columns in the table through the yolov5 line segment detection algorithm, and record their starting positions; S4, discover the table cell through the row and column segments, and intercept the cell position and save the cell image; S5, use OCR recognition to perform text recognition on the cell image to obtain cell text information; S6, find the table header according to the table structure, and fill the cell text into the corresponding table cell.

[0017] Preferably, in step S1, the bid document file in pdf format is converted into an image file using the ffmpeg tool; the pdf file is converted into an image format by inputting an appropriate command in the command line interface; for example: ffmpeg -i input.pdfoutput.png; Preferably, in step S2, the table in the tender document image file is identified using the yolov5 target detection method; the table in the image is identified using the yolov5 target detection model to determine the position and boundary of the table.

[0018] Preferably, in step S3, the yolov5 line segment detection algorithm is used to detect the row and column line segments in the table, and the starting positions of the row and column line segments in the table are recorded and recorded for subsequent processing.

[0019] Preferably, in step S4, discovering table cells through row and column segments, and intercepting the cell positions and saving the cell images include: Based on the detected row and column segments, the cells in the table are found, and the cell positions are captured and saved as separate image files for subsequent processing.

[0020] Preferably, in step S5, using OCR recognition to perform text recognition on the cell image, and obtaining the cell text information includes using OCR recognition to perform text recognition on the image of each cell, and extracting the text information in the cell.

[0021] Preferably, in step S6, discovering the table header according to the table structure and filling the cell text into the corresponding table cell includes: According to the table structure and text content, the table header is found, and the identified cell text information is filled into the corresponding table cell to complete the sorting and filling of the table content. The specific method is as follows: The table header content dictionary is constructed by manually or by analyzing the table header data in the historical table to obtain the approximate character content of the table header; Table format analysis: analyze the upper and lower structures and left and right structures of the table format; obtain the table format by classifying and analyzing the contents of the first few rows of the table and comparing the table header contents with the dictionary; Get the header information, and get the header content of the table based on the table format content and the dictionary comparison of the header content; Supplement the content across rows and columns of the table. According to the table constructed by row and column segments, calculate the position of the table across rows and columns and position it, and fill the content from top to bottom and from left to right. Structural data is sorted according to table format content and header information.

[0022] Embodiment 2: like Figure 2 As shown, this embodiment provides a specific application process of a method for extracting content of a chart or table based on an OCR engine, comprising the following steps: Step 1: Use the ffmpeg tool to convert the pdf format tender document file into an image file; enter the appropriate command in the command line interface to convert the pdf file into an image format; Step 2: Use yolov5 target detection technology to identify the table in the tender image file. Use the yolov5 target detection model to identify the table in the image and determine the position and boundaries of the table; Step 3: Use the yolov5 line segment detection algorithm to detect and identify the rows and columns in the table, and record their starting positions; Use the yolov5 line segment detection algorithm to detect the row and column segments in the table, and record their starting positions for subsequent processing; Step 4: Find the table cells through the row and column segments, and intercept the cell position and save the cell image. According to the detected row and column segments, find the cells in the table, and intercept the cell position and save it as a separate image file for subsequent processing; Step 5: Use OCR recognition technology to perform text recognition on the cell image to obtain the cell text information. Use OCR technology to perform text recognition on each cell image to extract the text information in the cell.

[0023] like Figure 3As shown in the figure, the OCR recognition results of each cell in the bid letter appendix table are {"tablesInfo": [{"word": "Serial number", "rect": {"left": 32, "top": 22, "width": 92, "height": 73}},{"word": "Clause content", "rect": {"left": 124, "top": 22, "width": 278, "height":73}}, {"word": "Contract clause number", "rect": {"left": 402, "top": 22, "width": 132, "height": 73}}, {"word": "Agreed content", "rect": {"left": 534, "top": 22, "width":251, "height": 73}}, {"word": "Remarks", "rect": {"left": 785, "top": 22, "width": 78, "height": 73}}, {"word": "1", "rect": {"left": 32, "top": 95, "width": 92, "height": 239}}, {"word": "project manager", "rect": {"left": 124, "top": 95, "width": 278, "height": 240}}, {"word": "1.1.2.4", "rect": {"left":402, "top": 95, "width": 132, "height": 239}}, {"word": "Name:", "rect": {"left": 534, "top": 95, "width": 251, "height": 57}}, {"word": " / ", "rect": {"left": 785, "top": 95, "width": 78, "height": 58}}, {"word": "Constructor Registration Certificate Level: First Level Major: Construction Engineering", "rect": {"left": 534, "top": 152, "width": 251, "height": 109}}, {"word": "", "rect": {"left": 785, "top": 153, "width": 78, "height": 108}}, {"word": "Registration Certificate Number: 1312C", "rect": {"left": 534, "top":261, "width": 251, "height": 72}}, {"word": "", "rect": {"left": 785, "top":261, "width": 78, "height": 73}}, {"word": "2", "rect": {"left": 32, "top":334, "width": 92, "height": 58}}, {"word": "duration", "rect": {"left": 124, "top": 335, "width": 278, "height": 57}}, {"word": "1.1.4.3", "rect": {"left":402, "top": 334, "width": 132, "height": 58}}, {"word": "760 days", "rect": {"left": 534, "top": 333, "width": 251, "height": 59}}, {"word": "", "rect": {"left": 785, "top": 334, "width": 78, "height": 58}}, {"word": "3", "rect": {"left": 32, "top": 392, "width": 92, "height": 58}}, {"word": "Defect Liability Period", "rect": {"left": 124, "top": 392, "width": 278, "height": 59}}, {"word": "1.1.4.5", "rect": {"left": 402, "top": 392, "width": 132, "height": 58}}, {"word": "24 months", "rect": {"left": 534, "top": 392, "width": 251, "height":58}}, {"word": "", "rect": {"left": 785, "top": 392, "width": 78, "height":58}}, {"word": "4", "rect": {"left": 32, "top": 450, "width": 92, "height":56}}, {"word": "Contractor's Performance Bond Amount", "rect": {"left": 124, "top": 451, "width": 278, "height": 55}}, {"word": "4.2", "rect": {"left": 402, "top":450, "width": 132, "height": 56}}, {"word": "10% of the contract price", "rect": {"left": 534, "top": 450, "width": 251, "height": 56}}, {"word": "", "rect": {"left": 785, "top": 450, "width": 78, "height": 56}}, {"word": "5", "rect": {"left": 32, "top": 506, "width": 92, "height": 58}}, {"word": "Quality Standards", "rect": {"left": 124, "top": 506, "width": 278, "height": 58}}, {"word": "13.1", "rect": {"left": 402, "top": 506, "width": 132, "height": 58}}, {"word": "Qualified", "rect": {"left": 534, "top": 506, "width": 251, "height":58}}, {"word": "", "rect": {"left": 785, "top": 506, "width": 78, "height":58}}, {"word": "6", "rect": {"left": 32, "top": 564, "width": 92, "height":58}}, {"word": "Quality deposit withholding percentage", "rect": {"left": 124, "top": 564, "width": 278, "height": 58}}, {"word": "17.4.1", "rect": {"left": 402, "top":564, "width": 132, "height": 58}}, {"word": "3%", "rect": {"left": 534, "top": 564, "width": 251, "height": 58}}, {"word": "", "rect": {"left": 785, "top": 564, "width": 78, "height": 58}}]}.

[0024] like Figure 4 As shown, the table header is found according to the table structure, and the cell text is filled into the corresponding table cell; the table header is found according to the table structure and text content, and the identified cell text information is filled into the corresponding table cell to complete the sorting and filling of the table content.

[0025] Table header content dictionary construction: Get the approximate character content of the table header manually or by analyzing the table header data in the historical table; Table format analysis: top-bottom structure, left-right structure. Obtain the table format by classifying and analyzing the contents of the first few rows of the table and comparing the table header contents with the dictionary; Get the header information, and compare the table format and header content dictionary to get the approximate content of the table header; Supplement the content across rows and columns of the table. According to the table constructed by row and column segments, calculate the position of the table across rows and columns and position it, and fill the content from top to bottom and from left to right. Structural data is sorted according to table format content and header information.

[0026] like Figure 5As shown, the structured extraction results of the bid letter appendix table are as follows, [{"Serial number":"1","Clause content":"Project manager","Contract clause number":"1.1.2.4","Agreed content":"Name:","Remarks":""}],[{"Serial number":"1","Clause content":"Project manager","Contract clause number":"1.1.2.4","Agreed content":"Constructor registration certificate level: Level 1 major: Construction engineering","Remarks":""}],[{"Serial number":"1","Clause content":"Project manager","Contract clause number":"1.1.2.4","Agreed content":"Registration certificate number: 13120","Remarks":""}],[{"Serial number":"2","Clause content":"Construction period","Contract clause number":"1.1.4.3","Agreed content ":"760 days","Remarks":""}],[{"Serial number":"3","Clause content":"Defect liability period","Contract clause number":"1.1.4.5","Agreed content":"24 months","Remarks":""}],[{"Serial number":"4","Clause content":"Contractor's performance guarantee amount","Contract clause number":"4.2","Agreed content":"10% of the contract price","Remarks":""}],[{"Serial number":"5","Clause content":"Quality standard","Contract clause number":"13.1","Agreed content":"Qualified","Remarks":""}],[{"Serial number":"6","Clause content":"Percentage of quality deposit withheld","Contract clause number":"17.4.1","Agreed content":"3%","Remarks":""}].

[0027] Embodiment three: like Figure 6 As shown, this embodiment provides a chart and table content extraction system based on an OCR engine, and the specific architecture is: a document format conversion module, a table detection module, a row and column line segment detection module in the table, a table cell discovery module, and a table content structured conversion module; the system is used to execute the described chart and table content extraction method based on an OCR engine.

Claims

1. A method for extracting content from a chart or table based on an OCR engine, characterized in that: The following steps are involved: S1, convert the tender document file in pdf format into an image file; S2, identifying the table in the tender image file through object detection; S3, detect and identify the rows and columns in the table through the yolov5 line segment detection algorithm, and record their starting positions; S4, discover the table cell through the row and column segments, and intercept the cell position and save the cell image; S5, use OCR recognition to perform text recognition on the cell image to obtain cell text information; S6, find the table header according to the table structure, and fill the cell text into the corresponding table cell.

2. The method for extracting contents of a chart or table based on an OCR engine according to claim 1, characterized in that: In step S1, the ffmpeg tool is used to convert the bid document file in pdf format into an image file; the pdf file is converted into an image format by inputting an appropriate command in the command line interface.

3. The method for extracting contents of a chart or table based on an OCR engine according to claim 1, characterized in that: In step S2, the table in the tender document image file is identified using the yolov5 target detection method; the table in the image is identified using the yolov5 target detection model to determine the position and boundary of the table.

4. The method for extracting contents of a chart or table based on an OCR engine according to claim 1, characterized in that: In step S3, the yolov5 line segment detection algorithm is used to detect the row and column line segments in the table, and the starting positions of the row and column line segments in the table are recorded and recorded for subsequent processing.

5. The method for extracting contents of a chart or table based on an OCR engine according to claim 4, characterized in that: In step S4, the table cell is discovered through row and column line segments, and the cell position is intercepted and the cell image is saved, including: Based on the detected row and column segments, the cells in the table are found, and the cell positions are captured and saved as separate image files for subsequent processing.

6. The method for extracting contents of a chart or table based on an OCR engine according to claim 1, characterized in that: In step S5, using OCR recognition to perform text recognition on the cell image, and obtaining the cell text information includes using OCR recognition to perform text recognition on the image of each cell to extract the text information in the cell.

7. The method for extracting contents of a chart or table based on an OCR engine according to claim 1, characterized in that: In step S6, the table header is found according to the table structure, and the cell text is filled into the corresponding table cell, including: According to the table structure and text content, the table header is found, and the identified cell text information is filled into the corresponding table cell to complete the sorting and filling of the table content. The specific method is as follows: The table header content dictionary is constructed by manually or by analyzing the table header data in the historical table to obtain the approximate character content of the table header; Table format analysis: analyze the upper and lower structures and left and right structures of the table format; obtain the table format by classifying and analyzing the contents of the first few rows of the table and comparing the table header contents with the dictionary; Get the header information, and get the header content of the table based on the table format content and the dictionary comparison of the header content; Supplement the content across rows and columns of the table. According to the table constructed by row and column segments, calculate the position of the table across rows and columns and position it, and fill the content from top to bottom and from left to right. Structural data is sorted according to table format content and header information.

Citation Information

Patent Citations

  • Table data structuring method based on machine learning

    CN110362620A

  • OCR (Optical Character Recognition) method for contract with table

    CN111709349A

  • E-commerce table image recognition method and device based on deep learning

    CN117710999A

  • Table picture standardized output method based on deep learning

    CN118116021A

  • Systems and methods of transforming image data to product storage facility location information

    US20240119408A1