Electric wire intersection detection method and system based on semantic segmentation large model
Through the wire intersection detection method based on semantic segmentation large model, the Grounded-Segment-Anything model and Zhang-Suen refinement algorithm are used to solve the problem of insufficient computing resources and explanation of wire intersection detection in the existing technology, and the wire is realized Accurate and efficient detection of intersection points.
Patent Information
- Application Number
- CN202411258514.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-11-22
AI Technical Summary
The prior art has problems such as large computing resource requirements and insufficient model interpretation in wire intersection detection, making it difficult to achieve accurate and efficient detection.
The wire intersection detection method based on the semantic segmentation large model is used, and the wire pixel map is refined by the Grounded-Segment-Anything model, and neighborhood pixel analysis is performed to detect intersection points.
Accurate and efficient detection of wire intersection points is achieved, combined with the feature extraction ability of deep learning and the stability and efficiency of traditional image processing, reducing the amount and time of training data.
Smart Images

Figure CN119006829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to machine vision and image processing, and in particular to a method and system for detecting electric wire intersections based on a semantic segmentation large model. Background Art
[0002] Ensuring power safety is a very important issue in modern society. It is not only related to the normal operation of the power grid, but also directly related to the safety of people's lives and property. Among the many power safety issues, the messy wires not only affect the city appearance, but are more likely to cause a series of safety accidents, such as fire and electric shock. Therefore, the detection of messy wires has gradually become one of the key tasks of urban management and power maintenance. Figure 2 and Figure 3 Some real-life scenes of messy wires are given in the article.
[0003] In the detection of cluttered wires, the detection of wire intersections is particularly critical. Intersections are often high-incidence areas for power failures, because wires are more likely to have poor contact or wear here, which can lead to serious consequences such as short circuits. Existing technologies generally use methods such as deep learning to detect wire intersections. Although deep learning has advantages in processing large-scale data, in some cases there may be problems such as large computing resource requirements and insufficient model interpretability. Traditional image processing technology makes up for these shortcomings to a certain extent with its simplicity and directness. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] In view of the above-mentioned shortcomings of the prior art, the present invention provides a method and system for detecting wire intersections based on a semantic segmentation large model, which can effectively overcome the defect of the prior art that it is difficult to accurately and efficiently detect wire intersections.
[0006] (II) Technical solution
[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0008] A method for detecting electric wire intersections based on a semantic segmentation large model comprises the following steps:
[0009] S1. Obtain the original wire image, use the Grounded-Segment-Anything model to perform semantic segmentation on the original wire image, and obtain a wire pixel map;
[0010] S2, using the Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain a wire skeleton map;
[0011] S3. Perform neighborhood pixel analysis on the wire skeleton image to obtain wire intersection points.
[0012] Preferably, in S2, the Zhang-Suen thinning algorithm is used to thin the lines in the binary image of the wire pixel map to obtain a wire skeleton map, including:
[0013] S21, for each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions:
[0014] 1) Pixel P1 is black and has 2 to 6 black neighboring pixels;
[0015] 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel;
[0016] 3) Taking the pixel point P2 to the upper left of the pixel point P1 as the starting point and going back to the starting point in a clockwise direction, whether the pixel sequence formed satisfies the number of changes from 0 to 1 is 1;
[0017] 4) Check if there are no other black pixels in the neighborhood of pixel P1;
[0018] If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration.
[0019] S22. For each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions:
[0020] 1) Pixel P1 is black and has 2 to 6 black neighboring pixels;
[0021] 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel;
[0022] 3) Taking the pixel point P6 below the pixel point P1 as the starting point and going back to the starting point in a counterclockwise direction, whether the pixel sequence formed satisfies the number of changes from 0 to 1 is 1;
[0023] 4) Check if there are no other black pixels in the neighborhood of pixel P1;
[0024] If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration.
[0025] S23, returning to S21, until no pixel point P1 in the binary image of the wire pixel map is marked as deletable;
[0026] S24, outputting the refined wire skeleton diagram;
[0027] The neighborhood pixels are the remaining 8 pixels surrounding the pixel P1 in a 3*3 grid with the pixel P1 as the center.
[0028] Preferably, performing neighborhood pixel analysis on the wire skeleton image in S3 to obtain wire intersections includes:
[0029] S31, traverse each non-edge pixel in the wire skeleton diagram, and if the pixel is white, obtain the pixel value of the neighboring pixel;
[0030] S32, matching the pixel value of the neighborhood pixel point with the valid intersection pattern, if the match is successful, adding the pixel point to the target list;
[0031] S33, traverse each pixel in the target list, calculate the distance between each pixel and other pixels, and remove duplicates according to the calculation results;
[0032] S34, using the target list after deduplication as a wire intersection list.
[0033] Preferably, there are 34 valid intersection point modes, covering most intersection point pixel situations, which are specifically divided into the following categories:
[0034] 1) T-shaped intersection:
[0035] [0,1,0,1,0,0,1,0]: A vertical line and a horizontal line intersect to form a T shape;
[0036] [0,0,1,0,1,0,0,1]: A horizontal line and a vertical line intersect to form a T shape;
[0037] 2) L-shaped intersection:
[0038] [1,0,0,1,0,1,0,0]: A vertical line and a horizontal line intersect to form an L shape;
[0039] [0,0,1,0,1,0,1,0]: A horizontal line and a vertical line intersect to form an L shape;
[0040] 3) Cross intersection:
[0041] [0,1,0,0,1,0,1,0]: two lines intersect in the middle to form a cross;
[0042] [1,0,0,0,1,0,0,1]: two lines intersect in the middle to form a cross;
[0043] 4) Other complex intersections:
[0044] [0,1,0,1,0,1,0,0]: multiple lines intersect to form a complex intersection;
[0045] [1,0,1,0,1,0,1,0]: Multiple lines intersect to form a complex intersection.
[0046] Preferably, in S33, each pixel in the target list is traversed, and the distance between each pixel and other pixels is calculated, and duplicate removal is performed according to the calculation result, including:
[0047] Traverse each pixel in the target list and calculate the distance between it and other pixels. If the Euclidean distance between two pixels is less than 10, delete one of the pixels.
[0048] A wire intersection detection system based on a semantic segmentation large model, comprising an original wire image acquisition module, a semantic segmentation module, a line thinning module and an intersection detection module;
[0049] An original wire image acquisition module is used to acquire the original wire image;
[0050] The semantic segmentation module uses the Grounded-Segment-Anything model to perform semantic segmentation on the original wire image to obtain a wire pixel map;
[0051] The line thinning module uses the Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain the wire skeleton map;
[0052] The intersection detection module performs neighborhood pixel analysis on the wire skeleton diagram to obtain the wire intersections.
[0053] (III) Beneficial effects
[0054] Compared with the prior art, the present invention provides a method and system for detecting wire intersections based on a semantic segmentation large model, which utilizes deep learning to perform semantic segmentation of original wire images, and combines traditional image refinement technology to accurately extract wire lines, and finally detects wire intersections through neighborhood pixel analysis, wherein deep learning performs well in identifying wires in complex scenes, while traditional image processing demonstrates its stability and efficiency in wire refinement and detecting wire intersections. The semantic segmentation of deep learning is combined with traditional image processing technology, which fully utilizes the powerful ability of deep learning in feature extraction and the advantages of traditional image processing in efficiency and directness. In addition, compared with directly using a target detection model to detect intersections, the present invention combines traditional image processing technology to reduce the required amount of training data and training time. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0056] Figure 1 It is a schematic diagram of the process of the present invention;
[0057] Figure 2 For real-life scenes with messy wires Figure 1 ;
[0058] Figure 3 For real-life scenes with messy wires Figure 2 ;
[0059] Figure 4 For the present invention Figure 2 Pixel map of wires obtained after semantic segmentation;
[0060] Figure 5 For the present invention Figure 4 The wire skeleton diagram obtained after line thinning;
[0061] Figure 6 It is a schematic diagram of judging the number of changes from 0 to 1 in a pixel sequence when the Zhang-Suen thinning algorithm is used to thin the lines in the binary image of the wire pixel map in the present invention;
[0062] Figure 7 is a schematic diagram of a T-shaped intersection of [0,1,0,1,0,0,1,0] in the present invention;
[0063] Figure 8Schematic diagram of the T-shaped intersection of [0,0,1,0,1,0,0,1] in the present invention. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0065] A method for detecting wire crossing points based on semantic segmentation large models, such as Figure 1 As shown in S1, the original wire image is obtained, and the Grounded-Segment-Anything model is used to perform semantic segmentation on the original wire image to obtain a wire pixel map (such as Figure 4 shown).
[0066] Grounded-Segment-Anything (GSA) is a computer vision model that builds on the SegmentAnything (SA) model and adds visual grounding capabilities. Visual grounding refers to mapping natural language descriptions to specific regions in an image, while the SegmentAnything model is a powerful image segmentation model that can segment any object in an image.
[0067] The SegmentAnything model is pre-trained on a large amount of image data, which enables it to perform well on a variety of different image segmentation tasks. The SegmentAnything model also comes with a large segmentation dataset called "SA-1B", which contains more than 11 million segmentation masks, which are predicted by the model on 11 million images.
[0068] Grounding DINO is a computer vision model based on the Transformer architecture, which is specifically designed for the task of matching natural language descriptions with specific areas in an image, a task often referred to as "visual grounding". In short, Grounding DINO can understand the content of an image and locate the objects or scenes mentioned in the natural language description.
[0069] S2, use Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain the wire skeleton map (such as Figure 5), including:
[0070] S21, for each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions:
[0071] 1) Pixel P1 is black and has 2 to 6 black neighboring pixels;
[0072] 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel;
[0073] 3) Take the pixel point P2 to the upper left of the pixel point P1 as the starting point, and go back to the starting point in a clockwise direction to form a pixel sequence that satisfies the number of changes from 0 to 1 of 1 (e.g. Figure 6 shown);
[0074] 4) Check if there are no other black pixels in the neighborhood of pixel P1;
[0075] If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration.
[0076] S22. For each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions:
[0077] 1) Pixel P1 is black and has 2 to 6 black neighboring pixels;
[0078] 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel;
[0079] 3) Taking the pixel point P6 below the pixel point P1 as the starting point and going back to the starting point in a counterclockwise direction, whether the pixel sequence formed satisfies the number of changes from 0 to 1 is 1;
[0080] 4) Check if there are no other black pixels in the neighborhood of pixel P1;
[0081] If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration.
[0082] S23, returning to S21, until no pixel point P1 in the binary image of the wire pixel map is marked as deletable;
[0083] S24, outputting the refined wire skeleton diagram;
[0084] The neighborhood pixels are the remaining 8 pixels surrounding the pixel P1 in a 3*3 grid with the pixel P1 as the center.
[0085] The Zhang-Suen thinning algorithm is a classic image processing algorithm used to thin lines in binary images to one pixel width while maintaining the topology and shape of the lines as much as possible. The Zhang-Suen thinning algorithm is an iterative process that mainly conditionally deletes non-edge pixels in a binary image until there are no more non-edge pixels that can be deleted.
[0086] S3, performing neighborhood pixel analysis on the wire skeleton map to obtain wire intersection points, specifically including:
[0087] S31, traverse each non-edge pixel in the wire skeleton diagram, and if the pixel is white, obtain the pixel value of the neighboring pixel;
[0088] S32, matching the pixel value of the neighborhood pixel point with the valid intersection pattern, if the match is successful, adding the pixel point to the target list;
[0089] S33, traverse each pixel in the target list, calculate the distance between each pixel and other pixels, and remove duplicates according to the calculation results;
[0090] S34, using the target list after deduplication as a wire intersection list.
[0091] Specifically, there are 34 valid intersection point modes, covering most intersection point pixel situations, which are divided into the following categories:
[0092] 1) T-shaped intersection:
[0093] [0,1,0,1,0,0,1,0](e.g. Figure 7 As shown): a vertical line and a horizontal line intersect to form a T shape;
[0094] [0,0,1,0,1,0,0,1](e.g. Figure 8 As shown): a horizontal line and a vertical line intersect to form a T shape;
[0095] 2) L-shaped intersection:
[0096] [1,0,0,1,0,1,0,0]: A vertical line and a horizontal line intersect to form an L shape;
[0097] [0,0,1,0,1,0,1,0]: A horizontal line and a vertical line intersect to form an L shape;
[0098] 3) Cross intersection:
[0099] [0,1,0,0,1,0,1,0]: two lines intersect in the middle to form a cross;
[0100] [1,0,0,0,1,0,0,1]: two lines intersect in the middle to form a cross;
[0101] 4) Other complex intersections:
[0102] [0,1,0,1,0,1,0,0]: multiple lines intersect to form a complex intersection;
[0103] [1,0,1,0,1,0,1,0]: Multiple lines intersect to form a complex intersection.
[0104] Specifically, in S33, each pixel in the target list is traversed, and the distance between each pixel and other pixels is calculated, and duplicate removal is performed according to the calculation result, including:
[0105] Traverse each pixel in the target list and calculate the distance between it and other pixels. If the Euclidean distance between two pixels is less than 10, delete one of the pixels.
[0106] In the technical solution of the present application, on the basis of disclosing the above-mentioned wire intersection detection method based on the semantic segmentation large model, a wire intersection detection system based on the semantic segmentation large model is also disclosed, including an original wire image acquisition module, a semantic segmentation module, a line thinning module and an intersection detection module;
[0107] An original wire image acquisition module is used to acquire the original wire image;
[0108] The semantic segmentation module uses the Grounded-Segment-Anything model to perform semantic segmentation on the original wire image to obtain a wire pixel map;
[0109] The line thinning module uses the Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain the wire skeleton map;
[0110] The intersection detection module performs neighborhood pixel analysis on the wire skeleton diagram to obtain the wire intersections.
[0111] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting electric wire intersections based on a semantic segmentation large model, characterized in that: The following steps are involved: S1. Obtain the original wire image, use the Grounded-Segment-Anything model to perform semantic segmentation on the original wire image, and obtain a wire pixel map; S2, using the Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain a wire skeleton map; S3. Perform neighborhood pixel analysis on the wire skeleton image to obtain wire intersection points.
2. The method for detecting electric wire intersections based on a semantic segmentation large model according to claim 1, characterized in that: In S2, the Zhang-Suen thinning algorithm is used to thin the lines in the binary image of the wire pixel map to obtain the wire skeleton map, including: S21, for each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions: 1) Pixel P1 is black and has 2 to 6 black neighboring pixels; 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel; 3) Taking the pixel point P2 to the upper left of the pixel point P1 as the starting point and going back to the starting point in a clockwise direction, whether the pixel sequence formed satisfies the number of changes from 0 to 1 is 1; 4) Check if there are no other black pixels in the neighborhood of pixel P1; If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration. S22. For each pixel point P1 in the binary image of the wire pixel map, determine whether the pixel point P1 satisfies all of the following conditions: 1) Pixel P1 is black and has 2 to 6 black neighboring pixels; 2) Check whether the pixel point P1 satisfies the 4-connectivity condition, that is, whether the pixel point P1 has exactly one black diagonal pixel and at least one white neighboring pixel; 3) Taking the pixel point P6 below the pixel point P1 as the starting point and going back to the starting point in a counterclockwise direction, whether the pixel sequence formed satisfies the number of changes from 0 to 1 is 1; 4) Check if there are no other black pixels in the neighborhood of pixel P1; If the pixel point P1 meets all the above conditions, the pixel point P1 is marked as deletable, and all the pixel points P1 marked as deletable are deleted after the current iteration. S23, returning to S21, until no pixel point P1 in the binary image of the wire pixel map is marked as deletable; S24, outputting the refined wire skeleton diagram; The neighborhood pixels are the remaining 8 pixels surrounding the pixel P1 in a 3*3 grid with the pixel P1 as the center.
3. The method for detecting electric wire intersections based on a semantic segmentation large model according to claim 1, characterized in that: In S3, the neighborhood pixel analysis of the wire skeleton image is performed to obtain the wire intersection points, including: S31, traverse each non-edge pixel in the wire skeleton diagram, and if the pixel is white, obtain the pixel value of the neighboring pixel; S32, matching the pixel value of the neighborhood pixel point with the valid intersection pattern, if the match is successful, adding the pixel point to the target list; S33, traverse each pixel in the target list, calculate the distance between each pixel and other pixels, and remove duplicates according to the calculation results; S34, using the target list after deduplication as a wire intersection list.
4. The method for detecting electric wire intersections based on a semantic segmentation large model according to claim 3, characterized in that: There are 34 valid intersection point modes, covering most intersection point pixel situations, which are specifically divided into the following categories: 1) T-shaped intersection: [0,1,0,1,0,0,1,0]: A vertical line and a horizontal line intersect to form a T shape; [0,0,1,0,1,0,0,1]: A horizontal line and a vertical line intersect to form a T shape; 2) L-shaped intersection: [1,0,0,1,0,1,0,0]: A vertical line and a horizontal line intersect to form an L shape; [0,0,1,0,1,0,1,0]: A horizontal line and a vertical line intersect to form an L shape; 3) Cross intersection: [0,1,0,0,1,0,1,0]: two lines intersect in the middle to form a cross; [1,0,0,0,1,0,0,1]: two lines intersect in the middle to form a cross; 4) Other complex intersections: [0,1,0,1,0,1,0,0]: multiple lines intersect to form a complex intersection; [1,0,1,0,1,0,1,0]: Multiple lines intersect to form a complex intersection.
5. The method for detecting electric wire intersections based on a semantic segmentation large model according to claim 3, characterized in that: In S33, each pixel in the target list is traversed, and the distance between each pixel and other pixels is calculated. Duplicates are removed based on the calculation results, including: Traverse each pixel in the target list and calculate the distance between it and other pixels. If the Euclidean distance between two pixels is less than 10, delete one of the pixels.
6. A wire intersection detection system based on a semantic segmentation large model, used to execute the wire intersection detection method based on a semantic segmentation large model according to claim 1, characterized in that: It includes original wire image acquisition module, semantic segmentation module, line refinement module and intersection detection module; An original wire image acquisition module is used to acquire the original wire image; The semantic segmentation module uses the Grounded-Segment-Anything model to perform semantic segmentation on the original wire image to obtain a wire pixel map; The line thinning module uses the Zhang-Suen thinning algorithm to thin the lines in the binary image of the wire pixel map to obtain the wire skeleton map; The intersection detection module performs neighborhood pixel analysis on the wire skeleton diagram to obtain the wire intersections.
Citation Information
Patent Citations
Lane line instance detection method and system based on fusing and fusion
CN116935065A
