Vectorization method of secondary graph paper of power system

CN119540959BActive Publication Date: 2026-11-03YANGZHOU HAOCHEN POWER DESIGN CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411609258.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2026-11-03
Estimated Expiration
2044-11-12

AI Technical Summary

Technical Problem

Converting bitmap drawings to vector drawings in existing power systems is inefficient and cumbersome to do manually, making it difficult to achieve efficient automation.

Method used

The UNet image-text separation model is used to automatically separate text sub-images and line sub-images. OCR technology is used to recognize text, skeleton topology tracing and GCN are used to vectorize and repair lines, YOLO is used to detect components and replace them with standard primitives, and large images are processed by tiled image segmentation detection method.

Benefits of technology

It achieves efficient and automated vectorization of power system drawings, improves the accuracy and efficiency of drawing processing, reduces dependence on training datasets, and generates high-quality CAD documents suitable for secondary drawing processing of power systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540959B_ABST
    Figure CN119540959B_ABST
Patent Text Reader

Abstract

The application discloses a secondary graph paper vectorization method of a power system, and relates to the technical field of power systems. The method comprises the following steps: S1, UNet text and line separation, to obtain a text subgraph and a line subgraph; S2, performing OCR (optical character recognition) on the text subgraph; S3, performing vectorization, vector graph repair and beautification on the line subgraph; S4, detecting components by Yolo v5 (a classic monitoring network) and replacing them with standard graph elements; and S5, generating results. The application provides an efficient, accurate and intelligent solution for processing secondary graph papers of power systems, and helps to improve the quality and efficiency of graph paper vectorization work and promote the development of graph paper processing technology in the power field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system technology, and in particular to a method for vectorizing secondary drawings of power systems. Background Technology

[0002] In the power industry, blueprints are crucial for design and construction. Many early existing blueprints were in bitmap format, which suffers from distortion upon enlargement and is difficult to edit. With technological advancements, vector graphics have gained popularity due to their ability to be enlarged without distortion and their ease of editing. However, converting bitmap drawings to vector graphics typically requires significant manual work, resulting in low efficiency. Summary of the Invention

[0003] To address the above problems, this invention provides a method for vectorizing secondary drawings of power systems, solving the problem of low efficiency in traditional manual drawing.

[0004] The technical solution of this invention is: a method for vectorizing secondary drawings of power systems, comprising the following steps:

[0005] S1 and UNet image-text separation yields text sub-images and line sub-images;

[0006] S2. Perform OCR (Optical Character Recognition) on the text sub-image;

[0007] S3. Perform vectorization on the line sub-image and repair and beautify the vector image;

[0008] S4 and YOLO v5 (a classic monitoring network) detect components and replace them with standard primitives;

[0009] S5, Results Generation.

[0010] In this invention, S1, using the UNet network, the original image is input, and line sub-images + text sub-images are output. The UNet network is then used for training to obtain a general image-text separation model, including:

[0011] S1.1: Data preparation: Using existing CAD drawings, export three sub-images—original image, text, and line drawing—through an automated script;

[0012] S1.2: Using the original image obtained in S1.1 as input and the text sub-image and line sub-image as output, construct a UNet model with a single-channel input and two-channel output. Through training, obtain a general image-text separation model, specifically including:

[0013] 1) Convert the original image to grayscale, divide by 255, and normalize it to between 0 and 1;

[0014] 2) Using the original image as input, the encoder performs continuous convolutional pooling, doubling the number of channels each time, to obtain several intermediate features;

[0015] 3) Then decode, using a series of resize (image size adjustment) functions, halving the number of channels each time to obtain intermediate features;

[0016] 4) By using a span connection, the intermediate features at the same position between the encoder and decoder are fused and finally mapped to two channels (the two channels correspond to the line sub-image and the text sub-image respectively).

[0017] 5) Use text sub-images and line sub-images as standard output.

[0018] S2. Perform OCR recognition on the text sub-image:

[0019] The text detection model is applied to the text sub-image for detection, and then the text recognition model is applied to each detected rectangular area to obtain the position and content of the text.

[0020] Among them, the text detection model uses the PaddleOCR detection model, takes a text sub-image as input, and outputs the bounding rectangle hotspot of the text region;

[0021] The text recognition model, since it mainly targets printed fonts, uses text generation and enhancement techniques to generate a large number of various font samples and trains them.

[0022] In the application, the detection model inputs a text sub-image and outputs a rectangular region of text. The recognition model inputs a text image within the rectangular region and outputs the text content, thereby obtaining the position and content of the text.

[0023] S3. Perform vectorization on the line sub-image and repair and enhance the vector graphics:

[0024] Topological tracing is performed based on the skeleton to generate a graph. A polygon approximation method is used to obtain a line segment vector map. Edges are classified using a GCN (Graph Neural Network), and coordinate averaging is performed on horizontal and vertical connected regions respectively. The bounds are then calculated to obtain complete line segments. This method stably achieves vector connectivity and orthogonality restoration. The specific steps are as follows:

[0025] S3.1 Image to Graph

[0026] S3.11. Perform image binarization on the line sub-image (convert the original image into a black and white binary image);

[0027] S3.12. Image thinning to obtain a skeleton image with only single lines (image skeleton algorithm, which makes the image content into single lines);

[0028] S3.13. Perform a 3x3 convolution on the foreground points on the skeleton map, with the center of the convolution kernel being 0 and the surrounding area being 1;

[0029] S3.14. Find all endpoints and nodes, and perform floodfill (flood fill algorithm, which fills a connected region by pushing onto the stack) tracing.

[0030] S3.15. Create a graph. Due to pixel tracing, the path is pixel-dense. A polygon simplification algorithm is needed to simplify the dense points of the tracing to obtain the graph form of the skeleton image.

[0031] S3.2 Vector Graphics Enhancement

[0032] Since the graph obtained using the above method is derived from an image and undergoes polygon simplification algorithms, the orthogonality of lines cannot be guaranteed, and imperfections are inevitable at the corners of broken lines. Therefore, the graph needs to be beautified, specifically as follows:

[0033] S3.21. Graph Edge Classification: Since the vast majority of elements in a quadratic graph are horizontal or vertical, with only a small number of components or connections being diagonal lines, all paths in the graph can be classified into four categories: horizontal lines, vertical lines, diagonal lines, and noise.

[0034] Horizontal lines: horizontal lines;

[0035] Vertical lines: lines that run vertically;

[0036] Diagonal line: diagonal line;

[0037] Noise: Error segments introduced by the polygon simplification algorithm.

[0038] S3.22. Connectivity Subgraph Partitioning: Based on S3.21, the graph is divided into several subgraphs according to the following principles:

[0039] Interconnected graphs that are all horizontally aligned form a subgraph;

[0040] Interconnected and all arranged vertically, they form a single character image;

[0041] When extracting noise laterally, it is treated as lateral noise; when extracting noise vertically, it is treated as longitudinal noise.

[0042] S3.23 Orthogonal Repair: Based on the partitioning results of S3.22, for horizontally connected node sets, adjust the y-coordinate values ​​of the nodes to be consistent so that they are on the same horizontal line; for vertically connected node sets, adjust the x-coordinate values ​​of the nodes to be consistent so that they are on the same vertical line.

[0043] a. When calculating coordinates, the path should be used as the reference, not the node. This means that when calculating coordinates, the path information between nodes should be considered, rather than the coordinates of a single node.

[0044] b. The coordinates of a path are represented by the vector average of its two endpoints. That is, the coordinates of each path are represented by the average of the coordinates of its two endpoints (x1, y1) and (x2, y2). The average coordinates are...

[0045] c. The weight of Path is defined as the magnitude of the vector difference between the two endpoints, i.e., the length of the line segment, and can be expressed as: The longer the path, the greater the weight;

[0046] d. Calculate a set of uniform coordinates X or Y for a set of horizontal or vertical connecting paths using a weighted average method. That is, multiply the average coordinate of each path by its weight (path length), add them together, and finally divide by the total weight.

[0047] e. Verify whether the coordinates of the horizontal and vertical connected nodes meet the orthogonality requirements, and output the coordinates of the path nodes after orthogonal repair.

[0048] S4 and YOLO detect components and replace them with standard primitives:

[0049] S4.1. Use a YOLO network to detect components in the original image. For each detected component, draw a bounding box to indicate its position in the image. Replace the bounding boxes with pre-defined standard primitives to standardize them. This detection is performed on the line sub-image.

[0050] Optimization of drawing preprocessing and postprocessing during component testing:

[0051] Since components are all line elements with strict drawing ratios, traditional image preprocessing methods, such as direct scaling, are not suitable. For texture information and large blocks of color information, such as pedestrian detection and vehicle detection, the image is directly scaled to the input size of the YOLO model, such as 480x480 or 720x720. However, for drawings, the size of a single image is usually over 3000 pixels, or even reaches 8000 pixels. Direct scaling will lead to: line distortion, or even complete disappearance, and component deformation.

[0052] Therefore, a tiled image segmentation detection method is used here to process large images. The method flow is as follows:

[0053] a. Divide the original image into tiles of a specific size, such as 720*720, and ensure that there is at least 50 pixels of overlap between the tiles to prevent the target from being cut off at the tile boundaries.

[0054] b. Use the YOLO network to detect targets in each tile, and merge the original YOLO detection results; the YOLO detection output for each tile is a series of rectangles, along with information such as category encoding and confidence level.

[0055] c. Merge all tiles and restore the coordinates of the detected rectangles from the tile coordinate system to the original large image coordinate system; then find the best box (the best rectangle in the detected target) and other nearby best boxes based on the confidence score; by calculating the intersection-union ratio of all rectangles, merge the overlapping rectangles using the non-maximum suppression (NMS) algorithm, and similarly use the confidence score to find the best rectangle in the overlapping area to detect the target.

[0056] S4.2. Component recovery using graphical primitives: Since the line relationships of components are more complex and difficult to repair than ordinary connections, pre-made vector graphical primitives are used to replace the detected components. Specifically, this includes:

[0057] S4.21. Use CAD design tools to save all types of components as independent DXF unit files;

[0058] S4.22. Based on the YOLO detection results, fill the corresponding primitives from the independently stored DXF primitive files in S4.21 into the rectangle of the YOLO detection results.

[0059] The graphic element designed in this invention is a fixed image, but how to place it in the corresponding position requires adaptation of position, size, orientation, and fine-tuning of connection points. To address these issues, the following method is adopted:

[0060] S4.221. When creating graphic elements, operate within a unit range, that is, all vector graphics are limited to a unit square of 0-1, so as to calculate the scaling ratio later and ensure the scalability and versatility of the graphic elements.

[0061] S4.222. The graphic elements are divided into three layers: point, line, and surface. The point layer marks the connection points to ensure accurate alignment during placement. The line layer draws the lines of the components to ensure the basic shape and structure of the graphic elements. The surface layer marks the filled surface and draws an erase area (the background lines in the original image are erased if they fall into the erase area, which can effectively prevent line contamination).

[0062] S4.223. Calculate the scaling and translation factors based on the position and size of the rectangle:

[0063] In the horizontal direction, when the size of the graphic element within the unit square is W unit ×H unit The detected rectangle has a size of W. rect ×H rect Then its scaling factor is

[0064]

[0065] Among them, S x S represents the scaling factor of the primitive in the horizontal direction. y This represents the scaling factor of the graphic element in the vertical direction;

[0066] The translation factor is the distance a primitive needs to be moved to place it in the correct position within the detected bounding box. Assume the top-left corner coordinates of the detected bounding box are (X... rect ,Y rect The translation factor is calculated as follows:

[0067] T x =X rect

[0068] T y =Y rect

[0069] Among them, T x T represents the distance the graphic element needs to move horizontally, i.e., the x-coordinate of the top-left corner of the rectangle; y This represents the distance the graphic element needs to move vertically, i.e., the ordinate of the top-left corner of the rectangle;

[0070] S4.224. Calculate the number and position of the intersection points of the rectangle and the background lines on the four sides (top, bottom, left, and right).

[0071] S4.225. Based on the location of the connection point of the graphic element, and the location of the intersection point of the rectangle and the background line, perform precise direction and position matching;

[0072] S4.226. Insert the graphic element as a block element in CAD into the corresponding position on the drawing.

[0073] S5. Results Generation:

[0074] The above OCR results, vector graphics results, and component inspection results are merged and written into dxf to form the final CAD document;

[0075] The generated results are saved as DXF files, divided into three layers: text, vector graphics, and component diagrams, and can be viewed using CAD software.

[0076] The beneficial effects of this invention are as follows: A text-image separation model trained based on the Unet network avoids the tedious and error-prone process of manually exporting images and extracting backgrounds, thus improving efficiency and accuracy. OCR recognition is performed on text sub-images, and PaddleOCR can quickly and automatically acquire text positions and content, providing good support for Chinese characters and demonstrating high efficiency and stability. In line sub-image processing, multiple technologies such as skeleton topology tracing, polygon approximation, and GCN are used to acquire line connection information and restore and beautify vector graphics, ensuring vector connectivity and orthogonality. Combining multiple algorithms leverages their respective advantages to make data processing more accurate and efficient. YOLO is used to detect components and replace them with standard primitives. The tile-based image segmentation detection method solves the problems of line distortion and component deformation in large image processing, reducing dependence on the training dataset and improving recognition accuracy and stability. Primitive design achieves precise placement through layering and calculating scaling and translation factors. The final generated CAD document is saved as a DXF file with multiple layers, which can be easily viewed with CAD software. This provides an efficient, accurate, and intelligent solution for secondary drawing processing in power systems, helping to improve the quality and efficiency of drawing vectorization and promoting the development of drawing processing technology in the power field. Attached Figure Description

[0077] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In the drawings, the parts are not necessarily drawn to scale.

[0078] Figure 1 This is a schematic diagram showing the separation of the original drawing, line sub-drawing, and text sub-drawing of the present invention;

[0079] Figure 2 This is a schematic diagram of the UNet image-text separation structure of the present invention;

[0080] Figure 3 This is a schematic diagram of the OCR text detection and recognition of the present invention;

[0081] Figure 4 The detection results of isolated points, loops, and breakpoints implemented using connected domains in this invention;

[0082] Figure 5 This is a schematic diagram illustrating the vectorization of drawing lines and the enhancement of vector graphics in this invention;

[0083] Figure 6 This is a schematic diagram of the YOLO detection component of the present invention;

[0084] Figure 7 This is a schematic diagram of the pre-fabricated vector graphics of the present invention;

[0085] Figure 8This is an overall block diagram of the secondary drawing generation vectorized CAD file of the present invention. Detailed Implementation

[0086] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0087] In the description of this invention, it should be understood that the terms "upper," "lower," "left," "right," "vertical," and "horizontal," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0088] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0089] refer to Figures 1-8 This invention provides a method for vectorizing secondary drawings of power systems, comprising the following steps:

[0090] S1 and UNet image-text separation yields text sub-images and line sub-images;

[0091] S2. Perform OCR (Optical Character Recognition) on the text sub-image;

[0092] S3. Perform vectorization on the line sub-image and repair and beautify the vector image;

[0093] S4 and YOLO v5 (a classic monitoring network) detect components and replace them with standard primitives;

[0094] S5, Results Generation.

[0095] Step S1: Use the UNet network to separate the text and image, resulting in a text sub-image and a line segment sub-image. Separating the text and lines in the drawing facilitates subsequent processing. The text becomes simpler in the text sub-image, eliminating interference from lines. Component detection and connection relationship detection also become clearer in the line sub-image.

[0096] Using existing CAD drawings, an automated script is used to export three sub-images: the original image, text, and lines. Then, UNet is used for training to obtain a general-purpose image-text separation model.

[0097] (1) Data preparation: Using existing CAD drawings, an automated script is used to export three sub-images: the original image, text, and lines. This invention uses pyautocad to filter out the text portion of the original document, obtaining clean text and line sub-images, which are then exported as bitmaps, resulting in three images: the original image, the text sub-image, and the line sub-image. Using the original image as input, two sub-images, the text sub-image and the line sub-image, are output separately. This method allows for the rapid acquisition of a large number of samples from existing data without the need for manual annotation.

[0098] PyAutocad (a Python extension package for AutoCAD used for automation) is a Python library for interacting with AutoCAD. It allows developers to control AutoCAD via Python scripts, performing various operations such as creating, modifying, and exporting drawings. PyAutocad communicates with AutoCAD through a COM (Windows Components) interface, therefore it is primarily designed for AutoCAD on the Windows platform.

[0099] (2) Using the original image obtained in (1) as input and the text sub-image and line sub-image as output, construct a UNet model with a single-channel input and two-channel output. Through training, obtain a general image-text separation model. Specifically, it includes:

[0100] 1) Convert the original image to grayscale, divide by 255, and normalize it to between 0 and 1;

[0101] 2) Using the original image as input, the encoder performs continuous convolutional pooling, doubling the number of channels each time, to obtain several intermediate features;

[0102] 3) Then decode, using a series of resize (image size adjustment) functions, halving the number of channels each time to obtain intermediate features;

[0103] 4) By using a span connection, the intermediate features at the same position between the encoder and decoder are fused and finally mapped to two channels (the two channels correspond to the line sub-image and the text sub-image respectively).

[0104] 5) Use text sub-images and line sub-images as standard output.

[0105] This invention uses pyautocad to write automated scripts that can quickly obtain training datasets from existing drawings without manual labeling. Furthermore, leveraging the robustness of Unet, it trains a model capable of automatically separating text and images (i.e., decomposing the original image into line sub-images and text sub-images).

[0106] Without pyautocad, you would need to manually export the CAD drawing as an image, and then use drawing tools to cut out the lines and text, which is time-consuming, laborious, and prone to errors. UNet is suitable for graph-to-graph learning and can train a general-purpose model based on the dataset.

[0107] The image-text separation method in this invention (decomposing the original image into line sub-images and text sub-images) greatly simplifies subsequent processing such as text detection and recognition, component detection, and schematic connection relationships. Text detection and recognition are clearly shown on the text sub-images; while component and schematic connection relationships are clearly shown on the line sub-images. This reduces the reliance on datasets for subsequent text and component detection.

[0108] Step S2: Perform OCR recognition on the text sub-image: Input the drawing into the text-image separation model to obtain the text sub-image, and use OCR technology to detect and recognize the text on the text sub-image.

[0109] The text detection model is used to detect text on the text sub-image, and then the text recognition model is used on each detected rectangular area to obtain the position and content of the text.

[0110] The text detection model uses PaddleOCR (PaddleOCR is an open-source OCR framework from Baidu, a conventional and mature model that can be used directly). It takes a text sub-image as input and outputs the bounding rectangle hotspot of the text region. The text recognition model, since the recognition is mainly for printed fonts, uses text generation and enhancement techniques to generate a large number of various font samples and trains them (PaddleOCR's built-in model is very mature and can be used directly).

[0111] In the application, the detection model inputs a text sub-image and outputs a rectangular region of text. The recognition model inputs a text image within the rectangular region and outputs the text content, thereby obtaining the position and content of the text.

[0112] OCR technology can be used to quickly and automatically obtain the position and content of text in images. PaddleOCr, as an open-source OCR framework from Baidu, has good support for Chinese characters and is highly efficient and stable.

[0113] Step S3: Vectorization and restoration / enhancement of vector graphics on line sub-graphs: In power drawings, especially terminal block diagrams and schematic diagrams, the connection relationships of lines are very important information. The following steps involve obtaining the connection relationship information of lines on the line sub-graphs output by the text-image separation model.

[0114] Topological tracing is performed based on the skeleton to generate a graph. A polygon approximation method is used to obtain a line segment vector map. Edges are classified using a GCN (Graph Neural Network), and coordinate averaging is performed on horizontal and vertical connected regions respectively. The bound is then calculated to obtain complete line segments. This method can stably achieve vector connectivity and orthogonality restoration.

[0115] S3.1 Image to Graph

[0116] S3.11. Perform image binarization on the line sub-image (convert the original image into a black and white binary image);

[0117] S3.12. Image thinning to obtain a skeleton image with only single lines (image skeleton algorithm, which makes the image content into single lines);

[0118] S3.13. Perform a 3x3 convolution on the foreground points on the skeleton map, with the center of the convolution kernel being 0 and the surrounding area being 1;

[0119] Among them, a point with no neighbors is an isolated point, a point with one neighbor is an endpoint, a point with two neighbors is a path, and a point with three or more neighbors is a node.

[0120] S3.14. Find all endpoints and nodes, and perform floodfill (flood fill algorithm, which fills a connected region by pushing onto the stack) tracing.

[0121] In this context, isolated points are ignored, all nodes and endpoints are treated as nodes (node ​​elements in the graph), and paths are treated as edges (edge ​​elements in the graph).

[0122] S3.15, Creating a graph

[0123] Because pixel tracing results in a densely packed path, a polygon simplification algorithm is needed to simplify the densely packed points. For example, an original horizontal broken line consists of many points; ideally, only the endpoints and corners remain after simplification, making the representation simpler. The final skeleton image is in graph form.

[0124] S3.2 Vector Graphics Enhancement

[0125] Since the graph obtained in the above method is derived from an image and undergoes polygon simplification algorithms, the orthogonality of the lines cannot be guaranteed, and imperfections are inevitable at the corners of polylines. Therefore, the graph needs to be beautified.

[0126] S3.21. Graph edge classification: Since the vast majority of elements in a quadratic graph are horizontal or vertical, and a small number of components or connections are diagonal lines, all paths in a graph can be classified into four categories: horizontal lines, vertical lines, diagonal lines, and noise.

[0127] Horizontal lines: horizontal lines;

[0128] Vertical lines: lines that run vertically;

[0129] Diagonal line: diagonal line;

[0130] Noise: Error segments introduced by the polygon simplification algorithm.

[0131] S3.22. Connectivity Subgraph Partitioning: Based on S3.21, the graph is divided into several subgraphs according to the following principles:

[0132] a. Graphs that are interconnected and all horizontally aligned form a subgraph;

[0133] b. Interconnected and all vertically aligned, forming a single character image;

[0134] c. When extracting noise horizontally, it is treated as horizontal noise; when extracting noise vertically, it is treated as vertical noise.

[0135] S3.23 Orthogonal Repair: Based on the partitioning results of S3.22, for horizontally connected node sets, adjust the y-coordinate values ​​of the nodes to be consistent so that they are on the same horizontal line; for vertically connected node sets, adjust the x-coordinate values ​​of the nodes to be consistent so that they are on the same vertical line.

[0136] a. When calculating coordinates, the path should be used as the reference, not the node. This means that when calculating coordinates, the path information between nodes should be considered, rather than the coordinates of a single node.

[0137] b. The coordinates of a path are represented by the vector average of its two endpoints. That is, the coordinates of each path are represented by the average of the coordinates of its two endpoints (x1, y1) and (x2, y2). The average coordinates are...

[0138] c. The weight of Path is defined as the magnitude of the vector difference between the two endpoints, i.e., the length of the line segment, and can be expressed as: The longer the path, the greater the weight;

[0139] d. Calculate a set of uniform coordinates X or Y for a set of horizontal or vertical connecting paths using a weighted average method. That is, multiply the average coordinate of each path by its weight (path length), add them together, and finally divide by the total weight.

[0140] e. Verify whether the coordinates of the horizontal and vertical connected nodes meet the orthogonality requirements, and output the coordinates of the path nodes after orthogonal repair.

[0141] The above method combines traditional image processing methods with computational geometry, graph theory, and graph convolution methods, fully leveraging the advantages of each approach. The image processing algorithm converts the image into a graph, uses computational geometry algorithms to simplify edges, making the data concise and clear. It then utilizes the robustness of graph convolutional networks (GCNs) to classify edges. Finally, graph theory algorithms are used to perform region-by-region restoration on the vector data.

[0142] Step S4: YOLO detects the components and replaces them with standard primitives.

[0143] S41. Use the YOLO network to detect components in the original image. For each detected component, draw a bounding box to indicate its position in the image. Replace the bounding boxes with pre-defined standard primitives to standardize them. This detection is performed on the line sub-image.

[0144] In the process of component inspection, drawing preprocessing and post-processing optimization are crucial. Since components are all line elements with strict drawing ratios, traditional image preprocessing methods, such as direct scaling, are not suitable. For texture information and large blocks of color information, such as pedestrian detection and vehicle detection, the image is directly scaled to the input size of the YOLO model, such as 480x480 or 720x720. However, for drawings, the size of a single image is usually over 3000 pixels, or even reaches 8000 pixels. Direct scaling will lead to: line distortion or even complete disappearance, and component deformation.

[0145] Therefore, a tiled image segmentation detection method is used to process large images. The method flow is as follows:

[0146] a. Divide the original image into tiles of a specific size, such as 720*720, and ensure that there is at least 50 pixels of overlap between the tiles to prevent the target from being cut off at the tile boundaries.

[0147] b. Use the YOLO network to detect targets in each tile, and merge the original YOLO detection results; the YOLO detection output for each tile is a series of rectangles, along with information such as category encoding and confidence level.

[0148] c. Merge all tiles and restore the coordinates of the detected rectangles from the tile coordinate system to the original large image coordinate system; then, find the bestbox (the best bounding box among the detected targets) and other nearby bestboxes based on the confidence score; by calculating the intersection-union ratio of all rectangles, merge overlapping rectangles using the non-maximum suppression (NMS) algorithm, and similarly use the confidence score to find the best bounding box of the detected targets within the overlapping area. This process ensures accurate detection and labeling even at tile boundaries, effectively processing large images.

[0149] This invention performs YOLO detection on line subimages, resulting in cleaner images free from text interference. It also significantly reduces reliance on the training dataset and greatly improves recognition accuracy and stability.

[0150] Using slicing instead of image scaling, and then fusing the slice information into the original coordinate system before performing bestbox filtering, avoids the loss and proportional distortion of line images caused by image scaling.

[0151] S42. Components are restored using graphic elements. Since the line relationships of components are more complex than ordinary connections, they are more difficult to repair. Therefore, pre-made vector graphics elements are used to replace the detected components.

[0152] S4.21. Use CAD design tools to save all types of components as independent DXF unit files;

[0153] S4.22. Based on the YOLO detection results, fill the corresponding primitives from the independently stored DXF primitive files in step 1) into the rectangle of the YOLO detection results.

[0154] The graphic element designed in this invention is a fixed image, but how to place it in the corresponding position requires adaptation of position, size, orientation, and fine-tuning of connection points. The position and size can be calculated based on the rectangular frame of the component detection. However, for a component, such as a resistor, it is necessary to ensure that after replacing the graphic element, it can be placed horizontally or vertically according to the original image, and that the connection points on both sides of the resistor are aligned with the background wires after placement.

[0155] To address the above issues, the following methods can be adopted:

[0156] S4.221. When creating graphic elements, operate within a unit range, that is, all vector graphics are limited to a unit square of 0-1, so as to calculate the scaling ratio later and ensure the scalability and versatility of the graphic elements.

[0157] S4.222. The graphic elements are divided into three layers: points, lines, and surfaces. The point layer marks the connection points to ensure accurate alignment during placement. The line layer draws the lines of the components to ensure the basic shape and structure of the graphic elements. The surface layer marks the filled surfaces and draws an erase area (the background lines in the original image are erased if they fall into the erase area, which can effectively prevent line contamination).

[0158] S4.223. Calculate the scaling and translation factors based on the position and size of the rectangle.

[0159] In the horizontal direction, when the size of the graphic element within the unit square is W unit ×H unit The detected rectangle has a size of W. rect ×H rect Then its scaling factor is:

[0160]

[0161] Among them, S x S represents the scaling factor of the primitive in the horizontal direction. y This represents the scaling factor of the graphic element in the vertical direction;

[0162] The translation factor is the distance a primitive needs to be moved to place it in the correct position within the detected bounding box. Assume the top-left corner coordinates of the detected bounding box are (X... rect ,Y rect The translation factor is calculated as follows:

[0163] T x =X rect

[0164] T y =Y rect

[0165] Among them, T x T represents the distance the graphic element needs to move horizontally, i.e., the x-coordinate of the top-left corner of the rectangle; y This represents the distance the graphic element needs to move vertically, i.e., the ordinate of the top-left corner of the rectangle;

[0166] S4.224. Calculate the number and position of the intersection points of the rectangle and the background lines on the four sides (top, bottom, left, and right).

[0167] S4.225. Based on the location of the connection point of the graphic element, and the location of the intersection point of the rectangle and the background line, perform precise direction and position matching;

[0168] S4.226. Insert the graphic element as a block element in CAD into the corresponding position on the drawing.

[0169] This completes the converted CAD drawing.

[0170] Step 5: Result Generation

[0171] The OCR results, vector graphics results, and component inspection results are combined and written into dxf to form the final CAD document.

[0172] The generated results are saved as DXF files, divided into three layers: text, vector graphics, and component diagrams, and can be viewed using CAD software.

[0173] Regarding the information disclosed in this case, the following points need to be clarified:

[0174] (1) The accompanying drawings of the embodiments disclosed in this case only involve the structures involved in the embodiments disclosed in this case. Other structures can be referred to the general design.

[0175] (2) Where there is no conflict, the embodiments and features disclosed in this case can be combined with each other to obtain new embodiments;

[0176] The above are merely specific embodiments disclosed in this case, but the scope of protection of this disclosure is not limited thereto. The scope of protection disclosed in this case shall be determined by the scope of protection of the claims.

Claims

1. A method for vectorizing secondary drawings of power systems, characterized in that, Includes the following steps: S1 and UNet separate text and image data to obtain text sub-images and line sub-images; S2. Perform OCR on the text sub-image; S3. Perform vectorization on the line sub-image and repair and beautify the vector image; S4 and YOLO v5 detect components and replace them with standard primitives; S5. Results Generation; Step S1 includes: S1.1: Data preparation: Using existing CAD drawings, export three sub-images—original image, text, and line drawing—through an automated script; S1.2: Using the original image obtained in S1.1 as input and the text sub-image and line sub-image as output, construct a UNet model with a single-channel input and two-channel output. Through training, obtain a general image-text separation model, specifically including: 1) Convert the original image to grayscale, divide by 255, and normalize it to between 0 and 1; 2) Using the original image as input, the encoder performs continuous convolutional pooling, doubling the number of channels each time, to obtain several intermediate features; 3) Then perform decoding, using a series of resize functions to halve the number of channels each time to obtain intermediate features; 4) By using a span connection, the intermediate features at the same position between the encoder and decoder are fused and finally mapped to two channels, which correspond to the line sub-image and the text sub-image, respectively. 5) Use text and line sub-images as standard output; Step S3 includes: S3.1 Image to graph S3.

11. Perform image binarization on the line sub-image; S3.

12. Image thinning to obtain a skeleton diagram with only single lines; S3.

13. Perform a 3x3 convolution on the foreground points on the skeleton map, with the center of the convolution kernel being 0 and the surrounding area being 1; S3.

14. Locate all endpoints and nodes, and perform floodfill tracing; S3.

15. Create a graph by using a polygon simplification algorithm to simplify the dense points being traced, resulting in a graph form of the skeleton image. S3.2 Vector Graphics Enhancement S3.21, Graph edge classification, which divides all paths of the graph into four categories: horizontal lines, vertical lines, diagonal lines, and noise; S3.

22. Connectivity Subgraph Partitioning: Based on S3.21, the graph is divided into several subgraphs according to the following principles: Interconnected graphs that are all horizontally aligned form a subgraph; Interconnected and all arranged vertically, they form a single character image; When extracting noise laterally, it is treated as lateral noise; when extracting noise vertically, it is treated as longitudinal noise. S3.23 Orthogonal Repair: Based on the partitioning results of S3.22, for horizontally connected node sets, adjust the y-coordinate values ​​of the nodes to be consistent so that they are on the same horizontal line; for vertically connected node sets, adjust the x-coordinate values ​​of the nodes to be consistent so that they are on the same vertical line. Step S4 includes: S4.

1. Use the YOLO network to detect the components in the original image. Draw a rectangle for each detected component to mark its position in the image. Replace the component rectangle with a pre-made standard primitive to standardize it. The image is processed using a tiled image segmentation detection method, and the process is as follows: a. Divide the original image into tiles of a preset size; b. Use the YOLO network to detect targets in each tile, and then merge the original YOLO output detection results; c. Merge all tiles and restore the coordinates of the detected rectangles from the tile coordinate system to the original large image coordinate system; then find the best box and other nearby best boxes based on the confidence score; by calculating the intersection-union ratio of all rectangles, merge overlapping rectangles using the non-maximum suppression algorithm, and similarly use the confidence score to find the best rectangle for detecting targets within the overlapping area. S4.

2. Restore components using graphic elements; replace detected components using pre-made vector graphic elements; specifically including: S4.

21. Use CAD design tools to save all types of components as independent DXF unit files; S4.

22. Based on the YOLO detection results, fill the corresponding primitives from the independently stored DXF primitive files in S4.21 into the rectangle of the YOLO detection results. When placing graphic elements, the following methods should be used: S4.

221. When creating graphic elements, operate within a unit range, and limit all vector graphics to a unit square of 0-1; S4.

222. The graphic elements are divided into three layers: point, line, and surface. The point layer marks the connection points; the line layer draws the lines of the components; and the surface layer marks the filled surfaces and draws an erase area. S4.

223. Calculate the scaling and translation factors based on the position and size of the rectangle: In the horizontal direction, when the size of the graphic element within the unit square is The size of the detected rectangle is Then its scaling factor is: Among them, S x S represents the scaling factor of the primitive in the horizontal direction. y This represents the scaling factor of the graphic element in the vertical direction; The translation factor is the distance the primitive needs to move. Assuming the top-left corner coordinates of the detected bounding box are... The translation factor is calculated as follows: Where Tx is the distance the graphic element needs to move in the horizontal direction; Ty is the distance the graphic element needs to move in the vertical direction. S4.

224. Calculate the number and position of the intersection points of the rectangle and the background lines on the four sides (top, bottom, left, and right). S4.

225. Based on the location of the connection point of the graphic element, and the location of the intersection point of the rectangle and the background line, perform precise direction and position matching; S4.

226. Insert the graphic element as a block element in CAD into the corresponding position on the drawing.

2. The method for vectorizing secondary drawings of a power system according to claim 1, characterized in that, In step S2, The text detection model is used to detect text on the text sub-image, and then the text recognition model is used on each detected rectangular area to obtain the position and content of the text.

3. The method for vectorizing secondary drawings of a power system according to claim 1, characterized in that, Step S5 includes: The above OCR results, vector graphics results, and component inspection results are merged and written into dxf to form the final CAD document; The generated results are saved as DXF files, divided into three layers: text, vector graphics, and component diagrams, and can be viewed using CAD software.

Citation Information

Patent Citations

  • Method for scanning and converting paper electric power engineering drawing into electronic edition CAD drawing

    CN114529936A

  • Electric power drawing detection and extraction method and system

    CN115359505A

  • Method and system for digitizing geological profile drawing

    CN118865429A