CAD vector drawing automatic identification method and device, electronic equipment and storage medium
By dividing the CAD vector drawing into overlapping rectangular sub-tiles, extracting and encoding the geometric features of the primitives, and inputting the deep learning model for identification and data fusion, the problem of automatic recognition of CAD vector drawings in the prior art is solved, and high-accuracy drawing recognition and structured processing is achieved.
Patent Information
- Application Number
- CN202510117650.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-03-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing CAD vector drawing automatic identification technology is difficult to accurately extract the positions and dimensions of each component in the drawing, and the abstraction of the symbols of the engineering drawings and lack of texture and color, resulting in poor recognition effect. Especially when similar symbols represent different meanings in different environments, the recognition effect is particularly difficult.
A method of automatic identification of CAD vector drawings is proposed, including drawing reading, segmentation, serialization coding, deep learning prediction, data fusion and post-processing, and structured processing. By dividing the vector drawing into overlapping rectangular sub-tiles, the geometric features of the primitives are extracted and encoded, input into a deep learning model for identification, and perform data fusion and post-processing, and finally converting the drawing into a structured component record.
It effectively identifies key information of various components in the drawing, improves the recognition accuracy, and can be directly used in scenarios such as drawing review and intelligent calculation of quantities, which is better than traditional computer vision methods.
Smart Images

Figure CN119559660A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of graphic recognition technology, and in particular relates to a method, a device, an electronic device and a storage medium for automatic recognition of CAD vector drawings. Background Art
[0002] Along with the rapid development of the economy, the construction industry has also been vigorously developed. The widespread application of computer-aided drafting (CAD) software in the field of architectural engineering design has greatly improved the work efficiency and drawing quality of designers. However, faced with a large number of drawings in engineering projects, it is very time-consuming and labor-intensive to rely on manpower to extract CAD drawings.
[0003] With the development of image processing and deep learning, it has provided favorable conditions for replacing manpower with machines to realize automatic recognition of CAD drawings. Existing CAD drawing automatic recognition technology faces challenges in several aspects. First, it is difficult for deep learning models to accurately extract the position and size of each component in the drawing, resulting in the loss of some important details. Secondly, the symbols in engineering drawings are relatively abstract and lack rich colors and textures, which makes the model more difficult to recognize. Finally, similar symbols may represent different meanings in different contexts, but existing methods do not take the surrounding environment into consideration enough, resulting in poor recognition of these similar symbols. Summary of the invention
[0004] The purpose of the present invention is to provide a reasonably designed CAD vector drawing automatic recognition method, device, electronic device and storage medium in order to solve the above problems.
[0005] To achieve the above object, the present invention provides a method for automatically identifying CAD vector drawings in a first aspect, comprising the following steps: Step 1: Read the drawing: read the original vector drawing file, parse and obtain the multiple element expression information of the drawing; Step 2: Drawing segmentation: Divide the vector drawing into multiple overlapping rectangular sub-blocks according to segmentation rules; Step 3: Drawing serialization coding: extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serialization coding to convert the rectangular sub-block into a coding sequence of the primitives; Step 4, deep learning prediction: input the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; the semantic information is a category vector, including the semantic category information of the instance to which the primitive belongs; the instance information is a position vector, including the center position information of the instance to which the primitive belongs; Step 5: Data fusion and post-processing: Data fusion is performed based on the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and post-processing is performed based on the final recognition result to obtain the structured data record of the vector drawing; Step 6: Structural processing: Perform structural processing based on the recognition results of the rectangular sub-blocks to convert the drawings into structured component records.
[0006] As a further optimization solution of the present invention, the expression form of the multiple primitive expression information is in the form of a list; The steps of parsing and obtaining multiple element expression information of the drawing include: Obtain basic geometric elements of multiple primitives of the drawing, and use the reading results of the basic geometric elements of the primitives as the dictionary of the corresponding primitives; The dictionaries of multiple graphic elements form a list, and the information contained in the list is the expression information of multiple graphic elements; The graphic element is provided with a unique graphic element number, and the graphic element numbers of a plurality of graphic elements constitute a graphic element data group of the vector drawing.
[0007] As a further optimization scheme of the present invention, the segmentation rule is to segment the vector drawing in a sliding window manner, wherein the area overlap ratio between adjacent rectangular sub-blocks along the direction of the sliding window is ρ, 0<ρ<1; In the process of segmenting the vector drawing, the primitives are segmented by rectangular sub-blocks at the same time, wherein the primitives include line segments, arcs, circles and ellipses; When the primitive is a line segment, the step of segmenting the primitive includes: determining whether both ends of the line segment are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the line segment is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the line segment and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the line segment; When the primitive is an arc, the step of segmenting the primitive includes: determining whether the two ends of the arc are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the arc is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the arc and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the arc; When the graphic element is a circle or an ellipse, the step of segmenting the graphic element includes: determining whether the entire circle or ellipse is located inside the rectangular sub-block, and when the determination result is yes, no additional processing is performed; when a portion of the circle or ellipse is outside the rectangular sub-block, calculating the intersection of the circle or ellipse with the boundary of the rectangular sub-block, and using the intersection as the two endpoints of the arc portion of the circle or ellipse located inside the rectangular sub-block, and changing the circle or ellipse into an arc, wherein when the circle or ellipse is changed into an arc, the number of the graphic element does not change.
[0008] As a further optimization scheme of the present invention, the step of converting the rectangular sub-block into a coding sequence of primitives includes: inputting geometric feature parameters of the primitives into a deep learning network to obtain geometric coding of the primitives, wherein the geometric coding of multiple primitives in the rectangular sub-block constitutes the coding sequence of the rectangular sub-block; The geometric characteristic parameters of the primitive include the starting point, end point, length, angle, position, category, and the calculation result of the parameters. The geometric characteristic of the primitive is described as a vector ; Among them, when the primitive is a line segment, , represents the midpoint of a line segment, , represents the starting point of the line segment, , represents the end point of the line segment, represents the length of the line segment, represents the inclination of the line segment; When the primitive is an arc, , Indicates the coordinates of the midpoint of the line connecting the arc endpoints. , Indicates the starting point of the arc, , Indicates the end point of the arc, Indicates the length of the endpoint connection. Indicates the inclination of the line connecting the endpoints; When the primitive is a circle, , , , , , Both represent the geometric center of the circle. represents the length of the circle's diameter, The default setting is 0; When the primitive is an ellipse, , represents the geometric center of the ellipse, , and , Represent the two endpoints of the major axis of the ellipse, represents the length of the major axis of the ellipse, represents the inclination of the major axis of the ellipse; It is a four-dimensional one-hot vector, indicating the category of the primitive.
[0009] As a further optimization solution of the present invention, the step of obtaining the final recognition result of the primitive includes: reading the recognition results of all the primitives in the overlapping area, judging whether the primitive has more than one set of recognition results, and if the judgment result is yes, performing average processing on the output vectors corresponding to the multiple sets of recognition results to obtain the final recognition result of the primitive; if the judgment result is no, taking the set of recognition results as the final recognition result of the primitive; The steps for obtaining the structured data record of the vector drawing include: obtaining the semantic category information of the instance to which the graphic element belongs, that is, the semantic category vector, and obtaining the semantic category of the instance to which the graphic element belongs after normalization; obtaining the center position information of the instance to which the graphic element belongs, that is, the instance center vector, clustering the centers of the instance to which the graphic element belongs according to density, and obtaining the instance distinction to which the graphic element belongs. The semantic categories of the instances to which all graphic elements belong and the instance distinctions to which all graphic elements belong constitute the structured data record of the vector drawing.
[0010] As a further optimization solution of the present invention, in step six, performing structured processing according to the recognition result of the rectangular sub-block includes: calculating the geometric envelope or fill of the instance, and converting the drawing into a structured component record; The structured component record is based on components or furniture instances as basic units, and each instance includes the following fields: number, geometry, category and location.
[0011] To achieve the above object, the second aspect of the present invention provides a CAD vector drawing automatic recognition device, comprising: Drawing reading module, used to read the original file of vector drawing, parse and obtain the expression information of multiple graphic elements of the drawing; A drawing segmentation module is used to segment a vector drawing into multiple overlapping rectangular sub-blocks according to segmentation rules; The encoding module is used to extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serial encoding to convert the rectangular sub-block into a coding sequence of the primitives; A deep learning prediction module is used to input the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, wherein the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; the semantic information is a category vector containing the semantic category information of the instance to which the primitive belongs; the instance information is a position vector containing the center position information of the instance to which the primitive belongs; A data processing module is used to perform data fusion according to the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and perform post-processing according to the final recognition result to obtain the structured data record of the vector drawing; The structured processing module is used to perform structured processing according to the recognition results of the rectangular sub-blocks and convert the drawings into structured component records.
[0012] To achieve the above-mentioned purpose, the third aspect of the present invention proposes an electronic device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned CAD vector drawing automatic recognition method when executing the computer program.
[0013] To achieve the above-mentioned purpose, the fourth aspect of the present invention proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for automatically identifying a CAD vector drawing is implemented.
[0014] The present invention has at least the following beneficial effects: the CAD vector drawing automatic recognition method, device, electronic device and storage medium provided by the present invention parse and obtain multiple primitive expression information of the drawing by reading the original vector drawing file; divide the vector drawing into a plurality of rectangular sub-blocks with overlapping areas according to the segmentation rule; extract the primitives in the rectangular sub-blocks, analyze the geometric feature parameters of the primitives, and perform serialization encoding to convert the rectangular sub-blocks into a coding sequence of the primitives; input the coding sequence of the primitives into a deep learning model to obtain the recognition result of the rectangular sub-blocks, and the recognition result includes the semantic information and instance information of the instance to which the primitives belong; perform data fusion according to the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitives, and perform post-processing according to the final recognition result to obtain the structured data record of the vector drawing; The results are structured and the drawings are converted into structured component records. In the drawing segmentation process, considering that there are instances (such as doors) that are segmented by boundaries and the instances are incomplete, which leads to a decrease in the overall recognition accuracy, the present invention adopts an overlapping segmentation method, which makes the segmentation windows overlap, so that the instances can be fully displayed in at least one window, effectively avoiding the situation of incomplete instance segmentation and improving the recognition accuracy. The semantic information of the instances to which all graphic elements in the vector drawings belong is obtained through a deep learning method, and the instances are distinguished. The key information of various components in the drawings is extracted from the recognition results, which can be directly used in specific scenarios such as downstream drawing review and intelligent quantity calculation, and has strong practicality. In addition, the method effectively identifies the semantic information and instance information of the instance to which each graphic element belongs, and is effectively superior to traditional computer vision methods in terms of instance recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of a flow chart of a method for automatically identifying CAD vector drawings provided by an embodiment of the present invention; Figure 2 This is an example diagram of nested information of blocks and primitives of an engineering drawing provided by an embodiment of the present invention; Figure 3is a schematic diagram of the sliding window overlapping area of the rectangular sub-blocks provided by an embodiment of the present invention; Figure 4 It is a schematic diagram of the process information of the drawing serialization coding provided by an embodiment of the present invention; Figure 5 is an example diagram of internal semantic correction of a block provided by an embodiment of the present invention; Figure 6 is an example diagram of a polygonal envelope of a drawing example provided by an embodiment of the present invention; Figure 7 This is an example diagram of rectangular filling of a drawing example provided by an embodiment of the present invention; Figure 8 It is a functional structure diagram of a CAD vector drawing automatic recognition device provided by an embodiment of the present invention; Fig. 9 It is a functional structure diagram of an electronic device provided by an embodiment of the present invention.
[0016] In the figure: 1. electronic device; 101. memory; 102. processor; 103. communication bus; 104. communication interface. DETAILED DESCRIPTION
[0017] The present application is further described in detail below in conjunction with the accompanying drawings. It is necessary to point out here that the following specific implementation methods are only used to further illustrate the present application and cannot be understood as limiting the scope of protection of the present application. Technical personnel in this field can make some non-essential improvements and adjustments to the present application based on the above application content.
[0018] Traditional engineering drawing recognition methods convert drawings into pixel images and combine computer vision methods such as semantic segmentation, object detection, and instance segmentation to establish drawing datasets, obtain the approximate location and distribution of components in drawings, and further post-process the recognition results to obtain detailed information of components. However, existing recognition methods have the following problems: First, image deep learning methods often cannot accurately extract the location and size information of specific components in drawings, resulting in the loss of key geometric and topological details, which limits the practicality of recognition results; second, the symbols in engineering drawings are highly abstract and lack the rich texture and color appearance of natural images, which poses a huge challenge to the resolution ability of image deep learning methods; third, there is a dependency relationship between component symbols and the surrounding environment. Symbols with similar morphology express different semantics in different environments. Image-based deep learning methods pay insufficient attention to the surrounding environment and have poor recognition effects on some components with high similarity.
[0019] like Figure 1 As shown, the present invention discloses a method for automatically identifying CAD vector drawings, comprising the following steps: Step 1: Read the drawing: read the original vector drawing file, parse and obtain the multiple element expression information of the drawing; Step 2: Drawing segmentation: Divide the vector drawing into multiple overlapping rectangular sub-blocks according to segmentation rules; Step 3: Drawing serialization coding: extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serialization coding to convert the rectangular sub-blocks into a coding sequence of the primitives; Step 4: Deep learning prediction: Input the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, wherein the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; Step 5: Data fusion and post-processing: Data fusion is performed based on the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and post-processing is performed based on the final recognition result to obtain the structured data record of the vector drawing; Step 6: Structural processing: Perform structural processing based on the recognition results of the rectangular sub-blocks to convert the drawings into structured component records.
[0020] In the above-mentioned embodiments, the CAD vector drawing automatic recognition method provided in the embodiments of the present application obtains the semantic information of the instances to which all graphic elements in the vector drawing belong through a deep learning method, distinguishes the instances, and extracts the key information of various components in the drawing from the recognition results. Specifically, the recognition result is convenient for obtaining the specific position, size relationship, and topological connection of the instance, and can be directly used in specific scenarios such as downstream drawing review and intelligent quantity calculation, and has strong practicality; in addition, the method effectively identifies the semantic information and instance information of the instance to which each graphic element belongs, and is effectively superior to traditional computer vision methods in terms of instance recognition accuracy, including semantic segmentation, instance segmentation and other algorithms.
[0021] Exemplarily, in step 1, the expression form of the plurality of graphic element expression information is in the form of a list; The steps of parsing and obtaining multiple element expression information of the drawing include: Obtain basic geometric elements of multiple primitives of the drawing, and use the reading results of the basic geometric elements of the primitives as the dictionary of the corresponding primitives; The dictionaries of multiple graphic elements form a list, and the information contained in the list is the expression information of multiple graphic elements; Among them, the graphic element is set with a unique graphic element number, and the graphic element numbers of multiple graphic elements constitute the graphic element data group of the vector drawing. By assigning a unique graphic element number to the graphic element, subsequent processing is facilitated, and the same graphic elements are connected according to the number.
[0022] It should be noted that the basic geometric elements of graphics are mainly divided into line segments, arcs, circles and ellipses. For the polylines in the drawings, they are converted into a combination of line segments and arcs.
[0023] When the basic geometric elements of a graphic element are read to obtain the reading result, the reading result should include the starting point, end point, position (center of the circle), length (radius), layer, color, line width, line type, etc., that is, the key fields included in the sub-dictionary of the corresponding graphic element.
[0024] It should be noted that, in the process of reading the original vector drawing file, that is, the CAD engineering drawing file, the information of the instance block in the drawing can be further obtained, wherein the block contains primitives, such as Figure 2 As shown, there is a nested relationship between blocks and primitives. When the blocks are recorded as a list, the expression information of all primitives in the drawing is presented in the form of primitive codes to form a primitive data group.
[0025] Exemplarily, in step 2, the vector drawing is divided into a plurality of overlapping rectangular sub-blocks according to a segmentation rule, wherein the segmentation rule is to segment the vector drawing in a sliding window manner, wherein the area overlap ratio between adjacent rectangular sub-blocks along the direction of the sliding window is ρ, 0<ρ<1; Figure 3 , the width of the rectangular sub-block is , the height is , the width of the drawing is , the height is , the overlap ratio is The left figure shows that the sliding direction of the sliding window is horizontal. At this time, the overlapping distance of the rectangular sub-blocks in the width direction is , Figure 3 The right figure shows that the sliding direction of the sliding window is vertical. At this time, the overlapping distance of the rectangular sub-blocks in the height direction is ; In the process of segmenting the vector drawing, the primitives are segmented by rectangular sub-blocks at the same time, wherein the primitives include line segments, arcs, circles and ellipses; When the primitive is a line segment, the step of segmenting the primitive includes: determining whether both ends of the line segment are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the line segment is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the line segment and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the line segment; When the primitive is an arc, the step of segmenting the primitive includes: determining whether the two ends of the arc are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the arc is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the arc and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the arc; When the graphic element is a circle or an ellipse, the step of segmenting the graphic element includes: determining whether the entire circle or ellipse is located inside the rectangular sub-block, and when the determination result is yes, no additional processing is performed; when a portion of the circle or ellipse is outside the rectangular sub-block, calculating the intersection of the circle or ellipse with the boundary of the rectangular sub-block, and using the intersection as the two endpoints of the arc portion of the circle or ellipse located inside the rectangular sub-block, and changing the circle or ellipse into an arc, wherein when the circle or ellipse is changed into an arc, the graphic element numbering does not change, and the graphic element in the rectangular sub-block can still be accurately matched to the graphic element in the original drawing through the graphic element numbering.
[0026] In the drawing segmentation process, considering that there are instances (such as doors) that are segmented by boundaries and thus become incomplete instances, resulting in a reduction in the overall recognition accuracy, the present invention adopts an overlapping segmentation method, which allows the segmentation windows to have regional overlaps, so that the instance can be fully displayed in at least one window, effectively avoiding the situation of incomplete instance segmentation and improving the recognition accuracy.
[0027] For example, Figure 4 As shown, in step three, the step of converting the rectangular sub-block into a coding sequence of primitives includes: inputting the geometric feature parameters of the primitives into a deep learning network to obtain the geometric coding of the primitives, wherein the geometric coding of multiple primitives in the rectangular sub-block constitutes the coding sequence of the rectangular sub-block; The geometric characteristic parameters of the primitive include the starting point, end point, length, angle, position, category, and the calculation result of the parameters. The geometric characteristic of the primitive is described as a vector ; For different types of primitives, the encoding meaning of geometric feature representation is slightly different. When the primitive is a line segment, , represents the midpoint of a line segment, , represents the starting point of the line segment, , represents the end point of the line segment, represents the length of the line segment, represents the inclination of the line segment; When the primitive is an arc, , Indicates the coordinates of the midpoint of the line connecting the arc endpoints. , Indicates the starting point of the arc, , Indicates the end point of the arc, Indicates the length of the endpoint connection. Indicates the inclination of the line connecting the endpoints; When the primitive is a circle, , , , , , Both represent the geometric center of the circle. represents the length of the circle's diameter, The default setting is 0; When the primitive is an ellipse, , represents the geometric center of the ellipse, , and , Represent the two endpoints of the major axis of the ellipse, represents the length of the major axis of the ellipse, represents the inclination of the major axis of the ellipse; is a four-dimensional one-hot vector used to represent features of a finite number of categories, indicating the category of the primitive. The four dimensions correspond to line segments, arcs, circles, and ellipses, respectively. Exemplarily, the four-dimensional one-hot vectors of line segments, arcs, circles, and ellipses are represented as [1,0,0,0], [0,1,0,0], [0,0,0,1], [0,0,1,0], respectively, which are not limited here.
[0028] It should be noted that the above geometric features have been normalized, and each value is between 0 and 1.
[0029] It should be noted that deep learning networks are an important machine learning method in the field of artificial intelligence, and are particularly suitable for processing large amounts of data and complex pattern recognition tasks. Deep learning networks include convolutional neural networks, recursive neural networks, graph neural networks, etc. By inputting geometric features into deep learning networks, they are mapped into high-dimensional encodings; among them, deep learning networks are fully connected layers with multiple learnable parameters, and their parameters are determined through subsequent end-to-end training.
[0030] In this step, if Figure 4 As shown, each primitive in the rectangular sub-block is encoded as a high-dimensional vector. At this time, the rectangular sub-block is described as a coding sequence of primitives, wherein the order of the sequence has no effect on the final result of the algorithm.
[0031] Exemplarily, in step 4, the primitive coding sequence obtained in step 3 is input into the deep learning model, and each primitive can be treated as a "word" or "node" for processing, wherein the deep learning model can adopt a transformer architecture, or a graph neural network, a graph attention network, and other architectures. Preferably, in the processing, in order to reduce computational complexity, it is not necessary to model the relationship between primitives, and only the correlation between primitives and their neighboring primitives needs to be considered. Specifically, the sparse attention mechanism is used to optimize the transformer model, or graph sparsification is used to optimize the graph neural network and graph attention network, thereby increasing the speed of model training.
[0032] After being processed by the deep learning model, the recognition result of the rectangular sub-block is output, namely the semantic information and instance information of the instance to which the primitive belongs, wherein the semantic information of the instance to which the primitive belongs is a category vector, containing the semantic category information of the instance to which the primitive belongs; the instance information is a position vector, containing the center position information of the instance to which the primitive belongs.
[0033] Exemplarily, in step five, in order to ensure the accuracy of recognition, there are overlapping areas between adjacent rectangular sub-blocks during the process of dividing the rectangular sub-blocks, and each rectangular sub-block has obtained recognition results through deep learning, so it is necessary to perform data fusion on the recognition results of the overlapping areas to obtain the final recognition result of the graphic element.
[0034] Exemplarily, the step of obtaining the final recognition result of the primitive includes: reading the recognition results of all the primitives in the overlapping area, determining whether the primitive has more than one set of recognition results, and if the determination result is yes, performing average processing on the output vectors corresponding to the multiple sets of recognition results to obtain the final recognition result of the primitive; if the determination result is no, taking the set of recognition results as the final recognition result of the primitive; It should be noted that the process of averaging the output vectors corresponding to multiple groups of recognition results is as follows: when the recognition result is the semantic information of the instance to which the primitive belongs, the multiple groups of semantic category vectors are averaged according to the average method, and when the recognition result is instance information, the multiple groups of instance category vectors are averaged according to the average method.
[0035] Exemplarily, in step five, the step of obtaining the structured data record of the vector drawing includes: obtaining the semantic category information of the instance to which the graphic element belongs, that is, the semantic category vector, and obtaining the semantic category of the instance to which the graphic element belongs after normalization; obtaining the center position information of the instance to which the graphic element belongs, that is, the instance center vector, clustering the centers of the instance to which the graphic element belongs according to density, and obtaining the instance distinction to which the graphic element belongs. The semantic categories of all instances to which the graphic elements belong and the instance distinctions to which all the graphic elements belong constitute the structured data record of the vector drawing.
[0036] It should be noted that the recognition results are optimized for the known nested relationship between rectangular sub-blocks and primitives, including: screening all primitives in the instance block. If the semantic recognition results of the primitives in the instance block are all the same, the recognition of the instance block is considered accurate and no additional processing is performed; if the semantic recognition results of the primitives in the instance block are different, the semantic categories of all primitives in the instance block can be aligned according to the voting principle, that is, the rule of minority obeys majority, that is, the final semantic category of the instance block is determined. This method can reduce the impact of misrecognition. Figure 5 As shown, the misclassified parts inside the instance block are corrected and optimized to determine the semantic category information to which the final primitive belongs.
[0037] Further calibration and optimization of the recognition results can help improve the accuracy of the results.
[0038] Exemplarily, in step six, performing structured processing according to the recognition result of the rectangular sub-block includes: calculating the geometric envelope or fill of the instance, and converting the drawing into a structured component record; The structured component record is based on components or furniture instances as basic units, and each instance includes the following fields: number, geometry, category and location.
[0039] Specifically, for general structural components or fixtures, a polygon is used as its geometric envelope, and the polygon should cover all vertices of the component. The geometric shape is recorded in the form of all vertices of the polygon. The position is recorded in the form of the polygon geometric center. Figure 6 shown.
[0040] For example, for the wall structure in the drawing, all the elements with the semantic category label of wall in the drawing are filtered, and multiple rectangles are used to fill the polygonal area surrounded by the wall line. In the corners and intersections of the wall, the filling rectangles are allowed to overlap to a certain extent. Figure 7 shown.
[0041] The wall is split into multiple rectangle instances, the geometry is recorded as all the vertices of the rectangle, and the position is recorded as the geometric center of the rectangle.
[0042] It should be noted that the structured records of drawings can be stored and called in different forms, including but not limited to databases, json files and other formats.
[0043] In one embodiment, continue to refer to Figure 8 The present invention discloses a CAD vector drawing automatic recognition device, comprising: Drawing reading module, used to read the original file of vector drawing, parse and obtain the expression information of multiple graphic elements of the drawing; A drawing segmentation module is used to segment a vector drawing into multiple overlapping rectangular sub-blocks according to segmentation rules; The encoding module is used to extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serial encoding to convert the rectangular sub-block into a coding sequence of the primitives; A deep learning prediction module, used for inputting the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, wherein the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; A data processing module is used to perform data fusion according to the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and perform post-processing according to the final recognition result to obtain the structured data record of the vector drawing; The structured processing module is used to perform structured processing according to the recognition results of the rectangular sub-blocks and convert the drawings into structured component records.
[0044] An automatic recognition device for CAD vector drawings provided by an embodiment of the present invention reads a vector drawing original file through a drawing reading module, parses and obtains multiple primitive expression information of the drawing, divides the vector drawing into multiple rectangular sub-blocks with overlapping areas according to a segmentation rule through a drawing segmentation module, extracts primitives in the rectangular sub-blocks through an encoding module, analyzes geometric feature parameters of the primitives, performs serial encoding, converts the rectangular sub-blocks into a coding sequence of the primitives, inputs the coding sequence of the primitives into a deep learning model through a deep learning prediction module, obtains a recognition result of the rectangular sub-block, and the recognition result includes semantic information and instance information of the instance to which the primitive belongs. The processing module performs data fusion according to the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition results of the primitives, and performs post-processing according to the final recognition results to obtain the structured data records of the vector drawings, and the structured processing module performs structured processing according to the recognition results of the rectangular sub-blocks to convert the drawings into structured component records, thereby realizing the automatic recognition of the engineering CAD vector drawings. The obtained recognition results are convenient for obtaining the specific position, size relationship, and topological connection of the instance, and effectively identify the semantic information and instance information of the instance to which each primitive belongs, and are effectively superior to the traditional computer vision method in the recognition accuracy of the instance. In addition, the recognition device can calibrate and optimize the recognition results in combination with the characteristics of the layers, blocks, etc. in the engineering drawings, further improving the accuracy of the results. Furthermore, in the drawing segmentation process, considering that the instance (such as a door) is segmented by the boundary and the instance is incomplete, thereby reducing the overall recognition accuracy, the present invention adopts an overlapping segmentation method, which makes the segmentation windows overlap, so that the instance can be fully displayed in at least one window, effectively avoiding the incomplete instance segmentation and improving the recognition accuracy.
[0045] In one embodiment, the present invention discloses an electronic device 1, such as Fig. 9 As shown, the electronic device 1 includes a memory 101, a processor 102, a communication bus 103 and a communication interface 104, wherein the memory 101, the processor 102 and the communication interface 104 communicate with each other through the communication bus 103. The memory 101 stores a computer program, and the processor 102 implements the above-mentioned CAD vector drawing automatic recognition method when executing the computer program.
[0046] In one embodiment, the present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned CAD vector drawing automatic recognition method is implemented.
[0047] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A method for automatically identifying CAD vector drawings, characterized in that: The steps include: Step 1: Read the drawing: read the original vector drawing file, parse and obtain the multiple element expression information of the drawing; Step 2: Drawing segmentation: Divide the vector drawing into multiple overlapping rectangular sub-blocks according to segmentation rules; Step 3: Drawing serialization coding: extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serialization coding to convert the rectangular sub-block into a coding sequence of the primitives; Step 4, deep learning prediction: input the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; the semantic information is a category vector, including the semantic category information of the instance to which the primitive belongs; the instance information is a position vector, including the center position information of the instance to which the primitive belongs; Step 5: Data fusion and post-processing: Data fusion is performed based on the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and post-processing is performed based on the final recognition result to obtain the structured data record of the vector drawing; Step 6: Structural processing: Perform structural processing based on the recognition results of the rectangular sub-blocks to convert the drawings into structured component records.
2. A method for automatically identifying CAD vector drawings according to claim 1, characterized in that: The expression form of multiple graphic element expression information is in list form; The steps of parsing and obtaining multiple element expression information of the drawing include: Obtain basic geometric elements of multiple primitives of the drawing, and use the reading results of the basic geometric elements of the primitives as the dictionary of the corresponding primitives; The dictionaries of multiple graphic elements form a list, and the information contained in the list is the expression information of multiple graphic elements; The graphic element is provided with a unique graphic element number, and the graphic element numbers of a plurality of graphic elements constitute a graphic element data group of the vector drawing.
3. A method for automatically identifying CAD vector drawings according to claim 2, characterized in that: The segmentation rule is to segment the vector drawing in a sliding window manner, wherein the area overlap ratio between adjacent rectangular sub-blocks along the direction of the sliding window is ρ, 0<ρ<1; In the process of segmenting the vector drawing, the primitives are segmented by rectangular sub-blocks at the same time, wherein the primitives include line segments, arcs, circles and ellipses; When the primitive is a line segment, the step of segmenting the primitive includes: determining whether both ends of the line segment are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the line segment is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the line segment and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the line segment; When the primitive is an arc, the step of segmenting the primitive includes: determining whether the two ends of the arc are located inside the rectangular sub-block, and if the determination result is yes, no additional processing is performed; when one end of the arc is located inside the rectangular sub-block and the other end is located outside the rectangular sub-block, calculating the intersection of the arc and the boundary of the rectangular sub-block, and taking the intersection as the endpoint of the arc; When the graphic element is a circle or an ellipse, the step of segmenting the graphic element includes: determining whether the entire circle or ellipse is located inside the rectangular sub-block, and when the determination result is yes, no additional processing is performed; when a portion of the circle or ellipse is outside the rectangular sub-block, calculating the intersection of the circle or ellipse with the boundary of the rectangular sub-block, and using the intersection as the two endpoints of the arc portion of the circle or ellipse located inside the rectangular sub-block, and changing the circle or ellipse into an arc, wherein when the circle or ellipse is changed into an arc, the number of the graphic element does not change.
4. A method for automatically identifying CAD vector drawings according to claim 3, characterized in that: The step of converting the rectangular sub-block into a coding sequence of the primitives includes: inputting the geometric feature parameters of the primitives into a deep learning network to obtain the geometric coding of the primitives, wherein the geometric coding of the multiple primitives in the rectangular sub-block constitutes the coding sequence of the rectangular sub-block; The geometric feature parameters of the primitive include the starting point, end point, length, angle, position, category, and the calculation result of the parameters. The geometric feature description of the primitive is a vector\left [ {{x}_{c},{y}_{c},{x}_{1,}{y}_{1}{,x}_{2},{y}_{2},l,\cos {a,\sin {a,t}}} \right ] ; Among them, when the primitive is a line segment, , represents the midpoint of a line segment, , represents the starting point of the line segment, , represents the end point of the line segment, represents the length of the line segment, represents the inclination of the line segment; When the primitive is an arc, , Indicates the coordinates of the midpoint of the line connecting the arc endpoints. , Indicates the starting point of the arc, , Indicates the end point of the arc, Indicates the length of the endpoint connection. Indicates the inclination of the line connecting the endpoints; When the primitive is a circle, , , , , , Both represent the geometric center of the circle. represents the length of the circle's diameter, The default setting is 0; When the primitive is an ellipse, , represents the geometric center of the ellipse, , and , Represent the two endpoints of the major axis of the ellipse, represents the length of the major axis of the ellipse, represents the inclination of the major axis of the ellipse; It is a four-dimensional one-hot vector, indicating the category of the primitive.
5. A method for automatically identifying CAD vector drawings according to claim 4, characterized in that: The step of obtaining the final recognition result of the graphic element includes: reading the recognition results of all graphic elements in the overlapping area, judging whether the graphic element has more than one set of recognition results, and if the judgment result is yes, performing average processing on the output vectors corresponding to the multiple sets of recognition results to obtain the final recognition result of the graphic element; if the judgment result is no, taking the one set of recognition results as the final recognition result of the graphic element; The steps for obtaining the structured data record of the vector drawing include: obtaining the semantic category information of the instance to which the graphic element belongs, that is, the semantic category vector, and obtaining the semantic category of the instance to which the graphic element belongs after normalization; obtaining the center position information of the instance to which the graphic element belongs, that is, the instance center vector, clustering the centers of the instance to which the graphic element belongs according to density, and obtaining the instance distinction to which the graphic element belongs. The semantic categories of the instances to which all graphic elements belong and the instance distinctions to which all graphic elements belong constitute the structured data record of the vector drawing.
6. A method for automatically identifying CAD vector drawings according to claim 5, characterized in that: In step six, structural processing is performed based on the recognition results of the rectangular sub-blocks, including: calculating the geometric envelope or fill of the instance, and converting the drawing into a structured component record; The structured component record is based on components or furniture instances as basic units, and each instance includes the following fields: number, geometry, category and location.
7. A CAD vector drawing automatic recognition device, characterized in that: include: Drawing reading module, used to read the original file of vector drawing, parse and obtain the expression information of multiple graphic elements of the drawing; A drawing segmentation module is used to segment a vector drawing into a plurality of overlapping rectangular sub-blocks according to segmentation rules; The encoding module is used to extract the primitives in the rectangular sub-block, analyze the geometric feature parameters of the primitives, and perform serial encoding to convert the rectangular sub-block into a coding sequence of the primitives; A deep learning prediction module is used to input the coding sequence of the primitive into the deep learning model to obtain the recognition result of the rectangular sub-block, wherein the recognition result includes the semantic information and instance information of the instance to which the primitive belongs; the semantic information is a category vector containing the semantic category information of the instance to which the primitive belongs; the instance information is a position vector containing the center position information of the instance to which the primitive belongs; A data processing module is used to perform data fusion according to the recognition results of the overlapping areas of adjacent rectangular sub-blocks to obtain the final recognition result of the primitive, and perform post-processing according to the final recognition result to obtain the structured data record of the vector drawing; The structured processing module is used to perform structured processing according to the recognition results of the rectangular sub-blocks and convert the drawings into structured component records.
8. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements a CAD vector drawing automatic recognition method as described in any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, a method for automatically identifying CAD vector drawings as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
CAD drawing recognition method and device based on domain knowledge and target detection
CN110909650A
Component identification method and device, training set construction method and device, equipment and storage medium
CN113657202A
CAD drawing recognition method, device and equipment
CN117523597A
Engineering drawing information extraction method and device, electronic equipment and storage medium
CN118762381A