Water conservancy drawing auditing method and system based on vector analysis and semantic fusion
By combining vector analysis and semantic fusion methods with deep convolutional neural networks and geometric matching algorithms, the problems of low structural recognition accuracy and missing dimension annotations in water conservancy engineering drawings have been solved, achieving efficient and reliable intelligent drawing review.
Patent Information
- Application Number
- CN202511859867.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-10
- Publication Date
- 2026-03-20
AI Technical Summary
In existing intelligent drawing review methods for water conservancy projects, the insufficient utilization of vector geometric information and image semantic information leads to low structural recognition accuracy and a lack of logic for detecting missing dimension annotations, making it difficult to meet the review requirements of water conservancy projects.
A method based on vector parsing and semantic fusion is adopted. By parsing the vector files of water conservancy engineering drawings, the coordinates of line segment endpoints and dimension annotation data are extracted. Combined with a deep convolutional neural network model, structural recognition and geometric matching are performed to identify missing objects and perform differentiated marking.
It improves the accuracy of structure recognition, reduces false alarms and missed detections, realizes automated dimension annotation omission detection, and improves the efficiency and reliability of drawing review.
Smart Images

Figure CN121708623A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent review technology for water conservancy engineering drawings, specifically to a method and system for reviewing water conservancy drawings based on vector analysis and semantic fusion. Background Technology
[0002] Water conservancy engineering drawings are crucial technical bases for the construction and acceptance of water conservancy projects. The completeness and accuracy of their dimensional annotations directly affect the quality and safety of the project. With the increasing digitalization of the industry, using artificial intelligence technology to assist in drawing review has become an effective means to improve review efficiency. Currently, common intelligent drawing review methods are mostly based on general computer vision technology. This involves converting CAD-format vector drawings into raster images such as JPG or PNG, and then using deep learning models for object detection or semantic segmentation to identify structural objects in the drawings.
[0003] However, existing methods have certain limitations in the review of hydraulic engineering drawings. Hydraulic engineering drawings are typically complex in structure, densely packed with lines, and contain numerous detailed components and natural terrain features. During the conversion of vector graphics to raster images, the precise geometric information in the original files is easily lost, making it difficult for general image recognition models to accurately distinguish target buildings from background elements in pixel-level classification tasks. Furthermore, in the crucial step of reviewing the completeness of dimension annotations, existing methods generally lack an effective verification mechanism for the logical relationship between structural entities and annotation information. Relying solely on visual recognition cannot confirm whether a structure has been correctly dimensioned based on geometric relationships, thus easily leading to misjudgments and missed detections in practical applications. Therefore, it is necessary to improve existing technologies to address the poor review results caused by insufficient utilization of vector information, inadequate structural recognition accuracy, and the lack of annotation matching mechanisms. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of the existing technology and provide a method and system for reviewing water conservancy drawings based on vector analysis and semantic fusion, so as to solve the problems of low structural recognition accuracy and missing dimension annotation detection logic caused by insufficient utilization of vector geometric information and image semantic information in the existing water conservancy engineering drawing review methods.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a method for reviewing hydraulic drawings based on vector analysis and semantic fusion, comprising the following steps: Step S100: Parse the vector file of the water conservancy engineering drawing to be reviewed, extract the endpoint coordinate information of all line segments in the vector file to construct a set of graphic information, and extract the dimension annotation entity data in the vector file to construct a set of dimension annotations; Step S200: Based on the endpoint coordinate information in the graphic information set, the vector line segment is redrawn as a scalar image, and the scalar image is input into a pre-trained deep convolutional neural network model with an encoder-decoder architecture, and the output is a confidence matrix covering the categories to which each pixel in the scalar image belongs. Step S300: Based on the mapping relationship from vector coordinates to image pixels established during the redrawing process, and combined with the confidence matrix, the structural category of each line segment in the graphic information set is determined using a classification decision algorithm, and target line segments belonging to the target building category are selected. Step S400: Based on the endpoint coordinate information of the target line segment and the geometric attributes of the dimension entity data in the dimension annotation set, use a geometric matching algorithm to determine whether there is a corresponding valid dimension annotation for the target line segment one by one; Step S500: The target line segment that does not match a valid dimension annotation is identified as a missing annotation object, and the missing annotation object is output with differentiated marking in the visualization view of the drawing.
[0006] The present invention further proposes that the specific implementation of step S100 includes: Call the DXF file parsing interface to read the vector file of the water conservancy project drawings; Traverse the geometric entity objects in the vector file, decompose the multi-segment line entity into multiple independent line segment entities, and store the starting horizontal and vertical coordinates and the ending horizontal and vertical coordinates of each line segment entity in the form of a quadruple into the graphic information set. Extract the coordinates of the endpoints of the dimension boundary lines, the angles of the dimension lines, and the numerical values of the dimension text of the entities in the dimension layer of the vector file, and store them in the dimension annotation set.
[0007] The present invention further proposes that the deep convolutional neural network model in step S200 specifically adopts the UNet network architecture, whose structural features include: The encoder section uses a ResNet-101 residual network as the backbone network to extract deep semantic features of the scalar image; The decoder part gradually restores the resolution of the feature map through upsampling operations and performs skip connections to fuse the feature maps of the corresponding layers of the encoder. The output layer outputs a mask matrix with N output channels, where N corresponds to the number of preset categories, and the values in the mask matrix represent the probability values of the corresponding pixel belonging to each category.
[0008] The present invention further proposes that the training process of the deep convolutional neural network model in step S200 includes: In CAD drawing software, drawing objects are categorized by modifying the line color index. The preset categories include at least target buildings, natural environment, auxiliary lines, and irrelevant objects. The marked drawing file is parsed, the color information of the line segments is extracted as the category label for supervised training, and the endpoint coordinate information of the line segments is extracted to construct the training dataset. The deep convolutional neural network model is iteratively trained using the training dataset, and the model parameters are optimized using the binary cross-entropy loss function.
[0009] The present invention further proposes that the classification decision algorithm in step S300 includes: Based on the mapping relationship, determine the set of pixels covered by each line segment in the graphic information set on the scalar image; Obtain the confidence score value of each pixel in the pixel set under each preset category; The confidence scores of each of the preset categories are summed to obtain the total confidence score, and the category with the highest total confidence score is determined as the final structure category of the line segment.
[0010] The present invention further proposes that the step S400 of using a geometric matching algorithm to determine whether each target line segment has a corresponding valid dimension annotation includes: Calculate the slope and geometric length of the target line segment based on the endpoint coordinate information; Traverse the set of dimension annotations and select dimension annotation entities whose slope and geometric length in the geometric attributes are equal to the target line segment as candidate annotations; Construct four connection vectors connecting the endpoints of the target line segment to the endpoints of the dimension line of the candidate annotation; Determine whether there are two vectors among the four connection vectors that are perpendicular to the target line segment. If so, determine that the target line segment matches the candidate label successfully.
[0011] The present invention further proposes that, in the process of screening the candidate labels, step S400 further includes: Based on the slope of the target line segment, determine its geometric regions in the horizontal, vertical, and perpendicular directions; Only the dimension entities in the dimension set are retrieved within the geometric region, and these are used as the initial screening range for the candidate dimensions.
[0012] The present invention further proposes that step S500 includes: When the target line segment is determined to be a missing object, calculate the geometric length of the target line segment in the drawing coordinate system; Based on the successfully matched line segments and their corresponding dimension values, calculate the scaling factor between the drawing coordinate system and the actual physical space; The default physical size of the missing object is calculated using the geometric length and the scaling factor, and the default physical size is output as a suggested value.
[0013] The present invention further proposes that the differential label output in step S500 includes: Generate an image containing the error-corrected result of the original drawing structure; The target line segment identified as an unmarked object is highlighted with a first preset color, and the line segment that has matched a valid dimension mark is drawn with a second preset color. The first preset color and the second preset color are different from each other.
[0014] Secondly, the present invention also provides a water conservancy drawing review system based on vector analysis and semantic fusion, comprising: The data parsing module is used to call the parsing interface to read the vector file of the water conservancy engineering drawings, decompose the polyline into independent line segments and extract the endpoint coordinate information to construct a set of graphic information, and at the same time extract the geometric attributes of the labeled entities to construct a set of dimension annotations. The semantic recognition module is used to convert the vector data in the graphic information set into a scalar image, input it into a deep convolutional neural network model with an encoder-decoder architecture, output a confidence matrix covering the confidence of each pixel in the scalar image to each preset category, and determine the structural category of the line segment by accumulating the confidence of the pixel covered by the line segment based on the mapping relationship established by redrawing, thereby filtering out the target building line segment. The geometric verification module is used to calculate the slope and geometric length of the target building line segment and the dimensioned entity, and to determine whether there is a valid dimension matching by verifying the perpendicular relationship between the vector connecting the endpoints of the line segment and the endpoints of the dimension line. The results output module is used to identify target building line segments that have not been matched with valid dimension annotations, calculate their default dimensions based on the scale factor of the matched objects, and generate review results that highlight the missing line segments and display suggested dimension values.
[0015] This invention discloses a method and system for reviewing hydraulic engineering drawings based on vector analysis and semantic fusion. Its core lies in directly parsing vector files to preserve geometric accuracy, and combining deep learning semantic segmentation and geometric rule verification to achieve accurate detection of missing dimension annotations. Compared to existing technologies, this invention offers significant advantages: native vector data processing avoids rasterization information loss and improves structural recognition accuracy; a geometric matching algorithm establishes rigorous annotation association logic, reducing false alarms and missed detections; modular design supports flexible deployment and can be expanded to different hydraulic engineering scenarios; simultaneously, the system can automatically calculate suggested values for missing dimensions to assist manual review, significantly improving the efficiency and reliability of drawing review. Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating a water conservancy drawing review method based on vector analysis and semantic fusion according to the present invention.
[0017] Figure 2 This is a schematic diagram of the module structure of a water conservancy drawing review system based on vector analysis and semantic fusion according to the present invention.
[0018] Figure 3 This diagram illustrates a comparison between the dimensioning omission detection results output by the drawing review method of this invention and manual inspection. Figure 1 ; Figure 4 This diagram illustrates a comparison between the dimensioning omission detection results output by the drawing review method of this invention and manual inspection. Figure 2 ; Figure 5 This is an example of the effect of a deep convolutional neural network reconstructing water conservancy drawings.
[0019] The following are the markings in the attached diagram: 100. Data parsing module; 200. Semantic recognition module; 300. Geometric verification module; 400. Result output module. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0021] In the description of this invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0022] Existing intelligent drawing review technologies for water conservancy projects suffer from low structural recognition accuracy due to the loss of vector information, lack of logical correlation between dimension annotations and structures, and poor detection of missing annotations, making it difficult to meet the review requirements of water conservancy projects. Therefore, to improve upon these issues, this application provides a water conservancy drawing review method based on vector analysis and semantic fusion, such as... Figure 1 As shown, the method includes the following steps S100 to S500: Step S100: Parse the vector file of the water conservancy engineering drawing to be reviewed, extract the endpoint coordinate information of all line segments in the vector file to construct a set of graphic information, and extract the dimension annotation entity data in the vector file to construct a set of dimension annotations; Step S200: Based on the endpoint coordinate information in the graphic information set, the vector line segment is redrawn as a scalar image, and the scalar image is input into a pre-trained deep convolutional neural network model with an encoder-decoder architecture, and the output is a confidence matrix covering the categories to which each pixel in the scalar image belongs. Step S300: Based on the mapping relationship from vector coordinates to image pixels established during the redrawing process, combined with the confidence matrix, the classification decision algorithm is used to determine the structural category of each line segment in the graphic information set, and the target line segments belonging to the target building category are selected. Step S400: Based on the endpoint coordinate information of the target line segment and the geometric attributes of the dimension entity data in the dimension annotation set, use the geometric matching algorithm to determine whether there is a corresponding valid dimension annotation for each target line segment; Step S500: Identify the target line segments that do not match valid dimension annotations as missing annotation objects, and output the missing annotation objects with differentiated markings in the visualization view of the drawing.
[0023] In step S100, the vector file preferably uses the DXF format, which is a common CAD vector format and easy to parse. During parsing, the ezdxf library can be used as the DXF file parsing interface. This library supports directly reading geometric entities (such as line segments and polylines) and dimension entities (such as dimensions) from the file, offering strong compatibility. The coordinate information of the line segment endpoints is expressed in (…). x 1, y 1, x2, y 2) Stored in the form of a quadruple. x , y The drawing coordinates in the vector file ensure that the position, length, and direction of the line segments can be accurately restored during subsequent redrawing; the dimension annotation entity data includes the coordinates of the two endpoints of the dimension line (used to calculate the geometric range corresponding to the annotation), the angle between the dimension line and the horizontal direction (used to determine the dimension direction), and the numerical values in the annotation text (used for subsequent scale factor calculation). These data together constitute the geometric attributes of the dimension annotation, providing a basis for subsequent matching.
[0024] The scalar image redrawing in step S200 can be implemented using the OpenCV library. Line segments are drawn on a blank image canvas based on their endpoint coordinates. The image resolution can be set according to the actual size of the drawing (e.g., 10 pixels per millimeter) to ensure clear and distinguishable line segment details. The deep convolutional neural network model uses an encoder-decoder architecture. This architecture extracts deep semantic features from the image through the encoder and then gradually restores the feature map resolution through the decoder, making it suitable for processing densely structured images in hydraulic drawings. Preset categories include target structures (e.g., dam bodies, gate chamber bottoms), natural environments (e.g., topographic lines, water boundaries), auxiliary lines (e.g., axes, outlines), and irrelevant objects (e.g., tables, explanatory text), meeting the core requirement of structural differentiation in hydraulic drawings. The confidence matrix is a three-dimensional probability distribution matrix with dimensions H×W×N, where H and W are the height and width of the scalar image, respectively, and N is the number of preset categories. Each element in this matrix... The coordinates in the image are The pixel belongs to the first The probability values of each category (usually processed by Softmax normalization) range from [0,1]. This confidence matrix provides pixel-level semantic information of the entire image and is the basic data source for the subsequent segment-level classification decision in step S300.
[0025] The mapping relationship in step S300 is the "vector coordinate-pixel coordinate" correspondence recorded synchronously during redrawing, such as the vector coordinates of the endpoints of a line segment ( x 0, y 0) The pixel coordinates of the corresponding scalar image ( u 0, v 0), through this relationship, the coverage range of each line segment on the scalar image can be accurately determined; the classification decision algorithm avoids the misjudgment of a single pixel affecting the overall category judgment by accumulating the confidence of the line segment covering all pixels, thus improving the reliability of structure classification.
[0026] The geometric attributes in step S400 include the slope of the target line segment (calculated from the endpoint coordinates using the slope formula), the geometric length (calculated from the distance formula between two points), and the angle and length of the dimension annotations. Geometric matching is verified through multi-dimensional verification (slope consistency, length consistency, existence of perpendicular vectors) to ensure the accurate correspondence between annotations and the structure. When comparing slope and length, considering drawing errors, a tolerance threshold can be set (e.g., error range within ±5% or ±0.01). As long as the difference between the two is within the tolerance range, they are considered equal.
[0027] In step S500, the differentiation markers can be drawn in red for missing markings and in green for matched markings. The colors are clearly contrasted, making it easy for reviewers to visually identify the missing marking areas.
[0028] This method preserves key information through vector analysis and combines semantic recognition and geometric matching, effectively solving the problems of low structure recognition accuracy and missing label detection logic in existing technologies. It can provide accurate and efficient technical support for the review of water conservancy drawings.
[0029] The present invention further proposes that the specific implementation of step S100 includes: calling the DXF file parsing interface to read the vector file of the water conservancy engineering drawing; traversing the geometric entity objects in the vector file, decomposing the polyline entity into multiple independent line segment entities, and storing the starting horizontal and vertical coordinates and the ending horizontal and vertical coordinates of each line segment entity in the form of a quadruple into the graphic information set; extracting the dimension boundary line endpoint coordinates, dimension line angles and dimension text values of the dimension layer entities in the vector file, and storing them into the dimension dimension set.
[0030] The reason for decomposing polyline entities is that "LWPOLYLINE" type entities in DXF files are composed of multiple continuous line segments. If they are treated directly as a single entity, subsequent structure identification may lead to the polylines being classified as a single category, making it impossible to distinguish the independent structures within them. During decomposition, the vertex coordinate list of the polyline is read, and two adjacent vertices are treated as the endpoints of an independent line segment. For example, if the polyline vertex is (… x 1, y 1) ( x 2 ,y 2), ( x 3 ,y 3), then it can be broken down into ( x 1 ,y 1 ,x 2 ,y 2) and ( x 2 , y 2 ,x 3 ,y 3) Two line segments, ensuring that each line segment can be used as a separate structural identification unit.
[0031] When extracting entities from the dimension layer, first identify the layer in the CAD drawing specifically used to store dimension annotations (usually named "DIMENSION" or "Dimension Layer"). Only read entities of type "DIMENSION" under this layer to eliminate interference from irrelevant annotations (such as text annotations) in other layers. When parsing dimension annotation entities, use the attribute reading function of the DXF file parsing interface to obtain the coordinates of the two endpoints of the dimension line (corresponding to the annotation range), the angle of the dimension line (corresponding to the annotation direction), and the numerical values in the annotation text (corresponding to the actual dimensions) to ensure the integrity of the dimension annotation data.
[0032] As an alternative embodiment, those skilled in the art can also use other DXF parsing tools such as the dxfgrabber library to parse vector files, and polyline decomposition can also be achieved by calculating the vector relationship between adjacent vertices, all of which can achieve the purpose of accurately extracting line segments and annotation information.
[0033] This step, by specifically processing polylines and annotation layer entities, provides high-quality data for subsequent structure identification and annotation matching, reducing the impact of invalid data on the review results.
[0034] The present invention further proposes that the deep convolutional neural network model in step S200 specifically adopts the UNet network architecture, the structural features of which include: the encoder part adopts a ResNet-101 residual network as the backbone network to extract deep semantic features of the scalar image; the decoder part gradually restores the resolution of the feature map through upsampling operation and performs skip connections to fuse the feature maps of the corresponding layers of the encoder; the output layer outputs a mask matrix with N channels, where N corresponds to the number of preset categories, and the values in the mask matrix represent the probability values of the corresponding pixel belonging to each category.
[0035] The encoder employs a ResNet-101 residual network, which addresses the vanishing gradient problem in deep network training through its residual block structure. This network effectively extracts semantic features from shallow to deep layers in scalar images. Shallow features (such as edges and textures) can be used to distinguish line segment details, while deep features (such as structural outlines) can be used to identify the overall structural category, making it suitable for feature extraction of complex structures in hydraulic drawings. The decoder's upsampling operation uses transposed convolution. Each upsampling doubles the feature map resolution, while simultaneously incorporating the corresponding layer's feature map from the encoder into the current decoder's feature map via skip connections. For example, the second layer's feature map from the decoder is fused with the third layer's feature map from the encoder. This replenishes the detailed information lost during upsampling, improving the accuracy of pixel category determination. The mask matrix of the output layer has dimensions of H×W×N (H is the image height, W is the image width, and N is the number of preset categories). The value range of each element in the matrix is [0,1], which represents the probability of the corresponding pixel belonging to a certain category. For example, if the probability of a pixel in the target building channel is 0.92 and the probability in other channels is less than 0.1, then the pixel is determined to belong to the target building category.
[0036] As an alternative embodiment, those skilled in the art can also use improved UNet architectures such as UNet++, or use ResNet-50 as the encoder backbone. While ensuring the feature extraction effect, the network complexity can be adjusted according to the hardware computing power to meet the needs of different deployment scenarios.
[0037] This model structure, through the combination of encoder-decoder and skip connections, can accurately extract the semantic features of water conservancy drawings, providing a reliable basis for subsequent structural classification.
[0038] The present invention further proposes that the training process of the deep convolutional neural network model in step S200 includes: classifying drawing objects in CAD drawing software by modifying the line color index, with the preset categories including at least target buildings, natural environment, auxiliary lines and irrelevant objects; parsing the marked drawing file, extracting the color information of the line segments as category labels for supervised training, and extracting the endpoint coordinate information of the line segments to construct a training dataset; iteratively training the deep convolutional neural network model using the training dataset, and optimizing the model parameters using the binary cross-entropy loss function.
[0039] Among them, the CAD drawing software can be AutoCAD or ZWCAD, such as... Figure 5As shown, the color index labeling rule can be set as follows: target buildings correspond to color index number 1 (red), natural environment corresponds to color index number 3 (green), auxiliary lines correspond to color index number 2 (yellow), and irrelevant objects correspond to color index number 5 (blue). This rule is simple and intuitive, easy for reviewers to operate, and requires no additional learning of professional annotation software. When constructing the training dataset, the labeled DXF file is first parsed, and the color information of each line segment is extracted as a category label (e.g., color index number 1 corresponds to the label "target building"). Then, the scalar image is redrawn according to the coordinates of the line segment endpoints to form a training sample pair of "scalar image-category mask". The category mask is a matrix with the same size as the scalar image, and the value of each pixel corresponds to the label of the category to which the pixel belongs.
[0040] In the specific implementation of model iterative training, the stochastic gradient descent (SGD) optimizer is adopted, with the initial learning rate set to 0.0001, weight decay set to 0.0005, and the number of training epochs set to 1000. Batch training (batch size set to 8) is used to improve training efficiency. The binary cross-entropy loss function is used to calculate the error between the confidence matrix output by the model and the class mask. The model parameters are adjusted through backpropagation to minimize the error and ensure that the model can accurately learn the features of each class structure.
[0041] As an alternative embodiment, those skilled in the art can also use the Adam optimizer instead of the SGD optimizer, or adjust the batch size and training epochs according to the number of training samples, all of which can achieve effective model training. This training process reduces data preparation costs by constructing a dataset through simple color labeling, while accurately optimizing the model using the binary cross-entropy loss function to ensure that the model has high-quality semantic recognition capabilities.
[0042] The present invention further proposes that the classification decision algorithm in step S300 includes: determining the set of pixels covered by each line segment in the graphic information set on the scalar image according to the mapping relationship; obtaining the confidence value of each pixel in the pixel set under each preset category; summing the confidence values under each preset category to obtain the total confidence value, and determining the category with the largest total confidence value as the final structure category of the line segment.
[0043] The determination of the set of pixels covered by a line segment is achieved through a mapping relationship, for example, the range of vector coordinates of the line segment is... x ∈[ x 1, x 2] y∈[ y 1, y 2], the pixel coordinate range of the corresponding scalar image is u ∈[ u 1, u2]、 v ∈[ v 1, v [2] All pixels within this range belong to the coverage set of the line segment, ensuring that no pixel on the line segment is missed. When accumulating confidence, for each line segment's coverage pixel set, the sum of the confidence scores of all pixels under each preset category is calculated. For example, the total confidence score of the target building category is the sum of the confidence scores of all pixels under that category. The total confidence scores of the natural environment, auxiliary lines, and irrelevant object categories are calculated similarly. Final category determination is achieved by comparing the total confidence scores of each preset category. The category with the highest total confidence score is the final structural category of the line segment. For example, if the total confidence score of the target building category for a line segment is 125.6, and all other categories are below 50, then the line segment is determined to belong to the target building.
[0044] As an alternative embodiment, those skilled in the art can also use the "total confidence ratio" (total confidence of a certain category / sum of total confidence of all categories) as the basis for judgment. When the ratio exceeds a preset threshold (such as 0.6), the category is determined, which further improves the reliability of the judgment.
[0045] This classification decision algorithm avoids the impact of single pixel errors on the overall category judgment by accumulating the confidence scores of the pixels covered by line segments, ensuring accurate structural classification results and providing a reliable foundation for subsequent target building screening.
[0046] The present invention further proposes that step S400, which uses a geometric matching algorithm to determine whether a target line segment has a corresponding valid dimension annotation, includes: calculating the slope and geometric length of the target line segment based on the endpoint coordinate information; traversing the dimension annotation set and selecting dimension annotation entities whose slope and geometric length are equal to those of the target line segment as candidate annotations; constructing four connection vectors connecting the endpoints of the target line segment and the endpoints of the dimension boundary lines of the candidate annotations; determining whether two of the four connection vectors are perpendicular to the target line segment, and if so, determining that the target line segment and the candidate annotation are successfully matched.
[0047] The slope of the target line segment is determined by the coordinates of its endpoints (…). x 1, y 1) ( x 2, y 2) Calculation, the formula is: k= ( y 2 -y 1) / ( x 2 - x 1) x 2 ≠x (1 hour), if x 2 =x1. The slope is infinite (vertical line segment); the geometric length is calculated using the distance formula between two points, the formula is... L= √[( x 2 -x 1)² + ( y 2 -y 1)²], ensuring accurate slope and length calculations. During candidate annotation screening, each annotation entity in the dimension annotation set is traversed, and its geometric attributes (annotation line slope compared to the target line segment slope) and annotation length (compared to the target line segment geometric length) are extracted. When both are equal, the annotation entity is used as a candidate annotation, initially narrowing the matching range and reducing subsequent calculations. For example, if the two endpoints of the target line segment of the four connecting vectors are A and B, and the two endpoints of the dimension line of the candidate annotation are C and D, then the connecting vectors are AC, AD, BC, and BD. To determine if a vector is perpendicular to the target line segment, the dot product of the vector and the direction vector of the target line segment is calculated. If the dot product is 0 (or close to 0, considering calculation errors), then they are determined to be perpendicular. For example, if the direction vector of the target line segment is (dx, dy), and the connecting vector AC is (ux, uy), if dx, dy, ... x ×u x +d y ×u y If ≈0, then AC is perpendicular to the target line segment; when two of the four connecting vectors (such as AC and BD) are perpendicular to the target line segment, it means that the dimension annotation exactly corresponds to the length of the target line segment, and the match is determined to be successful.
[0048] This geometric matching algorithm establishes a precise association between the target line segment and the dimension annotation through multi-dimensional verification of slope, length, and perpendicular vector, avoiding the problem of "mistaking adjacent structural annotations as target annotations" in existing technologies and improving the accuracy of dimension annotation matching.
[0049] The present invention further proposes that, in the process of screening candidate annotations, step S400 includes: determining the geometric regions of the target line segment in the horizontal, vertical and perpendicular directions based on the slope of the target line segment; and retrieving only the dimension annotation entities in the dimension annotation set within the geometric region, and using them as the initial screening range of candidate annotations.
[0050] The determination of the horizontal, vertical, and perpendicular geometric regions of the target line segment is based on the slope of the line segment, which determines its direction and defines a specific area. For example, if the slope of the target line segment is close to 0 (horizontal line segment), its horizontal region is a rectangle extending a certain distance to the left and right, and its vertical region is a rectangle extending a certain distance up and down. If the slope of the target line segment is infinite (vertical line segment), its vertical region is a rectangle extending a certain distance up and down, and its horizontal region is a rectangle extending a certain distance to the left and right. If the target line segment is an inclined line segment (e.g., with a slope of 1), its vertical region is a rectangle extending a certain distance perpendicular to the line segment. Searching for dimension entities only within this geometric region excludes dimension entities that are too far from the target line segment. For example, if a horizontal target line segment is located on the left side of the drawing, dimension entities far to the right will not be included in the initial screening, significantly reducing the number of candidate dimension entities, lowering the computational load for subsequent geometric matching, and improving drawing review efficiency. This initial screening step narrows down the range of candidate annotations by delineating geometric regions, thereby improving the efficiency of the geometric matching algorithm while ensuring matching accuracy, and meeting the needs of rapid review of large-scale water conservancy drawings.
[0051] The present invention further proposes that step S500 includes: when the target line segment is determined to be a missing object, calculating the geometric length of the target line segment in the drawing coordinate system; calculating the scaling factor between the drawing coordinate system and the actual physical space based on the successfully matched line segments and their corresponding dimension values; using the geometric length and scaling factor to estimate the default physical size of the missing object, and outputting the default physical size as a suggested value.
[0052] The geometric length of the missing object in the drawing coordinate system is calculated using the distance formula between two points based on the coordinates of its endpoints. This length is the drawing unit length (e.g., millimeters) in the vector file. The scale factor calculation is based on successfully matched line segments (i.e., line segments with corresponding dimension annotations). The formula is k = actual physical size / length of the drawing coordinate system. For example, if the drawing length of a matched line segment is 50mm and the corresponding dimension annotation value (actual physical size) is 5m (5000mm), then the scale factor k = 5000 / 50 = 100, representing that 1mm in the drawing coordinate system corresponds to 100mm in actual physical space. If multiple matched line segments exist, the average of all calculated scale factors is taken to improve the accuracy of the scale factor. The default physical dimension calculation formula is: Default physical dimension = drawing length of the missing object × scale factor. For example, if the drawing length of the missing object is 30mm and the scale factor is 100, then the default physical dimension = 30 × 100 = 3000mm. When outputting the suggested value, this physical dimension is associated with the location information of the missing object. In the drawing review results, it is displayed as "Missing dimension of a target building (such as the bottom plate segment of the gate chamber) at a certain location, suggested dimension is 3m", providing specific reference for the drawing reviewers and reducing the workload of manual calculation.
[0053] As an alternative embodiment, those skilled in the art can also use the median instead of the average to calculate the scale factor, avoiding the influence of individual abnormal matched line segments on the scale factor and ensuring the accuracy of the default physical size calculation. This step realizes the conversion from drawing size to actual physical size through the scale factor, providing specific size suggestions for omissions in the marking, and further improving the practicality and efficiency of drawing review.
[0054] The present invention further proposes that the differential marking output in step S500 includes: generating an error correction result image containing the original structure of the drawing; highlighting the target line segment determined to be an object with missing markings with a first preset color; and drawing the line segment that has matched the valid dimension annotation with a second preset color, wherein the first preset color and the second preset color are different from each other.
[0055] The error correction result image is generated by overlaying missing markers and size suggestions onto a scalar image. It retains the original structure of the drawing (such as the background and non-target building lines), adjusting only the color of the target building lines to ensure that reviewers can visually compare the original drawing with the error correction result. The first preset color is red, which has high contrast in the drawing and quickly attracts the reviewer's attention, facilitating the location of missing markers. The second preset color is green, which contrasts sharply with red, clearly distinguishing matched lines from missing ones. Non-target building lines (such as natural environments and auxiliary lines) are still drawn in their original color (such as black) to avoid interfering with the identification of the target building. As an alternative embodiment, those skilled in the art can also use other high-contrast color combinations (such as orange and blue), or further highlight the missing markers by thickening the line width of the missing markers (such as 4 pixels for the missing markers compared to the original line width of 2 pixels), improving the readability of the error correction result. This differentiated marking method visually displays the missing areas through color contrast, facilitating quick identification and confirmation of missing marker issues by reviewers and improving the efficiency of drawing review.
[0056] This invention further proposes a water conservancy drawing review system based on vector analysis and semantic fusion, such as... Figure 2 As shown, it includes: The data parsing module 100 is used to call the parsing interface to read the vector file of the water conservancy engineering drawings, decompose the polyline into independent line segments and extract the endpoint coordinate information to construct a set of graphic information, and at the same time extract the geometric attributes of the labeled entities to construct a set of dimension annotations. The semantic recognition module 200 is used to convert vector data in the graphic information set into scalar images, input them into a deep convolutional neural network model with an encoder-decoder architecture, output a confidence matrix covering the confidence of each pixel in the scalar image to belong to each preset category, and determine the structural category of the line segment by accumulating the confidence of the pixel covered by the line segment based on the mapping relationship established by redrawing, thereby filtering out the target building line segment. The geometric verification module 300 is used to calculate the slope and geometric length of the target building line segment and the dimensioned entity, and to determine whether there is a valid dimension matching by verifying the perpendicular relationship between the vector connecting the endpoints of the line segment and the endpoints of the dimension line. The result output module 400 is used to identify target building line segments that have not been matched with valid dimension annotations, calculate their default dimensions based on the scale factor of the matched objects, and generate review results that highlight the missing line segments and display suggested dimension values.
[0057] The core function of the data parsing module 100 is to extract key data from vector files. Its parsing interface (such as the ezdxf library) supports batch reading of multiple DXF files, suitable for batch review of multiple drawings. The polyline decomposition function is implemented through a built-in line segment splitting algorithm, ensuring the integrity of the decomposed line segment information. The semantic recognition module 200 includes three sub-functions: model loading, image redrawing, and classification decision. The model loading sub-function loads pre-trained UNet model weight files; the image redrawing sub-function uses OpenCV to convert vector line segments to scalar images; and the classification decision sub-function executes confidence accumulation and category judgment logic to filter out target building line segments. The geometric verification module 300 includes two sub-functions: geometric attribute calculation and matching verification. The geometric attribute calculation sub-function calculates the slope and length of line segments and annotations using mathematical formulas; and the matching verification sub-function executes a geometric matching algorithm and outputs the matching results. The result output module 400 includes three sub-functions: dimension calculation, image generation, and result export. The dimension calculation sub-function calculates the default physical dimensions of omitted objects; the image generation sub-function generates error-correcting images with differentiated markings; and the result export sub-function supports exporting the review results as PDF or image formats for easy archiving and viewing by reviewers. As an alternative embodiment, those skilled in the art can also add a data storage module to the system to save historical review data, facilitating subsequent traceability and statistical analysis, and improving the system's usability. Through modular design, this system integrates vector analysis, semantic recognition, geometric verification, and result output functions, achieving automation and intelligence in the review of water conservancy drawings, effectively replacing the inefficient traditional manual review method.
[0058] The overall working principle of the method and system of this invention is as follows: First, a training dataset of water conservancy drawings with color category labels is constructed in CAD software. A deep convolutional neural network model using the UNet architecture is trained to obtain a semantic recognition model that can accurately identify the structural category of the drawings. After the water conservancy engineering drawings to be reviewed are input into the system, the data parsing module 100 calls the DXF parsing interface to read its vector file, decomposes the polyline and extracts the coordinates of the endpoints of the line segments to construct a set of graphic information. At the same time, the dimension annotation entity data of the annotation layer is extracted to construct a set of dimension annotations. The semantic recognition module 200 redraws the scalar image according to the line segment coordinates in the set of graphic information, inputs the image into the trained UNet model, outputs the pixel category confidence matrix, and then combines it with the data generated during the redrawing process. The system establishes a vector-pixel mapping relationship and uses a classification decision algorithm to determine the structural category of each line segment, thus filtering out target building line segments. The geometric verification module 300 calculates the slope, length, and geometric attributes of the dimensioned entities of the target building line segments. It first screens candidate dimensions using geometric regions, then verifies the slope, length, and vertical vector to achieve precise matching, determining whether each target building line segment has a valid dimension. The result output module 400 identifies unmatched target building line segments as missing dimensions, calculates the scale factor based on matched line segments, infers the default physical dimensions of the missing dimensions, generates a correction result image with the missing dimensions highlighted in red and the matched line segments drawn in green, and outputs a review report containing default dimension suggestions. This entire process achieves deep integration of vector information, semantic recognition, and geometric matching, ensuring accurate structural recognition of hydraulic drawings and reliable detection of missing dimension markings, significantly improving the accuracy and efficiency of review.
[0059] To further verify the feasibility and effectiveness of the proposed water conservancy drawing review method based on vector analysis and semantic fusion in actual engineering scenarios, this embodiment constructed a dedicated test dataset and conducted quantitative performance tests on the core modules.
[0060] This embodiment first constructs a dataset containing 50 real water conservancy engineering drawings. Then, using a color-coded indexing method in CAD drawing software, supervisory labels are generated. Specifically, target buildings are assigned red index number 1, auxiliary lines are assigned yellow index number 2, the natural environment is assigned green index number 3, and irrelevant objects are assigned blue index number 5. Subsequently, the data is divided into training and testing sets. Addressing the data imbalance issue caused by a large number of target building samples in the early stages of training, this embodiment adopts a strategy of merging the natural environment, auxiliary lines, and irrelevant objects into the "non-target building" class. This transforms the four-class classification task into a two-class classification task for training, significantly improving the model's convergence performance.
[0061] In the performance test of the semantic recognition module, the CNN classification model was trained and evaluated with datasets of 20 and 40 samples, respectively. The experimental results are shown in the table below: Table 1. Test results of 3 test cases for the first drawing. Table 2. Test results for 3 test cases in the second drawing. As can be seen, the model's recognition ability significantly improves with the increase in training data: with 20 data points, the classification accuracy is 62.53%; while with 40 data points, the model's classification accuracy for target building segments increases to 88.40%. This key data demonstrates that, with sufficient data support, the method of classification decision-making using a confidence matrix in this invention can accurately extract target building segments from complex backgrounds.
[0062] In the performance testing of the geometry verification module, a "missing dimension" scenario was simulated by manually deleting some dimension annotations, and two typical drawings were selected for verification. The test results show that, without considering classification bias, the module achieved an average accuracy of 85.05% in dimension annotation matching. Some test cases achieved an accuracy as high as 98.20%, and this high accuracy ensures a low false alarm rate when detecting missing dimension annotations.
[0063] like Figure 3 and Figure 4 The image shows a comparison of the dimension omission detection results and manual inspection results for two typical drawings based on the drawing review method of this invention. In the image, the upper image represents the system's assessment results, where colored lines indicate "target buildings whose dimensions were not matched" (i.e., omissions), and green lines indicate "target buildings whose dimensions were successfully matched" (i.e., compliant parts). The elliptical area in the lower image represents the manual inspection results of the dimension annotations. (This is achieved through comparison with...) Figure 3 and Figure 4 A comparison of the two images shows that the system successfully identified the vast majority of missing annotations, with the red highlighted areas highly overlapping with the missing annotation areas found by manual review.
[0064] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for reviewing hydraulic engineering drawings based on vector analysis and semantic fusion, characterized in that, Includes the following steps: Step S100: Parse the vector file of the water conservancy engineering drawing to be reviewed, extract the endpoint coordinate information of all line segments in the vector file to construct a set of graphic information, and extract the dimension annotation entity data in the vector file to construct a set of dimension annotations; Step S200: Based on the endpoint coordinate information in the graphic information set, the vector line segment is redrawn as a scalar image, and the scalar image is input into a pre-trained deep convolutional neural network model with an encoder-decoder architecture, and the output is a confidence matrix covering the categories to which each pixel in the scalar image belongs. Step S300: Based on the mapping relationship from vector coordinates to image pixels established during the redrawing process, and combined with the confidence matrix, the structural category of each line segment in the graphic information set is determined using a classification decision algorithm, and target line segments belonging to the target building category are selected. Step S400: Based on the endpoint coordinate information of the target line segment and the geometric attributes of the dimension entity data in the dimension annotation set, use a geometric matching algorithm to determine whether there is a corresponding valid dimension annotation for the target line segment one by one; Step S500: The target line segment that does not match a valid dimension annotation is identified as a missing annotation object, and the missing annotation object is output with differentiated marking in the visualization view of the drawing.
2. The method for reviewing hydraulic engineering drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The specific implementation of step S100 includes: Call the DXF file parsing interface to read the vector file of the water conservancy project drawings; Traverse the geometric entity objects in the vector file, decompose the multi-segment line entity into multiple independent line segment entities, and store the starting horizontal and vertical coordinates and the ending horizontal and vertical coordinates of each line segment entity in the form of a quadruple into the graphic information set. Extract the coordinates of the endpoints of the dimension boundary lines, the angles of the dimension lines, and the numerical values of the dimension text of the entities in the dimension layer of the vector file, and store them in the dimension annotation set.
3. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The deep convolutional neural network model in step S200 specifically adopts the UNet network architecture, whose structural features include: The encoder section uses a ResNet-101 residual network as the backbone network to extract deep semantic features of the scalar image; The decoder part gradually restores the resolution of the feature map through upsampling operations and performs skip connections to fuse the feature maps of the corresponding layers of the encoder. The output layer outputs a mask matrix with N output channels, where N corresponds to the number of preset categories, and the values in the mask matrix represent the probability values of the corresponding pixel belonging to each category.
4. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The training process of the deep convolutional neural network model in step S200 includes: In CAD drawing software, drawing objects are categorized by modifying the line color index. The preset categories include at least target buildings, natural environment, auxiliary lines, and irrelevant objects. The marked drawing file is parsed, the color information of the line segments is extracted as the category label for supervised training, and the endpoint coordinate information of the line segments is extracted to construct the training dataset. The deep convolutional neural network model is iteratively trained using the training dataset, and the model parameters are optimized using the binary cross-entropy loss function.
5. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The classification decision algorithm in step S300 includes: Based on the mapping relationship, determine the set of pixels covered by each line segment in the graphic information set on the scalar image; Obtain the confidence score value of each pixel in the pixel set under each preset category; The confidence scores of each of the preset categories are summed to obtain the total confidence score, and the category with the highest total confidence score is determined as the final structure category of the line segment.
6. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The step S400, which uses a geometric matching algorithm to determine whether each target line segment has a corresponding valid dimension annotation, includes: Calculate the slope and geometric length of the target line segment based on the endpoint coordinate information; Traverse the set of dimension annotations and select dimension annotation entities whose slope and geometric length in the geometric attributes are equal to the target line segment as candidate annotations; Construct four connection vectors connecting the endpoints of the target line segment to the endpoints of the dimension line of the candidate annotation; Determine whether there are two vectors among the four connection vectors that are perpendicular to the target line segment. If so, determine that the target line segment matches the candidate label successfully.
7. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 6, characterized in that, Step S400, when filtering the candidate labels, further includes: Based on the slope of the target line segment, determine its geometric regions in the horizontal, vertical, and perpendicular directions; Only the dimension entities in the dimension set are retrieved within the geometric region, and these are used as the initial screening range for the candidate dimensions.
8. The method for reviewing hydraulic drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, Step S500 includes: When the target line segment is determined to be a missing object, calculate the geometric length of the target line segment in the drawing coordinate system; Based on the successfully matched line segments and their corresponding dimension values, calculate the scaling factor between the drawing coordinate system and the actual physical space; The default physical size of the missing object is calculated using the geometric length and the scaling factor, and the default physical size is output as a suggested value.
9. The method for reviewing hydraulic engineering drawings based on vector analysis and semantic fusion according to claim 1, characterized in that, The differential label output in step S500 includes: Generate an image containing the error-corrected result of the original drawing structure; The target line segment identified as an unmarked object is highlighted with a first preset color, and the line segment that has matched a valid dimension mark is drawn with a second preset color. The first preset color and the second preset color are different from each other.
10. A water conservancy drawing review system based on vector analysis and semantic fusion, characterized in that, include: The data parsing module is used to call the parsing interface to read the vector file of the water conservancy engineering drawings, decompose the polyline into independent line segments and extract the endpoint coordinate information to construct a set of graphic information, and at the same time extract the geometric attributes of the labeled entities to construct a set of dimension annotations. The semantic recognition module is used to convert the vector data in the graphic information set into a scalar image, input it into a deep convolutional neural network model with an encoder-decoder architecture, output a confidence matrix covering the confidence of each pixel in the scalar image to each preset category, and determine the structural category of the line segment by accumulating the confidence of the pixel covered by the line segment based on the mapping relationship established by redrawing, thereby filtering out the target building line segment. The geometric verification module is used to calculate the slope and geometric length of the target building line segment and the dimensioned entity, and to determine whether there is a valid dimension matching by verifying the perpendicular relationship between the vector connecting the endpoints of the line segment and the endpoints of the dimension line. The results output module is used to identify target building line segments that have not been matched with valid dimension annotations, calculate their default dimensions based on the scale factor of the matched objects, and generate review results that highlight the missing line segments and display suggested dimension values.