Method and system for generating wiring diagram through CAD image
The YOLOV5 algorithm and PaddleOCR algorithm of the SE-Net attention mechanism recognize electrical elements and text, combine the skeleton refinement algorithm to extract line segment information, and connect topological relationships based on the busbar, solving the insufficient recognition accuracy and automation of the power grid factory wiring diagram. The problem of this achieves efficient and accurate graphic recognition and maintenance.
Patent Information
- Application Number
- CN202410756952.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-11-01
AI Technical Summary
Traditional manual management methods are difficult to create and maintain power grid factory wiring diagrams efficiently and accurately. The existing automation technology lacks the recognition accuracy and degree of automation in terms of complex, diverse and non-standardized wiring diagram recognition.
The YOLOV5 algorithm using the SE-Net attention mechanism is used to recognize electrical elements, and the PaddleOCR algorithm is used to recognize text. The line segment information is extracted through the skeleton refinement algorithm, and topological relationship connections are made based on the busbar to achieve accurate identification of the power grid regulation graph.
It improves the accuracy of electrical element recognition rate and graphic combination, reduces processing time and cost, and is suitable for the digital needs of large-scale complex factory site maps.
Smart Images

Figure CN118887692A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer image processing, and in particular to a method and system for generating a wiring diagram from a CAD image. Background Art
[0002] As a key graphic material that depicts the connection relationship between electrical equipment in a substation or power plant, the accuracy and real-time performance of the power grid wiring diagram are directly related to the safe operation and efficient dispatching of the power system. These drawings not only include the location layout of key electrical components such as transformers, circuit breakers, disconnectors, busbars, etc., but also clearly show the complex connection relationship between the components. They are an indispensable information basis for power dispatchers to conduct daily monitoring, fault analysis, load adjustment and emergency response. With the continuous expansion of the scale and increasing complexity of the power system, the traditional manual management method is facing severe challenges.
[0003] At present, in many power dispatching centers, the creation, updating and maintenance of plant wiring diagrams are still highly dependent on the professional knowledge and practical experience of dispatchers. This process is not only time-consuming, but also easily affected by human factors, such as untimely updates, which may lead to dispatching decision-making errors, and even threaten the safe and stable operation of the entire power grid in serious cases. Although computer-aided design (CAD) has improved the efficiency of drawing wiring diagrams to a certain extent, they mostly focus on the design stage and have limited automatic recognition and conversion capabilities for existing paper or non-standardized electronic wiring diagrams. Some existing automation attempts, such as those based on image processing and pattern recognition, can recognize some elements in the drawings, but when faced with complex, diverse and highly professional actual wiring diagrams, it is often difficult to achieve satisfactory recognition accuracy and automation, and the limitations are more prominent.
[0004] Therefore, it is urgent to develop an efficient, accurate and adaptable automatic recognition method for electrical wiring drawings of various formats and qualities. Summary of the invention
[0005] In view of the above existing problems, the present invention is proposed.
[0006] Therefore, the present invention provides a method and system for generating wiring diagrams from CAD images to solve the problems that the current drawing and maintenance of plant wiring diagrams mainly rely on the work experience of dispatchers, the manual vectorization solution is time-consuming and labor-intensive, the existing paper or non-standardized electronic wiring diagrams have limited automatic recognition and conversion capabilities, and lack automation and accuracy.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] In a first aspect, the present invention provides a method for generating a wiring diagram from a CAD image, comprising:
[0009] Obtain the CAD plant station image to be identified;
[0010] The electrical element recognition model is used to perform element recognition on the plant station image to obtain an element annotation box; the electrical element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added;
[0011] Covering the primitives based on the primitive annotation frame to obtain a first image;
[0012] Performing text recognition on the first image by using an electrical text recognition model to obtain a text annotation box;
[0013] Covering the text based on the text annotation frame to obtain a second image;
[0014] Performing skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, integrating and connecting line segments based on the preliminary line segment information to obtain vertical and horizontal line segment sets and final line segment information respectively;
[0015] The line segments in the vertical and horizontal line segment sets are screened to obtain a busbar candidate set, and the number of connections around each line segment in the busbar candidate set is obtained. The busbar is determined based on the number of connections, and the topological relationship between the graphics elements is obtained by connecting with the busbar as the starting point.
[0016] As a preferred solution of the method for generating a wiring diagram from a CAD image of the present invention, the output of performing graphic element recognition on the plant diagram image through the electrical graphic element recognition model includes: a CAD image with the recognition graphic element annotation box and an electrical graphic element recognition result file;
[0017] The recognition result file includes the coordinates of the lower left corner and the lower right corner of the recognized primitive annotation box and the primitive type;
[0018] Performing text recognition on the first image through the electrical text recognition model to obtain a text annotation box includes:
[0019] The electrical text recognition model is a text recognition model based on the PaddleOCR algorithm;
[0020] The output is a CAD image with the recognized text annotation box marked and a text recognition result file. The recognition file content includes the coordinates of the upper left and lower right corners of the recognized text annotation box and the text content.
[0021] As a preferred solution of the method for generating a wiring diagram from a CAD image of the present invention, wherein: skeleton recognition is performed on the second image by a skeleton refinement algorithm to obtain preliminary line segment information, including:
[0022] The skeleton of horizontal and vertical line segments in the image is extracted through the skeleton thinning algorithm;
[0023] And traverse the image according to the obtained skeleton depth to obtain line segment information;
[0024] The traversal includes: finding any black pixel point, and judging four pixel points in the left and right directions or the upper and lower directions of the black pixel point;
[0025] If it is in the unvisited state, mark it as visited and determine whether it is a black pixel. If so, add its coordinates to the queue to be traversed;
[0026] Loop and record all the traversed black pixel sets to obtain the line segments with the minimum horizontal coordinate and the maximum horizontal coordinate connected to the black pixel and their preliminary line segment information;
[0027] If the left and right sides of the black pixel are judged, a horizontal line segment is obtained, and a horizontal line segment set is obtained after traversal;
[0028] If the up and down positions of the black pixel are judged, a vertical line segment is obtained, and a set of vertical line segments is obtained after traversal.
[0029] As a preferred solution of the method for generating a wiring diagram from a CAD image of the present invention, the method further comprises: integrating and connecting the line segments in combination with the preliminary line segment information to obtain a vertical and horizontal line segment set and final line segment information, respectively;
[0030] Determine and connect the line segments in the horizontal line segment set;
[0031] Determine and connect the line segments in the vertical line segment set;
[0032] The determination of connection is that for any two parallel line segments in the set, if the vertical distance between the two is less than a preset value and they intersect in the horizontal direction, the two are spliced to obtain a long line segment and obtain the final line segment information;
[0033] After looping and judging the connection, the vertical line segment set, the horizontal line segment set and the corresponding final line segment information are obtained respectively.
[0034] As a preferred solution of the method for generating a wiring diagram from a CAD image of the present invention, the line segments in the vertical and horizontal line segment sets are screened to obtain a busbar candidate set, including:
[0035] According to the final line segment information, a length threshold screening is performed on the horizontal or vertical line segment, wherein if the length of the line segment is greater than a first threshold, the line segment is added to the bus candidate set;
[0036] Obtaining the number of connections around each line segment in the bus candidate set, and determining the bus according to the number of connections, including:
[0037] For the busbar in the candidate set, it is determined whether the number of all connecting lines within the second threshold range around it is greater than the third threshold. If it is greater than the third threshold, the line segment is determined to be a busbar, otherwise it is an ordinary connecting line.
[0038] As a preferred solution of the method for generating a wiring diagram from a CAD image of the present invention, the topological relationship between the graphic elements is obtained by connecting the busbar as a starting point, including:
[0039] Starting from the identified bus, the wiring around the bus is determined according to a fourth threshold, and the bus is connected to the wiring within a range less than the fourth threshold;
[0040] Start from the wiring, and then continue to extend outward to determine whether the wiring is connected to the graphics element;
[0041] After cyclic judgment, the graphics elements are finally connected through wiring to obtain the topological relationship.
[0042] In a second aspect, the present invention provides a system for generating a wiring diagram from a CAD image, comprising:
[0043] An acquisition module is used to acquire a CAD plant station image to be identified;
[0044] The first recognition module is used to perform graphic element recognition on the plant station image through an electrical graphic element recognition model to obtain a graphic element annotation box; the electrical graphic element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added;
[0045] A first covering module, used for covering the primitives based on the primitive annotation frame to obtain a first image;
[0046] A second recognition module, configured to perform text recognition on the first image through an electrical text recognition model to obtain a text annotation box;
[0047] A second covering module, used for covering the text based on the text annotation frame to obtain a second image;
[0048] A third recognition module is used to perform skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, and integrate and connect the line segments in combination with the preliminary line segment information to obtain a vertical and horizontal line segment set and final line segment information respectively;
[0049] The connection screening module is used to screen the line segments in the vertical and horizontal line segment sets to obtain a bus candidate set, and obtain the number of connections around each line segment in the bus candidate set, determine the bus based on the number of connections, and connect with the bus as the starting point to obtain the topological relationship between the graphics elements.
[0050] As a preferred solution of the system for generating wiring diagrams from CAD images of the present invention, the traversal judgment module is used to find any black pixel point and judge the four pixel points in the left and right or upper and lower directions of the black pixel point;
[0051] A first screening module, configured to perform length threshold screening on horizontal or vertical line segments according to the final line segment information, wherein if the length of a line segment is greater than a first threshold, the line segment is added to a bus candidate set;
[0052] The first judgment module is used to judge whether the number of all connecting lines within the second threshold range around the busbar in the candidate set is greater than the third threshold. If it is greater than the third threshold, the line segment is judged to be a busbar, otherwise it is an ordinary connecting line.
[0053] In a third aspect, the present invention provides a computing device, comprising:
[0054] Memory and processor;
[0055] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the method for generating a wiring diagram from a CAD image are implemented.
[0056] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method for generating a wiring diagram from a CAD image.
[0057] Compared with the prior art, the present invention has the following beneficial effects: the present invention constructs a proprietary recognition model for electrical graphics elements in power grids, and fully utilizes the proprietary electrical graphics element model in combination with the YOLOV5 algorithm of the SE-Net attention mechanism, thereby improving the recognition rate of electrical graphics elements in plant diagrams; at the same time, a proprietary relationship model based on the busbar is constructed, which converts the complex association relationship problem between elements in the drawing into a connection relationship recognition problem starting from the busbar, thereby realizing the accurate recognition of power grid control graphic combinations. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0059] Figure 1 A schematic diagram of the overall process of a method for generating a wiring diagram from a CAD image according to an embodiment of the present invention;
[0060] Figure 2 The present invention is a schematic diagram of a specific process flow of a model in a method for generating a wiring diagram from a CAD image according to an embodiment of the present invention. DETAILED DESCRIPTION
[0061] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.
[0062] Example 1
[0063] Reference Figure 1-Figure 2 , as one embodiment of the present invention, provides a method for generating a wiring diagram from a CAD image, comprising:
[0064] S100: Acquire a CAD plant station image to be identified;
[0065] Specifically, the plant diagram image format to be identified includes: a CAD image in a png or jpg format obtained by converting a CAD file in a pdf format.
[0066] It should be noted that, optionally, the CAD plant drawing image to be identified is preprocessed before being input into the electrical graphic element recognition model. The preprocessing includes, by performing operations such as image expansion, corrosion, recoloring, Gaussian blurring, and sharpening on the CAD original image to be identified, so as to remove stains on the image to a certain extent; at the same time, remove the red watermark, highlight the features, and use the preprocessed image as the subsequent input image.
[0067] S200: The electrical element recognition model is used to perform element recognition on the plant image to obtain an element annotation box; the electrical element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added;
[0068] Specifically, for the electrical element recognition model, it can be obtained by adding the SE-Net attention mechanism module after the last layer of the network Backbone module and the three output layers of the Head module of the YOLOV5 algorithm model.
[0069] In an implementable manner, the electrical graphic element recognition model is used to perform graphic element recognition on the plant station image, and the output includes: a CAD image with a recognition graphic element annotation box and an electrical graphic element recognition result file;
[0070] The recognition result file includes the coordinates of the lower left and lower right corners of the recognized primitive annotation box and the primitive type.
[0071] S300: Covering the primitives based on the primitive annotation frame to obtain a first image;
[0072] Specifically, in this step, the primitives in the CAD image with the identified primitive labeling box outputted from S200 are covered, and the labeled box area can be filled with white pixel values to obtain a CAD image with the primitives covered, that is, a first image.
[0073] S400: Performing text recognition on the first image by using an electrical text recognition model to obtain a text annotation box;
[0074] It should be noted that the electrical text recognition model is mainly used to automatically extract and identify key electrical information from electrical engineering drawings, diagrams or on-site photos, such as component labels, circuit numbers, wire specifications, installation location instructions, etc.; it is usually based on deep learning algorithms, especially convolutional neural networks (CNN) and recurrent neural networks (RNN), and sometimes combined with long short-term memory (LSTM) or transformer architecture to process sequence data.
[0075] Preferably, the electrical text recognition model is a text recognition model based on the PaddleOCR algorithm; the output is a CAD image with a recognized text annotation box marked and a text recognition result file, and the recognition file content includes the coordinates of the upper left and lower right corners of the recognized text annotation box and the text content.
[0076] S500: Covering the text based on the text annotation frame to obtain a second image;
[0077] Specifically, in this step, the text in the CAD image with the recognized text annotation box outputted in S400 is covered, and the annotation box area can be filled with white pixel values to obtain a CAD image with the primitives and text covered, that is, a second image.
[0078] S600: performing skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, integrating and connecting the line segments based on the preliminary line segment information to obtain vertical and horizontal line segment sets and final line segment information respectively;
[0079] It should be noted that the skeleton thinning algorithm, also known as image skeleton extraction or character thinning, is an image processing technology that is mainly used to simplify the target outline in a binary image to its basic center line or skeleton structure, thereby reducing the number of pixels required to represent the image while maintaining its basic shape characteristics. Currently, there are mainly: Zhang-Suen algorithm, Pavlidis algorithm and Laplace shrinkage algorithm, all of which are applicable to this solution.
[0080] In an practicable manner, skeleton recognition is performed on the second image by using a skeleton refinement algorithm to obtain preliminary line segment information, including:
[0081] The skeleton of horizontal and vertical line segments in the image is extracted through the skeleton thinning algorithm;
[0082] And traverse the image according to the obtained skeleton depth to obtain line segment information;
[0083] The traversal includes: finding any black pixel point, and judging the four pixels to the left, right or top and bottom of the black pixel point;
[0084] If it is in the unvisited state, mark it as visited and determine whether it is a black pixel. If so, add its coordinates to the queue to be traversed;
[0085] Loop and record all the traversed black pixel sets to obtain the line segments with the minimum horizontal coordinate and the maximum horizontal coordinate connected to the black pixel and their preliminary line segment information;
[0086] If the left and right sides of the black pixel are judged, a horizontal line segment is obtained, and a horizontal line segment set is obtained after traversal;
[0087] If the up and down positions of the black pixel are judged, a vertical line segment is obtained, and a set of vertical line segments is obtained after traversal.
[0088] It should be noted that the line segment information includes the coordinates of the starting endpoint and the ending endpoint of the line segment.
[0089] It should also be noted that the initial horizontal (or vertical) line segment set obtained based on the above operation is usually rough, and a connecting line may be identified as multiple trivial short line segments, which are not directly usable. In order to obtain the final line segment set, the above obtained line segment set needs to be processed, that is, the following operations:
[0090] In an implementable manner, the line segments are integrated and connected in combination with the preliminary line segment information to obtain the vertical and horizontal line segment sets and the final line segment information, respectively, including:
[0091] Determine and connect the line segments in the horizontal line segment set;
[0092] Determine and connect the line segments in the vertical line segment set;
[0093] Determine whether any two parallel line segments in the connection pair set are connected. If the vertical distance between the two is less than a preset value and they intersect in the horizontal direction, then connect the two to obtain a long line segment and obtain its final line segment information.
[0094] Specifically, the preset value may be 10 pixel values or 15 pixel values.
[0095] After looping and judging the connection, the vertical line segment set, the horizontal line segment set and the corresponding final line segment information are obtained respectively.
[0096] S700: Screen the line segments in the vertical and horizontal line segment sets to obtain a busbar candidate set, and obtain the number of connections around each line segment in the busbar candidate set, determine the busbar based on the number of connections, and connect with the busbar as the starting point to obtain the topological relationship between the graphics elements.
[0097] In an implementable manner, the segments in the vertical and horizontal segment sets are screened to obtain a busbar candidate set, including:
[0098] According to the final line segment information, the horizontal or vertical line segment is screened by the length threshold, and if the line segment length is greater than the first threshold, the line segment is added to the bus candidate set;
[0099] Specifically, the first threshold may be 2 / 3 of the length of the longest line segment among all line segments.
[0100] Obtain the number of connections around each line segment in the busbar candidate set, and determine the busbar based on the number of connections, including:
[0101] For the busbar in the candidate set, it is determined whether the number of all connecting lines within the second threshold range around it is greater than the third threshold. If it is greater than the third threshold, the line segment is determined to be a busbar, otherwise it is an ordinary connecting line.
[0102] Specifically, the second threshold may be 20 pixels or 25 pixels, and the third threshold may be 3 or 4.
[0103] In an practicable manner, the nodes are connected starting from the busbar to obtain the topological relationship between the elements, including:
[0104] Starting from the identified bus, the wiring around the bus is determined according to a fourth threshold, and the bus is connected to the wiring within a range less than the fourth threshold;
[0105] Specifically, the fourth threshold may be 15 pixel values or 20 pixel values.
[0106] Start from the wiring, and then continue to extend outward to determine whether the wiring is connected to the graphics element;
[0107] After cyclic judgment, the graphics elements are finally connected through wiring to obtain the topological relationship.
[0108] It should be noted that after all the graphics elements have been traversed, there may still be some connections that are not connected. It is necessary to traverse the connection lines again and determine whether the connection lines with unconnected endpoints should be connected to other connection lines based on the distance.
[0109] Specifically, the wiring rule of the plant station diagram is that one end point of a connection line can only match one graphic element, or match one or more connection lines.
[0110] It should also be noted that the electrical graphic element recognition file obtained by S200, the text recognition file obtained by S400, the line segment recognition file obtained by S600 and the association relationship information obtained by S700 are formatted and output to the G file according to the power system graphic description specification.
[0111] The above is a schematic scheme of a method for generating a wiring diagram from a CAD image in this embodiment. It should be noted that the technical scheme of the system for generating a wiring diagram from a CAD image and the technical scheme of the method for generating a wiring diagram from a CAD image above belong to the same concept, and the details of the technical scheme of the system for generating a wiring diagram from a CAD image in this embodiment that are not described in detail can all be referred to the description of the technical scheme of the method for generating a wiring diagram from a CAD image above.
[0112] In this embodiment, the system for generating a wiring diagram from a CAD image includes:
[0113] An acquisition module is used to acquire a CAD plant station image to be identified;
[0114] The first recognition module is used to perform graphic element recognition on the plant image through an electrical graphic element recognition model to obtain a graphic element annotation box; the electrical graphic element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added;
[0115] A first covering module, used for covering the primitives based on the primitive annotation frame to obtain a first image;
[0116] A second recognition module is used to perform text recognition on the first image through an electrical text recognition model to obtain a text annotation box;
[0117] A second covering module, used for covering the text based on the text annotation box to obtain a second image;
[0118] A third recognition module is used to perform skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, and integrate and connect the line segments based on the preliminary line segment information to obtain vertical and horizontal line segment sets and final line segment information respectively;
[0119] The filtering connection module is used to filter the line segments in the vertical and horizontal line segment sets to obtain the busbar candidate set, and obtain the number of connections around each line segment in the busbar candidate set, determine the busbar based on the number of connections, and connect with the busbar as the starting point to obtain the topological relationship between the graphics elements.
[0120] Furthermore, the third recognition module includes: a traversal judgment module, which is used to find any black pixel point and judge four pixel points in the left and right or upper and lower directions of the black pixel point;
[0121] The screening connection module includes: a first screening module, which is used to perform length threshold screening on horizontal or vertical line segments according to the final line segment information, and if the length of the line segment is greater than the first threshold, the line segment is added to the bus candidate set;
[0122] And, a first judgment module is used to judge whether the number of all connecting lines within the second threshold range around the busbar in the candidate set is greater than the third threshold, if it is greater than the third threshold, the line segment is judged to be a busbar, otherwise it is an ordinary connecting line.
[0123] This embodiment also provides a computing device suitable for generating wiring diagrams from CAD images, comprising: a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the method for generating wiring diagrams from CAD images as proposed in the above embodiment.
[0124] This embodiment further provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for generating a wiring diagram from a CAD image as proposed in the above embodiment is implemented.
[0125] The storage medium proposed in this embodiment and the method for realizing the generation of wiring diagrams from CAD images proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0126] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ReadOnly, Memory, ROM), random access memory (RandomAccess Memory, RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform the methods of various embodiments of the present invention.
[0127] Example 2
[0128] Referring to Table 1, based on the previous embodiment, this embodiment provides an application example of a method for generating a wiring diagram from a CAD image, which proves its beneficial effect compared with the existing method model.
[0129] 10,000 plant and station diagrams of similar complexity were digitized to facilitate the construction of a smart grid management system. 5,000 of them were processed using an automated technology solution and a traditional manual vectorization solution, and both solutions were tested and evaluated.
[0130] Table 1 Comparison of scheme parameters
[0131]
[0132] It can be seen that this solution has shown significant advantages in accuracy, efficiency, scalability and consistency. The accuracy of identifying the primitives in the CAD plant diagram based on artificial intelligence can reach about 90%, and the accuracy of text annotation can reach about 85%. At the same time, combined with the construction of the primitive topological relationship based on the busbar, the drawing model can be automated, which can effectively improve the efficiency of plant diagram drawing and maintenance, and has good promotion prospects. Although the initial investment may be high, in the long run, it can greatly reduce processing time and cost, improve data quality, and is more suitable for the power company's digital needs for large-scale and complex plant diagrams.
[0133] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for generating a wiring diagram from a CAD image, characterized in that: include: Obtain the CAD plant station image to be identified; Performing graphic element recognition on the plant station image through an electrical graphic element recognition model to obtain a graphic element annotation frame; The electrical graph element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added; Covering the primitives based on the primitive annotation frame to obtain a first image; Performing text recognition on the first image by using an electrical text recognition model to obtain a text annotation box; Covering the text based on the text annotation frame to obtain a second image; Performing skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, integrating and connecting line segments based on the preliminary line segment information to obtain vertical and horizontal line segment sets and final line segment information respectively; The line segments in the vertical and horizontal line segment sets are screened to obtain a busbar candidate set, and the number of connections around each line segment in the busbar candidate set is obtained. The busbar is determined based on the number of connections, and the topological relationship between the graphics elements is obtained by connecting with the busbar as the starting point.
2. The method for generating a wiring diagram from a CAD image as claimed in claim 1, wherein: The output of performing graphic element recognition on the plant station image through the electrical graphic element recognition model includes: a CAD image with the recognition graphic element annotation box and an electrical graphic element recognition result file; The recognition result file includes the coordinates of the lower left corner and the lower right corner of the recognized primitive annotation box and the primitive type; Performing text recognition on the first image through the electrical text recognition model to obtain a text annotation box includes: The electrical text recognition model is a text recognition model based on the PaddleOCR algorithm; The output is a CAD image with the recognized text annotation box marked and a text recognition result file. The recognition file content includes the coordinates of the upper left and lower right corners of the recognized text annotation box and the text content.
3. The method for generating a wiring diagram from a CAD image as claimed in claim 2, wherein: Performing skeleton recognition on the second image by using a skeleton refinement algorithm to obtain preliminary line segment information, including: The skeleton of horizontal and vertical line segments in the image is extracted through the skeleton thinning algorithm; And traverse the image according to the obtained skeleton depth to obtain line segment information; The traversal includes: finding any black pixel point, and judging four pixel points in the left and right directions or the upper and lower directions of the black pixel point; If it is in the unvisited state, mark it as visited and determine whether it is a black pixel. If so, add its coordinates to the queue to be traversed; Loop and record all the traversed black pixel sets to obtain the line segments with the minimum horizontal coordinate and the maximum horizontal coordinate connected to the black pixel and their preliminary line segment information; If the left and right sides of the black pixel are judged, a horizontal line segment is obtained, and a horizontal line segment set is obtained after traversal; If the upper and lower parts of the black pixel are judged, a vertical line segment is obtained, and a set of vertical line segments is obtained after traversal.
4. The method for generating a wiring diagram from a CAD image as claimed in claim 3, characterized in that: Integrating and connecting the line segments in combination with the preliminary line segment information to obtain vertical and horizontal line segment sets and final line segment information respectively, including: Determine and connect the line segments in the horizontal line segment set; Determine and connect the line segments in the vertical line segment set; The determination of connection is that for any two parallel line segments in the set, if the vertical distance between the two is less than a preset value and they intersect in the horizontal direction, the two are spliced to obtain a long line segment and obtain the final line segment information; After looping and judging the connection, the vertical line segment set, the horizontal line segment set and the corresponding final line segment information are obtained respectively.
5. The method for generating a wiring diagram from a CAD image as claimed in claim 4, characterized in that: The segments in the vertical and horizontal segment sets are screened to obtain a candidate set of busbars, including: According to the final line segment information, a length threshold screening is performed on the horizontal or vertical line segment, wherein if the length of the line segment is greater than a first threshold, the line segment is added to the bus candidate set; Obtaining the number of connections around each line segment in the bus candidate set, and determining the bus according to the number of connections, including: For the busbar in the candidate set, it is determined whether the number of all the connecting lines within the second threshold range around it is greater than the third threshold. If it is greater than the third threshold, the line segment is determined to be a busbar, otherwise it is an ordinary connecting line.
6. The method for generating a wiring diagram from a CAD image as claimed in claim 5, characterized in that: The topological relationship between the elements is obtained by connecting the busbar as the starting point, including: Starting from the identified bus, the wiring around the bus is determined according to a fourth threshold, and the bus is connected to the wiring within a range less than the fourth threshold; Start from the wiring, and then continue to extend outward to determine whether the wiring is connected to the graphics element; After cyclic judgment, the graphics elements are finally connected through wiring to obtain the topological relationship.
7. A system using the method of generating a wiring diagram from a CAD image as claimed in claim 1, characterized in that: include: An acquisition module is used to acquire a CAD plant station image to be identified; The first recognition module is used to perform graphic element recognition on the plant station image through an electrical graphic element recognition model to obtain a graphic element annotation box; the electrical graphic element recognition model is a YOLOV5 algorithm model with an SE-Net attention mechanism added; A first covering module, used for covering the primitives based on the primitive annotation frame to obtain a first image; A second recognition module, configured to perform text recognition on the first image through an electrical text recognition model to obtain a text annotation box; A second covering module, used for covering the text based on the text annotation frame to obtain a second image; A third recognition module is used to perform skeleton recognition on the second image by using a skeleton thinning algorithm to obtain preliminary line segment information, and integrate and connect the line segments in combination with the preliminary line segment information to obtain a vertical and horizontal line segment set and final line segment information respectively; The connection screening module is used to screen the line segments in the vertical and horizontal line segment sets to obtain a bus candidate set, and obtain the number of connections around each line segment in the bus candidate set, determine the bus based on the number of connections, and connect with the bus as the starting point to obtain the topological relationship between the graphics elements.
8. The system for generating a wiring diagram from a CAD image as claimed in claim 7, characterized in that: A traversal judgment module is used to find any black pixel point and judge the four pixels in the left and right or upper and lower directions of the black pixel point; A first screening module, configured to perform length threshold screening on horizontal or vertical line segments according to the final line segment information, wherein if the length of a line segment is greater than a first threshold, the line segment is added to a bus candidate set; The first judgment module is used to judge whether the number of all connecting lines within the second threshold range around the busbar in the candidate set is greater than the third threshold. If it is greater than the third threshold, the line segment is judged to be a busbar, otherwise it is an ordinary connecting line.
9. An electronic device, comprising: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the method for generating a wiring diagram from a CAD image as described in any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method for generating a wiring diagram from a CAD image as claimed in any one of claims 1 to 6.
