CAD drawing primitive-level semantic annotation method and device and medium

By using the layer and tile information of the engineering drawings, semantic correspondence tables are established and automated analysis is carried out, the problem of overlapping boundary distinction and manual annotation workload in engineering vector drawings is solved, and efficient and accurate primitive-level semantic annotation is achieved.

CN119559642AInactive Publication Date: 2025-03-04TONGJI UNIV +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510117581.5
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

Technical Problem

The prior art is difficult to distinguish different entities or regions that overlap the boundaries in engineering vector drawings, and manual labeling is huge.

Method used

By using the layer and tile division information in engineering drawings, a layer semantic correspondence table is established, and the automated program analyzes the primitives and layers in the drawings, performs automatic comparison and analysis, and obtains the primitive-level annotations of the drawings.

Benefits of technology

It realizes the completion of element-level semantic annotation in a short time, improves the labeling accuracy and efficiency, is suitable for large-scale promotion, and helps to establish larger data sets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119559642A_ABST
    Figure CN119559642A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of engineering drawing recognition, and discloses a CAD drawing primitive-level semantic annotation method and device and a medium, and the method comprises the steps: obtaining a drawing dwg file, preprocessing the drawing, and forming a preprocessed drawing; all component instances in the preprocessed drawing are grouped in the form of blocks, and a grouped drawing is obtained; utilizing the layer information and the semantic information to establish a layer semantic correspondence table; forming an annotation file according to the corresponding relationship between the grouped drawings and the layer semantic corresponding table; reading the annotation file, screening all instances, carrying out semantic search for each instance to obtain the semantic category of the instance, carrying out primitive reverse annotation according to the semantic category of the instance, and generating a semantic category annotation result of the primitive, so that the primitive-level semantic annotation of the CAD drawing can be realized, and then a CAD vector drawing annotation data set is generated. Compared with a traditional image-based labeling method, the method has the advantage that the labeling precision of the vector diagram is obviously improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of engineering drawing recognition, and in particular to a method, a device and a computer-readable storage medium for semantic annotation of CAD drawings at the primitive level for constructing a CAD engineering vector drawing data set. Background Art

[0002] It is very important to establish a semantic annotation dataset for engineering drawings, which is the technical basis for automatic recognition and automatic review of engineering drawings. CAD drawings are vector graphics, which are graphics based on mathematical equations and geometric properties. They are composed of a series of basic geometric objects, such as line segments and arcs. Their basic components are called primitives, which have the characteristics of infinite magnification without distortion. Element-level semantic annotation is to give semantic labels to each primitive in the drawing, so that the computer can distinguish the meanings of different primitives in the drawing, and thus distinguish the patterns of components, walls, etc. in the drawing.

[0003] In terms of annotation technology for engineering vector drawings, the main annotation method at present is mapping based on image annotation, that is, the vector image is first regarded as a general image, and the image annotation method is used for annotation, and the annotation content is further reversely mapped to each primitive of the vector image. Common methods of image annotation include anchor box annotation, polygon annotation, key point annotation, cube annotation, etc. Its main principle is to divide the objects or areas in the image by geometric elements such as rectangles, polygons, key points, etc.

[0004] However, the current method has many shortcomings. Many elements in vector graphics have overlapping boundaries, and image-based annotation methods cannot distinguish different entities or regions at the overlapping boundaries. In addition, engineering drawings contain a large amount of information and a rich variety of element categories. A single drawing contains a large number of components, and the annotation workload is huge.

[0005] Therefore, a semantic annotation scheme at the element level for CAD drawings is proposed to promote the establishment of a semantic annotation dataset for engineering vector drawings. Summary of the invention

[0006] In order to overcome the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide a CAD drawing primitive-level semantic annotation method device and computer-readable storage, which utilizes the existing layers and block division information in the engineering drawings to reduce the workload of manual annotation; and establishes an automated program to parse the primitives and layers in the drawings, perform automated comparison and analysis, and obtain the primitive-level annotation of the drawings.

[0007] To achieve the above object, the present invention proposes a CAD drawing primitive-level semantic annotation method, comprising the following steps: Obtaining a drawing dwg file, preprocessing the drawing, and forming a preprocessed drawing; Grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; Using layer information and semantic information, a layer semantic correspondence table is established; Forming a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; The annotation file is read, all instances are screened, a semantic search is performed on each instance to obtain a semantic category of the instance, and a primitive is reversely annotated according to the semantic category of the instance to generate a semantic category annotation result of the primitive.

[0008] Preferably, the reading of the annotation file comprises the following steps: For the drawing files in the annotation files, read the shape, position, length, layer, and block nesting relationship of each element in the drawing; For the layer semantic correspondence table in the annotation file, the corresponding dictionary of the layer semantic correspondence table is read, and the dictionary is automatically matched to the corresponding drawing, wherein the layer semantic correspondence table is stored in the form of a dictionary.

[0009] Preferably, the screening of all instances comprises the following steps: According to the grouping of all component instances in the form of blocks, all blocks of each drawing are obtained; All simple tiles are screened, each of which corresponds to an instance, wherein the simple tile is a tile that does not contain a sub-tile.

[0010] Preferably, performing semantic search on each instance to obtain the semantic category of the instance includes the following steps: For each instance, find the graphic element inside the instance and obtain the layer where the graphic element is located; Acquire semantic information corresponding to the layer where the graphic element is located according to the layer semantic correspondence table; If the layer where the graphic element is located corresponds to only one kind of semantic information, obtaining the semantic information corresponding to the layer where the graphic element is located; If the layer where the graphic element is located corresponds to multiple semantic information, the semantic annotation of the instance is obtained by automatic comparison; The automatic comparison method includes using image cosine similarity to determine the difference between the instance and the template in the template library, selecting the closest template through comparison, and determining the semantic category of the instance according to the semantic category of the template.

[0011] Preferably, the method of using image cosine similarity to judge the difference between the instance and the template in the template library, selecting the closest template by comparison, and determining the semantic category of the instance according to the semantic category of the template comprises the following steps: Render instances as small images x, extract the instance template image corresponding to the semantic annotation from the template library y ; The small image x and the example template image y Through neural network f Convert it into a vector and calculate the cosine similarity, where the calculation formula of the cosine similarity is as follows: ; A template having a high similarity to the instance is selected, and the semantic category of the template is used as the semantic category of the instance.

[0012] Preferably, performing reverse annotation of the primitive according to the semantic category of the instance to generate the semantic category annotation result of the primitive includes the following steps: According to the semantic category of the instance, the semantic information of all the graphic elements of the instance is labeled as the semantic information of the instance; Add semantic information annotation and instance information annotation to the primitives. For primitives that cannot be distinguished as specific instances, no instance information is given. The semantic information annotation includes but is not limited to number and text form, and the instance information annotation includes but is not limited to number form; After labeling, all graphics elements are traversed and checked again. If there are graphics elements without semantic information labeling or instance information labeling, the semantic information of the graphics element is assigned as "other" and no instance information labeling is assigned.

[0013] Preferably, the method further comprises the steps of: Generate a CAD vector drawing annotation dataset according to the semantic category annotation results of the graphic elements; The data set is output in SVG format, and each primitive is proportionally mapped to the SVG primitive.

[0014] Preferably, the step of grouping all component instances in the preprocessed drawings in the form of blocks to obtain grouped drawings comprises the following steps: For the graphic elements that cannot be distinguished into specific instances, the graphic elements are placed in a separate layer as a whole instance; If the layers of graphic elements in the same instance are not unified, adjust the layer where the graphic elements are located to ensure that the layer where the graphic elements are located is consistent with the layer where the instance is located.

[0015] To achieve the above-mentioned purpose, the present invention also discloses a CAD drawing element-level semantic annotation device, comprising: The initial drawing acquisition module is used to acquire the drawing dwg file, pre-process the drawing, and form a pre-processed drawing; A drawing preprocessing module, used for grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; The instance segmentation module is used to establish a layer semantic correspondence table using layer information and semantic information; A layer correspondence table establishment module, used for forming a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; The module for automatically obtaining the primitive-level annotation is used to read the annotation file, screen all instances, perform semantic search on each instance, obtain the semantic category of the instance, perform primitive reverse annotation according to the semantic category of the instance, and generate the semantic category annotation result of the primitive.

[0016] To achieve the above-mentioned purpose, the present invention further discloses a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is used to execute any one of the above-mentioned CAD drawing primitive-level semantic annotation methods.

[0017] Compared with the prior art, the beneficial effects of the embodiments of the present invention include but are not limited to: Complete element-level semantic annotation of real architectural plan drawings in a relatively short time; The annotation results of a single drawing can be accurately mapped to each primitive, with high precision in primitive boundaries and overlapping positions. Compared with traditional image-based annotation methods, the accuracy of vector graphics annotation is significantly improved; By utilizing existing layers and blocks of engineering drawings, this embodiment takes about 5 minutes to manually annotate vector graphics, has good annotation efficiency, is suitable for large-scale promotion, and is conducive to establishing a larger data set. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 A flowchart of the steps of the primitive-level semantic annotation method disclosed in an embodiment of the present invention; Figure 2 A flowchart of the steps of a primitive-level semantic annotation method disclosed in another embodiment of the present invention; Figure 3 It is a block-specific structural diagram of an engineering drawing example disclosed in an embodiment of the present invention; Figure 4 A schematic diagram of a building plan disclosed in a specific embodiment of the present invention; Figure 5 A schematic diagram of a preprocessing result of a building plan disclosed in an embodiment of the present invention; Figure 6 A schematic diagram of block categories of a building plan example disclosed in an embodiment of the present invention; Figure 7 A schematic diagram of the results of differentiating the major categories of semantic annotation of a building plan view disclosed in an embodiment of the present invention; Figure 8 It is a schematic diagram of the structure of the primitive-level semantic annotation device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The following describes the implementation of the present invention through specific examples and in conjunction with the accompanying drawings. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific examples, and the details in this specification can also be modified and changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.

[0020] like Figure 1 As shown, a CAD drawing element-level semantic annotation method includes the following steps: Step S101, obtaining a drawing dwg file, preprocessing the drawing, and forming a preprocessed drawing; Step S102, grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; Step S103, using the layer information and semantic information, establishing a layer semantic correspondence table; Step S104, forming a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; Step S105 , reading the annotation file, screening all instances, performing semantic search on each instance to obtain the semantic category of the instance, performing reverse annotation of the primitive according to the semantic category of the instance, and generating a semantic category annotation result of the primitive.

[0021] Specifically, this method can be divided into two stages, namely the manual annotation stage and the automated reading program stage. The manual annotation stage is mainly based on CAD drawing software, and further standardizes blocks and layers based on existing engineering drawings; the automated reading stage is mainly based on automated programs, which read the results of manual annotation to form automated annotation files.

[0022] In one embodiment of the present invention, see Figure 2 ,The manual annotation stage is divided into the following steps: Step S201, obtaining the drawing dwg file: specifically, opening the engineering drawing dwg file and finding the main part of the drawing; Step S202, drawing preprocessing; specifically, preprocessing the drawing includes but is not limited to exploding large blocks, removing miscellaneous lines in the drawing, and removing redundant layers to form a preprocessed drawing; The above-mentioned large block refers to a block containing multiple component instances, which is generally set to improve drawing efficiency, such as a block consisting of a room and all the components inside it, a block consisting of all columns, etc.; Removing miscellaneous lines mainly includes removing annotations and box selections during the drawing review process, removing lead lines and redundant text descriptions, removing cut or incomplete instances, and removing other lines in unreasonable positions; Redundant layers mainly refer to layers with no graphics or only a small number of graphics inside. If an empty layer appears, it should be removed. If a layer has only a small number of graphics inside, it should be merged with other layers.

[0023] Step S203, performing instance segmentation; specifically, instance segmentation mainly utilizes the grouping function in CAD to group all component instances in the drawing in the form of blocks; the grouping form is as follows: Figure 3 As shown; Among them, component instances refer to drawing patterns of building structure components, furniture, etc. with distinguishable numbers, including but not limited to the following categories: building components represented by columns, doors, windows, openings, stairs and elevators; and furniture represented by tables, chairs, sofas, cabinets, toilets, sinks, gas stoves and refrigerators.

[0024] Furthermore, no additional processing is performed on the graphics that cannot be distinguished into specific instances; for indistinguishable structural components such as walls, they should be placed in a separate layer as a whole instance for ease of processing; during the instance segmentation process, if it is found that the graphics layer within the same instance is not unified, the layer where the graphics are located should be manually adjusted to make it consistent with the layer where the instance is located.

[0025] It should be noted that general architectural engineering drawings have certain common drawing specifications and habits, and there are relatively clear layers and block divisions. For example, walls, doors, windows, and furniture are generally divided into different layers, and instances such as doors and windows are generally combined in the form of blocks. Therefore, the above-mentioned instance block division work only needs to be further adjusted and standardized on the basis of the existing block division, and the wrongly divided layers should be corrected, and the ungrouped instances should be grouped.

[0026] Step S204, establishing a layer correspondence table; specifically, this step mainly requires manual matching of layers and specific semantics, matching layer information and semantic information, and establishing a layer semantic correspondence table; It should be noted that the layer is an important reference for semantic annotation. After the grouping in step S203, the division of the layer is standardized, but there is a lack of correspondence between the layer and the semantic annotation. In addition, there are instances where a layer contains one or more semantics, for example, a layer contains both doors and windows. Therefore, it is necessary to establish a layer semantic correspondence table.

[0027] Furthermore, the layer semantic correspondence table is stored in the form of a dictionary, and the main format is as follows: {"layer1": ["semantic1", "semantic2"], "layer2": ["semantic3"], ...} Among them, all layers should be mapped to one or more semantic labels.

[0028] Specifically, the layer semantic correspondence table and the drawings may not be one-to-one corresponding. If the layer segmentation of different drawings is highly similar, one layer semantic correspondence table can be applied to multiple drawings.

[0029] Step S203, the annotation file is saved and organized; specifically, the annotation file includes the processed drawings and layer semantic correspondence table; Furthermore, the layer file is saved in dxf format to facilitate subsequent reading and processing; the layer semantic correspondence table can be saved and read in json or other formats; the files are sorted according to the correspondence between the drawings and the layer semantic correspondence table to form a annotation file.

[0030] In one embodiment of the present invention, see Figure 2 , the automation process phase is divided into the following steps: Step S301, reading the marked drawings; Furthermore, for drawing files, the program can read the shape, position, length, layer, and block nesting relationship of each element in the drawing; For the layer semantic correspondence table, the program can complete the reading of the corresponding dictionary and automatically match it to its corresponding drawing.

[0031] Step S302, screening all instances; Specifically, for each drawing, all the blocks of the drawing are obtained according to the grouping of instances in the manual annotation, that is, the block nesting information; Filter all simple tiles, each of which corresponds to one instance; if a tile still contains sub-tiles, it is not considered to be a simple tile.

[0032] Step S303, instance semantic search; Specifically, for each instance, find the primitive inside it and obtain the layer where the primitive is located; According to the layer semantic correspondence table, obtain the semantic information corresponding to the layer; If the layer corresponds to only one kind of semantic information, all the primitives in the instance are labeled with the corresponding semantics; If the layer corresponds to multiple semantic information, it will enter the automatic comparison stage to obtain the semantic annotation of the instance through comparison.

[0033] Furthermore, the automatic comparison link mainly determines the difference between the instance and the template through the image cosine similarity, selects the closest template through comparison, and determines the semantic category of the instance according to the semantic category of the template, including the following steps: First, render the instance as a small image x , and further extract the instance template corresponding to the semantic annotation from the template library y ; Secondly, the two images are passed through the neural network separately f Convert it into a vector and calculate the cosine similarity. The calculation formula is as follows: ;

[0034] Finally, the template with the highest similarity to the instance is selected, and the semantic category of the template is used as the semantic category of the instance.

[0035] Step S304, automatically reverse marking the primitive; Specifically, according to the semantic category of the instance, the semantic information of all the primitives in the instance is annotated as the semantic information of the instance, and semantic information and instance information fields are added to the primitives; The semantic information annotation includes but is not limited to numbers, texts and other forms, and only needs to be able to distinguish the semantic information of different components; the instance information annotation can be in the form of numbers, and all sub-elements in each instance can be assigned the same number, indicating that the sub-elements belong to the same instance; for components such as walls whose number cannot be distinguished, no instance annotation is given; After labeling, all the primitives are checked again. If there are primitives without semantic labeling or instance labeling, the primitive is assigned semantic information of "other" and no instance labeling is assigned.

[0036] Step S305, marking results; Specifically, according to the semantic category labeling results of the graphic elements in step S304 to step S305, a CAD vector drawing labeling data set is generated; The dataset is output in svg format, and each CAD primitive is proportionally mapped to the svg primitive. In addition, the semantic annotation result and instance distinction result of the primitive are added to each svg primitive field.

[0037] Preferably, the SVG primitives can be rendered in different colors and line widths according to different semantic categories to enhance the visual display of the annotation results.

[0038] In a specific implementation disclosed by the present invention, a case study of the CAD primitive-level annotation method is shown as follows using a certain architectural plan drawing: Step S401, open the engineering drawing dwg file and find the main part of the drawing; the main part of the drawing is as follows: Figure 4 As shown; Step S402, drawing preprocessing: remove the lead lines and unnecessary text annotations around the drawing, and merge the layers for the wall; remove the more subtle facilities such as floor drains and pipes to ensure the simplicity of the drawing; the preprocessed drawing is as follows Figure 5 shown.

[0039] Step S403, instance block: Use the grouping function in CAD to group all component instances in the drawing in the form of blocks; after processing, in this example, mainly mark the structural components such as doors, windows, railings, and mark the furniture facilities such as sliding doors, gas stoves, sinks, refrigerators, washing machines, toilets, showers, etc.; for continuous components, mainly mark the wall components; some marked instances can be seen Figure 6 shown.

[0040] Step S404, establishing a layer correspondence table: matching the layer information and the semantic information to establish a layer semantic correspondence table. In this example, each type of layer is checked and its corresponding semantics is listed; Among them, doors, windows, sliding doors, and railings belong to different layers. Kitchen furniture is on the same layer, which includes three types of semantic information: gas stove, sink, and refrigerator; bathroom furniture is on the same layer, which includes three types of semantic information: toilet, shower, and washing machine. Based on the above layer correspondence, a layer semantic correspondence table is established.

[0041] Step S405, file storage and classification: save the adjusted drawing file in dxf format, save the layer semantic correspondence table in json format, and place the two in the same folder to form a annotation file; Step S406, read the annotation file: For drawing files, the program can read the shape, position, length, layer, and block nesting relationship of each element in the drawing; For the layer semantic correspondence table, the program can complete the reading of the corresponding dictionary and automatically match it to its corresponding drawing.

[0042] Step S407, filter all instances: For each drawing, all instances within the drawing are obtained based on the grouping of instances in manual annotation, that is, block nesting information.

[0043] Step S408, instance semantic search: For each instance, find the primitive inside it and obtain the layer where the primitive is located; according to the layer semantic correspondence table, obtain the semantic information corresponding to the layer; Specifically, for the four layers of door, window, railing, and sliding door, according to the layer semantic correspondence table, its internal instances correspond to the four semantic categories of door, window, railing, and sliding door respectively; For the wall layer, all walls are in the wall layer and can be mapped to the wall semantics according to the layer semantic mapping table; When distinguishing the kitchen furniture layer, the sink, gas stove, and refrigerator are automatically compared with the existing drawing templates to distinguish the three types of semantics; When distinguishing the bathroom furniture layers, the toilet, shower, and washing machine are automatically compared with the existing drawing templates to distinguish the three types of semantics.

[0044] Step S409: Automatic reverse annotation of primitives: For instances such as doors, windows, railings, sliding doors, sinks, gas stoves, refrigerators, toilets, showers and washing machines, the semantic information found is automatically annotated to all the graphics under the instances, that is, semantic information and instance information fields are added to the graphics respectively; for walls, only semantic annotations are given, not instance annotations; further screen all graphics, and assign the semantic label of "other" to instances without semantic annotations.

[0045] Step S410, save the annotation results: The dataset is output in svg format, where each CAD primitive is proportionally mapped to an svg primitive. In addition, the semantic annotation result and instance distinction result of the primitive are added to each svg primitive field. Different semantic categories are displayed in three categories: walls, doors and windows, and furniture. Figure 7 shown.

[0046] It should be noted that steps S401 to S410 are not shown in the drawings.

[0047] The present invention also discloses a CAD drawing element-level semantic annotation device, comprising: The initial drawing acquisition module 501 is used to acquire a drawing dwg file, pre-process the drawing, and form a pre-processed drawing; A drawing preprocessing module 502 is used to group all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; The instance segmentation module 503 is used to establish a layer semantic correspondence table using layer information and semantic information; A layer correspondence table establishing module 504 is used to form a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; The automatic acquisition of primitive-level annotation module 505 is used to read the annotation file, screen all instances, perform semantic search on each instance, obtain the semantic category of the instance, perform primitive reverse annotation according to the semantic category of the instance, and generate the semantic category annotation result of the primitive.

[0048] Furthermore, the drawing preprocessing module 502 is specifically used for: For the graphic elements that cannot be distinguished into specific instances, the graphic elements are placed in a separate layer as a whole instance; If the layers of graphic elements in the same instance are not unified, adjust the layer where the graphic elements are located to ensure that the layer where the graphic elements are located is consistent with the layer where the instance is located.

[0049] Furthermore, the automatic acquisition of primitive-level annotation module 505 also includes an annotated drawing reading module, which is used to: For the drawing files in the annotation files, read the shape, position, length, layer, and block nesting relationship of each element in the drawing; For the layer semantic correspondence table in the annotation file, the corresponding dictionary of the layer semantic correspondence table is read, and the dictionary is automatically matched to the corresponding drawing, wherein the layer semantic correspondence table is stored in the form of a dictionary.

[0050] Furthermore, the module 505 for automatically obtaining primitive-level annotations further includes an instance screening module for: According to the grouping of all component instances in the form of blocks, all blocks of each drawing are obtained; All simple tiles are screened, each of which corresponds to an instance, wherein the simple tile is a tile that does not contain a sub-tile.

[0051] Furthermore, the automatic acquisition of primitive-level annotation module 505 also includes an instance semantic search module, which is used to: for each instance, find the primitive inside the instance and obtain the layer where the primitive is located; Acquire semantic information corresponding to the layer where the graphic element is located according to the layer semantic correspondence table; If the layer where the graphic element is located corresponds to only one kind of semantic information, obtaining the semantic information corresponding to the layer where the graphic element is located; If the layer where the graphic element is located corresponds to multiple semantic information, the semantic annotation of the instance is obtained by automatic comparison; The automatic comparison method includes using image cosine similarity to determine the difference between the instance and the template in the template library, selecting the closest template through comparison, and determining the semantic category of the instance according to the semantic category of the template.

[0052] Furthermore, the method of using the image cosine similarity to judge the difference between the instance and the template, selecting the closest template by comparison, and determining the semantic category of the instance according to the semantic category of the template includes: Render instances as small images x , extract the instance template image corresponding to the semantic annotation from the template library y ; The small image x and the example template image y Through neural network f Convert it into a vector and calculate the cosine similarity, where the calculation formula of the cosine similarity is as follows: ; A template having a high similarity to the instance is selected, and the semantic category of the template is used as the semantic category of the instance.

[0053] Furthermore, the automatic primitive-level annotation module 505 further includes a primitive automatic reverse annotation module, which is used to: According to the semantic category of the instance, the semantic information of all the graphic elements of the instance is labeled as the semantic information of the instance; Add semantic information annotation and instance information annotation to the primitives. For primitives that cannot be distinguished as specific instances, no instance information is given. The semantic information annotation includes but is not limited to number and text form, and the instance information annotation includes but is not limited to number form; After labeling, all graphics elements are traversed and checked again. If there are graphics elements without semantic information labeling or instance information labeling, the semantic information of the graphics element is assigned as "other" and no instance information labeling is assigned.

[0054] Furthermore, the automatic primitive-level annotation module 505 further includes an annotation result module, which is used to: According to the semantic category labeling results of the primitives, a CAD vector drawing labeling dataset is generated, where the dataset is output in svg format, in which each CAD primitive is proportionally mapped to the svg primitive. In addition, the semantic labeling results and instance distinction results of the primitive are added to each svg primitive field.

[0055] Preferably, the SVG primitives can be rendered in different colors and line widths according to different semantic categories to enhance the visual display of the annotation results.

[0056] It should be noted that the device corresponds to the method, and other undescribed parts can be found in the method and will not be repeated here.

[0057] The present invention also discloses a computer-readable storage medium, wherein the computer-executable instructions are used to execute one or a combination of the steps of the above method embodiments when executed by a computer processor.

[0058] The computer storage medium of the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Examples of computer-readable storage media include, but are not limited to, electrical, optical, magnetic, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media include, but are not limited to: an electrical connection with one or more wirings, a portable computer disk box, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical fiber, an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, device or device.

[0059] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program codes. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0060] Computer program code for performing the operation of the present invention can be written in a CAD drawing element-level semantic annotation method or a plurality of programming languages ​​or a combination thereof, wherein the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and also includes a conventional procedural programming language, such as "C" language or a similar programming language. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0061] The above embodiments are only illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Any person skilled in the art may modify and change the above embodiments without violating the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be as set forth in the claims.

Claims

1. A method for semantic annotation of CAD drawings at the element level, comprising the following steps: Obtaining a drawing dwg file, preprocessing the drawing, and forming a preprocessed drawing; Grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; Using layer information and semantic information, a layer semantic correspondence table is established; Forming a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; The annotation file is read, all instances are screened, a semantic search is performed on each instance to obtain a semantic category of the instance, and a primitive is reversely annotated according to the semantic category of the instance to generate a semantic category annotation result of the primitive.

2. A CAD drawing primitive-level semantic annotation method as claimed in claim 1, characterized in that: The step of reading the annotation file comprises the following steps: For the drawing files in the annotation files, read the shape, position, length, layer, and block nesting relationship of each element in the drawing; For the layer semantic correspondence table in the annotation file, the corresponding dictionary of the layer semantic correspondence table is read, and the dictionary is automatically matched to the corresponding drawing, wherein the layer semantic correspondence table is stored in the form of a dictionary.

3. A CAD drawing element-level semantic annotation method as claimed in claim 1, characterized in that: The screening of all instances comprises the following steps: According to the grouping of all component instances in the form of blocks, all blocks of each drawing are obtained; All simple tiles are screened, each of which corresponds to an instance, wherein the simple tile is a tile that does not contain a sub-tile.

4. A CAD drawing element-level semantic annotation method as claimed in claim 1, characterized in that: The process of performing semantic search on each instance to obtain the semantic category of the instance includes the following steps: For each instance, find the graphic element inside the instance and obtain the layer where the graphic element is located; Acquire semantic information corresponding to the layer where the graphic element is located according to the layer semantic correspondence table; If the layer where the graphic element is located corresponds to only one kind of semantic information, obtaining the semantic information corresponding to the layer where the graphic element is located; If the layer where the graphic element is located corresponds to multiple semantic information, the semantic annotation of the instance is obtained by automatic comparison; The automatic comparison method includes using image cosine similarity to determine the difference between the instance and the template in the template library, selecting the template with the highest cosine similarity, and determining the semantic category of the instance according to the semantic category of the template.

5. A CAD drawing primitive-level semantic annotation method as claimed in claim 4, characterized in that: The method of using the image cosine similarity to judge the difference between the instance and the template in the template library, comparing and selecting the template with the highest cosine similarity, and determining the semantic category of the instance according to the semantic category of the template includes the following steps: Render instances as small images x , extract the instance template image corresponding to the semantic annotation from the template library y ; The small image x and the example template image y Through neural network f Convert it into a vector and calculate the cosine similarity, where the calculation formula of the cosine similarity is as follows: ; A template having the highest cosine similarity with the instance is selected, and the semantic category of the template is used as the semantic category of the instance.

6. A CAD drawing primitive-level semantic annotation method as claimed in claim 5, characterized in that: The reverse annotation of the primitive according to the semantic category of the instance to generate the semantic category annotation result of the primitive includes the following steps: According to the semantic category of the instance, the semantic information of all the graphic elements of the instance is labeled as the semantic information of the instance; Add semantic information annotation and instance information annotation to the primitives. For primitives that cannot be distinguished as specific instances, no instance information is given. The semantic information annotation includes but is not limited to number and text form, and the instance information annotation includes but is not limited to number form; After labeling, all graphics elements are checked again. If there are graphics elements without semantic information labeling or instance information labeling, the semantic information of the graphics element is assigned as "other" and no instance information labeling is assigned.

7. A CAD drawing element-level semantic annotation method as claimed in claim 1, characterized in that: The method further comprises the steps of: Generate a CAD vector drawing annotation dataset according to the semantic category annotation results of the graphic elements; The data set is output in SVG format, and each primitive is proportionally mapped to the SVG primitive.

8. A CAD drawing element-level semantic annotation method as claimed in claim 1, characterized in that: The step of grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing comprises the following steps: For the graphic elements that cannot be distinguished into specific instances, the graphic elements are placed in a separate layer as a whole instance; If the layers of graphic elements in the same instance are not unified, adjust the layer where the graphic elements are located to ensure that the layer where the graphic elements are located is consistent with the layer where the instance is located.

9. A CAD drawing element-level semantic annotation device, comprising: The initial drawing acquisition module is used to acquire the drawing dwg file, pre-process the drawing, and form a pre-processed drawing; A drawing preprocessing module, used for grouping all component instances in the preprocessed drawing in the form of blocks to obtain a grouped drawing; The instance segmentation module is used to establish a layer semantic correspondence table using layer information and semantic information; A layer correspondence table establishment module, used for forming a marking file according to the correspondence between the grouped drawings and the layer semantic correspondence table; The module for automatically obtaining the primitive-level annotation is used to read the annotation file, screen all instances, perform semantic search on each instance, obtain the semantic category of the instance, perform primitive reverse annotation according to the semantic category of the instance, and generate the semantic category annotation result of the primitive.

10. A computer-readable storage medium storing a computer program, wherein the computer program is used to execute the CAD drawing primitive-level semantic annotation method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • CAD drawing analysis method, device and equipment and storage medium

    CN113052023A

  • CAD drawing recognition method, device and equipment

    CN117523597A

  • Transformer substation three-dimensional parametric modeling method and system based on engineering design drawing

    CN119089541A

  • Semantic segmentation method and apparatus based on multispectral image, and storage medium

    WO2023221328A1