A method and system for identifying and extracting topology of a secondary circuit diagram
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-21
- Publication Date
- 2026-08-11
AI Technical Summary
现有的识别方案通常仅关注导线的整体几何轨迹,缺乏对交叉节点局部像素特征的专门判别逻辑,这导致系统容易将“跨越不连”的导线误认为物理连接,从而在后续数据中产生错误的连通关系
[0018]本发明通过引入置信度判定与标准符号模板库匹配的二次校验,对存在分类歧义的目标进行精准拦截与修正,有效滤除了深度学习的“幻觉”输出,大幅提升了底层图元识别的纯净度与准确率,为后续拓扑构建提供了高可靠的基础数据。引入“局部像素分布+连通域特征”的综合判定逻辑,通过在交叉点截取ROI区域计算黑色像素占比及连通域归属,精确区分了“有实体圆点的电气连接”与“半圆弧跨越不连”。 通过解析元件几何形态动态生成虚拟引脚,并依据当前图纸的实际DPI对连通阈值进行线性自适应缩放,使得系统能够兼容各种分辨率和质量的图纸,避免了因图像缩放导致的“断连”或“误连”。 引入了基于电气制图规范的方向约束,从几何逻辑层面模拟人工识图的“常识判断”,成功剔除违反制图方位的异常绑定关系,保证了最终输出的拓扑特征数据中“元件-编号”属性的一一对应。
Smart Images

Figure CN122551384A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of secondary circuit drawing recognition technology, and in particular to a method and system for primitive recognition and topology extraction of secondary circuit drawings. Background Technology
[0002] Electrical secondary circuit drawings contain a large number of relays, contacts, terminal blocks, and wires, and are core data for substation design and operation. Traditional manual data entry methods are inefficient. In recent years, the industry has begun to introduce image object detection technology based on deep learning to assist in extracting information from the drawings.
[0003] In practical engineering applications, directly applying general deep learning models to secondary circuit drawings still faces the following technical bottlenecks: On the one hand, existing deep learning models typically treat component symbols, wire segments, and text as independent detection targets, resulting in isolated sets of coordinates. Due to the lack of spatial association mechanisms for electrical drawing rules, after identifying discrete "component A" and "wire B", the system struggles to automatically deduce the physical connection relationship between the wire endpoints and specific component pins. Consequently, the identification results remain at the primitive detection level and cannot be directly converted into structured electrical topology network data that can be used by downstream systems.
[0004] On the other hand, secondary drawings contain a large number of symbols with highly similar shapes (such as normally open contacts and normally closed contacts). When the source file of the drawing is blurry, damaged, or has dense occlusion of graphic elements, relying solely on the semantic feature extraction of neural networks can easily lead to overlapping or ambiguity in the determination of similar symbols.
[0005] Furthermore, in complex drawing layouts, wires frequently intersect. According to electrical drawing standards, a solid dot at an intersection indicates an electrical connection, while the absence of a dot indicates a crossing without connection. Existing identification schemes typically focus only on the overall geometric trajectory of the wires, lacking dedicated logic for discriminating the local pixel features of intersection nodes. This leads the system to easily misinterpret "crossing without connection" wires as physically connected, resulting in incorrect connectivity relationships in subsequent data. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and system for primitive recognition and topology extraction of secondary circuit drawings, so as to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: A method for primitive recognition and topology extraction in a secondary circuit drawing includes the following steps: S1. Obtain the original secondary circuit drawing image, perform noise reduction, binarization and tilt correction preprocessing on the image, and output the standard image to be identified; S2. Input the standard image to be identified into a pre-trained lightweight convolutional neural network model, perform simultaneous target detection and instance segmentation on component symbols, wires, terminal blocks, and text regions in the drawing, and output the coordinate region, category label, instance mask, and classification confidence score corresponding to each target; and perform character recognition on the text region to output the corresponding text number content. S3. Determine whether there is classification ambiguity for the target based on the classification confidence score. If there is classification ambiguity, determine the coordinate region corresponding to the target with classification ambiguity as the ambiguous region, call the preset standard symbol template library to perform template matching verification on the ambiguous region, correct the target category label according to the template matching result, and output the confirmed primitive information. S4. Based on the confirmed primitive information, perform spatial topology association extraction, specifically including: Extract the vectorized endpoint coordinates of the conductor; When a spatial intersection of two wires is detected, the local pixel distribution features and connected region features within the intersection area are extracted, and the node type of the intersection is determined based on the local pixel distribution features and connected region features. Based on the preset virtual pin rules corresponding to the component symbol category, virtual pin coordinates are generated at the edge of the coordinate region of the component symbol; Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin. When the minimum Euclidean distance is less than the preset connectivity threshold, establish the physical connection between the wire and the corresponding component symbol. S5. Based on spatial proximity rules and directional constraint rules, bind the identified text number content with the corresponding component symbols and connection relationships to generate secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number" and output it.
[0008] Preferably, in step S1, for high-resolution drawing images, a fixed-size sliding window is used to segment the drawing image, and an overlap area of 10% to 30% is set between adjacent sliding windows; after preprocessing and recognition of the segmented sub-images, the recognition results are mapped and restored to global absolute coordinates based on the coordinate offset of each sub-image in the original drawing.
[0009] Preferably, the lightweight convolutional neural network model in S2 is an instance segmentation model that incorporates deformable convolution.
[0010] Preferably, the conditions for determining whether there is classification ambiguity in the target based on the classification confidence score in step S3 include: The highest classification confidence score corresponding to the target category falls within a preset low confidence range; or... The difference between the highest classification confidence score and the second highest classification confidence score corresponding to the target category is less than a preset difference threshold; When any condition is met, the target is determined to have classification ambiguity and template matching verification is triggered.
[0011] Preferably, the specific steps of the template matching verification include: Extract image blocks corresponding to ambiguous areas from the original drawing image; A normalized cross-correlation matching algorithm is used to perform sliding matching between the image patch and templates in the standard symbol template library at multiple scaling scales. The template category with the highest normalized cross-correlation similarity is used as the corrected category label.
[0012] Preferably, extracting the vectorized endpoint coordinates of the conductor in S4 includes: Morphological skeletonization is performed on the conductor instance mask to obtain the conductor centerline with a width of one pixel; The centerline of the conductor is vectorized using a multi-segment line fitting algorithm, and the coordinates of the starting and ending points of the vectorized polyline are extracted.
[0013] Preferably, in step S4, determining the type of intersecting nodes based on the local pixel distribution features and connected region features includes: Using the spatial intersection point of the two intersecting wires as the center, a circular region of interest with a preset radius is extracted; Calculate the percentage of black pixels and the number of connected regions within the region of interest; When the proportion of black pixels is greater than the first preset threshold and there is a central connected region, the intersection is determined to be an electrical connection node. When the proportion of black pixels is less than the second preset threshold and there is no central connected region, the intersection is determined to be an electrical crossing, and no connecting edge is generated in the topology data; Wherein, the first preset threshold is greater than the second preset threshold; When the proportion of black pixels is between the first preset threshold and the second preset threshold, the intersection point is marked as a suspected abnormal node and a warning message is output.
[0014] Preferably, step S4, which involves calculating the Euclidean distance between the vectorized endpoint coordinates of the conductor and the coordinates of each virtual pin and establishing the physical connection relationship, includes: Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin; When the minimum Euclidean distance is less than the preset connectivity threshold, it is determined that the corresponding wire endpoint and the corresponding virtual pin establish a physical connection relationship. The preset connectivity threshold is adaptively scaled according to the drawing resolution.
[0015] Preferably, in step S5, binding the identified text number content with the corresponding component symbol and connection relationship according to spatial proximity rules and directional constraint rules includes: Calculate the Euclidean distance between the center point of the text numbering area and the center point of each component symbol; Determine whether the text number area falls within the neighborhood formed by the outward expansion of the coordinate areas of each component symbol; Among the component symbols that satisfy the neighborhood range constraint, the component symbol that is closest in distance is selected as the target bound component symbol; In addition, by combining the positional characteristics of the text number area relative to the target bound element symbol, abnormal bindings that violate the preset cartographic orientation rules are eliminated; The text number content is bound to the attribute identifier of the target bound element symbol.
[0016] Another objective of this invention is to propose a system for primitive recognition and topology extraction of secondary loop drawings, used to implement the aforementioned method for primitive recognition and topology extraction of secondary loop drawings, comprising: The image preprocessing module is used to perform noise reduction, binarization, and tilt correction on the original secondary circuit drawing image, and output the standard image to be identified. The deep learning detection module is used to perform multi-target simultaneous detection and instance segmentation on the standard image to be identified based on the instance segmentation neural network model. It outputs coordinate regions, category labels, instance masks and classification confidence scores, and outputs text number recognition results. The template matching and verification module is used to determine classification ambiguity based on the classification confidence score, and when there is classification ambiguity, it calls the standard symbol template library to perform template matching and verification to correct the category label and output the confirmed primitive information. The spatial topology association module is used to perform topology extraction based on the confirmed primitive information. It includes the following components: The conductor vectorization unit is used to perform skeletonization and vectorization processing on the conductor instance mask and extract the coordinates of the vectorized endpoints of the conductor. The intersection determination unit is used to extract local pixel distribution features and connected region features in the intersection region of the conductor space, and determine the node type of the intersection based on the features; The pin generation unit is used to generate virtual pin coordinates at the edge of the coordinate area of the component symbol based on the preset virtual pin rules corresponding to the component symbol category. The endpoint connection unit is used to calculate the spatial distance between the wire endpoint and the coordinates of the virtual pin, and to establish a physical connection relationship based on a preset connectivity threshold. The structured output module is used to bind text number content with component symbols and connection relationships according to spatial proximity rules and directional constraint rules, and output secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number".
[0017] The present invention discloses a method and system for primitive recognition and topology extraction of secondary circuit drawings, which has the following beneficial effects.
[0018] This invention introduces a secondary verification process involving confidence level determination and matching with a standard symbol template library. This process accurately intercepts and corrects targets with classification ambiguities, effectively filtering out the "illusion" output of deep learning and significantly improving the purity and accuracy of underlying primitive recognition. This provides highly reliable foundational data for subsequent topology construction. A comprehensive judgment logic combining "local pixel distribution + connected component features" is introduced. By calculating the proportion of black pixels and the connected component affixation in the ROI region at intersection points, it accurately distinguishes between "electrical connections with physical dots" and "semi-circular arc crossings without connection." Virtual pins are dynamically generated by analyzing the geometric shape of components, and the connectivity threshold is linearly and adaptively scaled according to the actual DPI of the current drawing. This allows the system to be compatible with drawings of various resolutions and qualities, avoiding "disconnections" or "false connections" caused by image scaling. Directional constraints based on electrical drawing standards are introduced, simulating the "common sense judgment" of manual drawing interpretation from a geometric logic level. This successfully eliminates abnormal binding relationships that violate drawing orientation, ensuring a one-to-one correspondence between the "component-number" attribute in the final output topology feature data. Attached Figure Description
[0019] Figure 1 This is a flowchart of the method for primitive recognition and topology extraction of secondary circuit drawings according to the present invention.
[0020] Figure 2 This is a system architecture diagram for element recognition and topology extraction of secondary circuit drawings according to the present invention.
[0021] Figure 3 This is a schematic diagram of the high-resolution drawing sliding window slice and coordinate restoration of the present invention.
[0022] Figure 4 This is a schematic diagram illustrating the principle of conductor crossing node type determination (electrical connection and crossing) of the present invention.
[0023] Figure 5 This is a schematic diagram illustrating the virtual pin generation and endpoint connection distance calculation of the present invention.
[0024] Figure 6This is a schematic diagram illustrating the binding of spatial proximity and directional constraints for text numbering in this invention. Detailed Implementation
[0025] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0026] In the description of this invention, it should be understood that the terms "upper", "lower", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0027] Example 1
[0028] Please refer to Figure 1 A method for primitive recognition and topology extraction of secondary loop drawings, comprising the following steps: S1. Obtain the original secondary circuit drawing image, perform noise reduction, binarization and tilt correction preprocessing on the image, and output the standard image to be identified; Specifically, in this embodiment, after acquiring the original secondary circuit drawing image (e.g., a scanned PDF converted to TIFF format), the image is converted to grayscale, Gaussian filtering is applied, and the convolution kernel size is set. Standard deviation .
[0029] Use local adaptive threshold binarization (e.g., the adaptiveThreshold function in OpenCV) to set the block size. ,constant Output a black and white binary image (background value is 255, line value is 0).
[0030] The Hough line transform is used to detect straight lines on the edge of the drawing frame, and lines with angles between 85° and 95° are selected. Their average tilt angle is then calculated. A 2×3 affine transformation matrix is constructed for rotation correction, and the standard image to be recognized is output.
[0031] Preferably, in this embodiment, in step S1, for the high-resolution drawing image, a sliding window of fixed size is used to segment the drawing image, and an overlap area of 10% to 30% is set between adjacent sliding windows; after preprocessing and recognition of the segmented sub-images, the recognition results are mapped and restored to global absolute coordinates based on the coordinate offset of each sub-image in the original drawing.
[0032] For high-resolution drawings (e.g., A0 size, tens of thousands of pixels at 400 DPI), directly inputting them into a neural network can lead to memory overflow. This embodiment uses a fixed-size sliding window for segmentation, setting a fixed size for the sliding window. overlap rate Step size Pixels. After segmentation, record the first pixel. Offset of each subgraph The coordinates of any primitive detected within the subgraph. Its global absolute coordinates are restored as follows: Specifically, in combination Figure 3 The diagram shown illustrates a high-resolution drawing with a sliding window slice and coordinate reconstruction. The large image is divided into multiple grid regions by the sliding window. Overlapping areas are set between adjacent windows, indicated by diagonal lines in the diagram. The upper left corner is highlighted with a bold solid line, showing the currently processed sub-image. This sub-image contains a simulated recognition primitive, with its current local coordinates labeled next to it. The horizontal offset of the current sub-image relative to the starting point of the original large image is indicated by the dimension line with arrows at the bottom of the image. (i.e., stride) and vertical offset .
[0033] S2. Input the standard image to be identified into a pre-trained lightweight convolutional neural network model, and perform simultaneous target detection and instance segmentation on component symbols, wires, terminal blocks, and text regions in the drawing. Output the coordinate region, category label, instance mask, and classification confidence score corresponding to each target. Perform character recognition on the text region and output the corresponding text number content. Preferably, in this embodiment, the lightweight convolutional neural network model in S2 is an instance segmentation model that incorporates deformable convolution.
[0034] Specifically, in this embodiment, a lightweight object detection and instance segmentation network model incorporating deformable convolution (DCNv3) is used (e.g., the YOLOv8-seg model incorporating this operator). The model outputs four categories of objects: 0-component symbols, 1-wires, 2-terminal blocks, and 3-text regions. For each object, a bounding box is output. Category label C, confidence score S, and model input size The binary instance mask M is then used. Mask M is inversely scaled (upsampled) to the current subimage size (1024×1024). This is done for the category labels. The text region is cropped from the current 1024×1024 sub-image based on its inverted bounding box. If the image block height is less than 15 pixels, a 3-pixel black border is added at the top and bottom to meet OCR input requirements. The image block is then fed into a preset optical character recognition (OCR) model (such as the PaddleOCR model) for text extraction, outputting the text string content "Text".
[0035] S3. Determine whether there is classification ambiguity for the target based on the classification confidence score. If there is classification ambiguity, determine the coordinate region corresponding to the target with classification ambiguity as the ambiguous region, call the preset standard symbol template library to perform template matching verification on the ambiguous region, correct the target category label according to the template matching result, and output the confirmed primitive information. It should be noted that since the normally open and normally closed contacts in the secondary drawings differ by only one diagonal line, pure deep learning is prone to ambiguity. Therefore, this embodiment sets dual triggering conditions based on the classification confidence score.
[0036] Preferably, in this embodiment, the conditions for determining whether there is classification ambiguity in the target based on the classification confidence score in S3 include: The highest classification confidence score corresponding to the target category falls within a preset low confidence range; or... The difference between the highest classification confidence score and the second highest classification confidence score corresponding to the target category is less than a preset difference threshold; When any condition is met, the target is determined to have classification ambiguity and template matching verification is triggered.
[0037] Specifically, in this embodiment, the category label is... Component symbols perform ambiguity determination: Obtain the top-2 categories and confidence scores of the component symbol output by the model, and denote the highest as _____. The second highest is ; Triggering conditions: , or if If so, template matching will be triggered.
[0038] Preferably, in this embodiment, the specific steps of template matching verification include: Extract image blocks corresponding to ambiguous areas from the original drawing image; A normalized cross-correlation matching algorithm is used to perform sliding matching between image patches and templates in the standard symbol template library at multiple scaling scales; The template category with the highest normalized cross-correlation similarity is used as the corrected category label.
[0039] Specifically, in this embodiment, an image block is cropped from the original binary image by expanding the bounding box by 5 pixels. Set the scaling scale set. Use templates from the standard template library. Zoom to the current scale, in the image patch Step size Pixels are slid along, and normalized cross-correlation coefficients are calculated. : ; in, The pixel value of the image block; Template pixel values; and These are the average pixel values for the image patch and the template, respectively.
[0040] Iterate through all scales and take the largest one. Replace the original deep learning category label with the corresponding template category value. Output the confirmed graphic element information.
[0041] S4. Based on the confirmed primitive information, perform spatial topology association extraction, specifically including: Extract the vectorized endpoint coordinates of the conductor; Preferably, in this embodiment, extracting the vectorized endpoint coordinates of the conductor in S4 includes: Morphological skeletonization is performed on the conductor instance mask to obtain the conductor centerline with a width of one pixel; A multi-segment line fitting algorithm is used to vectorize the centerline of the conductor, and the coordinates of the starting and ending points of the vectorized polyline are extracted.
[0042] Specifically, in this embodiment, category labels are extracted. The mask M of the (conductor) is used to iteratively peel away boundary pixels using a morphological skeletonization thinning algorithm (e.g., the Zhang-Suen thinning algorithm) until the width is 1 pixel, obtaining the center line of the conductor with a single pixel width. Subsequently, a polyline fitting approximation algorithm (e.g., the Douglas-Peucker algorithm) is used to vectorize and approximate the center line, extracting the endpoints of the fitted polyline, denoted as... .
[0043] When a spatial intersection of two wires is detected, the local pixel distribution features and connected region features within the intersection area are extracted, and the node type of the intersection is determined based on the local pixel distribution features and connected region features. Preferably, in this embodiment, step S4, based on local pixel distribution features and connected region features, determines the type of intersecting nodes, including: Using the spatial intersection point of the two intersecting wires as the center, a circular region of interest with a preset radius is extracted; Calculate the percentage of black pixels and the number of connected regions within the region of interest; When the proportion of black pixels is greater than the first preset threshold and there is a central connected region, the intersection is determined to be an electrical connection node. When the proportion of black pixels is less than the second preset threshold and there is no central connected region, the intersection is determined to be an electrical crossing, and no connecting edge is generated in the topology data; Wherein, the first preset threshold is greater than the second preset threshold; When the proportion of black pixels is between the first preset threshold and the second preset threshold, the intersection point is marked as a suspected abnormal node and a warning message is output.
[0044] Specifically, in this embodiment, when a spatial geometric intersection is detected between two vectorized line segments of a conductor, the intersection point is extracted. .by Centered on the preset radius, intercept The circular region of interest (ROI) of the pixel. Since the foreground pixel value of the guide wire and the solid circle was defined as 0 (black) in step S1, the proportion of black pixels within this ROI is calculated here. ; ; Specifically, in combination Figure 4 The diagram illustrating the principle for determining the type of conductor intersection is used for judgment. The left diagram shows the case of an "electrical connection node," where two conductors intersect in space. A solid black dot (representing the physical connection point as required by electrical drawing standards) is drawn at the intersection point. A circular Region of Interest (ROI) is drawn around this solid black dot using a thin solid line. The right diagram shows the case of an "electrical crossing," where there is no physical connection at the intersection of the two conductors. A standard semi-circular arc symbol is used to represent the non-connection crossing, and a thin solid line circular ROI is also drawn around it. Subsequent calculations... In the case of connected components, logical decisions will be made based on the two different ROI pixel distribution characteristics.
[0045] In the formula, The total number of pixels within the ROI with a pixel value of 0 (i.e., black lines or dots); This represents the total number of pixels within the ROI mask area.
[0046] Simultaneously, the 8-neighborhood connected component labeling algorithm (Two-Pass algorithm) is applied to the ROI region to count the number of connected components within the ROI. .
[0047] like And there exists a point containing the intersection. The central connected domain is determined to be an electrical connection node; like If a line does not belong to any connected domain (i.e., there are multiple independent line segment branches with no central connection point), it is determined to be an electrical crossing and no connecting edge is generated. like This indicates that the image is blurry or contaminated; the point is marked as a suspected anomalous node and... The background system outputs warning logs.
[0048] Based on the pre-defined virtual pin rules corresponding to the component symbol category, virtual pin coordinates are generated at the edge of the component symbol's coordinate region (i.e., the component symbol's bounding box). Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin. When the minimum Euclidean distance is less than the preset connectivity threshold, establish the physical connection between the wire and the corresponding component symbol. Preferably, in this embodiment, calculating the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin in step S4 includes: Based on the pre-defined pin position rules for different component symbol categories, virtual pin coordinates are generated at the edge of the component symbol bounding box. Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin; When the minimum Euclidean distance is less than the preset connectivity threshold, it is determined that the corresponding wire endpoint and the corresponding virtual pin establish a physical connection relationship. The preset connectivity threshold is adaptively scaled based on the drawing resolution.
[0049] Specifically, in this embodiment, based on the component symbol category label Look up the table. For example, for a "relay coil" (horizontal rectangle), let its bounding box be... Then the coordinates of the left pin are generated. right pin .
[0050] Specifically, in combination Figure 5 The diagram shown illustrates the generation of virtual pins and the calculation of endpoint connection distance. For the horizontal rectangular component symbol bounding box, its four corners are marked with... Set vertex coordinates. Draw a thick solid line outward from the midpoint of the left edge, and draw solid black dots at the endpoints as virtual pins. The solid black dot on the right serves as a virtual pin. The diagram shows a horizontal wire entering from the left, with the wire's endpoints... Similarly, it is marked with solid black dots. To calculate the connection distance, a dashed distance measurement line with an arrow is drawn parallel to the wire and the pin, indicating the Euclidean distance. The calculated vector.
[0051] Vectorize all extracted conductors into polylines. Merge and construct as global wire endpoints Obtain the DPI of the input drawing (this can be obtained through image metadata or user input). Calculate the adaptive connectivity threshold: ; In the formula, The baseline connectivity threshold at the baseline resolution, the baseline threshold Pixel; The baseline resolution, the baseline resolution ; The actual resolution of the currently input drawing; Traverse the global wire endpoint set Calculate its path to all virtual pins Euclidean distance: ; like Then, the physical connection between the wire and the corresponding pin is established.
[0052] S5. Based on spatial proximity rules and directional constraint rules, bind the identified text number content with the corresponding component symbols and connection relationships to generate secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number" and output it.
[0053] Preferably, in this embodiment, step S5, which binds the identified text number content with the corresponding component symbol and connection relationship according to the spatial proximity rule and the direction constraint rule, includes: Calculate the Euclidean distance between the center point of the text numbering area and the center point of each component symbol; Determine whether the text number area falls within the neighborhood formed by the outward expansion of the coordinate areas of each component symbol; Among the component symbols that satisfy the neighborhood range constraint, the component symbol that is closest in distance is selected as the target bound component symbol; In addition, by combining the positional characteristics of the text number area relative to the target bound element symbol, abnormal bindings that violate the preset drawing position rules are eliminated; Bind the text number content as the attribute identifier of the target bound element symbol.
[0054] Specifically, in this embodiment, all text recognition results (Text) and their center points are traversed. Calculate its distance to the center point of all component symbols. distance To determine if the bounding box of the text region falls within the bounding box of the target symbol, expand the bounding box outward by a distance d=20 pixels to form an expanded frame. . determination Whether the text falls within the expanded box, excluding text outside the box.
[0055] Among the candidate element symbols that satisfy the neighborhood constraint, the element symbol with the closest Euclidean distance is selected as the target bound element symbol. An orientation constraint rule is introduced: relative orientation is calculated. In the formula, and The x and y coordinates of the center point of the text numbering area. and Bind the horizontal and vertical coordinates of the center point of the target component symbol, and combine them. Figure 6 The diagram illustrates the spatial proximity and directional constraint binding of text numbers. The outer dashed box represents the extended neighborhood formed by extending outward by a distance d=20 pixels from the bounding box of the component symbol (the inner solid box). The text box to be bound (e.g., "1KM") is located at the upper right of the component symbol box, with its center point... Center point of component symbol Horizontal and vertical offsets occurred. According to electrical drafting standards, the branching logic for drafting orientation rules is as follows: if the text annotation is directly above the component symbol, then it should satisfy... If the text is pre-labeled on both sides of the component symbol, then the mathematical condition must be strictly satisfied. The symbols conform to the left-right distribution, and .
[0056] It can effectively prevent incorrect associations caused by excessive horizontal or vertical drift of text boxes. If the calculation result violates any of the above preset drawing orientation rules (e.g., the text runs far below the component symbol), it is judged as an abnormal binding and is removed.
[0057] Finally, the legally bound text number content is used as the attribute identifier to generate secondary loop topology feature data (JSON format) containing the mapping relationship of "component symbol-pin-wire-number" and output it.
[0058] In this embodiment, the secondary loop topology feature data output in step S5 is in a structured data format, and the specific fields include: unique identifier of component symbol, component symbol type, global coordinates of component symbol, pin index, pin coordinates, associated wire identifier, associated wire endpoint coordinates, and bound text number attribute.
[0059] Example 2
[0060] like Figure 2 As shown, this embodiment provides a system for primitive recognition and topology extraction of secondary loop drawings, which is used to implement the method of Embodiment 1 above.
[0061] The system specifically includes: an image preprocessing module, which performs denoising, binarization, and tilt correction on the original secondary circuit drawing image, and outputs a standard image to be identified; The deep learning detection module is used to perform multi-target simultaneous detection and instance segmentation on the standard image to be identified based on the instance segmentation neural network model. It outputs coordinate regions, category labels, instance masks and classification confidence scores, and outputs text number recognition results. The template matching and verification module is used to determine classification ambiguity based on the classification confidence score, and when there is classification ambiguity, it calls the standard symbol template library to perform template matching and verification to correct the category label and output the confirmed primitive information. The spatial topology association module is used to perform topology extraction based on the confirmed primitive information. It includes the following components: The conductor vectorization unit is used to perform skeletonization and vectorization processing on the conductor instance mask and extract the coordinates of the vectorized endpoints of the conductor. The intersection determination unit is used to extract local pixel distribution features and connected region features in the intersection area of the conductor space, and determine the intersection node type based on the features. The pin generation unit is used to generate virtual pin coordinates at the edge of the coordinate area of the component symbol based on the preset virtual pin rules corresponding to the component symbol category. The endpoint connection unit is used to calculate the spatial distance between the wire endpoint and the coordinates of the virtual pin, and to establish a physical connection relationship based on a preset connectivity threshold. The structured output module is used to bind text number content with component symbols and connection relationships according to spatial proximity rules and directional constraint rules, and output secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number".
[0062] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Substitutions may be substitutions for some structures, devices, or method steps, or they may be complete technical solutions. Equivalent substitutions or modifications made to the technical solutions and inventive concepts of the present invention should all be covered within the scope of protection of the present invention.
Claims
1. A method for primitive recognition and topology extraction in a secondary circuit drawing, characterized in that, Includes the following steps: S1. Obtain the original secondary circuit drawing image, perform noise reduction, binarization and tilt correction preprocessing on the image, and output the standard image to be identified; S2. Input the standard image to be identified into a pre-trained lightweight convolutional neural network model, perform simultaneous target detection and instance segmentation on component symbols, wires, terminal blocks, and text regions in the drawing, and output the coordinate region, category label, instance mask, and classification confidence score corresponding to each target; and perform character recognition on the text region to output the corresponding text number content. S3. Determine whether there is classification ambiguity for the target based on the classification confidence score. If there is classification ambiguity, determine the coordinate region corresponding to the target with classification ambiguity as the ambiguous region, call the preset standard symbol template library to perform template matching verification on the ambiguous region, correct the target category label according to the template matching result, and output the confirmed primitive information. S4. Based on the confirmed primitive information, perform spatial topology association extraction, specifically including: Extract the vectorized endpoint coordinates of the conductor; When a spatial intersection of two wires is detected, the local pixel distribution features and connected region features within the intersection area are extracted, and the node type of the intersection is determined based on the local pixel distribution features and connected region features. Based on the preset virtual pin rules corresponding to the component symbol category, virtual pin coordinates are generated at the edge of the coordinate region of the component symbol; Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin. When the minimum Euclidean distance is less than the preset connectivity threshold, establish the physical connection between the wire and the corresponding component symbol. S5. Based on spatial proximity rules and directional constraint rules, bind the identified text number content with the corresponding component symbols and connection relationships to generate secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number" and output it.
2. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, In step S1, for high-resolution drawing images, a fixed-size sliding window is used to segment the drawing image, and an overlap area of 10% to 30% is set between adjacent sliding windows. After preprocessing and recognition of the segmented sub-images, the recognition results are mapped and restored to global absolute coordinates based on the coordinate offset of each sub-image in the original drawing.
3. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, The lightweight convolutional neural network model in step S2 is an instance segmentation model that incorporates deformable convolution.
4. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, The conditions for determining whether there is classification ambiguity in the target based on the classification confidence score in step S3 include: The highest classification confidence score corresponding to the target category falls within a preset low confidence range; or... The difference between the highest classification confidence score and the second highest classification confidence score corresponding to the target category is less than a preset difference threshold; When any condition is met, the target is determined to have classification ambiguity and template matching verification is triggered.
5. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 4, characterized in that, The specific steps of the template matching verification include: Extract image blocks corresponding to ambiguous areas from the original drawing image; A normalized cross-correlation matching algorithm is used to perform sliding matching between the image patch and templates in the standard symbol template library at multiple scaling scales. The template category with the highest normalized cross-correlation similarity is used as the corrected category label.
6. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, The step S4 of extracting the vectorized endpoint coordinates of the conductor includes: Morphological skeletonization is performed on the conductor instance mask to obtain the conductor centerline with a width of one pixel; The centerline of the conductor is vectorized using a multi-segment line fitting algorithm, and the coordinates of the starting and ending points of the vectorized polyline are extracted.
7. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, In step S4, determining the type of intersecting nodes based on the local pixel distribution features and connected region features includes: Using the spatial intersection point of the two intersecting wires as the center, a circular region of interest with a preset radius is extracted; Calculate the percentage of black pixels and the number of connected regions within the region of interest; When the proportion of black pixels is greater than the first preset threshold and there is a central connected region, the intersection is determined to be an electrical connection node; When the proportion of black pixels is less than the second preset threshold and there is no central connected region, the intersection is determined to be an electrical crossing, and no connecting edge is generated in the topology data; Wherein, the first preset threshold is greater than the second preset threshold; When the proportion of black pixels is between the first preset threshold and the second preset threshold, the intersection point is marked as a suspected abnormal node and a warning message is output.
8. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, Step S4, which involves calculating the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin and establishing the physical connection relationship, includes: Calculate the Euclidean distance between the vectorized endpoint coordinates of the wire and the coordinates of each virtual pin; When the minimum Euclidean distance is less than the preset connectivity threshold, it is determined that the corresponding wire endpoint and the corresponding virtual pin establish a physical connection relationship. The preset connectivity threshold is adaptively scaled according to the drawing resolution.
9. The method for primitive recognition and topology extraction of a secondary circuit drawing as described in claim 1, characterized in that, Step S5, which binds the identified text number content with the corresponding component symbol and connection relationship based on spatial proximity rules and directional constraint rules, includes: Calculate the Euclidean distance between the center point of the text numbering area and the center point of each component symbol; Determine whether the text number area falls within the neighborhood formed by the outward expansion of the coordinate areas of each component symbol; Among the component symbols that satisfy the neighborhood range constraint, the component symbol that is closest in distance is selected as the target bound component symbol; In addition, by combining the positional characteristics of the text number area relative to the target bound element symbol, abnormal bindings that violate the preset cartographic orientation rules are eliminated; The text number content is bound to the attribute identifier of the target bound element symbol.
10. A system for primitive recognition and topology extraction of secondary circuit drawings, characterized in that, For implementing the method as described in any one of claims 1 to 9, comprising: The image preprocessing module is used to perform noise reduction, binarization, and tilt correction on the original secondary circuit drawing image, and output the standard image to be identified. The deep learning detection module is used to perform multi-target simultaneous detection and instance segmentation on the standard image to be identified based on the instance segmentation neural network model. It outputs coordinate regions, category labels, instance masks and classification confidence scores, and outputs text number recognition results. The template matching and verification module is used to determine classification ambiguity based on the classification confidence score, and when there is classification ambiguity, it calls the standard symbol template library to perform template matching and verification to correct the category label and output the confirmed primitive information. The spatial topology association module is used to perform topology extraction based on the confirmed primitive information. It includes the following components: The conductor vectorization unit is used to perform skeletonization and vectorization processing on the conductor instance mask and extract the vectorized endpoint coordinates of the conductor. The intersection determination unit is used to extract local pixel distribution features and connected region features in the intersection area of the conductor space, and determine the node type of the intersection based on the features; The pin generation unit is used to generate virtual pin coordinates at the edge of the coordinate area of the component symbol based on the preset virtual pin rules corresponding to the component symbol category. The endpoint connection unit is used to calculate the spatial distance between the wire endpoint and the coordinates of the virtual pin, and to establish a physical connection relationship based on a preset connectivity threshold. The structured output module is used to bind text number content with component symbols and connection relationships according to spatial proximity rules and directional constraint rules, and output secondary loop topology feature data containing the mapping relationship of "component symbol-pin-wire-number".