A method for automatically identifying and parsing complex flowcharts in PDF
Through the combination of Faster R-CNN and NetworkX, automatic recognition and analysis of complex flow charts in PDF are realized, solving the problem of insufficient flow chart recognition capabilities in the existing technology, improving the recognition efficiency and building a stable and practical Point to the network of relationships.
Patent Information
- Application Number
- CN202110082098.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-21
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-01-21
AI Technical Summary
The existing technology lacks the ability to automatically identify and parse flowcharts in PDF documents, especially in the processing of complex flowcharts, and research is relatively weak.
Faster R-CNN is used to extract the coordinates of the required block diagram in the picture, and OCR is used to determine the pointing relationship between entities. The complex network analysis library NetworkX is used to build a complex network of pointing relationships to achieve automatic identification and analysis of complex flow charts in PDFs. .
This method can accurately and objectively identify the flow direction of the flow chart, improve the identification efficiency, reduce the workload of Faster R-CNN, and build a pointing relationship network with stability and practicality.
Smart Images

Figure CN113343744B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of image recognition processing, and relates to an automatic recognition and parsing method for solving complex flow charts in PDF. Background Art
[0002] Image recognition technology is an important field in artificial intelligence. It is the basis of stereoscopic vision, motion analysis, data fusion and other fields and has important application value. At present, image target recognition for license plates, faces, pedestrians and other features is relatively mature. The study of text is another important field of artificial intelligence. At present, the study of text is based on existing texts, and the research direction is mainly on word meaning conversion, word frequency statistics and other aspects.
[0003] However, the current development of PDF image recognition, text parsing and other aspects is narrow, and the research is limited to pure text or highly unified weak image analysis such as PDF text key information segmentation, text paragraph information extraction, table information processing, etc. There are very few studies on the extraction and analysis of important relationship diagrams in PDF.
[0004] In addition, current research on PDF at home and abroad is about PDF format archiving, format analysis, document video addition, locating specific locations, and image synthesis into PDF. There is no research on the technology of parsing relationship graphs in PDF. Summary of the invention
[0005] The purpose of the present invention is to provide a method for automatically identifying and parsing complex flowcharts in PDF documents, thereby solving the problem of lack of recognition of flowcharts in PDF documents in the prior art.
[0006] The present invention provides a method for automatically identifying and parsing complex flow charts in PDF, which is specifically implemented according to the following steps:
[0007] Step 1: Process the initial document;
[0008] Step 2: Extract the coordinates of the required frame in the image based on Faster R-CNN;
[0009] Step 3: Determine the pointing relationship between entities based on the coordinates obtained in step 2 and OCR;
[0010] Step 4: Build a complex network of pointing relationships based on the complex network analysis library NetworkX.
[0011] Step 1 is implemented according to the following steps:
[0012] The initial PDF document is denoted as A, the filtering condition function is denoted as L(x), and the remaining required part of the initial document after passing through the filtering condition function is denoted as B, B=L(A); then, the image conversion function is denoted as H(x), and the image after the initial document passes through the filtering condition function and then through the image conversion function is denoted as C, C=H(B).
[0013] Step 2 is as follows:
[0014] Step 2.1, use the convolutional layer to extract image features;
[0015] Step 2.2, using the RPN network layer to obtain the candidate matrix region;
[0016] Step 2.3: In the region of interest pooling layer, the input image sizes of different sizes are converted into fixed-length output collections;
[0017] Step 2.4: Use the feature map PFM in step 2.3 to calculate the category of the candidate area, and at the same time, use the bounding box regression again to obtain the final precise position of the entity class, percentage class, and arrow class detection box in the flowchart.
[0018] Step 3 is specifically as follows:
[0019] Step 3.1, pre-process the image by whitening it according to entity class and percentage class;
[0020] Step 3.2, refine the process pointing line segment;
[0021] Step 3.3, find the pointing and pointed relationships between entities;
[0022] Step 3.4: Find the corresponding percentages on the paths between objects with pointing relationships, and bind the paths to their percentages.
[0023] Step 4 is as follows:
[0024] Step 4.1, build a node graph, create an empty graph G, add the entity coordinates in step 2 as nodes into graph G, and build node graph G1;
[0025] Step 4.2, construct a directed graph, according to the pointing relationship between entities obtained in step 3.3.3, add them as directions into the node graph G1 in sequence to connect the entity nodes, and obtain the basic directed graph G2;
[0026] Step 4.3: Construct a weighted directed graph. According to step 3.4, obtain the percentage of path binding between entities, regard it as a weight, add it to the directed graph G2, and finally form a directed weighted graph G3 of the holding process.
[0027] Step 3.2 is as follows:
[0028] Step 3.2.1, decompose and identify the image D in the form of lines;
[0029] Step 3.2.2, adjust the lines that have problems due to detection;
[0030] Step 3.2.3, determine the line ij The relationship between them, update the line segment table L0.
[0031] Step 3.3 is as follows:
[0032] Step 3.3.1. Compare entity coordinates with line ij Binding is done at the inner point;
[0033] Step 3.3.2: Process line segment ij The breakpoint problem on the board can be solved by bridging the breakpoints;
[0034] Step 3.3.3, based on the line segment table line segment L0, find the pointing relationship between entities and store the coordinates of the pointing path points.
[0035] Step 3.4 is as follows:
[0036] Step 3.4.1, construct a search range according to the order of point coordinates stored in the path table L3, and determine the path and its percentage;
[0037] Step 3.4.2: Screen the many-to-one bindings between the path and its percentage obtained in step 3.4.1, and remove redundant bindings until the path and its percentage are one-to-one bindings.
[0038] The beneficial effects of the present invention are:
[0039] The present invention, through the processing of files (L(x)) and pictures (H(x)), filters out documents such as plain text and converts flowchart pages into pictures, thereby reducing the working time of Faster R-CNN. By extracting the coordinates of the required target block diagram through Faster R-CNN, all types of target block diagram coordinates can be extracted at the same time, which improves the efficiency of identifying target coordinates in the image. Based on the extracted block diagram coordinates, the recognition of arrows and the recognition of text by OCR, the flow direction of the flowchart can be accurately and objectively obtained; on this basis, a complex network of pointing relationships is constructed according to the NetworkX library, and the proportion relationship between any two boxes flowing from the out-degree direction to the in-degree direction can be obtained. The whole process has considerable stability, visibility and practicality. . BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1It is a process diagram of automatically identifying and acquiring a target image and extracting required coordinates through Faster R-CNN in the method for automatically identifying and parsing a complex flowchart in PDF of the present invention;
[0041] Figure 2 This is a practical diagram of automatically identifying and acquiring target images and extracting required coordinates through Faster R-CNN in the method for automatically identifying and parsing complex flowcharts in PDF of the present invention;
[0042] Figure 3 It is an analysis image flow chart of the method for automatically identifying and parsing complex flow charts in PDFs according to the present invention, wherein the TR node represents the direction of the determined arrow, the TE node represents the test data, the CPNW represents the constructed complex network, and the directed edges between the five nodes represent the direction for the next step to be implemented;
[0043] Figure 4 It is a specific example diagram of the method for automatically identifying and parsing complex flow charts in PDF according to the present invention. DETAILED DESCRIPTION
[0044] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0045] like Figure 1 As shown in the figure, a method for automatically identifying and parsing complex flowcharts in PDF is provided. The specific steps are as follows:
[0046] Step 1: Process the initial document
[0047] Step 1 is as follows:
[0048] The initial PDF document is denoted as A, the filtering condition function is denoted as L(x), and the remaining required part of the initial document after passing through the filtering condition function is denoted as B, B=L(A); then, the image conversion function is denoted as H(x), and the image after the initial document passes through the filtering condition function and then through the image conversion function is denoted as C, C=H(B).
[0049] Step 2: Extract the coordinates of the required frame in the image based on Faster R-CNN
[0050] Step 2.1: Use the convolutional layer to extract image features:
[0051] The image C obtained after step 1 is extracted by the convolution layer in Faster R-CNN to obtain the multi-layer feature map of image C, which is recorded as FM i Represents the feature map of the i-th layer, n∈N + Represents the number of layers.
[0052] Step 2.2: Use the RPN network layer to obtain the candidate matrix region
[0053] Enter the value from step 2.1 The available candidate matrix regions are screened by the classifier of the RPN network layer, and the values of the available candidate matrix regions are corrected by border regression to obtain the precise candidate values of the regions. The candidate regions are recorded as: (RP i is the i-th candidate region, m∈N + ), and then send it to the region of interest pooling layer.
[0054] Step 2.3: Convert input images of different sizes into fixed-length outputs in the region of interest pooling layer: Input the image in step 2.1 The candidate region in step 2.2 The information of the two is combined to extract the feature map, which is recorded as PFM.
[0055] Step 2.4: Use the feature map PFM in step 2.3 to calculate the category of the candidate area, and at the same time, use the bounding box regression again to obtain the final precise position of the entity class, percentage class, and arrow class detection box in the flowchart.
[0056] To sum up, the process expression of step 2 is:
[0057]
[0058] The purpose of the classification layer is to calculate the specific category of each candidate box in the image, output the category score, and use box regression again to obtain the predicted offset value of each candidate area relative to the actual position, which is used to correct the candidate box and obtain a more accurate target detection box.
[0059] Step 3: Determine the pointing relationship between entities based on the coordinates obtained in step 2 and OCR
[0060] Step 3.1: Pre-process the image by whitening it based on entity class and percentage class
[0061] According to the coordinates of the entity class and percentage class identified in step 2, find the entity class and percentage class parts in image C, whiten them, and save the processed image as image D;
[0062]
[0063] This step facilitates the subsequent identification of line segments in the graph and the refinement of the line segments, but it will also cause a certain degree of impact, mainly in terms of percentage, which can be divided into the following categories:
[0064] Some percentage classes are located in the center of the line segment instead of the side. In this case, whitening the percentage class part will cause the line segment to be truncate.
[0065] Some percentage classes are located very close to the side of the line segment. In such a close situation, whitening the percentage class part will cause the line segment pixels to be damaged.
[0066] Some percentage classes may not be completely whitened when whitening, and the residual pixels around the line segments will become noise, affecting line segment recognition.
[0067] Step 3.2: Refine the process pointing line segment
[0068] Step 3.2.1: Decompose and identify image D in the form of lines
[0069] (a) Analyze the lines in image D, decompose them, and build a table based on line segments. Create a line segment table L0, which is initially empty and has a j×j shape.
[0070] <![CDATA[line i1 ]]> <![CDATA[line i2 ]]> <![CDATA[line i3 ]]> …… <![CDATA[line ij ]]> <![CDATA[line i1 ]]> null null null …… null <![CDATA[line i2 ]]> null null null …… null <![CDATA[line i3 ]]> null null null …… null <![CDATA[line i4 ]]> null null null …… null …… …… …… …… …… …… <![CDATA[line ij ]]> null null null …… null
[0071] (b) Each block is divided into lines and stored in the form of points after parsing.
[0072]
[0073] The specific decomposition and storage content of the coordinate set of lines in a single block are as follows:
[0074]
[0075] in The coordinates of the two endpoints of the line; lineD ij Used to indicate the direction of the line. The value is 0 or 1. 0 indicates a horizontal line and 1 indicates a vertical line. Used to indicate the state of the line, with values of 0 starting point, 1 ending point, 2 intersection point, and 3 breakpoint. All equal to 3;
[0076] The seven values obtained after decomposition are stored in the diagonal part of the line segment table L0. The storage form is a set of lines. At this time, the table is updated as follows:
[0077] <![CDATA[line i1 ]]> <![CDATA[line i2 ]]> <![CDATA[line i3 ]]> <![CDATA[line i4 ]]> …… <![CDATA[line ij ]]> <![CDATA[line i1 ]]> <![CDATA[line i1 ]]> null null null …… null <![CDATA[line i2 ]]> null <![CDATA[line i2 ]]> null null …… null <![CDATA[line i3 ]]> null null <![CDATA[line i3 ]]> null …… null <![CDATA[line i4 ]]> null null null <![CDATA[line i4 ]]> …… null …… …… …… …… …… …… …… <![CDATA[line ij ]]> null null null null …… <![CDATA[line ij ]]>
[0078] (c) Position the reference horizontal and vertical axis and adjust the line ij A collection of coordinates.
[0079] Set the slope error value to μ, calculate the slope of all stored line segments, compare their slopes with the slopes of the reference horizontal and vertical coordinate axes, modify the line segment set with slope error values within μ, and store the adjusted coordinate set after the slope is fine-tuned. The coordinate adjustment rule is: if it is a horizontal line, the value of the X coordinate remains unchanged, and the value of the second endpoint of the Y coordinate is changed to the value of the first point; if it is a vertical line, the value of the second endpoint of the X coordinate is changed to the value of the first point, and the value of the Y coordinate remains unchanged.
[0080] The expression is as follows:
[0081]
[0082] The data stored in the diagonal of the line segment table L0 is updated according to the expression.
[0083] Step 3.2.2: Adjust the lines that have problems due to detection
[0084] (a) According to the line segment type, the line segments are classified and stored in the horizontal line table L1 and the vertical line table L2, that is, the types stored in the table are parallel to each other, and this table is updated synchronously with the line segment table L0;
[0085] (b) Merge the parallel and close line segments with a certain degree of overlap;
[0086] Taking the first line segment in the horizontal line table or vertical line table as the benchmark, traverse the remaining line segments and merge the line segments that meet the conditions:
[0087] First, select the first line segment in the collection and delete the coordinates of this line segment in the original collection.
[0088] Next, we search for similar lines in the same category, and let the similarity be θ. Lines whose distances are within the similarity range are similar lines. Next, we determine whether similar lines overlap, and let the overlap ε be the overlap of the line segment coordinate range. The expression is:
[0089]
[0090] If the above two conditions are met, the selected line segment is merged with the line segment that meets the conditions. The merge is divided into two cases: horizontal line merge and vertical line merge. When merging horizontal lines, the left end points of the two line segments are taken. Minimum, right endpoint The maximum value of the vertical line is merged, and the minimum value of the upper end points of the two line segments is taken when merging. Lower endpoint Maximum value.
[0091] This is done to ensure that the longest distance between the two lines is taken when merging. At this time, the two points with the farthest distance among the four endpoints of the two line segments are the two endpoints of the new line segment. The expression is:
[0092] After traversing all the coordinates in the set, the line segments obtained by operating the line segments selected from the original set are stored in the new line segment set, and then the first line segment is taken from the original line segment set, and the above cycle is repeated until the original line segment set becomes empty. Finally, when the original line segment set is empty, the new line segment set is continued to be regarded as the original line segment set, and the above merging steps are performed several times until the line segment set becomes empty. This cycle is repeated many times until the sum of the original line segment set and the new line segment set is equal in length, and then the process ends.
[0093] (c) Update the line segment table L0 based on the adjusted line results.
[0094] Step 3.2.3, determine the line ij Relationship between them, update line segment table L0
[0095] Take a line in the horizontal line table in step 3.2.2 as the benchmark, traverse the vertical lines and the remaining lines based on this line, determine the relationship between these lines and write these relationships and their contents into the table, and so on, until all lines have been traversed, and update the line segment table L0 according to the relationships obtained through the traversal.
[0096] Therefore, the relationship between lines has been determined in this step, so line ij The endpoint states of some line segments in the can be updated, i.e., the diagonal There should be two values at this time, 2 and 3. 2 means that this point is an intersection, and 3 means that this point is a breakpoint.
[0097] Get the adjacency list:
[0098] <![CDATA[line i1 ]]> <![CDATA[line i2 ]]> <![CDATA[line i3 ]]> <![CDATA[line i4 ]]> <![CDATA[line i1 ]]> <![CDATA[line i1 ]]> 0 0 <![CDATA[(3,(x i1 ,and i1 ))]]> <![CDATA[line i2 ]]> 0 <![CDATA[line i2 ]]> <![CDATA[(2,(x i2 ,and i2 ))]]> 0 <![CDATA[line i3 ]]> 0 <![CDATA[(1,(x i3 ,and i3 ))]]> <![CDATA[line i3 ]]> 0 <![CDATA[line i4 ]]> <![CDATA[(2,(x i4 ,and i4 ))]]> 0 0 <![CDATA[line i4 ]]>
[0099] The meaning of its content is: there are four lines (line i1 , line i2 , line i3 , line i4 ), the value is the type of intersection, 0 means the two lines have nothing to do with each other, 1 means the intersection of the two lines is at the first endpoint of the line, 2 means the intersection of the two lines is at the second endpoint of the line, and 3 means the intersection of the two lines is between the lines.
[0100] The relationship between these four lines is:
[0101] First line: line i1 and line i4 Intersect, linei1 The intersection point is between the line segments, and the endpoint coordinates are (x i1 ,y i1 ); Second line: line i2 and line i3 Intersect, line i2 The intersection point is at the second endpoint, and the endpoint coordinates are (x i2 ,y i2 ); line 3: line i3 and line i2 Intersect, line i3 The intersection point is at the first endpoint, and the endpoint coordinates are (x i3 ,y i3 ); Line 4: line i4 and line i1 Intersect, line i4 The intersection point is at the second endpoint, and the endpoint coordinates are (x i4 ,y i4 ).
[0102] Step 3.3: Find the pointing and pointed relationships between entities
[0103] Step 3.3.1. Compare entity coordinates with line ij Inner point binding
[0104] (a) Store entity coordinates and arrow coordinates
[0105] The entity coordinates obtained based on step 3.2 are the coordinates of the top, bottom, left, and right points of the selected part. The specific coordinate set of the entity is:
[0106]
[0107] The form is the set of four points of the entity range coordinates: upper left, upper right, lower left, and lower right;
[0108] The arrow coordinates obtained in step 3.2 are the coordinates of the top, bottom, left, and right points of the selected part. The specific coordinate set of the arrow is:
[0109]
[0110] The form is the set of four points in the arrow range coordinates: upper left, upper right, lower left, and lower right;
[0111] (b) Find the starting point and end point of the line segment coordinates based on the entity coordinates
[0112] Assume that the approximate error value is ∈, traverse the coordinate range of the entity in point form, and compare it with the surrounding lines Line i Inner line segment line ijThe stored endpoints are compared for distance, and after finding the closest point between the entity and the line segment, a judgment is made:
[0113] If the coordinates of this point are on the line i If the point is within the coordinate range but not within the arrow coordinate range, the point is used as the starting point of the entity and the line segment line is aligned at the diagonal line in the line segment table L0. ij Make updates;
[0114] If the coordinates of this point are on Line i If the point is within the coordinate range and the arrow coordinate range, the point is taken as the end point of the entity and the line segment line is aligned at the diagonal line in the line segment table L0. ij to update.
[0115] At this time, the diagonal of There should be four values at this time, 0, 1, 2, and 3. When it is equal to 0, it means that this point is the starting point, when it is equal to 1, it means that this point is the ending point, when it is equal to 2, it means that this point is the intersection point, and when it is equal to 3, it means that this point is the breakpoint.
[0116] Step 3.3.2: Process line segment ij The breakpoint problem on the
[0117] First, find the breakpoint in the line segment table L0, regard this breakpoint as the original breakpoint, determine whether the line segment where the original breakpoint is located is a horizontal line or a vertical line, find the nearest percentage based on the coordinates of this breakpoint, and use the found percentage as the range, then find other breakpoints near the distance percentage in the horizontal line table or vertical line table of the line segment where the original breakpoint is located, and perform a 1:1 corresponding binding;
[0118] Next, determine the line segments iine where other breakpoints near the percentage are located ip The line segment where the original breakpoint is located io Are they on the same horizontal line? If the n breakpoints found include a breakpoint on the same horizontal line as the original breakpoint, the two breakpoints are bridged, the line segment where the original breakpoint is located is deleted from the line segment table, and the breakpoint coordinates stored in the line segment where the other breakpoint is located are updated to the coordinates of the non-breakpoint of the line segment where the original breakpoint is located; after the bridging is completed, the next original breakpoint is found until all the corresponding breakpoints on the same horizontal line of the line segment where the breakpoint is located are bridged;
[0119] Finally, to solve the problem that the original breakpoint cannot find the corresponding breakpoint, determine whether the line segment where the original breakpoint is located is a horizontal line or a vertical line, find the nearest percentage based on the coordinates of this breakpoint, and use the found percentage as the range. Then, find other breakpoints near the distance percentage in the different line segment type table of the line segment where the original breakpoint is located. If the line segment where the original breakpoint is located is a horizontal line, find the corresponding breakpoint in the vertical line table. If the line segment where the original breakpoint is located is a vertical line, find the corresponding breakpoint in the horizontal line table; for the breakpoints found that are in a one-to-one correspondence with the original breakpoints but the line segments are not on the same horizontal line, find the coordinates of the intersection of the two breakpoints, and update the line segment where the breakpoint is located. ij The coordinates of the breakpoint are replaced by the coordinates of the intersection point, and the line segment line in the line segment table L0 is replaced by the coordinates of the intersection point. ij If there are breakpoints on the line, close them one by one according to the above operations until all line segments are ij The status of the upper endpoint does not include the breakpoint condition.
[0120] Step 3.3.3, according to the line segment table line segment L0, find the pointing relationship between the entities and store the coordinates of the pointing path points;
[0121] When a pair of pointing relationships is found, all points passed during the traversal are stored in the path table L3 in the order of starting point, passing point, and ending point.
[0122]
[0123] (a). Find the starting point according to the line segment table L0 and determine the starting line;
[0124] (b) Determine whether there is an end point on the starting line according to the line segment table L0. If there is an end point, the box bound to the starting point and the end point i The points passed are stored in the path table L3, and the process returns to (a) to continue; if there is no end point, continue;
[0125] (c) Find the intersection of the line determined by (b) and determine whether there is an end point on the intersection; if there is an end point, store the points passed by the entities bound to the starting point and the end point in the path table L3 and return to (a) to continue; if there is no end point, continue to repeat this step until a line containing a end point is found.
[0126] After repeating the above steps, some many-to-one pointing situations will not be traversed, and the steps taken for leak detection are changed to:
[0127] In the first step, based on the comparison between the path table L3 and the line segment table L0, the termination point stored in the line segment table L0 but not stored in the path table L3 is found to determine the termination line.
[0128] The second step is to determine whether there is a starting point on the end line according to the line segment table L0. If there is a starting point, the box bound to the starting point and the end point is i The points passed are stored in the path table L3, and the process returns to the first step to continue; if there is no starting point, the process continues to the third step.
[0129] The third step is to find the intersection of the lines determined in the previous step and determine whether there is a starting point on the intersection. If there is a starting point, the box bound to the starting point and the end point i The points passed are stored in the path table L3, and the process returns to the first step to continue; if there is no starting point, this step is repeated until a line containing the starting point is found.
[0130] After all the line segment tables L0 established in the entire image D are cycled through according to the above steps, the pointing relationship between the entities is established.
[0131] Step 3.4: Find the corresponding percentages on the paths between objects with pointing relationships, and bind the paths to their percentages
[0132] Step 3.4.1, construct a search range according to the order of point coordinates stored in the path table L3, and determine the path and its percentage;
[0133] The point coordinates of the path stored in the path table L3 are sequential coordinates from the starting point to the ending point. Two points determine a line segment, and a line segment determines a search range.
[0134] For example, the first path stored in path table L3
[0135] route1{spot1(x, y), spot2(x, y), spot1(x, y), spot3(x, y)...spot n (x, y)}
[0136] There are n points in total: starting point 1, passing point 2, passing point 3, and ending point n. The point coordinates are traversed sequentially, and the starting point 1 and passing point 2 are first found. If these two points are connected, a horizontal or vertical line segment will be formed. The state of the line segment after they are connected is determined based on their point coordinates, and the search direction is determined based on this state.
[0137] If the line segment is a horizontal line segment, the line segment formed by the two points is used as the reference, and the line segment is searched in the up and down directions to find the two closest percentages, and the distance is judged. If the distance between the two percentages and the line segment constructed by the two points is slightly different, both are retained. If the distance between the two percentages and the line segment constructed by the two points is greatly different, the closest one is retained and bound to the path currently being searched on the path table L3;
[0138] If the line segment is a vertical line segment, the line segment formed by the two points is taken as the center, and the search is performed in the left and right directions at the same time to find the two closest percentages and judge the distance. If the distance between the two percentages and the line segment constructed by the two points is slightly different, both are retained. If the distance between the two percentages and the line segment constructed by the two points is greatly different, the closest one is retained and bound to the path currently being searched on the path table L3.
[0139] Next, find passing point 2 and passing point 3, and repeat the above steps until all points on this path have been traversed.
[0140] After the above operation, the percentage of the path and its binding can be obtained. However, since the range search may have errors and duplications, further screening is required to eliminate erroneous searches.
[0141] Step 3.4.2: Screen the many-to-one bindings between the path and its percentage obtained in step 3.4.1, and remove redundant bindings until the path and its percentage are one-to-one bindings.
[0142] In the path table L3, based on the one-to-one binding between the path and the percentage, the percentages on the remaining paths are excluded, and this operation is repeated until the path and the percentage are all one-to-one bound.
[0143] With the path as the key and the percentage as the value, a one-to-one dictionary {key:value} binding is implemented so that {path:percentage}.
[0144] Step 4: Build a complex network of pointing relationships based on the complex network analysis library NetworkX
[0145] Step 4.1, build a node graph, create an empty graph G, add the entity coordinates in step 2 as nodes into graph G, and build node graph G1;
[0146] Step 4.2, construct a directed graph, according to the pointing relationship between entities obtained in step 3.3.3, add them as directions into the node graph G1 in sequence to connect the entity nodes, and obtain the basic directed graph G2;
[0147] Step 4.3: Construct a weighted directed graph. According to step 3.4, obtain the percentage of path binding between entities, regard it as a weight, add it to the directed graph G2, and finally form a directed weighted graph G3 of the holding process.
[0148] The specific process is as follows:
[0149]
[0150] In the specific operation of the method for designing automatic parsing of PDF graphics and texts described in the present invention, through the processing of files (L(x)) and pictures (H(x)), documents such as plain text are filtered out and flowchart pages are converted into pictures, thereby reducing the working time of Faster R-CNN. By extracting the coordinates of the required target block diagram through Faster R-CNN, all types of target block diagram coordinates can be extracted at the same time, thereby improving the efficiency of identifying target coordinates in the image. Based on the extracted block diagram coordinates, the recognition of arrows and the recognition of text by OCR, the flow direction of the flowchart can be accurately and objectively obtained; on this basis, a complex network of directional relationships is constructed according to the NetworkX library, and the proportion relationship between any two boxes flowing from the out-degree direction to the in-degree direction can be obtained. The whole process has considerable stability, visibility and practicality.
Claims
1. A method for automatically identifying and parsing complex flowcharts in PDF, characterized in that: Follow the steps below to implement it: Step 1: Process the initial document; Step 2: Extract the coordinates of the required frame in the image based on Faster R-CNN; Step 3: Determine the pointing relationship between entities based on the coordinates obtained in step 2 and OCR; The step 3 is specifically as follows: Step 3.1, pre-process the image by whitening it according to entity class and percentage class; Step 3.2, refine the process pointing line segment; Step 3.3, find the pointing and pointed relationships between entities; The step 3.3 is specifically as follows: Step 3.3.
1. Compare the entity coordinates with Binding of internal points; Step 3.3.2: Process line segments The breakpoint problem on the board can be solved by bridging the breakpoints; Step 3.3.3: Line segments according to the line segment table , find the pointing relationship between entities and store the coordinates of the pointing path points; Step 3.4, find the corresponding percentages on the paths between the objects with pointing relationships, and bind the paths and their percentages; Step 4: Construct a complex network of pointing relationships based on the complex network analysis library NetworkX; The step 4 is specifically as follows: Step 4.1, build a node graph, create an empty graph G, add the entity coordinates in step 2 as nodes into graph G, and build node graph G1; Step 4.2, construct a directed graph, according to the pointing relationship between entities obtained in step 3.3.3, add them as directions into the node graph G1 in sequence to connect the entity nodes, and obtain the basic directed graph G2; Step 4.3: Construct a weighted directed graph. According to step 3.4, obtain the percentage of path binding between entities, regard it as a weight, add it to the directed graph G2, and finally form a directed weighted graph G3 of the holding process.
2. According to claim 1, a method for automatically identifying and parsing complex flowcharts in PDF is characterized in that: The step 1 is specifically implemented according to the following steps: The initial PDF document is denoted as A, the filtering condition function is denoted as L(x), and the remaining required part of the initial document after passing through the filtering condition function is denoted as B, where B=L(A); then, the image conversion function is denoted as H(x), and the image after the initial document passes through the filtering condition function and then through the image conversion function is denoted as C, where C=H(B).
3. The method for automatically identifying and parsing complex flowcharts in PDF according to claim 1, characterized in that: The step 2 is specifically as follows: Step 2.1, use the convolutional layer to extract image features; Step 2.2, using the RPN network layer to obtain the candidate matrix region; Step 2.3: In the region of interest pooling layer, the input image sizes of different sizes are converted into fixed-length output collections; Step 2.4: Use the feature map PFM in step 2.3 to calculate the category of the candidate area, and at the same time, use the bounding box regression again to obtain the final precise position of the entity class, percentage class, and arrow class detection box in the flowchart.
4. The method for automatically identifying and parsing complex flowcharts in PDF according to claim 1, characterized in that: The step 3.2 is specifically as follows: Step 3.2.1, decompose and identify the image D in the form of lines; Step 3.2.2, adjust the lines that have problems due to detection; Step 3.2.3, judgment Relationship between them, update the line segment table .
5. The method for automatically identifying and parsing complex flowcharts in PDF according to claim 1, characterized in that: The step 3.4 is specifically as follows: Step 3.4.1: Based on the path table The order of the point coordinates stored in the memory is used to construct the search range and determine the path and its percentage; Step 3.4.2: Screen the many-to-one bindings between the path and its percentage obtained in step 3.4.1, and remove redundant bindings until the path and its percentage are one-to-one bindings.
