A method and device for identifying a layout file table
By preprocessing the table path lines in the layout file and determining vector points, the problem of low table recognition accuracy in the layout file in the prior art is solved, and the table recognition effect with high accuracy and wide application is achieved.
Patent Information
- Application Number
- CN202411907632.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-24
AI Technical Summary
The existing layout file table recognition method has the problem of low recognition accuracy.
By obtaining the table path line and its basic parameters in the layout file to be identified, preprocessing is performed to obtain the target path line, determining the initial target area and target vector points, and determining the target table based on the table rules.
It realizes accurate identification of tables in layout files, has high accuracy, low cost and wide use scenarios, and can be used offline.
Smart Images

Figure CN119360400B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer information processing, and in particular to a method and device for recognizing a format file table. Background Art
[0002] Layout electronic document technology is gradually becoming an indispensable technology for office work due to its security, accuracy, reliability and convenience. Layout documents are different from streaming documents. They have clear table units. Layout documents are like those drawn on a blackboard, except that they are drawn with vector graphics and have the characteristic of not being distorted when scaled. It is very important to use these path lines of layout documents to correctly identify tables. Tables account for a considerable proportion in the medical and other fields. The existing technical solution is to identify tables based on the metadata of layout documents, but this method has the problem of low recognition accuracy. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a method and device for recognizing a layout file table, which solves the problem of low recognition accuracy in the existing recognition method for layout file tables.
[0004] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0005] An embodiment of the present invention provides a method for identifying a format file table, comprising:
[0006] Obtaining the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: clipping area parameters, border parameters, and filling color parameters of the path lines to be processed;
[0007] Preprocessing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain target path lines in the target table;
[0008] According to the target path line, determining an initial target area corresponding to the target table;
[0009] According to the initial target area, determine the target vector point of the target table;
[0010] Determine the target table based on the target vector point and table formulation rules.
[0011] Optionally, preprocessing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain target path lines in the target table includes:
[0012] According to the basic parameters corresponding to each of the to-be-processed path lines and the preset area parameters of the target table, each of the to-be-processed path lines is clipped to obtain a plurality of first processed path lines;
[0013] Performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line;
[0014] Segmenting the second processing path line to obtain a fourth processing path line;
[0015] Performing merging processing on the fourth processed path lines to obtain a merged path line;
[0016] The merged path line is extended to obtain a target path line of a target table.
[0017] Optionally, performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line includes:
[0018] Determine all rectangular path lines in the first processed path line and initial parameters corresponding to the rectangular path lines, wherein the initial parameters include a rectangular line width, a rectangular line height, a rectangular shape parameter, and a rectangular fill color parameter of each rectangular path line;
[0019] Determine a rectangular path line with a filling color in the first processed path line according to the rectangular shape parameters and the rectangular filling color parameters in the initial parameters;
[0020] According to the first preset value, the rectangular line width and the rectangular line height in the initial parameters, the rectangular path line with filled color in the first processing path line whose rectangular line width is less than the first preset value is transformed into a vertical path line, and the rectangular path line with filled color in the first processing path line whose rectangular line height is less than the first preset value is transformed into a horizontal path line to obtain a second processing path line.
[0021] Optionally, segmenting the second processing path line to obtain a fourth processing path line includes:
[0022] Traversing each second processing path line, splitting the rectangular path lines whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line to obtain a third processing path line;
[0023] The Bezier curve in the third processing path line is segmented to obtain a fourth processing path line.
[0024] Optionally, merging the fourth processed path lines to obtain a merged path line includes:
[0025] Acquire a first distance between every two adjacent transverse path lines in the fourth processing path line and a second distance between every two adjacent vertical path lines in the fourth processing path line;
[0026] Two adjacent horizontal path lines whose first distance between them is less than a second preset value are merged into one horizontal path line, and two adjacent vertical path lines whose second distance between them is less than a second preset value are merged into one vertical path line to obtain a merged path line.
[0027] Optionally, extending the merged path line to obtain a target path line of a target table includes:
[0028] Obtain the third distance between the two ends of each horizontal path line and the two ends of each vertical path line in the merged path line;
[0029] When the third distance between the two horizontal path lines and each vertical path line is less than the third preset value, the horizontal path line and each vertical path line are respectively extended until the horizontal path line and each vertical path line intersect to obtain the target path line of the target table.
[0030] Optionally, determining an initial target area corresponding to the target table according to the target path line includes:
[0031] Performing intersection detection on all the target path lines to obtain initial intersection points;
[0032] According to the initial intersection points, two target path lines corresponding to each initial intersection point are determined;
[0033] According to the two target path lines corresponding to each initial intersection point, an envelope diagram corresponding to the target path line with the intersection point is calculated;
[0034] According to the envelope diagram, the initial target area corresponding to the target table is determined.
[0035] Optionally, according to the initial target area, a target vector point of the target table is determined, including:
[0036] Perform intersection detection on all target path lines in the initial target area to obtain target intersection points;
[0037] Acquire attribute parameters of each target intersection point, wherein the attribute parameters of the target intersection point include: direction and modulus of the current target intersection point;
[0038] According to the attribute parameters of the target intersection points, it is determined whether each target intersection point has connectivity, and the directions and module lengths of the target intersection points with connectivity are recorded in the order of rows and columns to obtain the target vector points of the target table.
[0039] Optionally, the target table is determined according to the target vector point and the target table formulation rule, including:
[0040] According to the formulation rules of the target table and the attributes of the target vector point, the four target endpoints of the target table are determined;
[0041] The target table is determined according to the target table formulation rules, the target endpoints and the remaining target vector points.
[0042] An embodiment of the present invention further provides a device for identifying a layout file table, comprising:
[0043] An acquisition module is used to acquire the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: a clipping area parameter, a border parameter, and a filling color parameter of the path line to be processed;
[0044] A processing module is used to pre-process the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain the target path lines of the target table; determine the initial target area corresponding to the target table according to the target path lines; determine the target vector points of the target table according to the initial target area; determine the target table according to the target vector points and the formulation rules of the table.
[0045] The above solution of the present invention includes at least the following beneficial effects:
[0046] The method for identifying a table in a layout file of the present invention obtains the path line to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: the clipping area parameter, the border parameter, and the fill color parameter of the path line to be processed; according to the basic parameters corresponding to each of the path lines to be processed, the path line to be processed is pre-processed to obtain the target path line of the target table; according to the target path line, the initial target area corresponding to the target table is determined; according to the initial target area, the target vector point of the target table is determined; according to the target vector point and the formulation rule of the table, the target table is determined. The method realizes the accurate identification of the table in the layout file, and has the advantages of high accuracy, low cost, wide application scenarios, and offline use. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a flow chart of the method for recognizing a format file table of the present invention;
[0048] Figure 2 It is a schematic diagram of a table before extension processing is performed in the method for recognizing a table in a layout file of the present invention;
[0049] Figure 3 It is a structural schematic diagram of the first two target path lines of the calculation envelope diagram in the recognition method of the layout file table of the present invention;
[0050] Figure 4 It is a structural schematic diagram of a minimum envelope diagram of two intersecting target path lines in the layout file table recognition method of the present invention;
[0051] Figure 5 It is a structural schematic diagram of a target table in a method for recognizing a layout file table of the present invention;
[0052] Figure 6 It is a schematic diagram of the specific flow structure of the method for recognizing the layout file table of the present invention;
[0053] Figure 7 It is a module schematic diagram of a device for recognizing a layout file table of the present invention;
[0054] Description of reference numerals:
[0055] 21. Horizontal path line; 22. Vertical path line; 31. First target path line; 32. Second target path line; 33. Initial intersection point. DETAILED DESCRIPTION
[0056] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0057] like Figures 1 to 6 As shown, an embodiment of the present invention provides a method for identifying a layout file table, comprising:
[0058] Step 11, obtaining the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: the clipping area parameters, the border parameters, and the filling color parameters of the path lines to be processed;
[0059] Step 12, pre-processing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain target path lines in the target table;
[0060] Step 13, determining the initial target area corresponding to the target table according to the target path line;
[0061] Step 14, determining the target vector point of the target table according to the initial target area;
[0062] Step 15, determining the target table according to the target vector point and the table formulation rules.
[0063] In the present embodiment, the layout file table recognition method is used to convert the path line parameters representing the table in the layout document into a visual table; the present invention pre-processes the path lines and converts the processed path lines into target vector points, determines the target table through the table formulation rules and the target vector points, thereby realizing the recognition and reading of the path lines in the layout document, and converting the path lines into a visual target table, thereby solving the problem of low recognition accuracy in the existing layout file table recognition method; at the same time, it has the advantages of high recognition accuracy, low cost, and a wide range of application scenarios. At the same time, this method does not need to be used online and has the advantage of being able to be used offline.
[0064] In an optional embodiment of the present invention, step 12 may include:
[0065] Step 121, cutting each of the to-be-processed path lines according to the basic parameters corresponding to each of the to-be-processed path lines and the preset area parameters of the target table, to obtain a plurality of first processed path lines;
[0066] Step 122, performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line;
[0067] Step 123, segmenting the second processing path line to obtain a fourth processing path line;
[0068] Step 124, merging the fourth processed path lines to obtain a merged path line;
[0069] Step 125, extending the merged path line to obtain a target path line of a target table.
[0070] In this embodiment, the layout file itself is an XML document that reads the path line from the document. According to the layout file standard, if there is a clipping area under each path line, there will be a clipping area label, i.e., clipping area parameters, and the clipping area parameters indicate that the content surrounded by the current path line is visible; the preset area parameters of the target table are the maximum visible range corresponding to the current target table; in this embodiment, the basic parameters also include: line width parameters, fill area parameters, and border color parameters of the path line to be processed;
[0071] Step 121 is mainly used to crop the path lines to be processed, retain the path lines in the visible area, and remove the path lines in the invisible area; specifically, firstly, according to the border parameters, filling area parameters, border color parameters and filling color parameters in the basic parameters corresponding to each of the path lines to be processed, the path lines to be processed are removed, specifically, the path lines to be processed without borders and without filling in the basic parameters of the path lines to be processed are set to be invisible, and the invisible path lines to be processed are removed to obtain the post-processing path lines after the invisible path lines to be processed are removed, and then based on the length parameters of each post-processing path line (the length parameter can be determined according to the length of the post-processing path line), the post-processing path lines are cut. The first processing path line is obtained by calculating the two endpoints of the post-processing path line, taking the intersection of the corresponding clipping area parameter and the preset area parameter and clipping the line outside the intersection to obtain the first processing path line; for example: the length parameter of the post-processing path line is 10mm, the corresponding clipping area parameter is 8mm, and the preset area parameter is 6mm, then the intersection of the three is 6mm, that is, the path line after the intersection is clipped, and 4mm of the 10mm post-processing path line is set as the invisible area, and then the invisible area is clipped, and the 10mm post-processing path line is clipped to a path line with a length parameter of 6mm, that is, 6mm of which is in the visible area.
[0072] In an optional embodiment of the present invention, step 122 may include:
[0073] Step 1221, determining all rectangular path lines in the first processed path line and initial parameters corresponding to the rectangular path lines, wherein the initial parameters include a rectangular line width, a rectangular line height, a rectangular shape parameter, and a rectangular fill color parameter of each rectangular path line;
[0074] Step 1222, determining a rectangular path line with a filling color in the first processed path line according to the rectangular shape parameters and the rectangular filling color parameters in the initial parameters;
[0075] Step 1223, according to the first preset value, the rectangular line width and the rectangular line height in the initial parameters, the rectangular path line with a filled color in the first processing path line whose rectangular line width is less than the first preset value is transformed into a vertical path line, and the rectangular path line with a filled color in the first processing path line whose rectangular line height is less than the first preset value is transformed into a horizontal path line to obtain a second processing path line.
[0076] In this embodiment, since there are many rectangles in the document that are actually used as lines, the line transformation processing is to obtain the smallest unit line that constitutes the table, and transform the rectangular path lines used by those rectangles as lines into specific lines. Specifically, first determine the rectangular path lines with fill colors in the first processing path lines according to the initial parameters, and then compare the rectangular line width and the rectangular line height of the rectangular path lines with the first preset value respectively. When the rectangular line width is less than the first preset value (the first preset value is 3 mm), the current rectangular path line is directly converted into a vertical path line. When the rectangular line height is less than the first preset value, the current rectangular path line is directly converted into a horizontal path line, so that all the rectangular path lines with fill colors in the first processing path lines are converted into single path lines, and the second processing path lines after the converted rectangles are obtained.
[0077] In an optional embodiment of the present invention, step 123 may include:
[0078] Step 1231, traverse each second processing path line, split the rectangular path lines whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line, and obtain the third processing path line;
[0079] Step 1232, segmenting the Bezier curve in the third processing path line to obtain a fourth processing path line.
[0080] In this embodiment, the rectangular path line in which the rectangular line width and the rectangular line height are both greater than the first preset value in the second processing path line can be determined in the following manner. First, the rectangular path line can be determined according to the shape parameters of the second processing path line, and then the rectangular line width and the rectangular line height of the rectangular path line are compared with the first preset value. The second processing path line in which the rectangular line width and the rectangular line height are both greater than the first preset value is determined as the rectangular path line in which the rectangular line width and the rectangular line height are both greater than the first preset value in the second processing path line.
[0081] The rectangular path line whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line is split into four straight lines. Specifically, the rectangular path line whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line is split into four straight lines.
[0082] In this embodiment, the Bezier curve is a standard curve recorded in the layout file; the Bezier curve in the third processing path line is segmented to obtain a fourth processing path line, specifically, the path line with the Bezier curve in the third processing path line is segmented, that is, the curve part is removed and only the straight line part is retained.
[0083] In an optional embodiment of the present invention, step 124 may include:
[0084] Step 1241, obtaining a first distance between every two adjacent horizontal path lines in the fourth processing path line and a second distance between every two adjacent vertical path lines in the fourth processing path line;
[0085] Step 1242, merge two adjacent horizontal path lines whose first distance between two adjacent horizontal path lines is less than a second preset value into one horizontal path line, and merge two adjacent vertical path lines whose second distance between two adjacent vertical path lines is less than a second preset value into one vertical path line, to obtain a merged path line.
[0086] In this embodiment, since the tables of many documents are composed of segments of small broken lines, the purpose of merging the fourth processing path line is to merge the adjacent broken lines in the fourth processing path line into a complete line. Specifically, the distance between all adjacent horizontal path lines, that is, the first distance, is first determined, and the distance between all adjacent vertical path lines, that is, the second distance, is then determined. Then, the sum of the maximum line width of the current two path lines and a preset error value is taken as the second preset value (that is, the second preset value is equal to the maximum line width of the current two adjacent horizontal path lines or adjacent vertical path lines plus a preset error value), and compared with the current first distance. If the current If the distance is less than the second preset value, the two current path lines are merged; if it is greater, they are not merged; through this design, path lines that are both horizontal or vertical lines and are very close to each other can be merged into one line, which can effectively merge the lines in the document table composed of segments of small broken lines into a complete line; in this embodiment, the horizontal path lines and vertical path lines in the fourth processing path lines can be determined according to the size of the line width and the line height. Specifically, if the line width of the current fourth processing path line is greater than the line height, the current fourth processing path line is a horizontal path line, and if the line width of the current fourth processing path line is less than the line height, the current fourth processing path line is a vertical path line.
[0087] In an optional embodiment of the present invention, step 125 may include:
[0088] Step 1251, obtaining a third distance between two ends of each horizontal path line and two ends of each vertical path line in the merged path line;
[0089] Step 1252, when the third distance between the two horizontal path lines and each vertical path line is less than the third preset value, the horizontal path line and each vertical path line are respectively extended until the horizontal path line and each vertical path line intersect, to obtain the target path line of the target table.
[0090] In this embodiment, the design of extending the merged path line can make two path lines that need to intersect but have not intersected intersect each other complete the intersection; specifically, assuming that there are two path lines, one is a horizontal path line and the other is a vertical path line (such as Figure 2 As shown, Figure 2 In the figure, 21 is a horizontal path line, and 22 is a vertical path line), the distance from the right end of the horizontal path line to the upper end of the vertical path line is the third distance. When the third distance is less than the third preset value, the right end of the horizontal path line is extended to the position of the vertical path line, and the upper end of the vertical path line is extended to the position of the horizontal path line, so that the right end of the horizontal path line intersects with the upper end of the vertical path line; wherein the third preset value is equal to twice the maximum line width of the two horizontal path lines and the vertical path line plus a preset distance, and the preset distance can be 1mm.
[0091] In an optional embodiment of the present invention, step 13 may include:
[0092] Step 131, performing intersection detection on all the target path lines to obtain initial intersection points;
[0093] Step 132, determining two target path lines corresponding to each initial intersection point according to the initial intersection points;
[0094] Step 133, calculating an envelope diagram corresponding to the target path line with the intersection according to the two target path lines corresponding to each initial intersection point;
[0095] Step 134: Determine the initial target area corresponding to the target table according to the envelope diagram.
[0096] In this embodiment, the purpose of calculating the envelope diagram is to calculate all possible areas of the target table to prevent the problem of missing or miscalculating the target table line, thereby solving the problem of low precision in the table generation process; the envelope diagram is the minimum circumscribed rectangle of two intersecting target path lines;
[0097] Step 13 is as follows: first, determine all target path lines with intersections in the target path line. When the target path line has an intersection, the current target path line must have another target path line intersecting with it. The envelope diagram corresponding to the two intersecting target path lines can be determined by the endpoint coordinates of the two target path lines; for example, Figure 3 As shown, Figure 3 Where 31 is the first target path line, 32 is the second target path line, and 33 is the initial intersection point of the two. After the intersection of the two is determined, the envelope diagram corresponding to the first target path line and the second target path line can be determined according to the coordinates of the two end points of the first target path line and the coordinates of the two end points of the second target path line, as shown in FIG. Figure 4 shown.
[0098] In an optional embodiment of the present invention, step 14 may include:
[0099] Step 141, performing intersection detection on all the target path lines in the initial target area to obtain target intersection points;
[0100] Step 142, obtaining attribute parameters of each target intersection point, wherein the attribute parameters of the target intersection point include: direction and modulus length of the current target intersection point;
[0101] Step 143, based on the attribute parameters of the target intersection points, determine whether each target intersection point has connectivity, and record the directions and module lengths of the connected target intersection points in the order of rows and columns to obtain the target vector points in the target table.
[0102] In this embodiment, since the table is a closed figure, each target intersection on the table must be connected to at least one other target intersection. The direction of the target intersection can be up, down, left, and right. Each direction means that there is a corresponding connected target intersection in the corresponding direction. The target vector point of the target table is determined according to the connectivity of the target intersection on the table; if the current target intersection has no attributes, such as Figure 2 As shown in A in the figure, it proves that this point is just the intersection of two target path lines and there is no other connection point. Therefore, this target intersection point has no attributes and does not need to be recorded. It needs to be removed directly.
[0103] In this embodiment, whether each target intersection has connectivity can be confirmed in the following manner. Specifically, for example, if one target intersection has a lower right attribute, then this intersection can go right or downward, and another target intersection has an upper right attribute, then this intersection can go upward or right. To calculate whether the two are connected, it can be determined whether the two have vectors in relative directions. Among them, the target intersection with the lower right attribute has a downward vector, and the other target intersection with the upper right attribute has an upward vector. Then, the two have vectors in relative directions. Then, it is determined whether the modulus length from the target intersection with the lower right attribute to the target intersection with the upper right attribute is equal to the modulus length from the target intersection with the upper right attribute to the target intersection with the lower right attribute. If they are the same, the two are connected, and if they are not equal, they are not connected. That is, it is determined whether the vectors in two relative directions can reach the other target intersection through a single-direction translation (the translation distance is the modulus length of the vector). If they can reach the other target intersection, the two are connected, otherwise they are not connected. By determining the connectivity between the intersections, other interference points can be effectively excluded, further ensuring the accuracy of the target table generation.
[0104] In an optional embodiment of the present invention, step 15 may include:
[0105] Step 151, determining four target endpoints of the target table according to the formulation rules of the target table and the attributes of the target vector point;
[0106] Step 152, determining the target table according to the target table formulation rule, the target endpoints and the remaining target vector points.
[0107] In this embodiment, according to the formulation rules of the target table and the attributes of the target vector point, the four target endpoints of the target table are determined specifically as follows: first, according to the rule that the direction of a point at the beginning of a table specified in the formulation rules of the target table must be the lower right and only the lower right, the starting point of the target table is determined, that is, according to the attributes of the target vector point, a target vector point whose direction is only the lower right is found among the target vector points, and this point is used as the starting point; then, according to the rule that the four target endpoints of the target table connected to the starting point must only have the lower left, upper left, and upper right directions respectively in the formulation rules of the target table, the four target endpoints of the target table are determined, and the four points are connected; then, based on the four endpoints and the specific rows and columns of the target table, the position of each target vector point is determined in turn, and all points are connected to obtain the target table; for example: the points in a column of the starting point must have the attributes of up and down to the right (except the first and last rows), and similarly, the points in a row of the starting point must have the attributes of down and down to the left (except the first and last columns), and in this way, all points that meet the requirements and have connectivity are found in turn, thereby generating a target table.
[0108] In this embodiment, if the target table is the main table and there are sub-tables in the target table, there must be two starting points with lower right information in the target table formulation rule. The target table is first generated based on the main table. After the main table is generated, the sub-table is generated based on another starting point through step 15. The specific flow chart is as follows: Figure 6 shown.
[0109] The layout file table recognition method described in the present invention can effectively improve the accuracy of the generated target table by processing the connectivity of the path lines of the layout file page and then taking their intersection design method. At the same time, the design does not require networking, and the corresponding application can be directly written into the storage device for offline use, thereby having the characteristics of low cost and wide application scenarios.
[0110] like Figure 7 As shown, an embodiment of the present invention further provides a layout file table recognition device 70, comprising:
[0111] An acquisition module 71 is used to acquire the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: a clipping area parameter, a border parameter, and a filling color parameter of the path lines to be processed;
[0112] The processing module 72 is used to pre-process the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain the target path lines of the target table; determine the initial target area corresponding to the target table according to the target path lines; determine the target vector points of the target table according to the initial target area; determine the target table according to the target vector points and the formulation rules of the table.
[0113] Optionally, preprocessing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain target path lines in the target table includes:
[0114] According to the basic parameters corresponding to each of the to-be-processed path lines and the preset area parameters of the target table, each of the to-be-processed path lines is clipped to obtain a plurality of first processed path lines;
[0115] Performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line;
[0116] Segmenting the second processing path line to obtain a fourth processing path line;
[0117] Performing merging processing on the fourth processed path lines to obtain a merged path line;
[0118] The merged path line is extended to obtain a target path line of a target table.
[0119] Optionally, performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line includes:
[0120] Determine all rectangular path lines in the first processed path line and initial parameters corresponding to the rectangular path lines, wherein the initial parameters include a rectangular line width, a rectangular line height, a rectangular shape parameter, and a rectangular fill color parameter of each rectangular path line;
[0121] Determine a rectangular path line with a filling color in the first processed path line according to the rectangular shape parameters and the rectangular filling color parameters in the initial parameters;
[0122] According to the first preset value, the rectangular line width and the rectangular line height in the initial parameters, the rectangular path line with filled color in the first processing path line whose rectangular line width is less than the first preset value is transformed into a vertical path line, and the rectangular path line with filled color in the first processing path line whose rectangular line height is less than the first preset value is transformed into a horizontal path line to obtain a second processing path line.
[0123] Optionally, segmenting the second processing path line to obtain a fourth processing path line includes:
[0124] Traversing each second processing path line, splitting the rectangular path lines whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line to obtain a third processing path line;
[0125] The Bezier curve in the third processing path line is segmented to obtain a fourth processing path line.
[0126] Optionally, merging the fourth processed path lines to obtain a merged path line includes:
[0127] Acquire a first distance between every two adjacent transverse path lines in the fourth processing path line and a second distance between every two adjacent vertical path lines in the fourth processing path line;
[0128] Two adjacent horizontal path lines whose first distance between them is less than a second preset value are merged into one horizontal path line, and two adjacent vertical path lines whose second distance between them is less than a second preset value are merged into one vertical path line to obtain a merged path line.
[0129] Optionally, extending the merged path line to obtain a target path line of a target table includes:
[0130] Obtain the third distance between the two ends of each horizontal path line and the two ends of each vertical path line in the merged path line;
[0131] When the third distance between the two horizontal path lines and each vertical path line is less than the third preset value, the horizontal path line and each vertical path line are respectively extended until the horizontal path line and each vertical path line intersect to obtain the target path line of the target table.
[0132] Optionally, determining an initial target area corresponding to the target table according to the target path line includes:
[0133] Performing intersection detection on all the target path lines to obtain initial intersection points;
[0134] According to the initial intersection points, two target path lines corresponding to each initial intersection point are determined;
[0135] According to the two target path lines corresponding to each initial intersection point, an envelope diagram corresponding to the target path line with the intersection point is calculated;
[0136] According to the envelope diagram, the initial target area corresponding to the target table is determined.
[0137] Optionally, according to the initial target area, a target vector point of the target table is determined, including:
[0138] Perform intersection detection on all target path lines in the initial target area to obtain target intersection points;
[0139] Acquire attribute parameters of each target intersection point, wherein the attribute parameters of the target intersection point include: direction and modulus of the current target intersection point;
[0140] According to the attribute parameters of the target intersection points, it is determined whether each target intersection point has connectivity, and the directions and module lengths of the target intersection points with connectivity are recorded in the order of rows and columns to obtain the target vector points of the target table.
[0141] Optionally, the target table is determined according to the target vector point and the target table formulation rule, including:
[0142] According to the formulation rules of the target table and the attributes of the target vector point, the four target endpoints of the target table are determined;
[0143] The target table is determined according to the target table formulation rules, the target endpoints and the remaining target vector points.
[0144] It should be noted that the device is a device corresponding to the above method, and all implementation methods in the above method are applicable to the embodiments of the device and can achieve the same technical effects.
[0145] The embodiment of the present invention further provides a computing device, comprising: a processor and a memory storing a computer program, wherein the computer program executes the above method when executed by the processor. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0146] The embodiment of the present invention further provides a computer-readable storage medium, including: storing instructions, when the instructions are executed on a computer, the computer executes the above method. All implementations in the above method embodiments are applicable to this embodiment and can achieve the same technical effect.
[0147] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments invented herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0148] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0149] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0152] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0153] In addition, it should be pointed out that in the apparatus and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. Moreover, the steps of performing the above series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order, and some steps can be performed in parallel or independently of each other. For those of ordinary skill in the art, it is understandable that all or any steps or components of the method and apparatus of the present invention can be implemented in hardware, firmware, software or a combination thereof in any computing device (including processors, storage media, etc.) or a network of computing devices, which can be achieved by those of ordinary skill in the art using their basic programming skills after reading the description of the present invention.
[0154] Therefore, the purpose of the present invention can also be achieved by running a program or a group of programs on any computing device. The computing device can be a well-known general device. Therefore, the purpose of the present invention can also be achieved by simply providing a program product containing a program code that implements the method or device. That is to say, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any well-known storage medium or any storage medium developed in the future. It should also be pointed out that in the device and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. In addition, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order. Some steps can be performed in parallel or independently of each other.
[0155] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for identifying a format file table, characterized in that: include: Obtaining the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: clipping area parameters, border parameters, and filling color parameters of the path lines to be processed; Preprocessing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain target path lines in the target table; According to the target path line, determining an initial target area corresponding to the target table; According to the initial target area, determine the target vector point of the target table; Determine the target table according to the target vector point and the table formulation rules; According to the basic parameters corresponding to each of the to-be-processed path lines, the to-be-processed path lines are pre-processed to obtain the target path lines in the target table, including: According to the basic parameters corresponding to each of the to-be-processed path lines and the preset area parameters of the target table, each of the to-be-processed path lines is clipped to obtain a plurality of first processed path lines; Performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line; Segmenting the second processing path line to obtain a fourth processing path line; Performing merging processing on the fourth processed path lines to obtain a merged path line; The merged path line is extended to obtain a target path line of a target table.
2. The method for recognizing a layout file table according to claim 1, characterized in that: Performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line includes: Determine all rectangular path lines in the first processed path line and initial parameters corresponding to the rectangular path lines, wherein the initial parameters include a rectangular line width, a rectangular line height, a rectangular shape parameter, and a rectangular fill color parameter of each rectangular path line; Determine a rectangular path line with a filling color in the first processed path line according to the rectangular shape parameters and the rectangular filling color parameters in the initial parameters; According to the first preset value, the rectangular line width and the rectangular line height in the initial parameters, the rectangular path line with filled color in the first processing path line whose rectangular line width is less than the first preset value is transformed into a vertical path line, and the rectangular path line with filled color in the first processing path line whose rectangular line height is less than the first preset value is transformed into a horizontal path line to obtain a second processing path line.
3. The method for recognizing a layout file table according to claim 1, characterized in that: The second processing path line is segmented to obtain a fourth processing path line, comprising: Traversing each second processing path line, splitting the rectangular path lines whose rectangular line width and rectangular line height are both greater than the first preset value in the second processing path line to obtain a third processing path line; The Bezier curve in the third processing path line is segmented to obtain a fourth processing path line.
4. The method for recognizing a layout file table according to claim 1, characterized in that: The fourth processed path line is merged to obtain a merged path line, comprising: Acquire a first distance between every two adjacent transverse path lines in the fourth processing path line and a second distance between every two adjacent vertical path lines in the fourth processing path line; Two adjacent horizontal path lines whose first distance between them is less than a second preset value are merged into one horizontal path line, and two adjacent vertical path lines whose second distance between them is less than a second preset value are merged into one vertical path line to obtain a merged path line.
5. The method for recognizing a layout file table according to claim 1, characterized in that: Extending the merged path line to obtain a target path line of a target table includes: Obtain the third distance between the two ends of each horizontal path line and the two ends of each vertical path line in the merged path line; When the third distance between the two horizontal path lines and each vertical path line is less than the third preset value, the horizontal path line and each vertical path line are respectively extended until the horizontal path line and each vertical path line intersect to obtain the target path line of the target table.
6. The method for recognizing a layout file table according to claim 1, characterized in that: Determining an initial target area corresponding to the target table according to the target path line includes: Performing intersection detection on all the target path lines to obtain initial intersection points; According to the initial intersection points, two target path lines corresponding to each initial intersection point are determined; According to the two target path lines corresponding to each initial intersection point, an envelope diagram corresponding to the target path line with the intersection point is calculated; According to the envelope diagram, the initial target area corresponding to the target table is determined.
7. The method for recognizing a layout file table according to claim 1, characterized in that: According to the initial target area, determine the target vector point of the target table, including: Perform intersection detection on all target path lines in the initial target area to obtain target intersection points; Acquire attribute parameters of each target intersection point, wherein the attribute parameters of the target intersection point include: direction and modulus of the current target intersection point; According to the attribute parameters of the target intersection points, it is determined whether each target intersection point has connectivity, and the directions and module lengths of the connected target intersection points are recorded in the order of rows and columns to obtain the target vector points of the target table.
8. The method for recognizing a layout file table according to claim 1, characterized in that: According to the rules for establishing the target vector point and the target table, the target table is determined, including: According to the formulation rules of the target table and the attributes of the target vector point, the four target endpoints of the target table are determined; The target table is determined according to the target table formulation rules, the target endpoints and the remaining target vector points.
9. A device for identifying a layout file table, characterized in that: include: An acquisition module is used to acquire the path lines to be processed corresponding to the table in the layout file to be identified and the basic parameters corresponding to each of the path lines to be processed, wherein the basic parameters include: a clipping area parameter, a border parameter, and a filling color parameter of the path line to be processed; A processing module, used for pre-processing the path lines to be processed according to the basic parameters corresponding to each of the path lines to be processed to obtain the target path lines of the target table; determining the initial target area corresponding to the target table according to the target path lines; determining the target vector points of the target table according to the initial target area; determining the target table according to the target vector points and the formulation rules of the table; According to the basic parameters corresponding to each of the to-be-processed path lines, the to-be-processed path lines are pre-processed to obtain the target path lines in the target table, including: According to the basic parameters corresponding to each of the to-be-processed path lines and the preset area parameters of the target table, each of the to-be-processed path lines is clipped to obtain a plurality of first processed path lines; Performing line transformation processing on the rectangular path line with a filling color in the first processed path line to obtain a second processed path line; Segmenting the second processing path line to obtain a fourth processing path line; Performing merging processing on the fourth processed path lines to obtain a merged path line; The merged path line is extended to obtain a target path line of a target table.
Citation Information
Patent Citations
PDF table content identification method and system and storage medium
CN115588210A
Method, device and equipment for generating dynamic table of layout file template
CN118966169A