Terminal block drawing terminal identification and cable connecting line matching method and system
By combining YOLOv8 and the RT-DETR model with sliding window and spatial hashing algorithms, the efficiency and accuracy issues in terminal block diagram recognition are solved, enabling automated matching of terminals and cable connections and generating structured data.
Patent Information
- Application Number
- CN202511521815.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2026-02-06
AI Technical Summary
Existing technologies are inefficient and have a high error rate in terminal block diagram recognition, making it difficult to accurately output cable connection relationships, especially when the image resolution is high and the primitives are small, making recognition and matching difficult.
The YOLOv8 and RT-DETR target detection models are combined with the sliding window method and spatial hashing algorithm to identify terminal block areas, cut them into multiple sub-images, determine cell coordinates, bind text information, and match cable segments using the spatial hashing algorithm.
It enables automated recognition of terminal block diagrams and precise matching of cable connections, generating structured data and improving recognition efficiency and accuracy.
Smart Images

Figure CN121482819A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and electrical drawing recognition technology, and in particular to a method and system for terminal block drawing terminal recognition and cable connection matching. Background Technology
[0002] Substation secondary wiring diagrams are the core carriers of power secondary system design, equipment connection relationships, and functional logic, spanning the entire lifecycle of project planning, production commissioning, and maintenance. Traditional electrical drawing processing relies on manual identification and interpretation, which is inefficient, has a high error rate, and human errors such as symbol confusion, misreading, and misjudgment can lead to subsequent construction failures or operational deviations. With the development of computer vision technology, target detection and text recognition technologies based on deep networks are widely used in electrical drawing recognition, realizing the automatic conversion from drawing images to structured information. However, these technologies still face some problems when processing terminal block drawings: the extraction and processing of drawing information depends on knowledge related to electrical and CAD fields; terminal block drawings are generally large in size and have high image resolution, while the elements to be detected are small, and direct application of models cannot solve the problem of target size differences; cable wiring is intricate, and accurately outputting connection relationships after identifying elements is still quite difficult. Summary of the Invention
[0003] The purpose of this invention is to propose a method and system for terminal block drawing terminal identification and cable connection matching, which can effectively solve the problems faced by the prior art in terminal block drawing identification, realize the automatic conversion of drawing information, and generate data quickly and with high accuracy.
[0004] To achieve the above objectives, the present invention employs the following technical solution:
[0005] In a first aspect, the present invention provides a method for terminal identification on terminal block diagrams and matching of cable connections, comprising:
[0006] Obtain the terminal block drawing, extract the required line segments and text information, scale the drawing according to a certain ratio, generate a terminal block image, and calculate the coordinates of the line segments and text in the terminal block image;
[0007] Based on a preset target detection model, the terminal block region in the terminal block image is identified, and a sub-image of the terminal block is cropped out.
[0008] The terminal block diagram is cut into multiple terminal block sub-diagrams with a certain overlapping area;
[0009] Based on a preset cell detection model, the cell coordinate information in the terminal block diagram is determined and restored to the original terminal block image; the terminal block diagram is presented in table form, and the cell refers to the smallest cell in the table;
[0010] Bind the extracted text information to the corresponding cells;
[0011] Calculate all line segments connected to the terminal block area, and bind the terminals and line segments;
[0012] Determine the cable assembly, match the segments and cables connected to the terminal block area, and then match the terminals and cables.
[0013] Preferably, the step of obtaining the terminal block drawing and extracting the required line segments and text information includes,
[0014] Obtain the structured data from the terminal block drawing CAD file, and extract the coordinate information of line segments and text entities from the structured data; extract the starting and ending coordinates of line segments, and extract the coordinates of the upper left and lower right corners of text entities, which are located within a rectangular area;
[0015] The coordinates of the line segments and text in the terminal block image are calculated by multiplying the coordinates of the line segments and text entities extracted from the CAD file by a scaling factor and mapping them onto the terminal block image.
[0016] Preferably, the target detection model uses a YOLOv8 network. The training process of the target detection model uses images converted from electrical substation terminal block drawings as the training set, marks the rectangular box positions of the terminal blocks in the images, expands the samples through data augmentation operations, and inputs them into the YOLOv8 network to complete the training.
[0017] Preferably, the step of cutting the terminal block diagram into multiple terminal block sub-diagrams with a certain overlapping area includes:
[0018] The terminal block sub-image is cut into multiple terminal block sub-images using the sliding window method. The width of the terminal block sub-image remains unchanged, while the height is cut using a fixed number of pixels, and a certain number of overlapping pixels are retained, thereby obtaining multiple terminal block sub-images with the same height and the same overlapping area. If the last sub-image does not meet the fixed height requirement, the original image is saved directly.
[0019] Preferably, the cell detection model adopts the RT-DETR model.
[0020] Preferably, determining the cell coordinate information in the terminal block diagram and restoring it to the original terminal block image includes:
[0021] The terminal block diagram is input into the trained cell detection model for prediction to obtain the cell coordinate information in the terminal block diagram;
[0022] Based on the coordinate information of the cells in the terminal block sub-graph, and combined with the position information of the terminal block sub-graph in the terminal block sub-graph, each cell is restored to the terminal block sub-graph. The process is as follows: for the first sub-graph, the coordinates do not need to be changed; for all subsequent sub-graphs, for the nth sub-graph, the horizontal coordinate of each cell does not change, and the vertical coordinate is increased by n*h, where h is the height of the sub-graph minus the height of the overlapping pixels.
[0023] Combining the position information of the terminal block diagram in the original terminal block image, each cell is restored to the original terminal block image. The process is as follows: The coordinates of the top-left corner of the rectangle containing the terminal block diagram in the entire terminal block image are ( ). For each cell in the terminal block diagram, record the coordinates of the top left corner of the rectangle as ( ). The coordinates of the bottom right corner of the rectangle are ( ),have , , , , ( ) represents the coordinates of the top-left corner of the rectangle that the cell is restored to in the terminal block image. () represents the coordinates of the bottom right corner of the rectangle that the cell is restored to in the original terminal block image.
[0024] Preferably, the step of binding the extracted text information to the corresponding cell includes,
[0025] For each cell in the terminal block diagram, iterate through the extracted set of text coordinates. If the center of the text rectangle falls within the cell, the text belongs to that cell and is bound. After binding all cells, arrange all cells and group the cells whose center ordinates are within the error range into a row. The information in a row of cells corresponds to all the information of a terminal block.
[0026] Preferably, the calculation of all line segments connected to the terminal block area, and the binding of terminals and line segments, includes:
[0027] The terminal block area is represented as a table area. Traverse all extracted line segments and determine whether the line segment coordinates are connected to the left or right side of the terminal block area table. Find all line segments connected to the terminal block area. Bind the connected line segments to the corresponding row of terminal cells. For each connected line segment, traverse all cell rows. If the center ordinate of the line segment falls in the cell, bind the cell to the line segment.
[0028] Preferably, determining whether the line segment coordinates are connected to the left or right side of the terminal block area table includes:
[0029] Let the coordinates of the upper left corner of the terminal block area be ( The coordinates of the lower right corner are ( ), coordinates of the starting point of the line segment ( ), endpoint coordinates ( ),satisfy , ,and , , ,in If the error threshold is met, then the line segment and the left side of the terminal block area are considered to be connected; if the condition is met... , , , , If so, it is determined that the line segment and the right side of the terminal block area are connected.
[0030] Preferably, determining the cable set involves matching the wire segments and cables connected to the terminal block area, and then matching the terminals and cables, including:
[0031] Use the starting and ending coordinates of all extracted line segments as keys to create a hash table;
[0032] For the line segment connected to the terminal block area, when the connected line segment is on the left side of the terminal block area, take the starting point of the line segment and search the hash table for an adjacent point. If there is an adjacent point, the line segment to which the adjacent point belongs is included in the cable set. When the connected line segment is on the right side of the terminal block area, take the ending point of the line segment and search the hash table for an adjacent point. If there is an adjacent point, the line segment to which the adjacent point belongs is included in the cable set.
[0033] Match the connecting lines and cables in the terminal block area. Traverse the cable set. If a line segment is connected to the start or end point of a connecting line segment or cable in the terminal block area, match the line segment with that cable. Otherwise, find all cables that intersect with the line segment and match the line segment with the cable that is furthest away.
[0034] After obtaining the matching relationship between the line segment and the cable, the terminals and the cable are matched according to the binding relationship between the terminal and the line segment.
[0035] Secondly, the present invention provides a terminal block drawing terminal identification and cable connection matching system for implementing the above-mentioned terminal block drawing terminal identification and cable connection matching method, the system comprising:
[0036] The drawing acquisition and conversion module is used to acquire terminal block drawings, extract the required line segments and text information, scale the drawings according to a certain ratio, generate terminal block images, and calculate the coordinates of the line segments and text in the terminal block images;
[0037] The identification and cropping module is used to identify the terminal block region in the terminal block image based on a preset target detection model, and crop out the terminal block sub-image.
[0038] A cutting module is used to cut the terminal block diagram into multiple terminal block sub-diagrams with a certain overlapping area;
[0039] The coordinate recognition and restoration module is used to determine the coordinate information of the cells in the terminal block diagram based on a preset cell detection model, and restore it to the original terminal block image; the terminal block diagram is in the form of a table, and the cell refers to the smallest cell in the table;
[0040] The information binding module is used to bind the extracted text information to the corresponding cells;
[0041] The line segment binding module is used to calculate all line segments connected to the terminal block area and bind the terminals and line segments.
[0042] The cable matching module is used to identify cable sets, match the wire segments and cables connected to the terminal block area, and then match the terminals and cables.
[0043] Thirdly, the present invention provides a computer-readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by a computing device, cause the computing device to perform any of the methods described above for terminal block diagram terminal identification and cable connection matching.
[0044] Fourthly, the present invention provides a computing device comprising one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for performing any of the methods described above for terminal identification and cable connection matching according to terminal block diagrams.
[0045] The beneficial effects achieved by this invention are as follows:
[0046] This invention, based on the YOLOv8 and RT-DETR target detection models, combines algorithms such as sliding window and spatial hashing to achieve terminal identification and cable connection matching in terminal block diagrams. Specifically, this invention addresses the issue of size differences in images with high resolution and small target elements by using a fixed-height pixel sliding window algorithm; it novelly introduces the RT-DETR model to achieve accurate cell detection; and it employs a spatial hashing algorithm to trace straight lines, accurately matching terminals and cable connections from complex wiring. The method based on this invention can automatically generate structured data of terminal information and terminal-cable matching relationships, offering strong real-time performance and high accuracy, effectively improving the automation level of electrical secondary drawing recognition. Attached Figure Description
[0047] Figure 1A schematic flowchart illustrating one embodiment of the terminal block drawing terminal identification and cable connection matching method provided by the present invention;
[0048] Figure 2 This is an example drawing of the terminal block used in an embodiment of the present invention;
[0049] Figure 3 This is an example diagram of a terminal block cut from a complete drawing according to an embodiment of the present invention;
[0050] Figure 4 This is a schematic diagram of the terminal block area extracted using the sliding window method in an embodiment of the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.
[0052] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.
[0053] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.
[0054] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.
[0055] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.
[0056] It should be emphasized here that the step markers mentioned below are not a limitation on the order of the steps, but should be understood as meaning that the steps can be executed in the order mentioned in the embodiments, or in a different order than in the embodiments, or several steps can be executed simultaneously.
[0057] Example 1
[0058] Figure 1 This is a schematic flowchart of a terminal block diagram terminal identification and cable connection matching method provided in Embodiment 1 of the present invention. In this embodiment, the method includes the following steps:
[0059] S1: Obtain the layer, geometric shape, and text element information of the terminal block drawing CAD file, extract the required line segments and text, scale the drawing according to a certain ratio, generate a PNG format image file, and calculate the coordinates of the line segments and text in the image;
[0060] In this step, obtaining information about elements such as layers, geometric shapes, and text refers to obtaining the structured data from the terminal block drawing CAD file, extracting the coordinate information of line segments and text entities from the structured data, extracting the starting and ending coordinates of line segments, and extracting the position area of text entities as a rectangle, extracting the coordinates of the upper left and lower right corners.
[0061] In this embodiment, the terminal block drawing CAD file used is in dxf format, the layout is extracted as Modelspace, and the entities are extracted as all entities in Modelspace and INSERT block.
[0062] In this step, calculating the coordinate position of the corresponding image specifically involves: calculating the scaling ratio between the drawing image and the CAD file, multiplying the coordinates of the line segments and text extracted from the CAD file by the scaling ratio, and mapping them onto the image.
[0063] Figure 2 This is an example diagram of the terminal block used in this embodiment.
[0064] S2: Train the target detection model to identify the terminal block region in the terminal block image and crop out the terminal block sub-image;
[0065] In this step, the target detection model adopts the YOLOv8 model. The dataset used in the training process is the image converted from the terminal block drawings of electrical substations. The annotation data is the rectangular box position of the terminal block in the image. After the image is annotated using the annotation tool, the sample is expanded by data augmentation operation and then input into the YOLOv8 network to complete the training.
[0066] In this embodiment, the annotation tool uses labelme, and the annotation label is "table" to indicate the category of terminal block. The selected data augmentation operations include: flipping, cropping, deformation, color change, etc.
[0067] Figure 3 The following is based on Figure 2 The terminal block diagram is cropped from the terminal block image.
[0068] S3: Using the sliding window method, the terminal block is cut into multiple sub-images with a certain overlapping area;
[0069] For the terminal block sub-image output in step S2, the sliding window method is used to cut the terminal block into multiple sub-images. The width remains unchanged, and the height is cut using pixels of fixed height, while retaining a certain number of overlapping pixels.
[0070] In this embodiment, the fixed height used for cutting is 1000 pixels, and the overlap is 200 pixels. Therefore, the first sub-image is the same width as the terminal block image, with a height of 0-1000 pixels; the second sub-image is the same width, with a height of 800-1800 pixels, and so on. For the last sub-image, if it does not meet the 1000-pixel requirement, the original image is saved directly.
[0071] Figure 4 The diagram shown is a schematic representation of the terminal block area extracted in this embodiment.
[0072] S4: The terminal block area is represented in a table format. The cells in the table are labeled, a dataset is created, and a cell detection model is trained.
[0073] In this embodiment, the cell detection model adopts the RT-DETR (Real-Time DetectionTransformer) model. The training process specifically includes: collecting the terminal block sub-images cut out in step S3, labeling all cells in the sub-images with the label category as cell and the label area as the rectangular frame position of the cell, and inputting the dataset into the RT-DETR network for training.
[0074] S5: Input the sub-image into the trained cell detection model for prediction, output the cell coordinate information in the sub-image, and restore it to the original PNG image;
[0075] In this step, the sub-image is input into the trained cell detection model RT-DETR for prediction to obtain the position information of each cell in the sub-image. Combined with the position information of the sub-image in the terminal block, each cell is restored to the terminal block image.
[0076] In this embodiment, step S3 takes a fixed height of 1000 pixels for cutting and an overlap of 200 pixels. The process of restoring the cell coordinates to the terminal block sub-image is as follows: For the first sub-image, the coordinates do not need to be changed; for all subsequent sub-images, for the nth sub-image, the horizontal coordinate of each cell does not change, and the vertical coordinate is increased by n*800.
[0077] Then, combining the position information of the terminal block diagram within the entire image, restore each cell to the original PNG image. Let the coordinates of the top-left corner of the rectangle containing the terminal block diagram within the entire PNG image be ( ). For each cell in the terminal block diagram, record the coordinates of the top left corner of the rectangle as ( ). The coordinates of the bottom right corner of the rectangle are ( ),have , , , , ( ) represents the coordinates of the top-left corner of the rectangle that the cell is restored to in the original image. () represents the coordinates of the bottom right corner of the rectangle that the cell is restored to in the original image.
[0078] S6: Bind text information to the corresponding cells and arrange the cells;
[0079] In this step, text information is bound to corresponding cells, and the cells are arranged. Specifically, after restoring the cell coordinates in step S5, the coordinates of both the cell and the drawing text are based on the drawing and can be directly compared. For each cell in the terminal block diagram, the set of text coordinates obtained in step S1 is traversed. If the center of the text rectangle's coordinates falls within a cell, the text is considered to belong to that cell and is bound. After binding all cells, all cells are arranged, grouping cells with similar center ordinates of their rectangles into a row. The information in a row is considered all the information corresponding to one terminal block. Here, when the difference between the center ordinates of two cells is less than 10 pixels, the two cells are considered close.
[0080] S7: Calculate all line segments connected to the terminal block area and bind the terminals and line segments;
[0081] In this step, all line segments connected to the terminal block area are calculated, and the terminals and line segments are bound together. Specifically, the terminal block area is represented as a table area. All line segments obtained in step S1 are traversed, and it is determined whether the coordinates of the line segments are connected to the left or right side of the terminal block area table. All line segments connected to the terminal block area are found.
[0082] In this embodiment, the rule for determining whether the line segment coordinates are connected to the left or right side of the terminal block area table can be refined as follows:
[0083] Let the coordinates of the upper left corner of the terminal block area be ( The coordinates of the lower right corner are ( ), coordinates of the starting point of the line segment ( ), endpoint coordinates ( ),satisfy , ,and , , ,in The error threshold is set to 5 in this embodiment, assuming that the line segment and the left side of the terminal block area are connected; thus satisfying the condition... , , , , It is assumed that the line segment and the right side of the terminal block area are connected.
[0084] Bind connected line segments to the corresponding row terminal cell. For each connected line segment, iterate through all cell rows. If the center ordinate of the line segment falls into a cell, bind that cell to the line segment.
[0085] S8: Use a spatial hash algorithm to find the cable set, match the line segments and cables connected to the terminal block area, and then match the terminals and cables.
[0086] Spatial hashing, also known as spatial hash collision checking, is a spatial partitioning algorithm that optimizes the efficiency of large-scale object collision detection. Its core idea is to allocate objects in two-dimensional space to discrete cells using hash mapping. In drawing recognition, spatial hashing can be used to detect line segment connections. In this embodiment, a spatial hash table is established by using the start and end coordinates of all line segments extracted in step S1 as keys. Considering the pixel distance between line segments in the drawing image, a value of 5 is chosen as the width and height of a grid in space. When two points fall into the same grid, a collision is considered triggered, indicating that the line segments to which the two points belong are connected.
[0087] For the connecting line segments of the terminal block area extracted in step S7, when the connecting line segment is on the left side of the terminal block, take the starting point of the line segment and search in the spatial hash table for whether there is an adjacent point. In this example, that is, it falls in the same grid of size 5*5. If the condition is met, the line segment to which the adjacent point belongs is included in the cable set. When the connecting line segment is on the right side of the terminal block, take the ending point of the line segment and search in the spatial hash table for whether there is an adjacent point. If the condition is met, the line segment to which the adjacent point belongs is included in the cable set.
[0088] Match the connected line segments and cables in the terminal block area. Traverse the cable set. If the start or end point of the connected line segment and cable are connected, match the line segment with the cable. Otherwise, find all cables that intersect with the line segment and match the line segment with the cable that is furthest away.
[0089] After obtaining the matching relationship between the line segment and the cable, the terminal and the cable are matched according to the matching relationship between the line segment and the terminal obtained in step S7.
[0090] Example 2
[0091] Based on the same inventive concept as Embodiment 1 above, Embodiment 2 provides a terminal block drawing terminal identification and cable connection matching system for implementing the terminal block drawing terminal identification and cable connection matching method of Embodiment 1 above. The system includes:
[0092] The drawing acquisition and conversion module is used to acquire terminal block drawings, extract the required line segments and text information, scale the drawings according to a certain ratio, generate terminal block images, and calculate the coordinates of the line segments and text in the terminal block images;
[0093] The identification and cropping module is used to identify the terminal block region in the terminal block image based on a preset target detection model, and crop out the terminal block sub-image.
[0094] A cutting module is used to cut the terminal block diagram into multiple terminal block sub-diagrams with a certain overlapping area;
[0095] The coordinate recognition and restoration module is used to determine the coordinate information of the cells in the terminal block diagram based on a preset cell detection model, and restore it to the original terminal block image; the terminal block diagram is in the form of a table, and the cell refers to the smallest cell in the table;
[0096] The information binding module is used to bind the extracted text information to the corresponding cells;
[0097] The line segment binding module is used to calculate all line segments connected to the terminal block area and bind the terminals and line segments.
[0098] The cable matching module is used to identify cable sets, match the wire segments and cables connected to the terminal block area, and then match the terminals and cables.
[0099] Example 3
[0100] Based on the same inventive concept as Embodiment 1 above, Embodiment 3 provides a computer-readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by a computing device, cause the computing device to perform any of the terminal block drawing terminal identification and cable connection matching methods according to Embodiment 1 above.
[0101] Example 4
[0102] Based on the same inventive concept as Embodiment 1 above, Embodiment 4 provides a computing device including one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the methods of terminal block drawing terminal identification and cable connection matching according to Embodiment 1 above.
[0103] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0104] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0105] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0106] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for terminal identification on terminal block diagrams and matching of cable connections, characterized in that, include: Obtain the terminal block drawing, extract the required line segments and text information, scale the drawing according to a certain ratio, generate a terminal block image, and calculate the coordinates of the line segments and text in the terminal block image; Based on a preset target detection model, the terminal block region in the terminal block image is identified, and a sub-image of the terminal block is cropped out. The terminal block diagram is cut into multiple terminal block sub-diagrams with a certain overlapping area; Based on a preset cell detection model, the cell coordinate information in the terminal block diagram is determined and restored to the original terminal block image; The terminal block diagram is presented in tabular form, and the cell refers to the smallest cell in the table. Bind the extracted text information to the corresponding cells; Calculate all line segments connected to the terminal block area, and bind the terminals and line segments; Determine the cable assembly, match the segments and cables connected to the terminal block area, and then match the terminals and cables.
2. The terminal identification and cable connection matching method for terminal block diagrams according to claim 1, characterized in that, The process of obtaining the terminal block drawing and extracting the required line segments and text information includes... Obtain the structured data from the terminal block drawing CAD file, and extract the coordinate information of line segments and text entities from the structured data; extract the starting and ending coordinates of line segments, and extract the coordinates of the upper left and lower right corners of text entities, which are located within a rectangular area; The coordinates of the line segments and text in the terminal block image are calculated by multiplying the coordinates of the line segments and text entities extracted from the CAD file by a scaling factor and mapping them onto the terminal block image.
3. The terminal identification and cable connection matching method for terminal block diagrams according to claim 1, characterized in that, The target detection model uses a YOLOv8 network. The training process of the target detection model uses images converted from electrical substation terminal block drawings as the training set, marks the rectangular box positions of the terminal blocks in the images, expands the samples through data augmentation operations, and inputs them into the YOLOv8 network to complete the training.
4. The terminal identification and cable connection matching method for terminal block diagrams according to claim 1, characterized in that, The step of cutting the terminal block diagram into multiple terminal block sub-diagrams with a certain overlapping area includes: The terminal block sub-image is cut into multiple terminal block sub-images using the sliding window method. The width of the terminal block sub-image remains unchanged, while the height is cut using a fixed number of pixels, and a certain number of overlapping pixels are retained, thereby obtaining multiple terminal block sub-images with the same height and the same overlapping area. If the last sub-image does not meet the fixed height requirement, the original image is saved directly.
5. The terminal identification and cable connection matching method for terminal block diagrams according to claim 1, characterized in that, The cell detection model uses the RT-DETR model.
6. The terminal identification and cable connection matching method for terminal block diagrams according to claim 1, characterized in that, The step of determining the cell coordinate information in the terminal block diagram and restoring it to the original terminal block image includes: The terminal block diagram is input into the trained cell detection model for prediction to obtain the cell coordinate information in the terminal block diagram; Based on the coordinate information of the cells in the terminal block sub-graph, and combined with the position information of the terminal block sub-graph in the terminal block sub-graph, each cell is restored to the terminal block sub-graph. The process is as follows: for the first sub-graph, the coordinates do not need to be changed; for all subsequent sub-graphs, for the nth sub-graph, the horizontal coordinate of each cell does not change, and the vertical coordinate is increased by n*h, where h is the height of the sub-graph minus the height of the overlapping pixels. Combining the position information of the terminal block diagram in the original terminal block image, each cell is restored to the original terminal block image. The process is as follows: The coordinates of the top-left corner of the rectangle containing the terminal block diagram in the entire terminal block image are ( ). For each cell in the terminal block diagram, record the coordinates of the top left corner of the rectangle as ( ). The coordinates of the bottom right corner of the rectangle are ( ),have , , , , ( ) represents the coordinates of the top-left corner of the rectangle that the cell is restored to in the terminal block image. () represents the coordinates of the bottom right corner of the rectangle that the cell is restored to in the original terminal block image.
7. The terminal identification and cable connection matching method for terminal block diagrams according to claim 2, characterized in that, The step of binding the extracted text information to the corresponding cell includes, For each cell in the terminal block diagram, iterate through the extracted set of text coordinates. If the center of the text rectangle falls within the cell, the text belongs to that cell and is bound accordingly. After binding all cells, arrange all cells, grouping cells whose center y-coordinate is within the error range into a row, with the information in a row corresponding to all the information of a terminal.
8. The terminal identification and cable connection matching method for terminal block diagrams according to claim 2, characterized in that, The calculation involves all line segments connected to the terminal block area, binding the terminals and line segments, including: The terminal block area is represented as a table area. Traverse all extracted line segments and determine whether the line segment coordinates are connected to the left or right side of the terminal block area table. Find all line segments connected to the terminal block area. Bind the connected line segments to the corresponding row of terminal cells. For each connected line segment, traverse all cell rows. If the center ordinate of the line segment falls in the cell, bind the cell to the line segment.
9. The terminal identification and cable connection matching method for terminal block diagrams according to claim 8, characterized in that, The determination of whether the line segment coordinates are connected to the left or right side of the terminal block area table includes: Let the coordinates of the upper left corner of the terminal block area be ( The coordinates of the lower right corner are ( ), coordinates of the starting point of the line segment ( ), endpoint coordinates ( ),satisfy , ,and , , ,in If the error threshold is met, then the line segment and the left side of the terminal block area are considered to be connected; if the condition is met... , , , , If so, it is determined that the line segment and the right side of the terminal block area are connected.
10. The terminal identification and cable connection matching method for terminal block diagrams according to claim 2, characterized in that, The process of determining the cable assembly involves matching the wire segments and cables connected to the terminal block area, and then matching the terminals and cables, including: Use the starting and ending coordinates of all extracted line segments as keys to create a hash table; For the line segment connected to the terminal block area, when the connected line segment is on the left side of the terminal block area, take the starting point of the line segment and search the hash table for an adjacent point. If there is an adjacent point, the line segment to which the adjacent point belongs is included in the cable set. When the connected line segment is on the right side of the terminal block area, take the ending point of the line segment and search the hash table for an adjacent point. If there is an adjacent point, the line segment to which the adjacent point belongs is included in the cable set. Match the connecting lines and cables in the terminal block area. Traverse the cable set. If a line segment is connected to the start or end point of a connecting line segment or cable in the terminal block area, match the line segment with that cable. Otherwise, find all cables that intersect with the line segment and match the line segment with the cable that is furthest away. After obtaining the matching relationship between the line segment and the cable, the terminals and the cable are matched according to the binding relationship between the terminal and the line segment.
11. A terminal block drawing terminal identification and cable connection matching system, characterized in that, The system is used to implement the terminal block diagram terminal identification and cable connection matching method according to any one of claims 1 to 10, the system comprising: The drawing acquisition and conversion module is used to acquire terminal block drawings, extract the required line segments and text information, scale the drawings according to a certain ratio, generate terminal block images, and calculate the coordinates of the line segments and text in the terminal block images; The identification and cropping module is used to identify the terminal block region in the terminal block image based on a preset target detection model, and crop out the terminal block sub-image. A cutting module is used to cut the terminal block diagram into multiple terminal block sub-diagrams with a certain overlapping area; The coordinate recognition and restoration module is used to determine the coordinate information of the cells in the terminal block diagram based on a preset cell detection model, and restore it to the original terminal block image; the terminal block diagram is in the form of a table, and the cell refers to the smallest cell in the table; The information binding module is used to bind the extracted text information to the corresponding cells; The line segment binding module is used to calculate all line segments connected to the terminal block area and bind the terminals and line segments. The cable matching module is used to identify cable sets, match the wire segments and cables connected to the terminal block area, and then match the terminals and cables.
12. A computer-readable storage medium for storing one or more programs, characterized in that, The one or more programs include instructions that, when executed by a computing device, cause the computing device to perform any of the terminal block diagram terminal identification and cable connection matching methods according to claims 1 to 10.
13. A computing device, characterized in that, include, One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including instructions for performing any of the terminal block drawing terminal identification and cable connection matching methods according to claims 1 to 10.
Citation Information
Cited By
Network topology verification method and device, electronic equipment and storage medium
CN122027548A