Electrical main wiring diagram character recognition and classification method fusing CAD (Computer Aided Design) and image data
By combining CAD and image data, combined with Canny edge detection and YOLOv8 object detection model, text recognition and classification of electrical main wiring diagrams is solved, and the problem of low recognition accuracy in the existing technology is solved, and more efficient and accurate text detection and classification is achieved.
Patent Information
- Application Number
- CN202411754474.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-04
AI Technical Summary
In the context of low-quality drawings or complex backgrounds, it is difficult to accurately identify the text in the electrical main wiring diagram, especially when the character size is small or the layout is irregular, the recognition accuracy is not high, resulting in low calibration efficiency.
The method of fusing CAD and image data is adopted to pre-process the drawings through the Canny edge detection algorithm, distinguish ordinary text from text labeling boxes, and text detection is performed in combination with the YOLOv8 object detection model, and standardized processing is performed by analyzing the linear entities and text information in CAD to ensure the accuracy of text detection.
It significantly improves text recognition capabilities in low-quality drawings or complex backgrounds, reduces false detection and missed detection problems, and improves the accuracy and recognition efficiency of text detection, especially when dealing with complex nested tables or irregularly typed drawings.
Smart Images

Figure CN119763125A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent recognition of electrical design drawings, and in particular to a method for character recognition and classification of electrical main wiring diagrams integrating CAD and image data. Background Art
[0002] The electrical main wiring diagram is an important part of the substation design, and its accuracy directly affects the safe operation of the substation. In the process of electrical drawing design, it is particularly important to extract the text information in the drawings, because these texts directly correspond to electrical equipment and contain important data such as equipment identification, parameters and connection relationships. In order to ensure the accuracy of the drawings, these texts must be efficiently identified and verified to ensure the correctness of the information conveyed. This can not only improve design efficiency, but also effectively reduce safety risks caused by information errors.
[0003] At present, text recognition in electrical drawings mainly relies on image recognition technology, which usually has high requirements for drawing quality. Therefore, in low-quality drawings or complex backgrounds, the recognition effect will be significantly affected when the characters are small or the layout is irregular, and the recognition accuracy is not high, resulting in low efficiency during verification. In addition, OCR technology often has difficulty in accurately distinguishing texts with semantic associations, resulting in inaccurate recognition results.
[0004] In the prior art CN114386504A, a method and system for text recognition in engineering drawings based on deep learning is disclosed, which automatically recognizes and segments tables and text areas in engineering drawings by combining the deep learning model CenterNet and OpenCV image processing technology. First, the text area is marked, and then a data set is made through the DSA algorithm, and the CenterNet model is trained to recognize the text area. Then, the OpenCV algorithm is used to further process the table lines and contours in the drawings, separate the text area and crop it, and finally the text is recognized through OCR technology, and the key information is matched and recognized in combination with the domain dictionary.
[0005] In the prior art, the recognition accuracy of key information in engineering drawings is improved to reduce the need for manual annotation. However, when faced with drawings with complex nested tables or irregular layouts, there may be a problem of reduced recognition accuracy. Summary of the invention
[0006] In order to solve the above problems existing in the prior art, the present invention proposes a method for text recognition and classification of electrical main wiring diagrams that integrates CAD and image data.
[0007] The technical solution of the present invention is as follows:
[0008] On the one hand, the present invention proposes a method for identifying and classifying text in an electrical main wiring diagram by integrating CAD and image data, and the specific steps include:
[0009] The collected DWG format electrical main wiring diagram is converted into a high-resolution JPG format drawing, and the Canny edge detection algorithm is used to pre-process the drawing to distinguish between ordinary text and text annotation boxes in the drawing, and the coordinates and category information of all text annotation boxes are extracted;
[0010] Collect the text content and insertion point coordinates and endpoint coordinate data of the straight line entity in the original DWG format electrical main wiring diagram, and standardize all coordinate data with the coordinate data of the target detection algorithm;
[0011] When using the object detection algorithm for text detection, the size of the text detection box is enlarged to ensure that all text insertion point coordinates are covered, the relative position of the coordinates of the enlarged text detection box and the coordinates of the text insertion point is compared, and a text detection box of appropriate size is selected as the final text detection box for text detection;
[0012] Divide all straight line entities into text annotation frames, and confirm the direction of the text annotation frames according to the directions of all straight line entities in each text annotation frame;
[0013] After determining the direction of the text annotation box, the equipment text and complete set text are classified according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point.
[0014] As a preferred implementation, the target detection algorithm is a YOLOv8 target detection model.
[0015] As a preferred implementation, the steps of preprocessing the drawings using the Canny edge detection algorithm, distinguishing between ordinary text and text annotation boxes in the drawings, and extracting the coordinates and category information of all text annotation boxes are as follows:
[0016] Firstly, the noise in the drawing is removed by Gaussian filtering to enhance the smoothness of the image;
[0017] The Sobel operator is used to calculate the gradient magnitude and direction of the image, and clear edges are obtained through non-maximum suppression and double threshold processing;
[0018] After detecting the edge contour of the drawing, the drawing is cropped based on the maximum circumscribed rectangular frame to ensure that only the valid area of the drawing is retained;
[0019] The cropped image is divided into sub-images of the target size, and each sub-image is input into the YOLOv8 target detection model for processing and detection to distinguish between ordinary text and text standard libraries in the drawings to be detected;
[0020] The detection results of all sub-images are combined to obtain the coordinates and category information of all text annotation boxes on the entire drawing.
[0021] As a preferred implementation, the steps of collecting the text content in the original DWG format electrical main wiring diagram and its insertion point coordinates and the endpoint coordinate data of the straight line entity are specifically as follows:
[0022] Use the ezdxf library to traverse the model space of the DWG file and extract the text content and its insertion point coordinates as well as the endpoint coordinate data of the line entity from the model space.
[0023] As a preferred implementation, in the step of normalizing all coordinate data and the coordinate data of the target detection algorithm, the normalization formula is as follows:
[0024]
[0025] In the formula, x and y are the coordinates of the target point, x min 、x max ,y min ,y max are the boundary values of the drawings respectively.
[0026] As a preferred implementation, the step of dividing all straight line entities into text annotation frames is specifically as follows:
[0027] Check whether the two endpoints of the target straight line are both within the boundary of the target text annotation box. If the condition is met, associate the target straight line with the target text annotation box, and traverse all straight line entities until there are straight line entities in all text annotation boxes.
[0028] As a preferred implementation, the step of classifying the directions of the text annotation boxes according to the directions of all the straight line entities in the text annotation boxes is specifically as follows:
[0029] Count the number of horizontal and vertical line entities in the text annotation frame, and determine the classification of the text annotation frame based on the direction of the line entities: when the number of horizontal lines in the text frame is greater than the number of vertical lines, it is considered a vertical text annotation frame; otherwise, it is a horizontal text annotation frame.
[0030] As a preferred embodiment, after determining the direction of the text annotation box, the steps of classifying the equipment text and the complete set of equipment text according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point are specifically as follows:
[0031] For vertical text annotation boxes, the text is pre-classified according to the coordinates of the vertical lines inside, that is, the horizontal coordinates of the vertical lines in the annotation box are extracted and sorted in ascending order. According to prior knowledge, three horizontal coordinates x v The sorting result x v1 <xv2 <x v3 , and then according to the text coordinates of the insertion point (x t ,y t ) and the horizontal coordinate, will satisfy the insertion point x v1 <x t <x v2 The text of the complete set of equipment is used as the text of the complete set of equipment, and x v2 <x t <x v3 The text in is used as the equipment text inside the complete set;
[0032] Then extract the ordinate y of the horizontal line h And sort y h1 >y h2 >...>y hn , where n is the number of horizontal lines detected, traversing the text insertion point y t , will satisfy the insertion point belongs to the adjacent horizontal line ordinate y hi >y t >y hi+1 The text is written into a list, where i = 1, 2, ..., n-1, and finally a list is obtained to represent the text information corresponding to a device;
[0033] Finally, based on the m vertical lines measured, by removing the longest vertical line, the remaining m-1 short vertical lines are recorded as L1, L2, ..., L m-1 , their ordinate range is [y v1 ,y v2 ],[y v2 ,y v3 ],...,[y vm-1 ,y vm ], and use it as the basis for the division of complete set equipment information, and set the vertical coordinate range of the insertion point in the equipment text of each list to meet the y vi >y t >y vi+1 The list where the text is located, that is, the equipment text within the corresponding remaining short vertical straight line ordinate belongs to the target set of equipment.
[0034] On the other hand, the present invention proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for text recognition and classification of electrical main wiring diagrams integrating CAD and image data as described in any embodiment of the present invention is implemented.
[0035] On the other hand, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for text recognition and classification of electrical main wiring diagrams that integrates CAD and image data as described in any embodiment of the present invention.
[0036] The present invention has the following beneficial effects:
[0037] 1. By combining CAD data with image recognition technology, the present invention can effectively improve the recognition ability in low-quality drawings or complex backgrounds, reduce the problems of false detection and missed detection when the character size is small or the layout is irregular, and significantly improve the accuracy of text detection.
[0038] 2. The present invention parses the straight line entities and text information in CAD, and uses a standardized coordinate system to unify the image recognition results and CAD data, thereby enhancing the recognition ability of semantically associated texts in drawings. In particular, when processing associated texts in device annotation boxes, the present invention can accurately identify the specific models and parameters of the devices, thereby improving the accuracy of matching text with device information.
[0039] 3. The present invention adopts the YOLOv8 target detection model for text box detection, and combines the straight line screening and text classification methods to design an effective equipment text division strategy for the complex annotation boxes of complete sets of equipment. Through the joint processing of horizontal and vertical straight lines, the accurate division of complete sets of equipment text and the efficient classification of semantically related texts are achieved, thereby improving the recognition efficiency of complex drawings and the integrity of equipment information analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic diagram of the steps of the present invention;
[0041] Figure 2 Format diagram for text callout boxes;
[0042] Figure 3 Schematic diagram of text detection box;
[0043] Figure 4 Schematic diagram of text detection box and parsed text;
[0044] Figure 5 Match the straight line entity diagram for the text detection box;
[0045] Figure 6 It is a simplified flow chart of the steps of the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.
[0048] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0049] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0050] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.
[0051] Embodiment 1:
[0052] See also Figure 1 , a method for text recognition and classification of electrical main wiring diagrams integrating CAD and image data, the specific steps include:
[0053] The collected DWG format electrical main wiring diagram is converted into a high-resolution JPG format drawing, and the Canny edge detection algorithm is used to pre-process the drawing to distinguish between ordinary text and text annotation boxes in the drawing, and the coordinates and category information of all text annotation boxes are extracted;
[0054] In this embodiment, the format of the text annotation box is as follows: Figure 2 shown.
[0055] Collect the text content and insertion point coordinates and endpoint coordinate data of the straight line entity in the original DWG format electrical main wiring diagram, and standardize all coordinate data with the coordinate data of the target detection algorithm;
[0056] When using the object detection algorithm for text detection, the size of the text detection box is enlarged to ensure that all text insertion point coordinates are covered, the relative position of the coordinates of the enlarged text detection box and the coordinates of the text insertion point is compared, and a text detection box of appropriate size is selected as the final text detection box for text detection;
[0057] In this embodiment, all text detection frames are first enlarged by 1.1 times to ensure that the insertion point area related to the text is covered to ensure the integrity of text recognition.
[0058] Then, by comparing the relative positions of the coordinates of the detection box and the text insertion point, if the text insertion point is located inside the expanded detection box, the text is considered to be associated with the box, and the processed annotation box is taken as the text box; wherein the text detection box is as follows Figure 3 As shown in the figure, when using the text detection box for detection, the detected text is as follows Figure 4 shown.
[0059] Through this method, the position, size and content of ordinary text in the drawing can be obtained, and then it can be matched with related equipment according to the text content or format.
[0060] Divide all straight line entities into text annotation frames, and confirm the direction of the text annotation frames according to the directions of all straight line entities in each text annotation frame;
[0061] In this embodiment, the result of matching the straight line entity with the text detection frame is as follows: Figure 5 shown.
[0062] After determining the direction of the text annotation box, the equipment text and complete set text are classified according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point.
[0063] As a preferred implementation of this embodiment, the target detection algorithm is the YOLOv8 target detection model.
[0064] As a preferred implementation of this embodiment, the steps of using the Canny edge detection algorithm to preprocess the drawing, distinguishing the ordinary text from the text annotation box in the drawing, and extracting the coordinates and category information of all the text annotation boxes are as follows:
[0065] Firstly, the noise in the drawing is removed by Gaussian filtering to enhance the smoothness of the image;
[0066] In this embodiment, the formula of Gaussian filtering is as follows:
[0067]
[0068] The Sobel operator is used to calculate the gradient magnitude and direction of the image, and clear edges are obtained through non-maximum suppression and double threshold processing;
[0069] In this embodiment, the dual threshold processing sets the upper threshold to 100 and the lower threshold to 30.
[0070] After detecting the edge contour of the drawing, the drawing is cropped based on the maximum circumscribed rectangular frame to ensure that only the valid area of the drawing is retained;
[0071] The cropped image is divided into sub-images of the target size, and each sub-image is input into the YOLOv8 target detection model for processing and detection to distinguish between ordinary text and text standard libraries in the drawings to be detected;
[0072] The detection results of all sub-images are combined to obtain the coordinates and category information of all text annotation boxes on the entire drawing.
[0073] As a preferred implementation of this embodiment, the steps of collecting the text content and the insertion point coordinates and the endpoint coordinate data of the straight line entity in the original DWG format electrical main wiring diagram are specifically as follows:
[0074] Use the ezdxf library to traverse the model space of the DWG file and extract the text content and its insertion point coordinates as well as the endpoint coordinate data of the line entity from the model space.
[0075] In this embodiment, the extracted data includes line entities and text in TEXT format.
[0076] As a preferred implementation of this embodiment, in the step of normalizing all coordinate data and the coordinate data of the target detection algorithm, the normalization formula is as follows:
[0077]
[0078] In the formula, x and y are the coordinates of the target point, x min 、x max ,y min ,y max are the boundary values of the drawings respectively.
[0079] In this embodiment, the text information in the CAD drawing is often closely related to the straight line entities (such as the dividing lines or busbars in the equipment marking box, loop connection lines, etc.). In order to improve the accuracy of the recognition results, the text and straight line entity information in the CAD drawing data are combined for analysis and data standardization processing.
[0080] As a preferred implementation of this embodiment, the step of dividing all straight line entities into text annotation frames is specifically as follows:
[0081] Check whether the two endpoints of the target straight line are both within the boundary of the target text annotation box. If the condition is met, associate the target straight line with the target text annotation box, and traverse all straight line entities until there are straight line entities in all text annotation boxes.
[0082] In this embodiment, the relationship between the device annotation box text and the straight line is used for the subsequent device text division. The method is to check the two endpoints of the straight line (x l1 ,y l1 ) and (x l2 ,y l2 ) are all within the boundaries of the text annotation box. If they meet the conditions, they are associated with the device annotation box, so that all straight line entities know that there are straight line entities in all device annotation boxes. The specific association conditions are:
[0083] x bmin <x l1 <x bmax ,y bmin <y l1 <y bmax ,x bmin <x l1 <x bmax ,y bmin <y l1 <y bmax .
[0084] Among them, x bmin ,x bmax ,y bmin ,y bmax Represents the minimum horizontal coordinate, maximum horizontal coordinate, minimum vertical coordinate, and maximum vertical coordinate of the detection box boundary.
[0085] As a preferred implementation of this embodiment, the step of classifying the directions of the text annotation boxes according to the directions of all the straight line entities in the text annotation boxes is specifically as follows:
[0086] Count the number of horizontal and vertical line entities in the text annotation frame, and determine the classification of the text annotation frame based on the direction of the line entities: when the number of horizontal lines in the text frame is greater than the number of vertical lines, it is considered a vertical text annotation frame; otherwise, it is a horizontal text annotation frame.
[0087] In this embodiment, the text annotation boxes in the electrical main wiring drawings are of various forms, but most of them can be divided into vertical annotation boxes and horizontal annotation boxes. The horizontal equipment annotation box divides the equipment text with horizontal lines and divides the complete set of equipment text with vertical lines. The vertical equipment annotation box corresponds to this. Therefore, it is necessary to further classify the equipment annotation boxes to obtain the corresponding scheme for the subsequent text division. The specific method is to first count the number of horizontal and vertical lines, and determine the classification of the text annotation box by the direction of the line (horizontal or vertical). When the number of horizontal lines in the text box is greater than the number of vertical lines, it is regarded as a vertical annotation box; otherwise, it is a horizontal annotation box. The conditions satisfied by the vertical line are: |x l1 -x l2 |≤ε, the horizontal line satisfies the following conditions: |y l1 -y l2 |≤ε, where (x l1 ,y l1 )、(x l2 ,y l2 ) is the endpoint of the straight line, ε is the threshold value set by experience, indicating the minimum allowable error. In this drawing, ε = 10 -6 .
[0088] As a preferred implementation of this embodiment, the steps of classifying the equipment text and the complete set of equipment text according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point after determining the direction of the text annotation box are specifically as follows:
[0089] For vertical text annotation boxes, the text is pre-classified according to the coordinates of the vertical lines inside, that is, the horizontal coordinates of the vertical lines in the annotation box are extracted and sorted in ascending order. According to prior knowledge, three horizontal coordinates x v The sorting result x v1 <x v2 <x v3 , and then according to the text coordinates of the insertion point (x t ,y t ) and the horizontal coordinate, will satisfy the insertion point x v1 <x t <x v2 The text of the complete set of equipment is used as the text of the complete set of equipment, and x v2 <x t <x v3 The text in is used as the equipment text inside the complete set;
[0090] Then extract the ordinate y of the horizontal line h And sort y h1 >y h2 >...>y hn , where n is the number of horizontal lines detected, traversing the text insertion point y t, will satisfy the insertion point belongs to the adjacent horizontal line ordinate y hi >y t >y hi+1 The text is written into a list, where i = 1, 2, ..., n-1, and finally a list is obtained to represent the text information corresponding to a device;
[0091] Finally, based on the m vertical lines measured, by removing the longest vertical line, the remaining m-1 short vertical lines are recorded as L1, L2, ..., L m-1 , their ordinate range is [y v1 ,y v2 ],[y v2 ,y v3 ],...,[y vm-1 ,y vm ], and use it as the basis for the division of complete set equipment information, and set the vertical coordinate range of the insertion point in the equipment text of each list to meet the y vi >y t >y vi+1 The list where the text is located, that is, the equipment text within the corresponding remaining short vertical straight line ordinate belongs to the target set of equipment.
[0092] In this embodiment, for texts that do not contain short vertical lines but whose ordinates belong to the names of complete sets of equipment in the step "dividing equipment text by horizontal lines", they are classified as complete set of equipment texts with only one equipment, ensuring that all texts are processed and texts that are not within any vertical line range are classified into a specific group. For the text classification of the horizontal equipment annotation box, the corresponding horizontal and vertical operation methods are reversed.
[0093] In combination with the above steps, the operation steps of this embodiment are shown in the following figure: Figure 6 shown.
[0094] Embodiment 2:
[0095] The present embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, a method for text recognition and classification of electrical main wiring diagrams integrating CAD and image data as described in any embodiment of the present invention is implemented.
[0096] Embodiment three:
[0097] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a method for identifying and classifying text in an electrical main wiring diagram that integrates CAD and image data as described in any embodiment of the present invention.
[0098] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data, characterized in that: The specific steps include: The collected DWG format electrical main wiring diagram is converted into a high-resolution JPG format drawing, and the Canny edge detection algorithm is used to pre-process the drawing to distinguish between ordinary text and text annotation boxes in the drawing, and the coordinates and category information of all text annotation boxes are extracted; Collect the text content and insertion point coordinates and endpoint coordinate data of the straight line entity in the original DWG format electrical main wiring diagram, and standardize all coordinate data with the coordinate data of the target detection algorithm; When using the object detection algorithm for text detection, the size of the text detection box is enlarged to ensure that all text insertion point coordinates are covered, the relative position of the coordinates of the enlarged text detection box and the coordinates of the text insertion point is compared, and a text detection box of appropriate size is selected as the final text detection box for text detection; Divide all straight line entities into text annotation frames, and confirm the direction of the text annotation frames according to the directions of all straight line entities in each text annotation frame; After determining the direction of the text annotation box, the equipment text and complete set text are classified according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point.
2. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: The target detection algorithm is the YOLOv8 target detection model.
3. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 2, characterized in that: The steps of using the Canny edge detection algorithm to preprocess the drawings, distinguishing between ordinary text and text annotation boxes in the drawings, and extracting the coordinates and category information of all text annotation boxes are as follows: Firstly, the noise in the drawing is removed by Gaussian filtering to enhance the smoothness of the image; The Sobel operator is used to calculate the gradient magnitude and direction of the image, and clear edges are obtained through non-maximum suppression and double threshold processing; After detecting the edge contour of the drawing, the drawing is cropped based on the maximum circumscribed rectangular frame to ensure that only the valid area of the drawing is retained; The cropped image is divided into sub-images of the target size, and each sub-image is input into the YOLOv8 target detection model for processing and detection to distinguish between ordinary text and text standard libraries in the drawings to be detected; The detection results of all sub-images are combined to obtain the coordinates and category information of all text annotation boxes on the entire drawing.
4. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: The steps of collecting the text content in the original DWG format electrical main wiring diagram and its insertion point coordinates and the endpoint coordinate data of the straight line entity are specifically as follows: Use the ezdxf library to traverse the model space of the DWG file and extract the text content and its insertion point coordinates as well as the endpoint coordinate data of the line entity from the model space.
5. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: In the step of normalizing all coordinate data and the coordinate data of the target detection algorithm, the normalization formula is as follows: In the formula, x and y are the coordinates of the target point, x min 、x max ,y min ,y max are the boundary values of the drawings respectively.
6. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: The steps of dividing all straight line entities into text annotation frames are specifically as follows: Check whether the two endpoints of the target straight line are both within the boundary of the target text annotation box. If the condition is met, associate the target straight line with the target text annotation box, and traverse all straight line entities until there are straight line entities in all text annotation boxes.
7. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: The step of classifying the directions of the text annotation boxes according to the directions of all the straight line entities in the text annotation boxes is specifically as follows: Count the number of horizontal and vertical line entities in the text annotation frame, and determine the classification of the text annotation frame based on the direction of the line entities: when the number of horizontal lines in the text frame is greater than the number of vertical lines, it is considered a vertical text annotation frame; otherwise, it is a horizontal text annotation frame.
8. The method for identifying and classifying text in electrical main wiring diagrams by integrating CAD and image data according to claim 1, characterized in that: After determining the direction of the text annotation box, the steps of classifying the equipment text and the complete set of equipment text according to the horizontal and vertical coordinates of the straight line entity in the text box and the relative position of the text insertion point are specifically as follows: For vertical text annotation boxes, the text is pre-classified according to the coordinates of the vertical lines inside, that is, the horizontal coordinates of the vertical lines in the annotation box are extracted and sorted in ascending order. According to prior knowledge, three horizontal coordinates x v The sorting result x v1 <x v2 <x v3 , and then according to the text coordinates of the insertion point (x t ,y t ) and the horizontal coordinate, will satisfy the insertion point x v1 <x t <x v2 The text of the complete set of equipment is used as the text of the complete set of equipment. v2 <x t <x v3 The text in is used as the equipment text inside the complete set; Then extract the ordinate y of the horizontal line h And sort y h1 >y h2 >...>y hn , where n is the number of horizontal lines detected, traversing the text insertion point y t , will satisfy the insertion point belongs to the adjacent horizontal line ordinate y hi >y t >y hi+1 The text is written into a list, where i = 1, 2, ..., n-1, and finally a list is obtained to represent the text information corresponding to a device; Finally, based on the m vertical lines measured, by removing the longest vertical line, the remaining m-1 short vertical lines are recorded as L1, L2, ..., L m-1 , their ordinate range is [y v1 ,y v2 ],[y v2 ,y v3 ],...,[y vm-1 ,y vm ], and use it as the basis for the division of complete set equipment information, and set the vertical coordinate range of the insertion point in the equipment text of each list to meet the y vi >y t >y vi+1 The list where the text is located, that is, the equipment text within the corresponding remaining short vertical straight line ordinate belongs to the target set of equipment.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for identifying and classifying text in an electrical main wiring diagram that integrates CAD and image data as described in any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a method for identifying and classifying text in an electrical main wiring diagram that integrates CAD and image data as described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Engineering drawing character recognition method
CN114386504A
Cited By
Terminal block drawing terminal identification and cable connecting line matching method and system
CN121482819A