A PDF document recognition method based on the open-source Paddle framework
By combining the Paddle framework with PaddleOCR and OpenCV, the problems of missing detection boxes and low recognition accuracy in the process of recognizing PDF documents of insurance products were solved, achieving efficient and accurate text extraction and error correction, and reducing the cost of manual verification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies for recognizing insurance product PDF documents suffer from problems such as missing detection boxes, difficulty in adapting to different types of text, low recognition accuracy, and high manual proofreading costs.
A PDF document recognition method based on the open-source Paddle framework is adopted. It combines the pre-trained model of the PaddleOCR framework with the morphological operations of OpenCV to detect text blocks and perform layout analysis. The PDFPLUMBER tool is used for character extraction, and the difflib tool is used to generate comparison files for error correction.
It improves the accuracy and completeness of text detection, reduces the cost of manual verification, achieves efficient and accurate text extraction and error correction, adapts to different layouts, and improves recognition efficiency and accuracy.
Smart Images

Figure CN116740723B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of text recognition, and particularly relates to a PDF document recognition method based on an open-source Paddle framework. BACKGROUND
[0002] Nowadays, the number of people purchasing insurance products is significantly increasing, and with the rapid development of the insurance industry, the number of insurance products is increasing, and for insurance companies, the massive insurance product PDF documents need an efficient management method. The content of the insurance product PDF document is rich and the form is various, and most insurance companies can only manually process the data by manpower, but the traditional manual insurance product file data sorting method is tedious and boring, the workload is huge, and the accuracy of manual input cannot be guaranteed, and a large amount of manual proofreading is required after sorting, which is very low in efficiency.
[0003] The development of OCR technology greatly improves the recognition and input efficiency of insurance products, but the extraction of insurance product data needs to ensure a high accuracy, and how to ensure the accuracy of OCR recognition to reduce the cost of manual proofreading is a problem that needs to be solved at present. At present, there are some related schemes in related technologies, but these schemes have the following shortcomings:
[0004] (1) Low efficiency. The traditional text detection technology is difficult to adaptively adjust the detection frame to cope with different types of text, and although the deep learning technology can adjust through adaptive threshold, there is a problem of missing detection frame.
[0005] (2) It is difficult to adaptively and structurally extract different plate-type documents, and the efficiency is low.
[0006] (3) There are still many errors in the recognized text, resulting in high cost in the final verification. SUMMARY
[0007] In order to solve the above problems existing in the related technology, the present application provides a PDF document recognition method based on an open-source Paddle framework. The technical problems to be solved by the present application are solved by the following technical solutions:
[0008] The present application provides a PDF document recognition method based on an open-source Paddle framework, comprising:
[0009] Obtaining a PDF document to be recognized;
[0010] Detecting the text blocks of each page in the PDF document through the pre-trained text detection model and the pre-trained character recognition model of the PaddleOCR framework, and the morphological operation and projection segmentation of OpenCV, to obtain a text block list of the PDF document;
[0011] recognize a class of a text region of each page in the PDF document through a pre-trained layout analysis model of a PaddleOCR framework, to obtain a text region list of the PDF document;
[0012] determine OCR recognized text of the PDF document according to the text block list and the text region list;
[0013] determine PDF recognized text of the PDF document based on the text region list and a character extraction tool;
[0014] generate a comparison file according to the OCR recognized text and the PDF recognized text; the comparison file is used to describe different parts between the OCR recognized text and the PDF recognized text.
[0015] The present application has the following beneficial technical effects:
[0016] 1. Good text detection effect, complete detection frame. In the aspect of text detection, the present application combines the high precision and high detection efficiency of DBNet of the lightweight deep learning model of the PaddleOCR framework and is assisted by the morphological method of OpenCV, which makes up for the possible problems of the deep learning model and the traditional method, and improves the accuracy and integrity of text detection.
[0017] 2. High universality and efficiency. The present application uses the deep learning pre-training model of the PaddleDetection framework as a layout analysis model, which does not need large parameter structures and a large amount of data training, and can train the layout analysis model using a small amount of insurance product document picture data labeled by itself, so as to obtain a better model that can cope with different layouts of insurance product documents and does not need to pre-set a matching template to extract structured text with higher efficiency.
[0018] 3. Low text correction cost. The present application compares and corrects the two results obtained by the OCR recognition method and the PDF recognition method with each other, which can perform full-text character correction. At the same time, a comparison file with marks is generated, which reduces the cost of manual checking while ensuring the accuracy of the text, and has high practical application value.
[0019] The present application will be further described in detail below in combination with the drawings and embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 a flowchart of a PDF document recognition method based on an open source Paddle framework provided by an embodiment of the present application;
[0021] Figure 2A flowchart of an exemplary OCR recognition method provided for an embodiment of the present application is shown in FIG. 1.
[0022] Figure 3 A flowchart of an exemplary PDF recognition method provided for an embodiment of the present application is shown in FIG. 2.
[0023] Figure 4 A flowchart of an exemplary contrast error correction method provided for an embodiment of the present application is shown in FIG. 3.
[0024] Figure 5 A general structure diagram of an exemplary PDF document recognition method based on an open source Paddle framework provided for an embodiment of the present application is shown in FIG. 4. DETAILED DESCRIPTION
[0025] The present application will be further described below in conjunction with specific embodiments, but the embodiments of the present application are not limited thereto.
[0026] In the description of the present application, the terms“first”,“second”, etc. are used only for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with“first”,“second” can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of“multiple” is two or more, unless otherwise specifically limited.
[0027] In the description of the present application, the description of the terms“one embodiment”,“some embodiments”,“example”,“specific example”, or“some examples” means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In the description of the present application, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in the specification.
[0028] Although the present application is described herein in conjunction with various embodiments, other variations of the disclosed embodiments can be understood and implemented by those skilled in the art with reference to the drawings, the disclosure, and the appended claims. In the claims, the word“comprising” does not exclude other components or steps, and“a” or“one” does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. Some measures described in mutually different dependent claims can be combined and produce good results. The application is not limited to the embodiments described herein, but can vary and be practiced within the scope of the appended claims. The application covers all technical equivalents that perform substantially the same function, have substantially the same results, and operate in substantially the same way, and are within the scope of the claims.
[0029] The existing solutions and their deficiencies in the related art are described as follows:
[0030] The patent document with the application number 201910436587.3 discloses a PDF file analysis method based on tesseract-ocr. The method converts the PDF file into a picture sequence using the fitz tool kit, and uses tesseract-ocr to extract, recognize and correct the pictures and tables in the picture. The deficiency of this solution is that it can only correct the table, and does not correct the remaining possible error text area, so the accuracy of the entire PDF file recognition cannot be guaranteed.
[0031] The patent document with the application number 202010493630.2 provides an insurance policy recognition method and device, and a computer equipment, which relates to the insurance policy recognition technical field, and solves the technical problem of low accuracy of insurance policy recognition for various types of insurance policy pages. The deficiency of this solution is that the recognition method for different page insurance policies is to match the various pre-set pages. If a new page is encountered, it cannot be adapted and needs to be re-set, which is low in efficiency.
[0032] The patent document with the application number 202210550788.8 discloses a PDF recognition method based on OCR recognition. The method calls multiple OCR recognition technologies to recognize each byte of the target PDF document, obtains the string recognized by each byte in the target PDF document by each OCR recognition technology, and selects the optimal byte string corresponding to the i-th byte according to the preset, outputs all byte optimal byte strings according to the byte sequence of the target PDF document, and obtains the recognition result of the target PDF document. The deficiency of this patent is that multiple OCR recognition technologies are called, which is low in recognition efficiency when facing massive data, and there is no effective error correction method to ensure the reliability of the OCR recognition result.
[0033] Figure 1 is a flowchart of the PDF document recognition method based on the open source Paddle framework provided by the embodiment of the present application, as shown in Figure 1 The method comprises the following steps:
[0034] S101, acquiring a PDF document to be recognized.
[0035] Here, the PDF document to be recognized can be any PDF document, for example, it can be a PDF document of an insurance product, or a PDF document of a scheme design, etc.
[0036] S102, detecting the text blocks of each page in the PDF document through the pre-trained text detection model and the pre-trained character recognition model of the PaddleOCR framework, and the morphological operation and projection segmentation of OpenCV, to obtain a text block list of the PDF document.
[0037] Here, S102 can be implemented by the following steps:
[0038] S1021, converting the PDF document into pictures and pre-processing each picture.
[0039] For example, a 20-page insurance product PDF document can be converted into 20 pictures, and then grayscale and binarization operations can be performed on each picture. The grayscale and binarization operations convert a colorful picture into a picture with only black and white colors through OpenCV, thereby excluding interference factors such as light and shadow, color, and watermark in the picture.
[0040] S1022, detecting the text blocks in each pre-processed picture through the pre-trained text detection model of the PaddleOCR framework, to obtain first text blocks and first text block information.
[0041] Here, the pre-trained text detection model can be a pre-trained DBNet model. The pre-trained DBNet text detection model of the PaddleOCR framework can be used to detect the text in each pre-processed picture, to obtain the coordinates of each text detection box in the picture. The text detection box detected by the DBNet text detection model is referred to as a first text block, and the coordinates of the first text block in the picture are referred to as first text block information.
[0042] S1023, detecting the text blocks in each pre-processed picture through the morphological operation and projection segmentation of OpenCV, to obtain second text blocks and second text block information.
[0043] Here, the text area in each pre-processed picture can be dilated through the morphological operation of OpenCV, and each dilated area can be projected horizontally and vertically according to the pixel value, to segment the text blocks through the projection value, and to obtain the coordinates of each text block. The text block detected by the morphological operation and projection segmentation of OpenCV is referred to as a second text block, and the coordinates of the second text block in the picture are referred to as second text block information.
[0044] S1024, performing text recognition on each first text block and each second text block through the pre-trained character recognition model of the PaddleOCR framework, to obtain a recognition result.
[0045] Here, the pre-trained character recognition model can be a pre-trained CRNN character recognition model, and the pre-trained CRNN character recognition model can be used to perform text recognition on each first text block and each second text block respectively to obtain the recognition result of each first text block and the recognition result of each second text block; wherein the recognition result of each first text block includes: the characters contained in the first text block, the coordinates of the first text block in the picture where it is located, and the confidence of the first text block; and the recognition result of each second text block includes: the characters contained in the second text block, the coordinates of the second text block in the picture where it is located, and the confidence of the second text block.
[0046] S1025, according to the recognition result, the first text block information and the second text block information, comparing and aligning the first text block and the second text block to obtain the target text block in each pre-processed picture and the target text block total information; wherein the target text block total information in each pre-processed picture constitutes the text block list of the PDF document.
[0047] Specifically, for each pre-processed picture, determine the difference between the coordinates of each first text block in the picture and the coordinates of each second text block in the picture; according to the difference, the preset threshold, the confidence of each first text block and the confidence of each second text block, filter out the first text block or the second text block from the set consisting of the first text block and the second text block in the picture as the target text block in the picture; for each target text block, the coordinates of the target text block and the characters contained in the target text block are taken as the target text block total information of the target text block.
[0048] Specifically, the difference is the difference between the ordinate, and the target text block in each picture can be determined by the following method: for the first first text block in the picture, it is judged whether there is a target second text block in all second text blocks in the picture, the difference between the ordinate of the first first text block and the ordinate of the target second text block is less than the preset threshold, if there is, the first first text block and the target second text block with high confidence are taken as a target text block in the picture, and the remaining second text blocks in the picture are obtained; if not, the first first text block is taken as a target text block in the picture, and the remaining second text blocks in the picture are obtained; for the second first text block in the picture, it is judged whether there is a target second text block in the remaining second text blocks in the picture, the difference between the ordinate of the second first text block and the ordinate of the target second text block is less than the preset threshold, if there is, the second first text block and the target second text block with high confidence are taken as a target text block in the picture, and the updated remaining second text blocks in the picture are obtained; if not, the second first text block is taken as a target text block in the picture, and the updated remaining second text blocks in the picture are obtained, and so on for each first text block in the picture, until the processing of the last first text block in the picture is completed, all target text blocks in the picture are obtained.
[0049] Through the above processing process, the morphological operation of OpenCV and the text block detected by projection segmentation are used to supplement the possible omissions of DBNet text detection, and the adjustment of the text block sticking problem existing in morphological text detection is realized.
[0050] S103, through the pre-trained layout analysis model of the PaddleOCR framework, the category of the text area of each page in the PDF document is recognized, and the text area list of the PDF document is obtained.
[0051] Here, the layout analysis model is obtained by training a target detection pre-trained model of the PaddleOCR framework using multiple PDF sample files, wherein each PDF sample file has annotation information in each page, and the annotation information describes at least the position of each title, the position of the main text and the position of the footnote in the text content of the page.
[0052] Illustratively, the layout analysis model can be a PP-PicoDet model.
[0053] In some embodiments, the above S103 can be implemented by the following steps:
[0054] S1031, identify the category of each text region in each pre-processed picture through the pre-trained PP-PicoDet model of the PaddleOCR framework, and obtain the coordinates and category of each text region in the picture.
[0055] For example, the category of each text region can be title, body, or footnote, etc.
[0056] S1032, store the coordinates and categories of all text regions in the picture in a list according to the order of the coordinates, and obtain a text region list of the picture.
[0057] S1033, according to the order of the pictures obtained by converting the PDF document, combine the text region lists of the pictures to obtain a text block list of the PDF document.
[0058] S104, determine the OCR recognized text of the PDF document according to the text block list and the text region list.
[0059] Here, the text block list of the PDF document includes the coordinates of each target text block in each page of the PDF document; the text region list of the PDF document includes the coordinates of each text region in each page of the PDF document, and the category of each text region; based on this, S104 can be specifically implemented as: for each page of the PDF document, according to the coordinates of each target text block of the page and the coordinates of each text region of the page, determine the text region to which each target text block of the page belongs, and take the category of the text region as the category of the target text block; put the target text blocks belonging to the same category in the same first category list according to the order of the coordinates of the target text blocks, and obtain multiple first category lists of the page; combine the multiple first category lists according to the categories corresponding to the multiple first category lists, and obtain the OCR recognized text of the page; combine the OCR recognized texts of the pages according to the page numbers of the pages of the PDF document, and obtain the OCR recognized text of the PDF document.
[0060] For example, the method for obtaining the OCR recognized text of the PDF document is as follows:
[0061] S1, extract the text blocks of the category of title into a new list, and if it is known from the vertical coordinates of the text blocks that a title text block contains multiple lines of text, then according to the coordinates of the text in the text block, determine the order of merging, and merge the title text scattered into multiple lines within a text block into one line.
[0062] S2, extract the text blocks of the category of body into a new list, add the list of title text blocks obtained in S1 to obtain a mixed list of title and body, and sort the text blocks according to the coordinates to obtain a text list consistent with the order of the original document.
[0063] S3. Extract the text blocks classified as footnotes separately into a new list, sort the footnote text blocks according to their coordinates, and add the sorted footnote text blocks to the text list obtained in S2 that is in the same order as the original document, thus obtaining the final complete OCR recognition text list.
[0064] The above steps S101 to S104 can be referred to as an OCR recognition method, for example, Figure 2 For an exemplary description of the OCR recognition method described in steps S101 to S104, see below. Figure 2 As shown, after inputting a PDF document (i.e., PDF data), firstly, each page of the PDF document is converted into an image and processed using image preprocessing methods. Then, OpenCV morphological operations and projection segmentation methods, as well as the DBNet model based on PaddleOCR, are used to perform text detection on each preprocessed image. Next, the detection results from both methods are fused. Then, based on the detection boxes, the CRNN model based on the PaddleOCR framework is used to perform text recognition on the fused detection results (the aforementioned target text blocks). Secondly, the PP-Picodet layout analysis model of the PadddleDetermination framework is trained using PDF sample files, and the trained PP-Picodet layout analysis model is used to perform layout analysis on each preprocessed image, obtaining the category and coordinates of each text region in each preprocessed image. Based on the obtained category and coordinates of each text region in each preprocessed image, the aforementioned fused detection results are classified and processed to obtain the OCR-recognized text of the PDF document (i.e., text recognized by the OCR method).
[0065] S105. Based on the text region list and character extraction tool, determine the PDF recognition text of the PDF document.
[0066] For example, a character extraction tool could be a PDFPLUMBER tool.
[0067] Specifically, the character extraction tool can be used to extract characters in each page of the PDF document and coordinates of each character; for each page of the PDF document, according to the coordinates of each character of the page and the coordinates of each text area of the page, determine the text area to which each character of the page belongs, and take the category of the text area to which the character belongs as the category of the character; put the characters belonging to the same category in the same second category list according to the order of the coordinates of the characters in the page, and obtain multiple second category lists of the page; combine the multiple second category lists according to the categories corresponding to the multiple second category lists, and obtain the PDF recognition text of the page; and combine the PDF recognition texts of the pages according to the page numbers of the pages of the PDF document, and obtain the PDF recognition text of the PDF document.
[0068] Step S105 can be referred to as a PDF recognition method, and an example of the flow of the PDF recognition method is shown in FIG. 5. Figure 3 For an example description of the flow of the PDF recognition method described in step S105, as shown in FIG. 5, after inputting the PDF document (i.e., PDF data), the text is extracted by the PDFPLUMBER tool, and then the structure of the text extracted by the PDFPLUMBER tool is adjusted according to the results obtained by the layout analysis in the OCR recognition method, so as to classify and process different types of text, and obtain the PDF recognition text of the PDF document (PDF method recognition text). Figure 3
[0069] S106, generating a comparison file according to the OCR recognition text and the PDF recognition text; the comparison file is used to describe different parts between the OCR recognition text and the PDF recognition text.
[0070] Specifically, the text similarity between the OCR recognition text and the PDF recognition text can be calculated line by line by a comparison tool (for example, the difflib tool), and the text similarity of each line is obtained; for each line, when the text similarity of the line is greater than or equal to a preset similarity threshold, and there are different characters at the same position in the line in the OCR recognition text and the PDF recognition text, the character at the position in the line in the OCR recognition text is replaced by the character at the position in the line in the PDF recognition text; when the text similarity of the line is less than the preset similarity threshold, the text in the line in the OCR recognition text and the PDF recognition text is marked respectively; and the comparison file is generated according to the marking.
[0071] Here, when marking, different marking methods can be used in the OCR recognition text and the PDF recognition text, for example, different parts are marked by different colors.
[0072] Here, the generated comparison file can be an HTML format comparison file. For example, in the HTML file, the different parts in the OCR recognized text and the PDF recognized text are marked with green highlights and red highlights respectively, so as to highlight the different parts in the two text files, so that during manual checking, only the highlighted parts need to be focused on, and the efficiency of manual checking can be improved.
[0073] Exemplarily, the comparison file can be generated by the following method:
[0074] S11, compare the texts obtained by the two methods line by line through the difflib tool, and if the similarity reaches a set threshold, the current line of the two texts is regarded as the same line that can be compared and corrected, and the different characters in the same line are marked with ‘\0^’ characters. If the similarity of two or more consecutive lines is low, ‘\0+’ or ‘\0-’ characters are used to mark the consecutive lines in the texts obtained by the two methods respectively, to represent the increased or decreased lines (such marking is considered as the difference in the formats recognized by the two methods);
[0075] S12, for the marked characters in the same line, the characters obtained by the PDF recognition method are used to replace the results in the OCR recognition method, and the ‘\0^’ character marking is removed. For the consecutive line marking, the format of the OCR recognition method is used, and the character marking is not removed;
[0076] S13, generate an HTML format comparison file, wherein the unremoved character markings ‘\0+’ and ‘\0-’ are used to perform green highlighting and red highlighting on the texts obtained by the two methods in the HTML file, so as to highlight the different parts in the texts obtained by the two methods, so that during manual checking, only the highlighted parts need to be focused on, and the efficiency of manual checking is improved.
[0077] Step S106 can be referred to as a comparison correction method, exemplarily, Figure 4 For an exemplary description of the flow of the comparison correction method described in step S106. As Figure 4 shown, the OCR recognized text and the PDF recognized text of the input PDF file are compared line by line through the difflib tool, the differences in the two texts are marked, then the OCR recognized text is corrected based on the PDF recognized text (the accuracy of the character extraction by the tool used for PDF recognition is extremely high) to improve the accuracy of the characters, and finally an HTML comparison file with highlighted different parts is generated, improving the efficiency of manual checking.
[0078] According to the above content, as Figure 5As shown, the PDF document recognition method based on the open source Paddle framework provided by the present application is composed of an OCR recognition method, a PDF recognition method and a comparison correction method.
[0079] In this embodiment, based on the deep learning PaddleOCR framework, OpenCV is used as an auxiliary for text detection to prevent detection omission and ensure the accuracy, efficiency and reliability of text detection. Moreover, the layout analysis model is trained by the PaddleDetection framework, which can efficiently and accurately extract structured text. Finally, the two results obtained by the OCR recognition method and the PDF recognition method are compared and corrected with each other to generate a comparison file with marks, which improves the final recognition accuracy and reduces the cost of manual checking, and has high practical application value.
[0080] The above is a further detailed description of the present application in combination with a specific preferred embodiment, and the specific implementation of the present application should not be limited to these descriptions. For ordinary skilled persons in the technical field to which the present application belongs, a number of simple deductions or substitutions can be made without departing from the concept of the present application, and all of them should be regarded as falling within the protection scope of the present application.
Claims
1. A PDF document recognition method based on an open source Paddle framework, characterized in that, The method comprises: acquiring a PDF document to be identified; detecting text blocks of each page in the PDF document by using a pre-trained text detection model and a pre-trained character recognition model of a PaddleOCR framework and morphological operations and projection segmentation of OpenCV to obtain a text block list of the PDF document; identifying a category of a text area of each page in the PDF document by using a pre-trained layout analysis model of the PaddleOCR framework to obtain a text area list of the PDF document; determining OCR-recognized text of the PDF document according to the text block list and the text area list; determining PDF-recognized text of the PDF document based on the text area list and a character extraction tool; generating a comparison file according to the OCR-recognized text and the PDF-recognized text; the comparison file is used to describe different parts between the OCR-recognized text and the PDF-recognized text; wherein the detecting of the text blocks of each page in the PDF document by using the pre-trained text detection model and the pre-trained character recognition model of the PaddleOCR framework and the morphological operations and projection segmentation of OpenCV to obtain the text block list of the PDF document comprises: converting the PDF document into pictures and pre-processing each picture; detecting text blocks in each pre-processed picture by using the pre-trained text detection model of the PaddleOCR framework to obtain first text blocks and first text block information; the first text block information is coordinates of the first text blocks; detecting text blocks in each pre-processed picture by using the morphological operations and projection segmentation of OpenCV to obtain second text blocks and second text block information; the second text block information is coordinates of the second text blocks; performing text recognition on each first text block and each second text block respectively by using the pre-trained character recognition model of the PaddleOCR framework to obtain recognition results; the recognition result of the first text block is characters contained in the first text block and a confidence degree of the first text block, and the recognition result of the second text block is characters contained in the second text block and a confidence degree of the second text block; for each pre-processed picture, determining a difference value between the coordinates of each first text block in the picture and the coordinates of each second text block in the picture; the difference value is a difference value between vertical coordinates; for a first first text block in the picture, determining whether there is a target second text block with a difference value between a vertical coordinate of the target second text block and a vertical coordinate of the first first text block less than a preset threshold in all second text blocks in the picture, if there is, taking a text block with a higher confidence degree from the first first text block and the target second text block as a target text block in the picture, and obtaining remaining second text blocks in the picture, and if there is not, taking the first first text block as a target text block in the picture, and obtaining remaining second text blocks in the picture. For the second first text block in the picture, it is judged whether there is a target second text block in the remaining second text blocks in the picture, the difference between the vertical coordinates of which and the vertical coordinates of the second first text block is less than the preset threshold value. If there is, the text block with higher confidence in the second first text block and the target second text block is taken as a target text block in the picture, and the updated remaining second text blocks in the picture are obtained. If there is not, the second first text block is taken as a target text block in the picture, and the updated remaining second text blocks in the picture are obtained. In this way, each first text block in the picture is processed in turn until the processing of the last first text block in the picture is completed, and all target text blocks in the picture are obtained. For each target text block, the coordinates of the target text block and the characters contained in the target text block are taken as the target text block total information of the target text block. The target text block total information of each target text block in each preprocessed picture constitutes the text block list of the PDF document.
2. The PDF document recognition method based on the open source Paddle framework according to claim 1, characterized in that, Before the layout analysis model pre-trained by the PaddleOCR framework is used to identify the category of the text area of each page of the PDF document, and the text area list of the PDF document is obtained, the method further comprises: Obtain a plurality of PDF sample files, each page of each PDF sample file has annotation information, and the annotation information is used to describe at least the position of each title, the position of the main text, and the position of the footnote in the text content of the page; Train the target detection pre-training model of the PaddleOCR framework using the plurality of PDF sample files to obtain the layout analysis model.
3. The PDF document recognition method based on an open-source Paddle framework according to claim 1, characterized in that, The generation of the comparison file according to the OCR recognized text and the PDF recognized text comprises: Calculate the text similarity between the OCR recognized text and the PDF recognized text line by line through a comparison tool to obtain the text similarity of each line; For each line, when the text similarity of the line is greater than or equal to a preset similarity threshold, and there are different characters at the same position in the line of the OCR recognized text and the PDF recognized text, replace the character at the position of the line in the OCR recognized text with the character at the position of the line in the PDF recognized text; When the text similarity of the line is less than the preset similarity threshold, label the text of the line in the OCR recognized text and the PDF recognized text respectively; Generate a comparison file according to the labeling.
4. The PDF document recognition method based on the open source Paddle framework according to claim 1, characterized in that, The text block list of the PDF document comprises the coordinates of each target text block in each page of the PDF document; and the text area list of the PDF document comprises the coordinates of each text area in each page of the PDF document and the category of each text area. The determination of the OCR recognized text of the PDF document according to the text block list and the text area list comprises: For each page of the PDF document, according to the coordinates of each target text block of the page and the coordinates of each text region of the page, determine the text region to which each target text block of the page belongs, and take the category of the belonging text region as the category of the target text block; Put the target text blocks belonging to the same category in the page into the same first category list according to the order of the coordinates of the target text blocks, to obtain multiple first category lists of the page; According to the categories corresponding to the multiple first category lists, combine the multiple first category lists to obtain the OCR recognized text of the page; According to the page numbers of the pages of the PDF document, combine the OCR recognized texts of the pages to obtain the OCR recognized text of the PDF document.
5. The PDF document recognition method based on the open source Paddle framework according to claim 1, characterized in that, The text region list includes the coordinates of each text region in each page of the PDF document and the category of each text region; The determination of the PDF recognized text of the PDF document based on the text region list and the character extraction tool includes: Extracting characters and coordinates of each character in each page of the PDF document by using a character extraction tool; For each page of the PDF document, according to the coordinates of each character of the page and the coordinates of each text region of the page, determine the text region to which each character of the page belongs, and take the category of the belonging text region as the category of the character; Put the characters belonging to the same category in the page into the same second category list according to the order of the coordinates of the characters, to obtain multiple second category lists of the page; According to the categories corresponding to the multiple second category lists, combine the multiple second category lists to obtain the PDF recognized text of the page; According to the page numbers of the pages of the PDF document, combine the PDF recognized texts of the pages to obtain the PDF recognized text of the PDF document.
6. The PDF document recognition method based on an open-source Paddle framework according to claim 1, characterized in that, The layout analysis model is a PP-PicoDet model; The identification of the categories of the text regions of each page in the PDF document by the pre-trained layout analysis model of the PaddleOCR framework includes: Identifying the category of each text region in each preprocessed picture by the pre-trained PP-PicoDet model of the PaddleOCR framework to obtain the coordinates and category of each text region in the picture; Store the coordinates and categories of all text regions in the picture in a list according to the order of the coordinates to obtain the text region list of the picture; According to the order of the pictures obtained by converting the PDF document, combine the text region lists of the pictures to obtain the text block list of the PDF document.
7. The PDF document recognition method based on an open-source Paddle framework according to claim 1, characterized in that, The text detection model is a DBNet model, and the character recognition model is a CRNN model.
Citation Information
Patent Citations
Method for analyzing pdf file based on tesseract-ocr
CN110188649A
Insurance policy identification method and device and computer equipment
CN111666868A
PDF identification method based on OCR identification
CN114973248A
Method and device for removing handwritten content in text image, and storage medium
CN111488881A
Text recognition method and device and character recognition method and device
CN112990172A