Water conservancy CAD drawing information identification method and system based on DBSCAN algorithm, and storage medium
By processing hydraulic CAD drawings using the DBSCAN algorithm, the automatic classification and organization of cross-sectional information is achieved, solving the problems of low efficiency and insufficient accuracy in existing technologies, and improving the efficiency and accuracy of hydraulic engineering information processing.
Patent Information
- Application Number
- CN202410956242.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-11-15
AI Technical Summary
Existing technologies struggle to efficiently and accurately process complex cross-sectional information in hydraulic CAD drawings, resulting in low information processing efficiency and a high susceptibility to errors, failing to meet the needs of modern hydraulic engineering projects.
The DBSCAN algorithm is used to process entity information in hydraulic CAD drawings, including entity information acquisition, two-dimensional element information table conversion, drawing frame and drawing name recognition, control point encryption, and clustering, so as to realize the automatic classification and organization of profile information.
It enables automatic classification and organization of cross-sectional information in water conservancy CAD drawings, improving processing efficiency and accuracy. It is applicable to water conservancy CAD drawings of different scales and types, and has good versatility.
Smart Images

Figure CN118968520A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAD drawing information extraction, and in particular to a water conservancy CAD drawing information recognition method, system and storage medium based on a DBSCAN algorithm. Background Art
[0002] In the field of water conservancy projects, CAD drawings are an important basis for design, construction and review. The accuracy of their information and the efficiency of their processing are crucial to the impact of engineering projects. However, with the increasing scale and complexity of water conservancy projects, the information in CAD drawings has also shown a trend of diversification and complexity. Traditional CAD drawing processing methods often rely on manual information extraction and classification, which is not only inefficient but also prone to errors, and it is difficult to meet the needs of modern water conservancy projects for efficient and accurate information processing.
[0003] In the prior art, information processing of CAD drawings mainly relies on some basic image processing and data analysis technologies, but these technologies can only achieve simple information extraction and classification, and cannot conduct in-depth mining and analysis of complex information in CAD drawings. Especially in water conservancy CAD drawings, since a large amount of cross-sectional information is involved, the classification and organization of this information is of great significance for subsequent construction and review work. Therefore, how to accurately classify and efficiently process small pictures involving cross-sectional information in water conservancy CAD drawings has become a problem that needs to be solved urgently in the current field of water conservancy engineering. Summary of the invention
[0004] Purpose of the invention: The purpose of the present invention is to provide a method, system and storage medium for water conservancy CAD drawing information recognition based on the DBSCAN algorithm for classifying and organizing section information in water conservancy CAD drawings.
[0005] Technical solution: To achieve the above purpose, the water conservancy CAD drawing information recognition method based on DBSCAN algorithm described in the present invention comprises the following steps:
[0006] Step 1: Get the entity information in the CAD drawing;
[0007] Step 2: Convert entity information into a two-dimensional graphic element information table;
[0008] Step 3: Identify the frame and name of the image based on the data in the image element information table;
[0009] Step 4: Encrypt control points based on the data in the graphic element information table after the graphic frame and graphic name are identified;
[0010] Step 5: Use the DBSCAN algorithm to cluster the encrypted control points to obtain a classification list of the encrypted control points and their thumbnail categories;
[0011] Step 6: Based on the classification list of encrypted control points and their thumbnail categories, update the entity information and complete the thumbnail clustering in the entity information.
[0012] The CAD drawing described in step 1 includes an A0 or extended A0 drawing frame, which contains multiple small drawings, each of which has a drawing name, wherein the drawing name text height is N, and the small drawing name text height is n.
[0013] Among them, the method for obtaining entity information in the CAD drawing described in step 1 is: converting the CAD drawing into DXF format, using the ezdxf library to read the DXF file, and obtaining all entity information in the drawing, wherein the entity information refers to entity type, layer, control point, wireframe; entity type includes straight line, arc, block, text, polyline, dimension.
[0014] Among them, the column labels included in the graphic element information table in step 2 are: entity handle handle, entity type type, control point points, name name, line width linewidth; among them, for text entities, the text content is stored in the column label text, and the text height is stored in the column label height.
[0015] The method for identifying the drawing frame and drawing name in step 3 is as follows: mark the polyline with a height greater than a set threshold as a drawing frame, take the lower left corner of the drawing frame as the origin, mark the polyline located in the rectangular range of (0.75, 0) to (1, 0.15) relative to the drawing frame with a "drawing frame" mark, and mark it in the "name" column;
[0016] In the drawing frame, the text entities with a text height of n are labeled "Drawing Name" in the "name" column; the text entities with a text height of N are labeled "Sheet Name" in the "name" column; according to the drawing frame range, the control point entities within the drawing frame rectangle are labeled with the sheet name corresponding to this drawing frame in the "paper_name" column.
[0017] Among them, the method for encrypting the control points described in step 4 is: read the control points whose "name" column is not "frame", "name" or "drawing name" in the graphic element information table after the frame and name recognition, and use equidistant encryption to insert new control points between the control points by setting an interval distance, so that the newly inserted control point will maintain the same distance as the previous control point.
[0018] Among them, the clustering method described in step 5 is: setting the DBSCAN algorithm parameters, including the neighborhood radius of the control point, and the minimum number of control points required in the ε-neighborhood considered to be the core point, so as to obtain a classification list of encrypted control points [(x1, y1), (x2, y2), (x3, y3), ...], and the small image categories corresponding to the classification list: ["small image i", "small image j", "small image k", ...].
[0019] Among them, the method for updating entity information described in step 6 is: for each control point coordinate in the entity information, traverse the encrypted control point classification list, find the encrypted control point that matches the control point coordinate in the entity information, and obtain the corresponding thumbnail category, assign the matched thumbnail category to the "pic_name" column of the entity information, update the entity information to reflect the thumbnail category to which each entity control point in the entity information belongs, and complete the thumbnail clustering.
[0020] The water conservancy CAD drawing information recognition system based on the DBSCAN algorithm described in the present invention comprises an entity information acquisition module: used for acquiring entity information in the CAD drawing;
[0021] Entity information conversion module: used to convert entity information into a two-dimensional graphic element information table;
[0022] Frame and name recognition module: recognizes frames and names based on the data in the graphic element information table;
[0023] Control point encryption module: encrypts control points based on the data in the graphic element information table after the picture frame and picture name are identified;
[0024] Clustering module: Use the DBSCAN algorithm to cluster the encrypted control points and obtain a classification list of the encrypted control points and their thumbnail categories;
[0025] Entity information update module: Based on the classified list of encrypted control points and their thumbnail categories, update the entity information and complete the thumbnail clustering in the entity information.
[0026] The present invention provides a computer-readable storage medium storing one or more programs, wherein the one or more programs include instructions, and when the instructions are executed by a computing device, the computing device executes any one of the above-mentioned methods for water conservancy CAD drawing information recognition based on the DBSCAN algorithm.
[0027] Beneficial effects: The present invention has the following advantages: 1. The present invention realizes the automatic classification and organization of section information in water conservancy CAD drawings, thereby improving the efficiency and accuracy of CAD graphic data processing; 2. The present invention can be applied to water conservancy CAD drawings of different scales and types, and has good versatility and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 A schematic diagram of the invention process;
[0029] Figure 2 It is a CAD graphic schematic diagram of an embodiment;
[0030] Figure 3 A schematic diagram for reading entity information in CAD drawings;
[0031] Figure 4 Removal Figure 3 Schematic diagram of redundant information in ;
[0032] Figure 5 For Figure 4 Schematic diagram of the effect of equidistant encryption of the central control points;
[0033] Figure 6 For Figure 5 Schematic diagram of clustering of control points;
[0034] Figure 7 To use the number of thumbnails Figure 6 Schematic diagram of adjusting the clustering results;
[0035] Figure 8 A schematic diagram for updating entity information. DETAILED DESCRIPTION
[0036] The technical solution of the present invention is described in detail below in conjunction with the embodiments and drawings.
[0037] like Figure 1 As shown, the water conservancy CAD drawing information recognition method based on the DBSCAN algorithm described in the present invention comprises the following steps:
[0038] Step 1: Get the entity information in the CAD drawing;
[0039] The CAD drawing includes an A0 or extended A0 drawing frame, which contains multiple small drawings, each of which contains a drawing name, wherein the drawing name text height is N, and the small drawing name text height is n. The small drawing refers to the view contained in the drawing, such as a sectional view.
[0040] The method for obtaining entity information in CAD drawings is: convert the CAD drawings into DXF format, use the ezdxf library to read the DXF file, and obtain all entity information in the drawings. The entity information refers to entity type, layer, control point, wireframe; entity type includes straight line, arc, block, text, polyline, dimension.
[0041] Step 2: Convert entity information into a two-dimensional graphic element information table;
[0042] The column labels included in the primitive information table are: entity handle handle, entity type type, control points points, name name, line width linewidth; for text entities, the text content is stored in the column label text, and the text height is stored in the column label height.
[0043] Step 3: Identify the frame and name of the image based on the data in the image element information table;
[0044] The method for identifying the drawing frame and the drawing name is as follows: a polyline with a height greater than a set threshold is marked as a drawing frame, and a polyline located in a rectangular range of (0.75, 0) to (1, 0.15) relative to the drawing frame is marked with a "drawing frame" mark in the "name" column, with the lower left corner of the drawing frame as the origin;
[0045] In the drawing frame, the text entities with a text height of n are labeled "Drawing Name" in the "name" column; the text entities with a text height of N are labeled "Sheet Name" in the "name" column; according to the drawing frame range, the control point entities within the drawing frame rectangle are labeled with the sheet name corresponding to this drawing frame in the "paper_name" column.
[0046] Step 4: Encrypt control points based on the data in the graphic element information table after the graphic frame and graphic name are identified;
[0047] The method for encrypting control points is: reading the control points whose "name" column is not "frame", "name" or "drawing name" in the graphic element information table after the frame and name recognition, and using equidistant encryption to insert new control points between control points by setting an interval distance, so that the newly inserted control point will maintain the same distance as the previous control point.
[0048] Step 5: Use the DBSCAN algorithm to cluster the encrypted control points to obtain a classification list of the encrypted control points and their thumbnail categories;
[0049] The clustering method is: setting DBSCAN algorithm parameters, including the neighborhood radius of the control point, and the minimum number of control points required in the ε-neighborhood that can be considered as a core point, so as to obtain a classification list of encrypted control points [(x1, y1), (x2, y2), (x3, y3), ...], and the small image categories corresponding to the classification list: ["small image i", "small image j", "small image k", ...].
[0050] The DBSCAN algorithm can automatically identify clusters of any shape and is robust to noise data and outliers. By adjusting the parameters of the DBSCAN algorithm, clusters of different densities and shapes can be accurately clustered.
[0051] Step 6: Based on the classification list of encrypted control points and their thumbnail categories, update the entity information and complete the thumbnail clustering in the entity information. The specific method is as follows:
[0052] The method for updating entity information is as follows: for each control point coordinate in the entity information, traverse the encrypted control point classification list, find the encrypted control point that matches the control point coordinate in the entity information, and obtain the corresponding thumbnail category, assign the matched thumbnail category to the "pic_name" column of the entity information, update the entity information to reflect the thumbnail category to which each entity control point in the entity information belongs, and complete thumbnail clustering.
[0053] Since the number of drawing names in a drawing is usually known, the clustering results can be verified and corrected based on the number of drawing names to ensure the accuracy of clustering.
[0054] Embodiment 1
[0055] like Figure 2 As shown, this is a CAD drawing of the rockfill gravity dam used in the project. The drawing contains multiple sets of water diversion tunnel profiles, and the distance between the small pictures is appropriate (only the outline of the graphics is indicated).
[0056] like Figure 3 As shown, Figure 2 The drawings shown are converted to DXF format, and the ezdxf library is imported into Python to read the entity information in the drawings. The information in the drawings is converted into coordinate point form, that is, each line segment is converted into the coordinate form of the corresponding control point, and some such as arcs are converted into endpoint coordinates.
[0057] like Figure 4 As shown, Figure 3 The schematic diagram of the effect after the corresponding control points in the drawing shown are equidistantly encrypted. Since the graphic element information is mostly line segments, non-line segment entries such as text are excluded to obtain the control point coordinate group of each line, which is then equidistantly encrypted.
[0058] like Figure 5 As shown, based on Figure 4 The drawing shown is a schematic diagram of the effect of removing redundant information (drawing frame, drawing title, etc.) and leaving useful information.
[0059] like Figure 6 As shown, based on Figure 5 The drawing shown in the figure uses the DBSCAN algorithm to cluster the control points in the figure. The DBSCAN algorithm is used to adjust the hyperparameter neighborhood radius and the minimum number of control points required in the ε-neighborhood that can be considered as the core point in combination with the equidistant encryption distance and the actual situation of the drawing. The control points after the above processing are clustered to obtain the clustering results.
[0060] like Figure 7 As shown, the clustering result is adjusted using the number of thumbnail names identified previously to ensure that the number of thumbnails is the same as the number of thumbnail names.
[0061] like Figure 8 As shown, update the entity information and assign graph names to each class, thus completing the clustering.
Claims
1. A method for identifying water conservancy CAD drawing information based on DBSCAN algorithm, characterized in that: The following steps are involved: Step 1: Get the entity information in the CAD drawing; Step 2: Convert entity information into a two-dimensional graphic element information table; Step 3: Identify the frame and name of the image based on the data in the image element information table; Step 4: Encrypt control points based on the data in the graphic element information table after the graphic frame and graphic name are identified; Step 5: Use the DBSCAN algorithm to cluster the encrypted control points to obtain a classification list of the encrypted control points and their thumbnail categories; Step 6: Based on the classification list of encrypted control points and their thumbnail categories, update the entity information and complete the thumbnail clustering in the entity information.
2. The water conservancy CAD drawing information recognition method based on the DBSCAN algorithm according to claim 1 is characterized in that: The CAD drawing described in step 1 includes an A0 or extended A0 drawing frame, which contains multiple small drawings. Each small drawing has a drawing name, wherein the text height of the drawing name is N, and the text height of the small drawing name is n.
3. The water conservancy CAD drawing information recognition method based on DBSCAN algorithm according to claim 1 is characterized in that: The method for obtaining entity information in the CAD drawing described in step 1 is: convert the CAD drawing into DXF format, use the ezdxf library to read the DXF file, and obtain all entity information in the drawing, wherein the entity information refers to entity type, layer, control point, wireframe; entity type includes straight line, arc, block, text, polyline, dimension.
4. The water conservancy CAD drawing information recognition method based on the DBSCAN algorithm according to claim 3 is characterized in that: The column labels of the primitive information table in step 2 are: entity handle handle, entity type type, control point points, name name, line width linewidth; For text entities, the text content is stored in the column label text, and the text height is stored in the column label height.
5. The water conservancy CAD drawing information recognition method based on DBSCAN algorithm according to claim 4 is characterized in that: The method for identifying the drawing frame and drawing name in step 3 is as follows: mark the polyline with a height greater than a set threshold as a drawing frame, take the lower left corner of the drawing frame as the origin, mark the polyline located in the rectangular range of (0.75, 0) to (1, 0.15) relative to the drawing frame with a "drawing frame" mark, and mark it in the "name" column; In the drawing frame, the text entities with a text height of n are labeled "drawing name" in the "name" column; the text entities with a text height of N are labeled "drawing name" in the "name" column; according to the drawing frame range, the control point entities within the drawing frame rectangle are labeled with the drawing name corresponding to this drawing frame in the "paper_name" column.
6. The water conservancy CAD drawing information recognition method based on DBSCAN algorithm according to claim 1 is characterized in that: The method for encrypting the control points described in step 4 is: read the control points whose "name" column is not "frame", "name" or "drawing name" in the graphic element information table after the frame and name recognition, and use equidistant encryption to insert new control points between the control points by setting an interval distance, so that the newly inserted control point will maintain the same distance with the previous control point.
7. The water conservancy CAD drawing information recognition method based on DBSCAN algorithm according to claim 1 is characterized in that: The clustering method described in step 5 is: setting the DBSCAN algorithm parameters, including the neighborhood radius of the control point, and the minimum number of control points required in the ε-neighborhood considered to be the core point, so as to obtain a classification list of encrypted control points [(x1, y1), (x2, y2), (x3, y3), ...], and the small image categories corresponding to the classification list: ["small image i", "small image j", "small image k", ...].
8. The water conservancy CAD drawing information recognition method based on DBSCAN algorithm according to claim 1 is characterized in that: The method for updating entity information described in step 6 is: for each control point coordinate in the entity information, traverse the encrypted control point classification list, find the encrypted control point that matches the control point coordinate in the entity information, and obtain the corresponding thumbnail category, assign the matched thumbnail category to the "pic_name" column of the entity information, update the entity information to reflect the thumbnail category to which each entity control point in the entity information belongs, and complete thumbnail clustering.
9. The water conservancy CAD drawing information recognition system based on DBSCAN algorithm according to claim 1 is characterized in that: The system includes an entity information acquisition module: used to acquire entity information in a CAD drawing; Entity information conversion module: used to convert entity information into a two-dimensional graphic element information table; Frame and name recognition module: recognizes frames and names based on the data in the graphic element information table; Control point encryption module: encrypts control points based on the data in the graphic element information table after the picture frame and picture name are identified; Clustering module: Use the DBSCAN algorithm to cluster the encrypted control points and obtain a classification list of the encrypted control points and their thumbnail categories; Entity information update module: Based on the classified list of encrypted control points and their thumbnail categories, update the entity information and complete the thumbnail clustering in the entity information.
10. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computing device, cause the computing device to perform any one of the methods according to claims 1 to 8.
Citation Information
Patent Citations
On-line multi-stroke axonometric sketch clustering method based on common boundaries of regions
CN107563449A
Curve classification method and device in engineering drawings
CN111881951A
Window recognition method and device based on CAD drawing and window three-dimensional reconstruction method
CN112417538A
Drawing segmentation method and device and electronic equipment
CN114429640A
Intelligent identification method and device for entity information in real estate drawing and electronic equipment
CN117421439A
Cited By
Architectural drawing processing method and device and medium
CN120656188A
Architectural drawing processing method, device, and medium
CN120656188B
Method for automatic categorisation of drawing data
RU2856757C1
