CAD coordinate table data extraction method and device
By identifying and processing the header text set and non-header text set in CAD surveying data, dynamically calculating the tilt angle and column boundaries, and removing abnormal text, automated slanted table data structuring is achieved. This solves the problems of low efficiency and low accuracy in existing technologies, and improves data conversion efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AEROSPACE INFORMATION RES INST CAS
- Filing Date
- 2026-04-17
- Publication Date
- 2026-06-30
Smart Images

Figure CN122049928B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer-aided design technology, and in particular to a method and apparatus for extracting CAD coordinate table data. Background Technology
[0002] Computer-aided design (CAD) software is a standard tool in the surveying industry, and the boundary point coordinates in the generated surveying data are usually presented in tabular form. Among these tables, there is a special type of unstructured table—that is, a table drawn with lines and text. This type of table consists of independent sets of line objects and text objects, and does not have a row and column structure that can be directly recognized by the program. As a result, its data cannot be directly read through conventional application programming interfaces (APIs) or automatically extracted efficiently and accurately through structured conversion tools (such as Feature Manipulation Engines (FME)). Existing technologies either rely on expensive deep learning solutions (which suffer from accuracy loss, high hardware costs, and fragmentation risks) or require manual input, which is inefficient and prone to errors, becoming a key bottleneck hindering the lossless and automated conversion of CAD surveying data to the target data format.
[0003] Therefore, how to automatically and accurately identify the tilted table structure from unstructured CAD survey tables composed of lines and text objects without human intervention, and ultimately extract accurate structured coordinate data, is a technical problem that urgently needs to be solved. Summary of the Invention
[0004] This application provides a method and apparatus for extracting CAD coordinate table data, which solves the problems in the prior art where CAD coordinate table data extraction relies on expensive deep learning schemes (which suffer from accuracy loss, high hardware costs, and the risk of data fragmentation) or requires manual input, resulting in low efficiency and a high risk of errors.
[0005] This application provides a method for extracting CAD coordinate table data, including the following steps:
[0006] Determine the set of header text and non-header text in the CAD survey data, wherein the CAD survey data includes: a boundary point coordinate table;
[0007] Based on the set of header text, determine the header tilt angle and header column boundaries;
[0008] Based on the tilt angle of the table header, abnormal characters in the non-header text set are removed to determine the candidate text set;
[0009] Determine the row number and column number corresponding to each candidate character in the candidate character set;
[0010] Based on the candidate text set and the row and column numbers corresponding to each candidate text, generate target structured data.
[0011] According to the CAD coordinate table data extraction method provided in this application, determining the set of header text and the set of non-header text in the CAD surveying data includes:
[0012] An initial set of characters is determined from the CAD surveying data based on a surveying keyword lexicon.
[0013] Spatial clustering is performed on the initial characters in the initial character set that meet the preset conditions to determine the header character set;
[0014] After determining the header text set, the remaining text in the CAD survey data is determined as the non-header text set.
[0015] According to the CAD coordinate table data extraction method provided in this application, determining the table header tilt angle and table header column boundaries based on the table header text set includes:
[0016] Based on the center coordinates of each header character in the header text set, the least squares method is used to fit the header baseline equation to determine the header tilt angle.
[0017] The header column boundary is determined based on the left and right boundaries of each header character in the header character set.
[0018] According to the CAD coordinate table data extraction method provided in this application, the step of removing abnormal text from the non-header text set based on the header tilt angle to determine the candidate text set includes:
[0019] Determine the angular deviation between the text rotation angle of each non-header character in the non-header character set and the head tilt angle;
[0020] If the angle deviation value is greater than the angle deviation threshold, the non-header text is identified as the abnormal text.
[0021] The abnormal characters in the non-header character set are removed to obtain the candidate character set.
[0022] According to the CAD coordinate table data extraction method provided in this application, determining the row number and column number corresponding to each candidate character in the candidate character set includes:
[0023] The baseline of each row is determined based on the tilt angle of the table header and the preset row spacing of each row;
[0024] Based on the baseline of each line, determine the line number corresponding to each candidate character in the candidate character set;
[0025] Based on the tilt angle of the table header and the column boundaries of the table header, determine the column number corresponding to each candidate character in the candidate character set.
[0026] According to the CAD coordinate table data extraction method provided in this application, the step of determining the row number corresponding to each candidate character in the candidate character set based on the row baseline of each row includes:
[0027] Determine the initial distance between each candidate character and the baseline of the k-th row, where k is a positive integer;
[0028] If the initial distance is less than or equal to the initial height, the row number of the candidate text corresponding to the initial distance is determined to be k, wherein the initial height is a preset multiple of the candidate text height.
[0029] According to the CAD coordinate table data extraction method provided in this application, the step of determining the column number corresponding to each candidate character in the candidate text set based on the table header tilt angle and the table header column boundary includes:
[0030] Based on the tilt angle of the table header and the preset row spacing, determine the lateral offset of each row relative to the table header;
[0031] The corrected column boundary of each row is determined based on the horizontal offset of each row and the header column boundary.
[0032] Based on the modified column boundaries of each row, determine the column number to which the candidate text in each row belongs.
[0033] According to the CAD coordinate table data extraction method provided in this application, the method further includes:
[0034] If the width of the candidate text exceeds a preset width and the character spacing of the candidate text is greater than a preset spacing, the candidate text is divided into multiple strings.
[0035] This application provides a CAD coordinate table data extraction device, including the following modules:
[0036] The first determining module is used to determine the set of header text and the set of non-header text in the CAD surveying data, wherein the CAD surveying data includes: a boundary point coordinate table;
[0037] The second determining module is used to determine the header tilt angle and header column boundaries based on the header text set;
[0038] The elimination module is used to eliminate abnormal characters in the non-header text set according to the header tilt angle, so as to determine the candidate text set;
[0039] The third determining module is used to determine the row number and column number corresponding to each candidate character in the candidate character set;
[0040] The generation module is used to generate target structured data based on the candidate text set and the row number and column number corresponding to each candidate text.
[0041] According to the CAD coordinate table data extraction device provided in this application, the first determining module is specifically used for:
[0042] An initial set of characters is determined from the CAD surveying data based on a surveying keyword lexicon.
[0043] Spatial clustering is performed on the initial characters in the initial character set that meet the preset conditions to determine the header character set;
[0044] After determining the header text set, the remaining text in the CAD survey data is determined as the non-header text set.
[0045] According to the CAD coordinate table data extraction device provided in this application, the second determining module is specifically used for:
[0046] Based on the center coordinates of each header character in the header text set, the least squares method is used to fit the header baseline equation to determine the header tilt angle.
[0047] The header column boundary is determined based on the left and right boundaries of each header character in the header character set.
[0048] According to the CAD coordinate table data extraction device provided in this application, the elimination module is specifically used for:
[0049] Determine the angular deviation between the text rotation angle of each non-header character in the non-header character set and the head tilt angle;
[0050] If the angle deviation value is greater than the angle deviation threshold, the non-header text is identified as the abnormal text.
[0051] The abnormal characters in the non-header character set are removed to obtain the candidate character set.
[0052] According to the CAD coordinate table data extraction device provided in this application, the third determining module is specifically used for:
[0053] The baseline of each row is determined based on the tilt angle of the table header and the preset row spacing of each row;
[0054] Based on the baseline of each line, determine the line number corresponding to each candidate character in the candidate character set;
[0055] Based on the tilt angle of the table header and the column boundaries of the table header, determine the column number corresponding to each candidate character in the candidate character set.
[0056] According to the CAD coordinate table data extraction device provided in this application, the third determining module is specifically used for:
[0057] Determine the initial distance between each candidate character and the baseline of the k-th row, where k is a positive integer;
[0058] If the initial distance is less than or equal to the initial height, the row number of the candidate text corresponding to the initial distance is determined to be k, wherein the initial height is a preset multiple of the candidate text height.
[0059] According to the CAD coordinate table data extraction device provided in this application, the third determining module is specifically used for:
[0060] Based on the tilt angle of the table header and the preset row spacing, determine the lateral offset of each row relative to the table header;
[0061] The corrected column boundary of each row is determined based on the horizontal offset of each row and the header column boundary.
[0062] Based on the modified column boundaries of each row, determine the column number to which the candidate text in each row belongs.
[0063] According to the CAD coordinate table data extraction device provided in this application, the third determining module is further used for:
[0064] If the width of the candidate text exceeds a preset width and the character spacing of the candidate text is greater than a preset spacing, the candidate text is divided into multiple strings.
[0065] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the CAD coordinate table data extraction methods described above.
[0066] This application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the CAD coordinate table data extraction method as described above.
[0067] This application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the CAD coordinate table data extraction methods described above.
[0068] This application provides a method and apparatus for extracting CAD coordinate table data. By identifying the set of header text and non-header text in the CAD surveying data, and then dynamically calculating the tilt angle and column boundaries, it overcomes the limitation of traditional methods that are only applicable to horizontal tables. Next, it intelligently searches and cleans data rows, effectively removing interfering text with abnormal direction or position, ensuring data purity. Subsequently, it performs dynamic column-oriented data segmentation, solving the parsing challenges of tilted tables and merged cells through adaptive boundary adjustment and character-level segmentation, accurately constructing row and column mapping relationships. Finally, the system converts the structured coordinate data into a standard format for output. This fully automated architecture significantly improves the data conversion efficiency from CAD to target structured data, and remains stable and reliable even when processing complex drawings with noise and tilt, effectively solving a key bottleneck in the information conversion of surveying data. Attached Figure Description
[0069] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0070] Figure 1 This is one of the flowcharts illustrating the CAD coordinate table data extraction method provided in this application.
[0071] Figure 2 This is the second flowchart illustrating the CAD coordinate table data extraction method provided in this application.
[0072] Figure 3 This is the third flowchart illustrating the CAD coordinate table data extraction method provided in this application.
[0073] Figure 4 This is a schematic diagram of the CAD coordinate table data extraction device provided in this application.
[0074] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0075] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0076] The following is combined Figures 1 to 3 This application describes the method for extracting CAD coordinate table data.
[0077] Figure 1 This is one of the flowcharts illustrating the CAD coordinate table data extraction method provided in this application, such as... Figure 1 As shown, the method includes the following:
[0078] Step 101: Determine the set of header text and non-header text in the CAD survey data. The CAD survey data includes: boundary point coordinate table.
[0079] CAD surveying data refers to graphic files (e.g., .dwg format) created using computer-aided design (CAD) software (such as AutoCAD) for surveying projects (such as cadastral surveying). These files contain graphic elements (lines, circles, etc.) and non-graphic elements (text).
[0080] Boundary point coordinate tables are a specialized data presentation format in the field of surveying (especially cadastral surveying and land surveying). In CAD surveying drawings, it refers to a data carrier that systematically and list-wise records and displays the spatial coordinates of various boundary points on the boundary of a land parcel.
[0081] The header text set refers to the collection of text objects in the title row at the top of the table, typically containing keywords such as period, X coordinate, and Y coordinate. It serves as the anchor point for locating and understanding the entire table structure.
[0082] The non-header text set refers to all text objects in the CAD drawing other than the header text set H. This includes the coordinate data row text to be extracted, and may also contain other irrelevant annotations or noise text.
[0083] Optionally, in some embodiments, determining the set of header text and the set of non-header text in the CAD surveying data includes: determining an initial set of text from the CAD surveying data based on a surveying keyword lexicon; and performing spatial clustering on the initial text in the initial set that meets preset conditions to determine the set of header text.
[0084] The surveying keyword lexicon is a pre-defined collection of professional terminology strings specific to the surveying field. It's a rule base or dictionary used to initially filter out text that might be table headers at a semantic level. The surveying keyword lexicon can be represented as: , For the j-th surveying keyword in the surveying keyword thesaurus, p represents the total number of keywords in the surveying keyword database. The surveying keyword database includes point numbers, serial numbers, X coordinates, Y coordinates, etc., and there are no restrictions on these.
[0085] Among them, the initial text set is the set of characters initially determined from CAD surveying data based on the surveying keyword lexicon.
[0086] In other words, in this embodiment of the application, the identification of text objects matching the keywords can be based on a mapping keyword lexicon.
[0087] ;
[0088] in, This represents a text object in CAD survey data. Not a match. For matching, The string content of the text object.
[0089] In other words, in this embodiment of the application, an initial set of characters can be determined from CAD surveying data based on a surveying keyword lexicon, and then, characters that meet the following criteria can be selected. Spatial clustering is performed on the initial set of characters to determine the set of header characters.
[0090] Spatial clustering can be, for example, a density-based spatial clustering method with noise (DBSCAN clustering algorithm), without limitation.
[0091] In other words, in the embodiments of this application, it can be to satisfy... The initial text set was subjected to density clustering using an improved DBSCAN clustering algorithm, which performs two-dimensional spatial clustering based on the coordinates of the center points of the text bounding boxes. The clustering parameters were set as follows: neighborhood radius. ,in for Height, minimum number of neighborhood points If clustering fails, then execute... Expand by 20% and retry; and / or if clustering fails, decrement MinPts by 1 and retry; if clustering succeeds, output the header text set. , The h-th element in the header text set. , This represents the total number of header characters in the header text set. It is a positive integer.
[0092] In this embodiment of the application, after determining the set of header text in the CAD survey data, the remaining text in the CAD survey data can be determined as the set of non-header text.
[0093] Step 102: Determine the header tilt angle and header column boundaries based on the header text set.
[0094] The header tilt angle (θ) refers to the rotation angle of the header text arrangement baseline relative to the horizontal axis (X-axis) of the CAD coordinate system (counterclockwise is positive).
[0095] The header column boundary (C_k) refers to the horizontal spatial range of each header text. It is used to initially divide the column area of the table. For a column composed of multiple texts (such as the X coordinate which may be a single text), its boundary is determined by the leftmost and rightmost boundaries of all texts in that column.
[0096] In some embodiments, determining the header tilt angle and header column boundaries based on the header text set can be achieved by statistically analyzing the vertex coordinates of the bounding boxes of all header texts to find a minimum tilted rectangle that can enclose all header texts (or by determining the principal direction through principal component analysis). The tilt direction of this rectangle is considered the header tilt angle. Subsequently, a local coordinate system is established along this tilt direction, and the bounding boxes of all header texts are projected onto an axis perpendicular to this direction. Clustering is performed based on the density of the projected points, with each cluster corresponding to a column. For each projection cluster, the corresponding original text is found by backtracking, and then the minimum and maximum projection values of these text bounding boxes in the local coordinate system perpendicular to the column direction are taken as the left and right header column boundaries of that column, respectively. There are no restrictions on this.
[0097] Alternatively, in some embodiments, a pre-trained large model can be used to determine the header tilt angle and header column boundaries based on the header text set. That is, the header text set can be input into the pre-trained large model, and the large model can process the header text set to determine the header tilt angle and header column boundaries. There are no restrictions on this.
[0098] Optionally, in some embodiments, determining the header tilt angle and header column boundaries based on the header text set includes: fitting the header baseline equation using the least squares method based on the center coordinates of each header text in the header text set to determine the header tilt angle; and determining the header column boundaries based on the left and right boundaries of each header text in the header text set.
[0099] For the detected header text set H, the least squares method can be used to fit the header baseline equation:
[0100] ;
[0101] in, θ is the ordinate of the table header baseline, θ is the table header tilt angle, x is the abscissa of the table header baseline, and b is the intercept (constant).
[0102] In this embodiment of the application, after fitting the header baseline equation using the least squares method based on the center coordinates of each header character in the header character set, the header tilt angle θ can be determined as follows:
[0103] ;
[0104] Where θ is the tilt angle of the meter head, which is the angle between the meter head baseline and the x-axis (counterclockwise is positive). and These are the x and y coordinates of the header text in the header text set, respectively. and These are the average values of the horizontal and vertical axes of the table header text, respectively.
[0105] In this embodiment of the application, the header column boundary can be determined based on the left and right boundaries of each header character in the header character set. left and right boundaries of the column The minimum left edge and maximum right edge of the bounding boxes for all header text in the column are determined. This method can be specifically expressed as follows:
[0106] ;
[0107] in, Indicates the first column of the table. The left and right boundaries of the column, For the first Subset of list header text This is the width of the header text.
[0108] Step 103: Based on the tilt angle of the table header, eliminate abnormal characters from the non-header text set to determine the candidate text set.
[0109] Abnormal text refers to text unrelated to the target table, such as drawing titles, dimension annotations, and temporary markers; there are no restrictions on this.
[0110] The candidate text set is the text set obtained after removing abnormal text from the non-header text set.
[0111] In some embodiments, the candidate text set is determined by eliminating abnormal characters from the non-header text set based on the header tilt angle. This can be done by calculating several virtual line baselines based on the header tilt angle θ and the predicted line spacing. For each non-header text, not only is the deviation of its own rotation angle from θ calculated, but more importantly, the vertical distance from its center point to each line baseline is calculated. A non-header text is considered a potential text for a line only if its angle deviation and its distance to a line baseline are less than a certain threshold (e.g., half a character height). Next, for the text initially assigned to each line, the average local rotation angle of the text within that line is calculated, and the deviation of the angle of each text in the group from the average angle of the line is checked again. Any text that exhibits angular isolation within the line (i.e., deviates from the mainstream direction within the line), even if its deviation from the global θ is small, will be judged as abnormal text and eliminated.
[0112] In other embodiments, abnormal characters in the non-header text set are removed based on the header tilt angle to determine the candidate text set. This can be achieved by inputting the non-header text set and the header tilt angle together into a pre-trained large model, which then identifies abnormal characters from the non-header text set. The abnormal characters identified by the large model can then be removed from the non-header text set to obtain the candidate text set.
[0113] Optionally, in some embodiments, abnormal characters in the non-header character set are removed based on the header tilt angle to determine the candidate character set, including: determining the angle deviation value between the character rotation angle and the header tilt angle of each non-header character in the non-header character set; if the angle deviation value is greater than the angle deviation threshold, the non-header character is identified as an abnormal character; and abnormal characters in the non-header character set are removed to obtain the candidate character set.
[0114] The text rotation angle refers to the rotation attribute (θ_j) of a single CAD text object. In CAD, each text object can be rotated independently by an angle.
[0115] The angle deviation value is the absolute value of the difference between the rotation angle of a non-header text and the tilt angle of the table header.
[0116] The angle deviation threshold is a preset allowable range. If the angle deviation of the text exceeds this threshold, it is considered that its direction is inconsistent with the table body and is likely abnormal text that does not belong to the table. This angle deviation threshold is usually set to a small value, such as 3°, 5° or 10°, and there is no restriction on it.
[0117] In other words, in this embodiment of the application, the angle of each line of candidate text can be checked to eliminate text rotation angles. The tilt angle of the meter exceeds a threshold (such as the threshold). Abnormal text with a value of 3° is denoted as In order to obtain a set of candidate characters.
[0118] Step 104: Determine the row number and column number corresponding to each candidate character in the candidate character set.
[0119] In this context, the row number corresponding to the candidate text refers to the vertical position index of each candidate text within the two-dimensional logical structure of the table. The table data is numbered sequentially from top to bottom (usually starting from the first row below the header) as row 1, row 2, ..., row n. Determining the row number means determining which horizontal data record each text object should belong to.
[0120] In this context, the column number corresponding to the candidate text refers to the horizontal position index of each candidate text within the two-dimensional logical structure of the table. Each column of the table from left to right is assigned a number (e.g., column 1 is the point number, column 2 is the X-coordinate, etc.). Determining the column number means determining which column (which data field) each text object should correspond to within its own row.
[0121] These two numbers together form a two-dimensional coordinate system (row number, column number), which is used to uniquely and accurately locate the data cell represented by each text object in the reconstructed table matrix.
[0122] In some embodiments, determining the row and column numbers corresponding to each candidate character in the candidate character set can be achieved by using the center point coordinates of all candidate characters as input during the row numbering stage, but primarily relying on their coordinate values perpendicular to the header baseline (i.e., height information) for one-dimensional clustering (such as density-based clustering). Each cluster center is considered a logical row, and all characters within the cluster are assigned the same row number. During the column numbering stage, fixed global column boundaries are no longer used directly. Instead, characters within the same row are sorted and subjected to secondary clustering or gap analysis based on their coordinate values along the header baseline (i.e., horizontal position). By analyzing the horizontal spacing distribution between characters in the same row, column segmentation is performed where gaps significantly larger than the average spacing occur, thereby dynamically generating column partitions for that row and assigning column numbers to each character.
[0123] In other embodiments, determining the row number and column number corresponding to each candidate character in the candidate character set can also be achieved by inputting the candidate character set into a pre-trained large model (which has pre-learned the first mapping relationship between sample characters and row numbers, and the second mapping relationship between sample characters and column numbers), and having the large model determine the row number and column number corresponding to each candidate character in the candidate character set.
[0124] Step 105: Generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0125] The target structured data refers to the conversion (or extraction) of a coordinate table image composed of discrete text and lines in a CAD drawing, which is visually readable but cannot be directly processed by the program, into a machine-readable, semantically clear, and formatted data file. The format of the target structured data can be, for example, comma-separated values (CSV), text file, or other output formats, without any restrictions.
[0126] In this embodiment, target structured data is generated based on the candidate text set and the row and column numbers corresponding to each candidate text. This can be achieved by reconstructing these hashed text objects into a two-dimensional data matrix in memory based on the row and column numbers corresponding to each candidate text, where the row number determines its vertical index in the matrix and the column number determines its horizontal index. Subsequently, the program assigns a field name with clear mapping semantics to each column of this two-dimensional matrix based on the initially identified header semantics or preset field mapping rules. Next, the data in the matrix is subjected to mandatory validation, including verifying whether the number of columns in each row of data meets expectations and parsing the text content into a numerical format to ensure data validity, and recording rows that fail validation in an error log. Finally, the validated data matrix is serialized into a standardized comma-separated value (CSV) file or text file according to the precision (e.g., decimal places) and format specifications configured by the user, thereby outputting target structured data that can be directly imported and used by Geographic Information System (GIS), database, or data analysis software.
[0127] The CAD coordinate table data extraction method of this application breaks through the limitation of traditional methods that are only applicable to horizontal tables by determining the set of header text and non-header text in the CAD surveying data, and then dynamically calculating the tilt angle and column boundaries. It then intelligently searches and cleans data rows, effectively removing interfering text with abnormal direction or position to ensure data purity. Subsequently, it performs dynamic column-oriented data segmentation, solving the parsing problems of tilted tables and merged cells through adaptive boundary adjustment and character-level segmentation, accurately constructing row and column mapping relationships. Finally, the system converts the structured coordinate data into a standard format for output. This fully automated architecture significantly improves the data conversion efficiency from CAD to target structured data and remains stable and reliable even when processing complex drawings with noise and tilt, effectively solving a key bottleneck in the information conversion of surveying data.
[0128] Figure 2This is the second flowchart illustrating the CAD coordinate table data extraction method provided in this application, as shown below. Figure 2 As shown, the method includes the following:
[0129] Step 201: Determine the set of header text and non-header text in the CAD survey data. The CAD survey data includes: boundary point coordinate table.
[0130] Step 202: Determine the header tilt angle and header column boundaries based on the header text set.
[0131] Step 203: Based on the tilt angle of the table header, eliminate abnormal characters from the non-header text set to determine the candidate text set.
[0132] For a detailed description of steps 201-203, please refer to the above embodiments, which will not be repeated here.
[0133] Step 204: Determine the baseline of each row based on the tilt angle of the table header and the preset row spacing of each row.
[0134] The preset line spacing refers to the vertical distance between the baselines of two adjacent lines of text in a slanted table. This value is a constant, denoted by e, which is calculated or set in advance based on the height of the table header text and multiplied by an empirical adjustment factor (such as 1.25).
[0135] The row baseline is a virtual reference line parallel to the table header baseline, used to define and position the center of each row of text in the table. It is not an actual CAD object, but a mathematical straight line equation calculated based on the table header baseline equation, the table header tilt angle θ, and the row spacing d.
[0136] In this embodiment, the baseline equation for the k-th row can be defined based on the header tilt angle θ and the row text height. The k-th row is parallel to the header baseline, and its baseline equation is... It can be represented as:
[0137] ;
[0138] in, d is the preset line spacing. This is an adjustment factor (generally between 1.2 and 1.5, with a default of 1.25). For the h-th header text The text height, offset is .
[0139] Step 205: Determine the line number corresponding to each candidate character in the candidate character set based on the baseline of each line.
[0140] In this embodiment of the application, the line number corresponding to each candidate character in the candidate character set is determined based on the line baseline of each line.
[0141] Optionally, in some embodiments, determining the row number corresponding to each candidate character in the candidate character set based on the row baseline of each row includes: determining the initial distance between each candidate character and the k-th row baseline, where k is a positive integer; and determining the row number of the candidate character corresponding to the initial distance as k when the initial distance is less than or equal to the initial height, where the initial height is a preset multiple of the candidate character height.
[0142] The initial distance between the candidate text and the baseline of the k-th row refers to the shortest vertical distance from the center point of a candidate text to a certain baseline. This distance is a geometric distance calculated after taking into account table tilt (coordinate system rotation).
[0143] In other words, in this embodiment of the application, each candidate character that does not belong to the header character set can be determined based on the following formula (i.e. ), the initial distance between the baseline of the k-th row :
[0144] ;
[0145] in, This refers to any reference point on the table header baseline; here, the center of the table header text is taken as the reference point. , , Indicates the center coordinates of the candidate text.
[0146] The initial height is a preset multiple of the candidate text height, which can be, for example, 1 / 2, and there are no restrictions on this.
[0147] In other words, in this embodiment of the application, after determining the initial distance between each candidate character and the baseline of the k-th line, the initial distance can be compared with the initial height, that is, in Candidate text When the initial distance to the baseline of the k-th line is less than or equal to half the height of the text, the line number of the candidate text is determined to be k.
[0148] Step 206: Determine the column number corresponding to each candidate character in the candidate character set based on the header tilt angle and header column boundaries.
[0149] Optionally, in some embodiments, determining the column number corresponding to each candidate character in the candidate character set based on the header tilt angle and the header column boundary includes: determining the horizontal offset of each row relative to the header based on the header tilt angle and a preset row spacing; determining the corrected column boundary of each row based on the horizontal offset of each row and the header column boundary; and determining the column number to which the candidate character in each row belongs based on the corrected column boundary of each row.
[0150] The horizontal offset refers to the displacement of the entire data in the k-th row relative to the header row in the horizontal direction (X-axis direction) due to the table's tilt.
[0151] The corrected column boundary refers to the column range applicable to the k-th row after horizontally shifting the original header column boundary and adding a tolerance.
[0152] In this embodiment, the lateral offset of each row relative to the table header is determined based on the header tilt angle and the preset row spacing. for:
[0153] ;
[0154] For the k-th line of text, the corrected line is... Column correction column boundaries for:
[0155] ;
[0156] in, Indicates the candidate text in the k-th row. The corrected left and right boundaries of the column. , indicating character width tolerance This represents the width of the c-th character in the candidate text.
[0157] In this embodiment of the application, after determining the modified column boundary of each row based on the horizontal offset of each row and the header column boundary, the column number to which the candidate text in each row belongs can be determined based on the modified column boundary of each row. This determination method can be expressed as follows:
[0158] ;
[0159] in, Indicates candidate text The center x-coordinate, Number the column to which the candidate text in each row belongs.
[0160] In other words, in the embodiments of this application, candidate characters can be jointly selected based on the modified column boundaries. The central x-coordinate is used to determine whether a candidate text belongs to the j-th column.
[0161] Optionally, in some embodiments, the candidate text may be divided into multiple strings if the width of the candidate text exceeds a preset width and the character spacing of the candidate text is greater than a preset spacing.
[0162] The preset width refers to a width threshold used to trigger character-level splitting. Typically, this threshold is a specific multiple of the standard width of the column (header), such as 1.2 times, and there is no restriction on this.
[0163] The preset spacing refers to the spacing threshold used to determine whether to perform segmentation. It is usually defined as the average character spacing plus a tolerance, such as 1.2 times the average spacing, and there is no limit to this.
[0164] Character spacing refers to the horizontal gap between the borders of two adjacent characters within a text string.
[0165] In other words, in this embodiment of the application, character-level segmentation is performed on text objects with abnormal widths, such as those exceeding 1.2 times the standard column width. Specifically, when the text width meets the following conditions, the character spacing distribution characteristics are statistically analyzed, and segmentation is performed at significant gaps, which can be expressed as:
[0166]
[0167] in, It is the width of the candidate text. It is the preset width.
[0168] In this embodiment of the application, when it is determined that the width of the candidate text exceeds a preset width, the character spacing of the candidate text can be further calculated. This calculation method can be expressed as:
[0169] ;
[0170] in, The total number of characters in the candidate text. The width of the c-th character in the candidate text.
[0171] In other words, in this embodiment of the application, when it is determined that the width of the candidate text exceeds the preset width, and it is determined that... In such cases, candidate text can be segmented into multiple strings.
[0172] Step 207: Generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0173] For a detailed description of step 207, please refer to the above embodiments, which will not be repeated here.
[0174] Figure 3 This is the third flowchart illustrating the CAD coordinate table data extraction method provided in this application, as shown below. Figure 3 As shown, this method includes four main stages: header keyword identification and spatial modeling, row coordinate data search and cleaning, column data dynamic segmentation, and structured data output. In the header keyword identification and spatial modeling stage, semantic recognition of the header can be performed on the CAD surveying data, followed by spatial clustering of the header to determine the header text set. Then, dynamic calculation and baseline equation fitting are performed based on the header tilt angle, and the header column boundaries are delineated. In the row coordinate data search and cleaning stage, row baseline positioning, row text capture, and abnormal data filtering are performed sequentially to determine the row number-text object mapping table. In the column data dynamic segmentation stage, dynamic column boundary adjustment, column mapping segmentation, and cross-column character-level segmentation are performed sequentially. Finally, in the structured data output stage, target structured data is generated, and after data constraint verification of the target structured data, the target structured data in a standard format is exported.
[0175] The CAD coordinate table data extraction device provided in this application is described below. The CAD coordinate table data extraction device described below can be referred to in correspondence with the CAD coordinate table data extraction method described above.
[0176] Figure 4 This is a schematic diagram of the CAD coordinate table data extraction device provided in this application, as shown below. Figure 4 As shown, the device includes the following:
[0177] The first determining module 401 is used to determine the set of header text and the set of non-header text in the CAD surveying data, wherein the CAD surveying data includes: a boundary point coordinate table;
[0178] The second determining module 402 is used to determine the tilt angle of the header and the boundary of the header column based on the header text set;
[0179] The elimination module 403 is used to eliminate abnormal characters in the non-header text set according to the tilt angle of the table header in order to determine the candidate text set.
[0180] The third determining module 404 is used to determine the row number and column number corresponding to each candidate character in the candidate character set;
[0181] The generation module 405 is used to generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0182] According to the CAD coordinate table data extraction device provided in this application, the first determining module 401 is specifically used for:
[0183] Based on the surveying keyword lexicon, an initial set of texts was determined from CAD surveying data;
[0184] Spatial clustering is performed on the initial text set that meets the preset conditions to determine the header text set;
[0185] After determining the header text set, the remaining text in the CAD survey data is determined as the non-header text set.
[0186] According to the CAD coordinate table data extraction device provided in this application, the second determining module 402 is specifically used for:
[0187] Based on the center coordinates of each header character in the header text set, the least squares method is used to fit the header baseline equation to determine the header tilt angle.
[0188] Determine the header column boundaries based on the left and right boundaries of each header character in the header text set.
[0189] According to the CAD coordinate table data extraction device provided in this application, the elimination module 403 is specifically used for:
[0190] Determine the angular deviation between the text rotation angle and the header tilt angle for each non-header text in the non-header text set;
[0191] If the angle deviation value is greater than the angle deviation threshold, non-header text will be identified as abnormal text.
[0192] Remove abnormal characters from the non-header text set to obtain the candidate text set.
[0193] According to the CAD coordinate table data extraction device provided in this application, the third determining module 404 is specifically used for:
[0194] Determine the baseline of each row based on the tilt angle of the table header and the preset row spacing of each row;
[0195] Based on the baseline of each line, determine the line number corresponding to each candidate character in the candidate character set;
[0196] Based on the tilt angle of the table header and the column boundaries of the table header, determine the column number corresponding to each candidate character in the candidate character set.
[0197] According to the CAD coordinate table data extraction device provided in this application, the third determining module 404 is specifically used for:
[0198] Determine the initial distance between each candidate character and the baseline of the k-th row, where k is a positive integer;
[0199] If the initial distance is less than or equal to the initial height, the line number of the candidate text corresponding to the initial distance is determined as k, where the initial height is a preset multiple of the candidate text height.
[0200] According to the CAD coordinate table data extraction device provided in this application, the third determining module 404 is specifically used for:
[0201] Based on the header tilt angle and preset row spacing, determine the lateral offset of each row relative to the header;
[0202] Determine the corrected column boundaries for each row based on the horizontal offset of each row and the header column boundaries.
[0203] Based on the modified column boundaries of each row, determine the column number to which the candidate text in each row belongs.
[0204] According to the CAD coordinate table data extraction device provided in this application, the third determining module 404 is further used for:
[0205] If the width of the candidate text exceeds the preset width and the character spacing of the candidate text is greater than the preset spacing, the candidate text will be split into multiple strings.
[0206] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a CAD coordinate table data extraction method, which includes:
[0207] Determine the set of header text and non-header text in the CAD survey data, where the CAD survey data includes: a table of boundary point coordinates;
[0208] Determine the header tilt angle and header column boundaries based on the header text set;
[0209] Based on the tilt angle of the table header, abnormal characters in the non-header text set are removed to determine the candidate text set;
[0210] Determine the row and column numbers corresponding to each candidate character in the candidate character set;
[0211] Generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0212] The CAD coordinate table data extraction device of this application, by determining the set of header text and non-header text in the CAD surveying data, and dynamically calculating the tilt angle and column boundaries, breaks through the limitation of traditional methods that are only applicable to horizontal tables. It then intelligently searches and cleans data rows, effectively removing interfering text with abnormal direction or position, ensuring data purity. Subsequently, it performs dynamic column-oriented data segmentation, solving the parsing problems of tilted tables and merged cells through adaptive boundary adjustment and character-level segmentation, accurately constructing row and column mapping relationships. Finally, the system converts the structured coordinate data into a standard format for output. This fully automated architecture significantly improves the data conversion efficiency from CAD to target structured data, and remains stable and reliable even when processing complex drawings with noise and tilt, effectively solving a key bottleneck in the information conversion of surveying data.
[0213] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0214] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the CAD coordinate table data extraction method provided by the above methods, the method including:
[0215] Determine the set of header text and non-header text in the CAD survey data, where the CAD survey data includes: a table of boundary point coordinates;
[0216] Determine the header tilt angle and header column boundaries based on the header text set;
[0217] Based on the tilt angle of the table header, abnormal characters in the non-header text set are removed to determine the candidate text set;
[0218] Determine the row and column numbers corresponding to each candidate character in the candidate character set;
[0219] Generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0220] Furthermore, this application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the CAD coordinate table data extraction method provided by the methods described above, the method comprising:
[0221] Determine the set of header text and non-header text in the CAD survey data, where the CAD survey data includes: a table of boundary point coordinates;
[0222] Determine the header tilt angle and header column boundaries based on the header text set;
[0223] Based on the tilt angle of the table header, abnormal characters in the non-header text set are removed to determine the candidate text set;
[0224] Determine the row and column numbers corresponding to each candidate character in the candidate character set;
[0225] Generate target structured data based on the candidate text set and the row and column numbers corresponding to each candidate text.
[0226] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0227] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0228] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A CAD coordinate table data extraction method characterized by, include: Determine the set of header text and non-header text in the CAD survey data, wherein the CAD survey data includes: a boundary point coordinate table; Based on the center coordinates of each header character in the header text set, the least squares method is used to fit the header baseline equation to determine the header tilt angle. The header column boundary is determined based on the left and right boundaries of each header character in the header character set. Based on the tilt angle of the table header, abnormal characters in the non-header text set are removed to determine the candidate text set; The baseline of each row is determined based on the tilt angle of the table header and the preset row spacing of each row; Determine the initial distance between each candidate character and the baseline of the k-th row, where k is a positive integer; If the initial distance is less than or equal to the initial height, the row number of the candidate text corresponding to the initial distance is determined to be k, wherein the initial height is a preset multiple of the candidate text height; Based on the tilt angle of the table header and the preset row spacing, determine the lateral offset of each row relative to the table header; The corrected column boundary of each row is determined based on the horizontal offset of each row and the header column boundary. Based on the modified column boundaries of each row, determine the column number to which the candidate text in each row belongs; Based on the candidate text set and the row and column numbers corresponding to each candidate text, generate target structured data.
2. The method of claim 1, wherein, The determination of the set of header text and the set of non-header text in the CAD surveying data includes: An initial set of characters is determined from the CAD surveying data based on a surveying keyword lexicon. Spatial clustering is performed on the initial characters in the initial character set that meet the preset conditions to determine the header character set; After determining the header text set, the remaining text in the CAD survey data is determined as the non-header text set.
3. The method of claim 1, wherein, The step of removing abnormal characters from the non-header text set based on the header tilt angle to determine the candidate text set includes: Determine the angular deviation between the text rotation angle of each non-header character in the non-header character set and the head tilt angle; If the angle deviation value is greater than the angle deviation threshold, the non-header text is identified as the abnormal text. The abnormal characters in the non-header character set are removed to obtain the candidate character set.
4. The method according to claim 1, characterized in that, The method further includes: If the width of the candidate text exceeds a preset width and the character spacing of the candidate text is greater than a preset spacing, the candidate text is divided into multiple strings.
5. A CAD coordinate table data extraction device, characterized in that, include: The first determining module is used to determine the set of header text and the set of non-header text in the CAD surveying data, wherein the CAD surveying data includes: a boundary point coordinate table; The second determining module is used to fit the header baseline equation using the least squares method based on the center coordinates of each header character in the header text set to determine the header tilt angle; and to determine the header column boundary based on the left and right boundaries of each header character in the header text set. The elimination module is used to eliminate abnormal characters in the non-header text set according to the header tilt angle, so as to determine the candidate text set. The third determining module is used to: determine the baseline of each row based on the header tilt angle and the preset row spacing of each row; determine the initial distance between each candidate character and the baseline of the kth row, where k is a positive integer; determine the row number of the candidate character corresponding to the initial distance as k if the initial distance is less than or equal to the initial height, where the initial height is a preset multiple of the candidate character height; determine the horizontal offset of each row relative to the header based on the header tilt angle and the preset row spacing; determine the corrected column boundary of each row based on the horizontal offset of each row and the header column boundary; and determine the column number to which the candidate character in each row belongs based on the corrected column boundary of each row. The generation module is used to generate target structured data based on the candidate text set and the row number and column number corresponding to each candidate text.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the CAD coordinate table data extraction method as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the CAD coordinate table data extraction method as described in any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the CAD coordinate table data extraction method as described in any one of claims 1 to 4.