CN-117037203-B - Positioning method and device for dotted line frame in electrical drawing
Abstract
The invention discloses a positioning method and device for a dashed box in an electrical drawing, and relates to the technical field of image processing. The method comprises the steps of detecting the area where the interference electrical element is located in an electrical drawing through a YOLOv target detection algorithm, reserving coordinates of the identification result, covering the area where the interference electrical element is located with blank, preprocessing the covered partial drawing, constructing a broken line convolution kernel, performing hit-miss transformation on the original drawing, performing logic judgment, finding out the point with the largest occurrence times in the horizontal and vertical directions, and determining the boundary of a broken line frame in the electrical drawing. Compared with a direct deep learning detection method, the method has strong practicability and higher reliability, can solve the problem that a dotted line frame in an actual electrical drawing cannot be accurately positioned, and can improve the positioning result of the dotted line frame and the accuracy of a detection algorithm.
Inventors
- CHEN ZHONG
- CAO WEIGUO
- QIAN JING
Assignees
- 南京云阶电力科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20230817
Claims (9)
- 1. The positioning method for the dotted line frame in the electrical drawing is characterized by comprising the following steps: Detecting the area where the interference electric element is located in the electric drawing by YOLOv target detection algorithm; Reserving coordinates of the identification result, and covering the area where the interference electrical element is located by using a blank; preprocessing the covered local drawing; Constructing a broken line convolution kernel, and performing hit-miss transformation on the preprocessed drawing; carrying out logic judgment, finding out the point with the largest occurrence frequency in the horizontal and vertical directions, and determining the boundary of a broken line frame in an electrical drawing; detecting the region where the interfered electrical element is located by YOLOv target detection algorithm specifically comprises: the PDF is designed and drawn according to the actual electrical engineering requirements through AutoCAD, and then converted into an image format which can be processed by a computer; labeling the region where the interference electrical element is located in the image, training out model weight, and using the weight to detect the region of the interference electrical element in the electrical design drawing; the loss function of YOLOv algorithm includes bbox loss, object loss, and class loss, and the formula is as follows: + + Wherein, the Indicating that if the jth bbox in the ith cell is responsible for predicting this ground truth, then it is 1, otherwise it is 0; indicating that if the jth bbox in the ith cell is not responsible for predicting this ground truth, then it is 1, otherwise it is 0; indicating that if there is an object in the ith cell, it is 1, otherwise it is 0.
- 2. The positioning method for a dashed box in an electrical drawing according to claim 1, wherein the step of reserving coordinates for the identification result and covering the area where the interfering electrical element is located with a blank comprises the steps of: Setting a save-TXT parameter in YOLOv algorithm, and keeping the detected coordinates of the region of the interference electric element in the TXT document; and performing blank coverage on the target picture according to the region coordinates reserved in the TXT document, and obtaining a covered picture.
- 3. The method for positioning a dashed box in an electrical drawing according to claim 1, wherein the preprocessing of the covered partial drawing specifically comprises the following steps: Gray processing is carried out on the covered picture: ; Wherein, the Is the gray value of the gray scale, 、 、 The values of the three color channels of red, green and blue respectively; and carrying out binarization processing on the picture subjected to gray level processing: ; Wherein, the Is the pixel value after binarization, Is the gray value of the gray scale, Is a set threshold; Open operation, remove some interference of points: ; Wherein, the Is the original image of the object to be processed, Is a structural element of the material, and is a structural element, The operation of the switch is represented by an on-state, Indicating the operation of the etching process, Representing an expansion operation; image refinement, skeleton extraction, wherein the refinement conditions generally comprise: the number of pixels in the 8-neighborhood of p is between 2 and 6, the number of times of changing from 0 to 1 in the 8-neighborhood of p is 1, the three pixels of north, south and west of p are not all 1, and the three pixels of west, east and south of p are not all 1.
- 4. The method for locating a dashed box in an electrical drawing according to claim 1, wherein the step of constructing a dashed convolution kernel to perform hit-miss transformation on the original image comprises the steps of: Defining a structural element and a center point position; Removing the corrosion original picture by using a first convolution kernel; removing the complement of the corrosion original graph by using a second convolution kernel; performing hit miss transformation: ; Wherein, the Is the original image of the object to be imaged, Is a structural element of the material, and is a structural element, Indicating that the hit is not a middle transition, The intersection operation is represented by a sequence of the intersection operations, Representation of Is added to the complement of (a), Representation of Is a complement of (a); the two transformation results are combined.
- 5. The method for locating a dashed box in an electrical drawing according to claim 1, wherein the step of performing logic judgment to determine the boundary of the dashed box specifically comprises the steps of: Finding out the outline and obtaining coordinates of the dotted line points; finding out the point with the largest occurrence number in the horizontal direction; finding out the point with the largest occurrence number in the vertical direction; Positioning a dashed line frame: ; Wherein, the Is the coordinates of the upper left corner of the rectangle, Is the coordinates of the lower right corner of the rectangle.
- 6. A positioning device for a dashed box in an electrical drawing, the device using the positioning method according to any one of claims 1-5, characterized in that the device comprises: the interference element detection module is used for detecting the area where the interference electrical element is located in the electrical drawing through YOLOv target detection algorithm; The blank covering module is used for reserving coordinates of the identification result and covering the area where the interference electrical element is located by utilizing a blank; The pretreatment module is used for carrying out pretreatment on the covered local drawing; The hit miss transformation module is used for constructing a broken line convolution kernel and performing hit miss transformation on the preprocessed drawing; and the logic judgment module is used for carrying out logic judgment and determining the boundary of a broken line frame in the electrical drawing.
- 7. The positioning device for a dashed box in an electrical drawing according to claim 6, wherein the interfering element detecting module comprises: The marking unit is used for marking the area where the interference element in the original picture is located; The training unit is used for training YOLOv the target detection model by using the marked sample picture; And the detection unit is used for detecting the area where the interference element in the original picture is located by using the trained YOLOv target detection model.
- 8. The positioning device for a dashed box in an electrical drawing according to claim 6, wherein the blank covering module specifically comprises: The coordinate storage unit is used for setting a save-TXT parameter in the YOLOv target detection model when the interference element area is detected, and storing the detected coordinates of the area where the interference element is located in a TXT document; and the covering unit is used for performing blank filling on the local original picture according to the region coordinates reserved in the TXT document to obtain a picture after blank covering.
- 9. The positioning device for a dashed box in an electrical drawing according to claim 6, wherein the covering unit specifically comprises: a file format conversion subunit, configured to convert the TXT document file in YOLO format into an XML markup file in VOC format; the covering subunit is used for reading the region coordinates reserved in the XML annotation file, and performing blank filling on the local original picture to obtain a picture after blank covering; The preprocessing module specifically comprises: the graying unit is used for carrying out gray processing on the covered picture; The binarization unit is used for carrying out binarization processing on the picture subjected to gray level processing; the hit miss conversion module specifically includes: the corrosion unit is used for corroding the preprocessed picture and the complement picture thereof; a subtracting unit for subtracting the effects after corrosion; The logic judging module specifically comprises: A horizontal unit for finding out a point having the largest number of occurrences in a horizontal direction; a vertical unit for finding out a point having the largest number of occurrences in a vertical direction; and the calculating unit is used for determining the boundary of the broken line frame in the electrical drawing according to the calculation results of the horizontal unit and the vertical unit.
Description
Positioning method and device for dotted line frame in electrical drawing Technical Field The invention relates to the technical field of image processing methods, in particular to a positioning method and device for a dashed frame in an electrical drawing. Background In the process of advancing the digitalization of the transformer substation drawing, the common practice is to conduct relevant information connection matching after drawing information is identified, so that the complete information and actual connection relation of the real drawing is simulated in a digital system. However, in the partial information of the electrical drawing, various connection relationships may occur, such as a letter appearing inside the dotted line box and a letter appearing outside the dotted line box, which are different. If characters are directly recognized, their attributes are the same, so that a dotted frame is recognized, and two characters are separated and recognized, and attributes are assigned to the characters. In order to deal with the above problems, the conventional method is considered to recognize the dashed box by a deep learning method, but this recognizes the text outside the dashed box together, and the problem cannot be solved. Disclosure of Invention The invention aims to provide a positioning method and a positioning system capable of accurately identifying a dotted line frame in an electrical drawing. In order to solve the technical problems, the technical scheme adopted by the invention is that the positioning method for the dotted line frame in the electrical drawing comprises the following steps: Detecting the area where the interference electric element is located in the electric drawing by YOLOv target detection algorithm; Reserving coordinates of the identification result, and covering the area where the interference electrical element is located by using a blank; preprocessing the covered local drawing; Constructing a broken line convolution kernel, and performing hit-miss transformation on the preprocessed drawing; And carrying out logic judgment, finding out the point with the largest occurrence frequency in the horizontal and vertical directions, and determining the boundary of a broken line frame in the electrical drawing. The invention also discloses a positioning device for the dashed line frame in the electrical drawing, which comprises: the interference element detection module is used for detecting the area where the interference electrical element is located in the electrical drawing through YOLOv target detection algorithm; The blank covering module is used for reserving coordinates of the identification result and covering the area where the interference electrical element is located by utilizing a blank; The pretreatment module is used for carrying out pretreatment on the covered local drawing; The hit miss transformation module is used for constructing a broken line convolution kernel and performing hit miss transformation on the preprocessed drawing; and the logic judgment module is used for carrying out logic judgment and determining the boundary of a broken line frame in the electrical drawing. The method has the beneficial effects that firstly, the area of the interference electric element in the original drawing picture is required to be detected, the area is subjected to blank filling to obtain a picture covered by the blank, the picture is converted into a gray level diagram and then binarized, the binary image is subjected to skeleton extraction and refinement after operation, the interference of some noise points is removed, special structural elements are constructed according to the characteristics of a dotted line, the original picture is subjected to hit-miss transformation, the detected points are subjected to logic judgment, the point with the largest occurrence times in the horizontal and vertical directions is found, and the boundary of a dotted line frame is determined. According to the method, the dotted line frame in the electrical drawing can be accurately identified through the steps, and relevant information connection matching is carried out, so that the complete information and actual connection relation of the real drawing can be simulated in a digital system. Drawings The invention will be described in further detail with reference to the drawings and the detailed description. FIG. 1 is a flowchart of a positioning method according to an embodiment of the invention; FIG. 2 is a schematic diagram of a positioning method according to an embodiment of the invention; FIG. 3 is an original image of an area of an electrical drawing provided in accordance with an embodiment of the present invention; FIG. 4 is a diagram of a blank coverage processed by a method according to an embodiment of the invention; FIG. 5 is a gray scale chart according to a first embodiment of the present invention; FIG. 6 is a diagram illustrating a binarization map according to