Method for scanning and converting paper power engineering drawings into electronic CAD drawings

Through deep learning and OpenCV technology, the paper power engineering drawings are targeted and detected and identified, which solves the problem of converting paper drawings into electronic version CAD drawings, and efficient and accurate electronic drawing conversion is achieved, which improves management efficiency and recognition accuracy.

CN114529936BActive Publication Date: 2025-04-15BAOSHAN POWER SUPPLY BUREAU OF YUNNAN POWER GRID CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210163747.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-22
Publication Date
2025-04-15
Estimated Expiration
2042-02-22

AI Technical Summary

Technical Problem

The prior art is difficult to effectively handle the electronic conversion of existing paper power engineering drawings, which makes it difficult to obtain and manage electronic files.

Method used

Object detection in deep learning combined with OpenCV's operation of pictures is used to realize object detection and identification of paper power engineering drawings, and converted into electronic version of CAD drawings through scanning. Specific steps include image rotation, cutting, binarization, noise reduction, segmentation, character and component recognition, line detection and clustering, and finally generate layer content in the DXF file.

Benefits of technology

It realizes efficient and accurate conversion of paper power engineering drawings into electronic version CAD drawings, improves character recognition accuracy to more than 95% and component recognition rate to more than 92%, and improves the utilization rate of electrical drawings and information management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114529936B_ABST
    Figure CN114529936B_ABST
Patent Text Reader

Abstract

The present invention relates to a method for scanning and converting paper electric power engineering drawings into electronic CAD drawings, and belongs to the technical field of electric power engineering drawings. The method first eliminates part of the image content that affects target detection, and then performs binarization and noise reduction processing on the image of the part to be identified. The processed image is first subjected to character frame selection and recognition, and the characters are covered according to the selection frame, and then the detection model of the electrical component is used to detect and identify the component part, and then line recognition and clustering are performed to obtain the line width, and the lines on the image are covered according to the coordinates, and finally the recognized results are generated in the CAD file according to the coordinates at the time of recognition. The present invention solves the problem of converting the above-mentioned paper drawings of electric power engineering into electronic CAD drawings, and utilizes the target detection in deep learning combined with the basic OpenCV operation on the image to more efficiently and accurately perform target detection and recognition on paper electric power engineering drawings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of electric power engineering drawings, and in particular relates to a method for scanning and converting paper electric power engineering drawings into electronic CAD drawings. Background Art

[0002] Drawings are one of the most basic means of production in power engineering projects. They play a very important role in project construction, acceptance, operation and maintenance, countermeasures inspection and other work. Therefore, power companies also attach great importance to the archiving and management of power engineering drawings. There are clear requirements in the company's archive management system and anti-accident measures inspection work forms.

[0003] Power engineering drawings require both the uniqueness of the drawings and the extensiveness of being shared by multiple professions. In the past, power drawings were all paper drawings that were uniformly printed, filed, stored, and maintained by dedicated personnel. With the development of computer technology, power engineering drawings have gradually been digitized, and electronic drawings are convenient for transmission, review, preservation, and modification. When using new systematic, information-based, and intelligent solutions to manage electronic drawings, how to deal with existing paper power engineering drawings is an urgent problem to be solved. For the convenience of management, the electronic version of the paper power drawings should be archived, but due to the time span, the electronic files are no longer available.

[0004] Therefore, it is particularly important to convert paper power engineering drawings into electronic CAD drawings through scanning. Summary of the invention

[0005] The purpose of the present invention is to address the deficiencies of the prior art and provide a method for scanning and converting paper power engineering drawings into electronic CAD drawings. The method solves the problem of converting the above-mentioned paper power engineering drawings into electronic CAD drawings. It utilizes target detection in deep learning combined with basic OpenCV operations on images to more efficiently and accurately perform target detection and recognition on paper power engineering drawings.

[0006] To achieve the above purpose, the technical solution adopted by the present invention is as follows:

[0007] The method for scanning and converting paper power engineering drawings into electronic CAD drawings includes the following steps:

[0008] Step (1), according to the four corner points drawn by the user on the scanned image, the angle at which the scanned image needs to be rotated is calculated and the image is rotated, the coordinates of the drawn points after rotation are calculated according to the coordinates of the drawn points and the rotation angle, and the image is cut according to these coordinates to remove the border;

[0009] Step (2), binarizing and denoising the image cut in step (1);

[0010] Step (3), dividing the image processed in step (2) into equal-sized pieces;

[0011] Step (4), performing character detection on the segmented images in turn, generating a character circumscribed rectangle based on the character detection result; cropping the character images one by one according to the circumscribed rectangle; then sending the character images to the OCR model for recognition, and screening the results based on the recognition accuracy;

[0012] Step (5), converting the obtained character coordinates to obtain the original coordinates corresponding to the character area;

[0013] Step (6), according to the original coordinates of the character area, the characters are covered on the original image; the covered image is sent to the detection model of the electrical component to obtain the recognition result of the component;

[0014] Step (7), according to the component recognition result, the component is covered on the original image, and the covered image is subjected to rapid line detection, and the lines are classified into vertical lines, horizontal lines, and oblique lines; the vertical lines and horizontal lines are connected and merged; and then the three types of lines are clustered respectively to obtain the coordinates of the lines and the corresponding line widths;

[0015] Step (8), creating layers in the DXF file, and generating required content in the corresponding layers according to the recognition results of characters, components, and lines;

[0016] The electrical component detection model adopts the MobileNet V3-YOLO V3 model. When the MobileNet V3-YOLO V3 model is trained, the existing component CAD file is first exported as an image, and then the components in the image are annotated manually. The image exported from the component CAD file is used as output, and the manually annotated content is used as output for training.

[0017] Furthermore, preferably, in step (2), the specific method of binarization processing is:

[0018] First, separate the image by color channel to obtain the red channel of the image, that is, obtain the original red channel image;

[0019] When binarizing the original red channel image, select the THRESH_BINARY function and pass in a parameter cv2.THRESH_OTSU to set the threshold to 0, which will automatically optimize.

[0020] Multiply the binary image of the red channel by the first threshold and then add it to the original image of the red channel. Figure 1Pass it into the binarization function and convert the resulting image back to 3 channels to obtain the binary image after removing the background color.

[0021] Further, preferably, the first threshold is 95%.

[0022] Furthermore, preferably, in step (2), during the noise reduction process, the kernel uses MORPH_CROSS.

[0023] Furthermore, preferably, in step (3), the image is divided into squares with a side length of 550 to 850 pixels.

[0024] Furthermore, preferably, in step (4), the character image is sent to the OCR model for recognition, and when the accuracy is lower than a second threshold, the recognition result is deleted; when the recognition accuracy is higher than the second threshold, the recognition result is retained; and the second threshold is not less than 75%.

[0025] Further, preferably, fast line detection based on OpenCV is used to obtain line data, including x and y values ​​of the starting coordinates and x and y values ​​of the end coordinates of the line;

[0026] The x with a smaller value is determined as the starting coordinate x value, and the x with a larger value is determined as the ending coordinate x value, and the y value is modified according to the corresponding relationship.

[0027] Further, preferably, in step (7), when classifying the lines, the offsets of the x and y values ​​are first calculated; the offset of the x value is obtained by subtracting the x value of the starting coordinate from the x value of the end coordinate of the line, and the offset of the y value is obtained by subtracting the y value of the starting coordinate from the y value of the end coordinate of the line;

[0028] If the x-coordinate offset is greater than the third threshold value, and the y-coordinate offset is less than the third threshold value, the line is a horizontal line;

[0029] If the y-coordinate offset is greater than the third threshold value, and the x-coordinate offset is less than the third threshold value, the line is a vertical line;

[0030] If the offsets of the x-coordinate and the y-coordinate are both greater than the third threshold, the line is a diagonal line; the classified line data are stored separately;

[0031] The third threshold value is between 10 and 20;

[0032] The specific method for clustering the three lines is:

[0033] The vertical lines are clustered according to the x-coordinate, and the difference between the x-coordinates of the two lines is calculated to determine the line width. The horizontal lines are clustered according to the y-coordinate, and the difference between the y-coordinates of the two lines is calculated to determine the line width. When the oblique lines are clustered, the coordinates of the center point of the line are calculated, and the clustering and line width are calculated based on this coordinate.

[0034] When clustering, the distance between the centroids of the lines is used as the basis for clustering. When the distance between the centroids of the lines is less than the threshold, the two lines are identified as two sides of a line, that is, they are clustered into one line. The distance between the centroids is the width of the line after clustering. The threshold is set to 10-20.

[0035] Furthermore, preferably, in step (8), the required content is generated in the corresponding layer according to the recognition results of the characters, elements and lines, and the specific method is as follows:

[0036] First, insert characters in the character layer, then insert lines in the line layer, insert components in the component layer, and finally generate a frame in the frame layer and insert an information frame in the information layer.

[0037] Furthermore, preferably, the method includes step (9), inserting the original image into the original layer and performing manual error correction.

[0038] In the present invention, the coordinates of the lines are represented by the pixel coordinates corresponding to the lines on the picture.

[0039] In the present invention, the MobileNet V3-YOLO V3 model is an existing model, also known as a YOLO V3 model based on Mobile V3, and the present invention does not make any improvements to it.

[0040] The present invention proposes a method for performing character recognition, line recognition, and component recognition on a scanned image of a paper power engineering drawing to obtain the contents of each part of the drawing and the coordinates corresponding to the contents, and creates a DXF file in layers in an electronic version of the CAD drawing according to the coordinates and the recognized contents, and generates corresponding contents according to the coordinate positions, thereby completing the entire process of converting the scanned image of the engineering drawing into a DXF file.

[0041] Compared with the prior art, the present invention has the following beneficial effects:

[0042] The present invention provides a method for scanning and converting paper power engineering drawings into electronic CAD drawings. The method first requires the angle correction of the picture, and the binarization and noise reduction processing of the corrected picture, and then the picture is segmented, and the part of the picture content that affects the target detection is eliminated, and then the picture of the part to be identified is binarized and noise-reduced. The processed picture is firstly subjected to character selection and recognition, and the characters are covered according to the selection box, and then the detection model of the electrical component is used to detect and identify the component part, and then line recognition and clustering are performed to obtain line width, and the lines on the picture are covered according to the coordinates, and finally the recognized result is generated in the CAD file after conversion according to the coordinates at the time of recognition.

[0043] This method fills the gap in the field of converting paper scanned drawings to CAD drawings, and in terms of accuracy, the accuracy of character recognition by this method reaches more than 95%, and the recognition rate of 25 trained components reaches more than 92%. This method can effectively improve the utilization rate of paper electrical drawings and further accelerate the process of information management of electrical drawings. It can save space costs and maintenance costs for electrical drawing management. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 It is a structural diagram of the method for scanning and converting paper power engineering drawings into electronic CAD drawings of the present invention;

[0045] Figure 2 It is a timing diagram of the method for scanning and converting paper power engineering drawings into electronic CAD drawings of the present invention;

[0046] Figure 3 It is a flow chart of a method for scanning and converting paper power engineering drawings into electronic CAD drawings of the present invention;

[0047] Figure 4 It is a scanned image of a paper power engineering drawing in the application example;

[0048] Figure 5 is the rotation diagram obtained in the application example;

[0049] Figure 6 This is the image after binarization and noise reduction in the application example.

[0050] Figure 7 This is a folder containing medium-sized partitions of the application instance;

[0051] Figure 8 It is a schematic diagram of the circumscribed regular rectangle of the character in the application example;

[0052] Fig. 9 It is a schematic diagram of a character image in an application example;

[0053] Fig.10 It is a character recognition result diagram in the application example;

[0054] Fig.11 It is the component identification result diagram in the application example;

[0055] Fig.12 It is the result graph of the line information table in the application example;

[0056] Fig.13 It is the dxf file drawing in the application example. DETAILED DESCRIPTION

[0057] The present invention is further described in detail below in conjunction with embodiments.

[0058] Those skilled in the art will appreciate that the following examples are only used to illustrate the present invention and should not be considered to limit the scope of the present invention. If no specific techniques or conditions are specified in the examples, the techniques or conditions described in the literature in the art or the product specifications are used. If the manufacturer of the materials or equipment used is not specified, they are all conventional products that can be purchased.

[0059] The method for scanning and converting paper power engineering drawings into electronic CAD drawings includes the following steps:

[0060] Step (1), according to the four corner points drawn by the user on the scanned image, the angle at which the scanned image needs to be rotated is calculated and the image is rotated, the coordinates of the drawn points after rotation are calculated according to the coordinates of the drawn points and the rotation angle, and the image is cut according to these coordinates to remove the border;

[0061] Step (2), binarizing and denoising the image cut in step (1);

[0062] Step (3), dividing the image processed in step (2) into equal-sized pieces;

[0063] Step (4), performing character detection on the segmented images in turn, generating a character circumscribed rectangle based on the character detection result; cropping the character images one by one according to the circumscribed rectangle; then sending the character images to the OCR model for recognition, and screening the results based on the recognition accuracy;

[0064] Step (5), converting the obtained character coordinates to obtain the original coordinates corresponding to the character area;

[0065] Step (6), according to the original coordinates of the character area, the characters are covered on the original image; the covered image is sent to the detection model of the electrical component to obtain the recognition result of the component;

[0066] Step (7), according to the component recognition result, the component is covered on the original image, and the covered image is subjected to rapid line detection, and the lines are classified into vertical lines, horizontal lines, and oblique lines; the vertical lines and horizontal lines are connected and merged; and then the three types of lines are clustered respectively to obtain the coordinates of the lines and the corresponding line widths;

[0067] Step (8), creating layers in the DXF file, and generating required content in the corresponding layers according to the recognition results of characters, components, and lines;

[0068] The electrical component detection model adopts the MobileNet V3-YOLO V3 model. When the MobileNet V3-YOLO V3 model is trained, the existing component CAD file is first exported as an image, and then the components in the image are annotated manually. The image exported from the component CAD file is used as output, and the manually annotated content is used as output for training.

[0069] In the preferred embodiment, in step (2), the specific method of binarization processing is:

[0070] First, separate the image by color channel to obtain the red channel of the image, that is, obtain the original red channel image;

[0071] When binarizing the original red channel image, select the THRESH_BINARY function and pass in a parameter cv2.THRESH_OTSU to set the threshold to 0, which will automatically optimize.

[0072] Multiply the binary image of the red channel by the first threshold and then add it to the original image of the red channel. Figure 1 Pass it into the binarization function and convert the resulting image back to 3 channels to obtain the binary image after removing the background color.

[0073] Preferably, the first threshold is 95%.

[0074] Preferably, in step (2), during the noise reduction process, the kernel uses MORPH_CROSS.

[0075] In a preferred embodiment, in step (3), the image is divided into squares with a side length of 550 to 850 pixels.

[0076] In a preferred embodiment, in step (4), the character image is sent to the OCR model for recognition. When the accuracy is lower than a second threshold, the recognition result is deleted; when the recognition accuracy is higher than the second threshold, the recognition result is retained; and the second threshold is not less than 75%.

[0077] The preferred solution is to use fast line detection based on OpenCV to obtain line data, including the x and y values ​​of the starting coordinates of the line and the x and y values ​​of the end coordinates;

[0078] The x with a smaller value is determined as the starting coordinate x value, and the x with a larger value is determined as the ending coordinate x value, and the y value is modified according to the corresponding relationship.

[0079] In the preferred embodiment, in step (7), when classifying the lines, the offsets of the x and y values ​​are first calculated; the offset of the x value is obtained by subtracting the x value of the starting coordinate from the x value of the end coordinate of the line, and the offset of the y value is obtained by subtracting the y value of the starting coordinate from the y value of the end coordinate of the line;

[0080] If the x-coordinate offset is greater than the third threshold value, and the y-coordinate offset is less than the third threshold value, the line is a horizontal line;

[0081] If the y-coordinate offset is greater than the third threshold value, and the x-coordinate offset is less than the third threshold value, the line is a vertical line;

[0082] If the offsets of the x-coordinate and the y-coordinate are both greater than the third threshold, the line is a diagonal line; the classified line data are stored separately;

[0083] The third threshold value is between 10 and 20;

[0084] The specific method for clustering the three lines is:

[0085] The vertical lines are clustered according to the x-coordinate, and the difference between the x-coordinates of the two lines is calculated to determine the line width. The horizontal lines are clustered according to the y-coordinate, and the difference between the y-coordinates of the two lines is calculated to determine the line width. When the oblique lines are clustered, the coordinates of the center point of the line are calculated, and the clustering and line width are calculated based on this coordinate.

[0086] When clustering, the distance between the centroids of the lines is used as the basis for clustering. When the distance between the centroids of the lines is less than the threshold, the two lines are identified as two sides of a line, that is, they are clustered into one line. The distance between the centroids is the width of the line after clustering. The threshold is set to 10-20.

[0087] In the preferred embodiment, in step (8), the required content is generated in the corresponding layer according to the recognition results of the characters, elements and lines, and the specific method is as follows:

[0088] First, insert characters in the character layer, then insert lines in the line layer, insert components in the component layer, and finally generate a frame in the frame layer and insert an information frame in the information layer.

[0089] The preferred solution includes step (9), inserting the original image into the original layer and performing manual error correction.

[0090] The OCR model described in the present invention is an existing open source model, which can be retrained by providing training data required for recognition, thereby obtaining a higher recognition accuracy rate. The OCR model can also be used for recognition, but the recognition accuracy rate will be insufficient. OpenCV is an existing open python function library.

[0091] Preferred solutions, specifically:

[0092] (1) To address the problem of tilted scanned images, an interactive point selection and rotation method is used. According to the points drawn by the user on the image, the point drawing method is as follows: click the image with the mouse to obtain the coordinates corresponding to the click point. The four points required are the coordinate point of the upper left corner of the image, the coordinate point of the upper right corner of the image, the coordinate point of the lower right corner of the image, and the coordinate point of the lower left corner of the image.

[0093] OpenCV's minAreaRect function is used to calculate the angle that the image needs to be rotated, and the image is rotated according to the calculated angle. The segmentation of the image selection area is also based on interactive point selection. The coordinates of the points after rotation are calculated based on the coordinates of the four corner points and the rotation angle, and the image is segmented based on these four coordinates to remove meaningless border interference.

[0094] (2) Image preprocessing requires binarization and noise reduction. This part can be performed using the basic functions of OpenCV and can obtain relatively suitable results. Since the scanned images of electrical drawings are basically blue-background images, in order to remove the blue background, it is necessary to obtain the red channel of the image before binarization. When binarizing the red channel image, select the THRESH_BINARY function and pass in an additional parameter cv2.THRESH_OTSU to set the threshold to 0. The binarization algorithm in the OpenCV library function will find the optimal threshold. Multiply the binarized image by the threshold (95%) to adjust it, and then compare it with the original red channel image. Figure 1 Pass it into the binarization function and convert the resulting image back to 3 channels to obtain the binary image after removing the background color. When performing noise reduction processing, determine the anchor point according to the size of the kernel. Due to the complexity of power engineering drawings, the cross kernel (MORPH_CROSS) is a more suitable choice.

[0095] Among them, multiplying the image by the threshold means multiplying the entire image by 95%. Because the image is saved in matrix form in OpenCV, the matrix of the image can be multiplied, so the entire image can be multiplied by 95%.

[0096] (3) Cut the preprocessed image to a fixed size. For better character recognition and component recognition, we need to cut a complete denoised image into equal sizes by pixel. For the best recognition effect, the length and width of the image should be set within the range of 550 to 850 pixels.

[0097] (4) When performing character recognition, it is first necessary to detect characters based on the OCR model, obtain the circumscribed rectangular coordinates of the characters, cut the image according to the circumscribed rectangular coordinates, cut out the text images in the same field, and then perform separate character recognition on each character image after cutting. By reducing other interference factors (cut the characters to be recognized from the original image to reduce the interference of other contents on the image, such as lines and components on character recognition), the influence of other factors on the character recognition results can be reduced. Use the OCR model to perform character recognition and filter according to the accuracy of the recognition results. When filtering the recognition results, compare the recognition accuracy calculated by OCR with the set threshold. If the accuracy is less than the threshold, the recognition result will be discarded. If the accuracy is greater than the threshold, the recognition result will be retained. After many experiments, the threshold needs to be set above 75% to achieve the screening of recognition results.

[0098] (5) The MobileNet V3-YOLO V3 model is used to train the detection model of electrical components. Electrical components have many small targets, and small target detection has always been a difficult problem in target detection. Multi-scale training methods, random cropping, and random flipping methods are used to achieve data enhancement and train the model. Before training the model, the image data is collected, the CAD drawings are exported as images, and the data is labeled manually. After training, the existing component recognition function has an accuracy rate of more than 92%, and can recognize 25 common components.

[0099] When training the MobileNet V3-YOLO V3 model, the existing component CAD file is first exported as an image, and then the components in the image are annotated manually (different components can be annotated with different numbers). The image exported from the component CAD file is used as output, and the manually annotated content is used as output for training to obtain a detection model for electrical components.

[0100] The 25 common components are: mutual inductor, coil, voltmeter, slash block, terminal, terminal block, resistor, grounding, switch, circuit breaker, pressure plate, diode, ammeter, transformer, indicator, inductor, circle, power supply, battery, small current grounding line selection, reactor, fuse, capacitor, voltage transformer, lightning arrester; when manually labeled, they can be labeled in order from 1 to 25. The accuracy of the trained model can reach more than 92%.

[0101] (6) Line detection is achieved through the method of fast line detection, and the line width is calculated based on the coordinates of the identification line generated by the line edge. The default fast line detector is created using the ximgproc.createFastLineDetector function of opencv, line vectors are obtained from the image, and similar line vectors are connected and merged through clustering. The line width threshold is set to filter the line edge identification line, and the line width of the line is calculated. The threshold can be set according to the line width. After repeated experiments, the standard line width threshold is set at 10 to 20, which can better achieve line clustering.

[0102] (7) Use the ezdxf library function to build DXF drawings. DXF files are a branch type of CAD file types and a graphic storage format in CAD file types. Because DXF drawings support the hierarchical creation of multiple layers, you can create Lines layer, Unit layer, Character layer, Frame layer, Inform layer, and O-image layer respectively, and create the recognized content in the corresponding layers respectively, which helps to better understand and modify the generated DXF. Before inserting lines, components and characters, the obtained coordinates need to be converted. Because in the OpenCV mode, the origin of the coordinate system is the vertex in the upper left corner of the image, while the origin of the coordinate system in the CAD drawing is in the lower left corner, so we need to convert the coordinates of the character recognition so that there will be no misalignment when inserting. When converting the coordinates, it is necessary to judge the pixel size of the image and calculate the corresponding coordinates of the content to be inserted in the CAD drawing based on the length and width pixel ratio of the image. Use the add_text function to add characters, use the add_line function to add lines, use multiple functions to create drawing frames corresponding to different paper widths, and use the add_image function to add information tables into the DXF file.

[0103] The method steps of the present invention are:

[0104] (1) For the scanned paper drawings that need to be converted into CAD drawings, it is necessary to distinguish which parts need to be identified and which parts are irrelevant. According to the four corner points drawn by the user on the scanned image, the angle that the scanned image needs to be rotated is calculated and rotated. The coordinates of the points after rotation are calculated based on the coordinates of the points and the rotation angle, and the image is cut based on these coordinates to remove the border;

[0105] (2) Binarize and denoise the cut images;

[0106] (3) Divide the preprocessed image into equal-sized pieces. Perform character detection on the segmented uniform-sized pictures in turn, and generate a regular circumscribed rectangle based on the character detection results;

[0107] (4) Crop the character images one by one according to the coordinates of the circumscribed rectangle result, and save them. Send the character images to the OCR model for recognition, and filter the results according to the recognition accuracy;

[0108] (5) Convert the obtained character coordinates. Since each image for character detection is a cropped image, the obtained character coordinates need to be reverse converted to obtain the original coordinates corresponding to the character area;

[0109] (6) Mask the characters on the original image based on the character recognition results. Send the masked image to the electrical component detection model to obtain the component detection results;

[0110] (7) Cover the components on the original image according to the component recognition results, perform fast line detection on the covered image, and classify the lines into vertical lines, horizontal lines, and oblique lines. Connect and merge the vertical lines and horizontal lines, and then cluster the three types of lines separately to obtain the line coordinates and corresponding line widths;

[0111] (8) Create layers in the DXF file and generate the required content in the corresponding layers based on the previous recognition results. First, insert characters in the character layer, then insert lines in the line layer, insert components in the component layer, and finally generate a frame in the frame layer and insert an information frame in the information layer;

[0112] Application Examples

[0113] The application example is as follows. This example is to rotate points and cut pictures according to the order of scanning of a paper power drawing; binarization and noise reduction; equal size segmentation and saving; character detection and character area selection and marking; cutting by selection box; character recognition, and data screening according to the accuracy of character recognition; character masking and component detection and recognition; component masking and line detection and line clustering; create dxf files, and create layers, insert characters, components, and lines in them. After the above steps, the scanned picture of the paper power drawing is converted into an electronic CAD picture.

[0114] Scanned paper power engineering drawings Figure 4 The specific method is as follows:

[0115] (1) According to the four corner points drawn by the user on the scanned image, the angle at which the scanned image needs to be rotated is calculated and the image is rotated. The coordinates of the drawn points after rotation are calculated based on the coordinates of the drawn points and the rotation angle. The image is cut based on these coordinates to remove the border, and the image is obtained as follows: Figure 5 Rotation diagram shown.

[0116] (2) Binarize and denoise the image cut in step (1). The result is as follows: Figure 6 shown.

[0117] (3) Divide the image processed in step (2) into equal sizes to obtain Figure 7 The following are the folders for storing multiple partition maps.

[0118] (4) Perform character detection on the segmented images one by one, and generate the character's circumscribed rectangle based on the character detection results; the result is as follows: Figure 8 shown.

[0119] (5) Crop the character images one by one according to the coordinates of the circumscribed rectangle result, and save them. The result is as follows: Fig. 9 shown.

[0120] (6) The character image is sent to the OCR model for recognition, and the results are screened according to the recognition accuracy. The character recognition results are as follows: Fig.10 As shown. The obtained character coordinates are transformed to obtain the original coordinates corresponding to the character area.

[0121] (7) According to the original coordinates of the character area, the characters are covered on the original image; the covered image is sent to the electrical component detection model to obtain the component recognition result; the component information table result is as follows Fig.11 shown.

[0122] (8) According to the component recognition results, the components are covered on the original image, and the covered image is quickly detected and the lines are classified into vertical lines, horizontal lines, and oblique lines; the vertical lines and horizontal lines are connected and merged; then the three types of lines are clustered separately to obtain the line coordinates and corresponding line widths. The line information table results are as follows: Fig.12 shown.

[0123] (9) Create layers in the DXF file and generate the required content in the corresponding layers based on the recognition results of characters, components, and lines. The final DXF file is as follows: Fig.13 shown.

[0124] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A method for scanning and converting paper power engineering drawings into electronic CAD drawings, characterized in that: The steps include: Step (1), according to the four corner points drawn by the user on the scanned image, the angle at which the scanned image needs to be rotated is calculated and the image is rotated, the coordinates of the drawn points after rotation are calculated according to the coordinates of the drawn points and the rotation angle, and the image is cut according to these coordinates to remove the border; Step (2), binarizing and denoising the image cut in step (1); Step (3), dividing the image processed in step (2) into equal-sized pieces; Step (4), performing character detection on the segmented images in turn, generating a character circumscribed rectangle based on the character detection result; cropping the character images one by one according to the circumscribed rectangle; then sending the character images to the OCR model for recognition, and screening the results based on the recognition accuracy; Step (5), converting the obtained character coordinates to obtain the original coordinates corresponding to the character area; Step (6), masking the characters on the original image according to the original coordinates of the character area; The masked image is sent to the detection model of the electrical component to obtain the recognition result of the component; Step (7), according to the component recognition result, the component is covered on the original image, and the covered image is subjected to rapid line detection, and the lines are classified into vertical lines, horizontal lines, and oblique lines; the vertical lines and horizontal lines are connected and merged; and then the three types of lines are clustered respectively to obtain the coordinates of the lines and the corresponding line widths; Step (8), creating a layer in the DXF file, and generating the required content in the corresponding layer according to the recognition results of the characters, components, and lines; The electrical component detection model adopts the MobileNet V3-YOLO V3 model. When the MobileNet V3-YOLO V3 model is trained, the existing component CAD file is first exported as an image, and then the components in the image are annotated manually. The image exported from the component CAD file is used as output, and the manually annotated content is used as output for training.

2. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: In step (2), the specific method of binarization processing is: First, separate the image by color channel to obtain the red channel of the image, that is, obtain the original red channel image; When binarizing the original red channel image, select the THRESH_BINARY function and pass in a parameter cv2.THRESH_OTSU to set the threshold to 0, which will automatically optimize. Multiply the red channel binarized image by the first threshold, and then pass it into the binarization function together with the red channel original image, and convert the resulting image back to 3 channels to obtain the binarized image after removing the background color.

3. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 2, characterized in that: The first threshold is 95%.

4. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: In step (2), when performing noise reduction processing, the kernel uses MORPH_CROSS.

5. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: In step (3), the image is divided into squares with a side length of 550 to 850 pixels.

6. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: In step (4), the character image is sent to the OCR model for recognition. When the accuracy is lower than the second threshold, the recognition result is deleted; when the recognition accuracy is higher than the second threshold, the recognition result is retained; The second threshold is not less than 75%.

7. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: Use OpenCV-based fast line detection to obtain line data, including the x, y values ​​of the starting coordinates of the line and the x, y values ​​of the end coordinates; The x with a smaller value is determined as the starting coordinate x value, and the x with a larger value is determined as the ending coordinate x value, and the y value is modified according to the corresponding relationship.

8. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 7, characterized in that: In step (7), when classifying the lines, first calculate the offset of the x and y values; subtract the x value of the starting coordinate from the x value of the end coordinate of the line to obtain the offset of the x value, and subtract the y value of the starting coordinate from the y value of the end coordinate of the line to obtain the offset of the y value; If the x-coordinate offset is greater than the third threshold value, and the y-coordinate offset is less than the third threshold value, the line is a horizontal line; If the y-coordinate offset is greater than the third threshold value, and the x-coordinate offset is less than the third threshold value, the line is a vertical line; If the offsets of the x-coordinate and the y-coordinate are both greater than the third threshold, the line is a diagonal line; the classified line data are stored separately; The third threshold value is between 10 and 20; The specific method for clustering the three lines is: The vertical lines are clustered according to the x-coordinate, and the difference between the x-coordinates of the two lines is calculated to determine the line width. The horizontal lines are clustered according to the y-coordinate, and the difference between the y-coordinates of the two lines is calculated to determine the line width. When the oblique lines are clustered, the coordinates of the center point of the line are calculated, and the clustering and line width are calculated based on this coordinate. When clustering, the distance between the centroids of the lines is used as the basis for clustering. When the distance between the centroids of the lines is less than the threshold, the two lines are identified as two sides of a line, that is, they are clustered into one line. The distance between the centroids is the width of the line after clustering. The threshold is set to 10-20.

9. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: In step (8), the required content is generated in the corresponding layer according to the recognition results of characters, components and lines. The specific method is as follows: First, insert characters in the character layer, then insert lines in the line layer, insert components in the component layer, and finally generate a frame in the frame layer and insert an information frame in the information layer.

10. The method for scanning and converting paper power engineering drawings into electronic CAD drawings according to claim 1, characterized in that: The method includes step (9), inserting the original image into the original layer and performing manual error correction.

Citation Information

Patent Citations

  • Urban three-dimensional space vector modeling method based on paper plane data

    CN104077447A

  • Electrical drawing automatic identification and examination method and device

    CN112613339A