Method and device for quickly detecting pole crack image based on opencv

By combining OpenCV with an infrared detector and an adaptive edge detection algorithm, rapid and accurate identification of cracks in utility poles is achieved, solving the problems of low detection efficiency and poor accuracy in existing technologies. This method is suitable for utility pole inspection in the power industry.

CN119887611BActive Publication Date: 2025-12-05XIAN TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411646035.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-12-05
Estimated Expiration
2044-11-18

AI Technical Summary

Technical Problem

Existing technologies for detecting cracks in utility poles are slow and inaccurate, making it impossible to achieve rapid and accurate identification.

Method used

A fast detection method for cracks in utility pole images based on OpenCV is proposed. By combining an infrared detector and a camera, using a filtering template and an adaptive edge detection algorithm, the weights of median filtering and mean filtering are automatically adjusted, and combined with dual threshold detection, the rapid identification of cracks in utility poles is achieved.

Benefits of technology

It enables rapid and accurate identification of cracks in utility poles, adapts to complex environments and traditional cumbersome procedures, improves detection efficiency and accuracy, and is suitable for daily maintenance and inspection in the power industry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119887611B_ABST
    Figure CN119887611B_ABST
Patent Text Reader

Abstract

The application discloses a power pole crack image rapid detection method and device based on opencv, belongs to the field of image processing technology and target tracking, and the power pole crack image rapid detection method based on opencv comprises the following steps: controlling a camera to shoot the outer surface of a power pole, and simultaneously using an infrared detector to detect the shooting area of the camera; acquiring the data of the camera and the infrared detector, and extracting the image shot by the camera when the infrared detector detects a crack signal; obtaining a binary image after image preprocessing, creating a filter template according to the binary image, adjusting the first weight of median filtering and the second weight of mean filtering, using the filter template to perform filter processing on the image according to the first weight and the second weight to obtain a gray-scale image, and obtaining an edge image of cracks on the power pole after edge detection of the gray-scale image. The application is applied to the identification of cracks in the daily maintenance and detection of power poles in the power-related industry.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of image processing technology and target tracking, and particularly relates to an opencv-based power pole crack image rapid detection method and device. BACKGROUND

[0002] The power pole is a pole for supporting electric wires, and is one of important infrastructures in China, which ensures the safety of electricity use of residents in China. The power pole may be cracked due to the unqualified production process, climate environment factors and non-standard post-construction operation.

[0003] In view of the crack problem in the production process and post-use environment of the power pole, the existing technology usually adopts manual detection and ultrasonic detection. The detection efficiency is slow, and the detection precision is low. SUMMARY

[0004] The application aims to provide an opencv-based power pole crack image rapid detection method and device, which is used for identifying the collected power pole crack image in real time and effectively, and solves the problems of slow detection speed and poor detection precision in the existing power pole crack detection.

[0005] In order to achieve the above-mentioned purpose, the application provides the following technical scheme:

[0006] An opencv-based power pole crack image rapid detection method comprises the following steps:

[0007] A camera is controlled to shoot the outer surface of the power pole, and an infrared detector is used to detect the shooting area of the camera;

[0008] Data of the camera and the infrared detector are acquired, and an image shot by the camera when the infrared detector detects a crack signal is extracted;

[0009] A binary image is obtained after the image is preprocessed, a filter template is created according to the binary image, a first average value of variances of all points in the filter template is used to adjust a first weight of median filtering and a second weight of mean filtering, and the image is filtered by using the filter template according to the first weight and the second weight to obtain a gray-scale image, wherein the first average value is E, the first weight is ω, the second weight is 1-ω, ω max is a first preset weight, and ω min is a second preset weight, G avg is a gray-scale mean value of the filter template, G med is a gray-scale median value of the filter template,

[0010] When E is greater than or equal to T:

[0011] When E is less than T: ω=ωmax ;

[0012] Edge images of cracks on utility poles are obtained after edge detection of grayscale images.

[0013] The specific steps of obtaining the edge image of the crack on the utility pole after edge detection of the grayscale image include:

[0014] Calculate the gradient and magnitude of the grayscale image, and divide the pixels of the grayscale image after non-maximum suppression into a first pixel set, a second pixel set, and a third pixel set. The first pixel set is the gradient set of non-boundary points of the crack in the grayscale image, the second pixel set is the gradient set of weak boundary points of the crack in the grayscale image, and the third pixel set is the gradient set of strong edges of the crack in the grayscale image.

[0015] The gradient values ​​of the first pixel set, the second pixel set, and the third pixel set are calculated respectively to obtain the maximum inter-class variance;

[0016] Replace the high and low thresholds in dual threshold detection with the maximum inter-class variance gradient values ​​of the first and third pixel sets;

[0017] Double thresholding of the grayscale image after nonmaximum suppression is performed using the replaced high and low thresholds to obtain the edge image of the crack on the utility pole.

[0018] When performing dual threshold checks on grayscale images after non-maximum suppression using the replaced high and low thresholds, if the gradient magnitude is higher than the high threshold, it is considered an edge and retained; if the gradient magnitude is lower than the low threshold, it is considered noise and discarded; if the gradient magnitude is between the maximum and minimum values ​​and is connected to a boundary, it is retained, otherwise it is discarded.

[0019] The specific steps for calculating the gradient values ​​of the first pixel set, the second pixel set, and the third pixel set to obtain the maximum inter-class variance are as follows:

[0020] Let the total number of pixels in the crack image be N, where the gradient p i The corresponding number of pixels is n i Let the first pixel set be L, the second pixel set be M, and the third pixel set be H. Then the gradient value p i The probability P i for:

[0021] P i =n i / N,i=0,1,2,...,h

[0022] Calculate the expected value E for each of the three parts L, M, and H. L E Mand E h :

[0023]

[0024] The between-class variance is calculated based on the maximum between-class variance:

[0025]

[0026] After iterating through the gradient values ​​in the first pixel set, the second pixel set, and the third pixel set, the maximum inter-class variance of the first pixel set, the second pixel set, and the third pixel set is obtained respectively.

[0027] The step of creating a filtering template based on the binary image specifically includes:

[0028] The filtering template is obtained by approximating the first derivative of the binary image in both the horizontal and vertical directions.

[0029] A fast image detection device for utility pole cracks based on OpenCV, comprising:

[0030] The command issuing unit is used to control the camera to take pictures of the outer surface of the utility pole, and at the same time uses an infrared detector to detect the camera's shooting area;

[0031] The data acquisition unit is used to acquire data from the camera and infrared detector, and extract the image captured by the camera when the infrared detector detects the crack signal;

[0032] The preprocessing unit is used to preprocess the image to obtain a binary image, and to create a filter template based on the binary image;

[0033] The improved filtering unit is used to adjust the first weight of median filtering and the second weight of mean filtering based on the first average of the variances of all points in the filtering template. Based on the first and second weights, the image is filtered using the filtering template to obtain a grayscale image. The first average is E, the first weight is ω, and the second weight is 1-ω. max Let ω be the first preset weight. min As the second preset weight, G avg G represents the grayscale mean of the filter template. med This represents the median grayscale value of the filter template.

[0034] When E≥T:

[0035] When E < T: ω = ω max ;

[0036] The edge detection unit is used to obtain the edge image of the crack on the utility pole after edge detection of the grayscale image.

[0037] The edge detection unit specifically includes:

[0038] An adaptive edge detection unit is used to calculate the gradient and magnitude of a grayscale image and divide the pixels of the grayscale image after non-maximum suppression into a first pixel set, a second pixel set, and a third pixel set. The first pixel set is the gradient set of non-boundary points of the crack in the grayscale image, the second pixel set is the gradient set of weak boundary points of the crack in the grayscale image, and the third pixel set is the gradient set of strong edges of the crack in the grayscale image.

[0039] The gradient values ​​of the first pixel set, the second pixel set, and the third pixel set are calculated respectively to obtain the maximum inter-class variance;

[0040] Replace the high and low thresholds in dual threshold detection with the maximum inter-class variance gradient values ​​of the first and third pixel sets;

[0041] Double thresholding of the grayscale image after nonmaximum suppression is performed using the replaced high and low thresholds to obtain the edge image of the crack on the utility pole.

[0042] In the adaptive edge detection unit, when performing dual threshold checks on the grayscale image after non-maximum suppression using the replaced high and low thresholds, if the magnitude of the gradient is higher than the high threshold, it is considered an edge and retained; if the magnitude of the gradient is lower than the low threshold, it is considered noise and discarded; if the magnitude of the gradient is between the maximum and minimum values ​​and is connected to the boundary, it is retained, otherwise it is discarded.

[0043] The adaptive edge detection unit calculates the gradient values ​​of the first pixel set, the second pixel set, and the third pixel set respectively to obtain the maximum inter-class variance. Specifically, this is done as follows:

[0044] Let the total number of pixels in the crack image be N, where the gradient p i The corresponding number of pixels is n i Let the first pixel set be L, the second pixel set be M, and the third pixel set be H. Then the gradient value p i The probability P i for:

[0045] P i =n i / N,i=0,1,2,...,h

[0046] Calculate the expected value E for each of the three parts L, M, and H. L E M and E h :

[0047]

[0048] The between-class variance is calculated based on the maximum between-class variance:

[0049]

[0050] After iterating through the gradient values ​​in the first pixel set, the second pixel set, and the third pixel set, the maximum inter-class variance of the first pixel set, the second pixel set, and the third pixel set is obtained respectively.

[0051] The step of creating a filtering template based on the binary image specifically includes:

[0052] The filtering template is obtained by approximating the first derivative of the binary image in both the horizontal and vertical directions.

[0053] Compared with existing technologies, the OpenCV-based fast image detection method for utility pole cracks provided in this invention treats utility pole cracks as target detection in image processing and applies an OpenCV-based target detection algorithm to detect utility pole cracks. This detection method only requires an image or video frame as input to quickly and accurately locate and identify utility pole cracks in the image and obtain the crack width, achieving high accuracy. It better achieves real-time target identification and low-power operation under complex conditions and traditionally cumbersome procedures, and can be applied to crack identification in the daily maintenance and inspection of utility poles in the power industry.

[0054] The present invention also provides a rapid detection device for cracked images of utility poles based on OpenCV, including a command issuing unit for controlling a camera to take pictures of the outer surface of the utility pole, and using an infrared detector to detect the area captured by the camera.

[0055] The data acquisition unit is used to acquire data from the camera and infrared detector, and extract the image captured by the camera when the infrared detector detects the crack signal;

[0056] The preprocessing unit is used to preprocess the image to obtain a binary image, and to create a filter template based on the binary image;

[0057] The improved filtering unit is used to adjust the first weight of the median filter and the second weight of the mean filter based on the first average of the variances of all points in the filtering template, wherein the first average is E, the first weight is ω, and the second weight is 1-ω. max Let ω be the first preset weight. min As the second preset weight, G avg G represents the grayscale mean of the filter template. med This represents the median grayscale value of the filter template.

[0058] When E≥T:

[0059] When E < T: ω = ω max ;

[0060] Based on the first and second weights, a filtering template is used to filter the image to obtain a grayscale image;

[0061] The edge detection unit is used to obtain the edge image of the crack on the utility pole after edge detection of the grayscale image.

[0062] Compared with the prior art, the beneficial effects of the OpenCV-based rapid detection device for cracked images of utility poles provided by the present invention are the same as those of the OpenCV-based rapid detection method for cracked images of utility poles described in the above technical solutions, and will not be repeated here. Attached Figure Description

[0063] Figure 1 This is a flowchart of the fast image detection method for cracked utility poles based on OpenCV according to the present invention.

[0064] Figure 2 This is a flowchart of the adaptive edge detection method in the fast image detection method for utility pole cracks based on OpenCV of the present invention;

[0065] Figure 3 This is a simplified flowchart of the fast image detection method for utility pole cracks based on OpenCV according to the present invention.

[0066] Figure 4 This is a block diagram of the fast image detection device for cracked utility poles based on OpenCV according to the present invention.

[0067] Figure 5 This is a schematic diagram of an embodiment of the fast image detection method for cracked utility poles based on OpenCV, in which a binary image is obtained after image preprocessing.

[0068] Figure 6 To and Figure 5 A schematic diagram of the horizontal filtering template for grayscale image matching;

[0069] Figure 7 To and Figure 5 A schematic diagram of the vertical filtering template for matching grayscale images. Detailed Implementation

[0070] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the present invention.

[0071] The present invention will be further described in detail below with reference to specific embodiments. These descriptions are for explanation purposes only and are not intended to limit the scope of the invention.

[0072] Please refer to Figure 1 and Figure 3 The flowchart illustrates a fast detection method for cracked utility pole images based on OpenCV. This method includes:

[0073] Step S101: Control the camera to take pictures of the outer surface of the utility pole, and at the same time use an infrared detector to detect the area to be photographed by the camera.

[0074] The aforementioned camera can be a CMOS visible light camera or a Tigris-640 infrared camera. The infrared detector is a conventional infrared detector used for crack detection. A host computer sends control commands to a slave computer, which then drives the camera and infrared detector to acquire images of the entire utility pole. The host computer runs the OpenCV-based rapid crack detection method for utility poles described in this invention, and the slave computer can be a robotic arm.

[0075] Step S102: Acquire data from the camera and infrared detector, and extract the image captured by the camera when the infrared detector detects the crack signal.

[0076] Step S103: After image preprocessing, a binary image is obtained. A filtering template is created based on the binary image. The first weight of the median filter and the second weight of the mean filter are adjusted according to the first average variance of all points in the filtering template. Based on the first and second weights, the image is filtered using the filtering template to obtain a grayscale image. Here, the first average is E, the first weight is ω, and the second weight is 1-ω. max Let ω be the first preset weight. min As the second preset weight, G avg G represents the grayscale mean of the filter template. med This represents the median grayscale value of the filter template.

[0077] When E≥T:

[0078] When E < T: ω = ω max .

[0079] In the above steps, median filtering, as the name suggests, involves sorting pixel values ​​within a certain region or sequence at a specific point in digital image processing, and selecting the median value of the sorted values ​​to replace other pixel values ​​near that point or sequence. Mean filtering, on the other hand, selects the mean value within the region to replace other pixel values. Based on this, this invention proposes a method for automatically adjusting the weights of median and mean filtering templates. In this process, the templates are traversed throughout the entire image, ultimately resulting in the filtered image. The specific implementation steps are as follows:

[0080] (1) The gradient of the crack image on the utility pole is calculated using the Sobel operator (filter template), and the parts with smaller gradients are removed as part of the image preprocessing. Typically, the gradient is larger at the image edges and smaller in noisy areas;

[0081] (2) Based on the image of the crack in the utility pole, create a suitable 3*3 window as a filtering template and calculate the mean gray value G of the template. avg and G med Median;

[0082] (3) Calculate the variance of the gray values ​​of all points in the filter template with respect to the mean gray value of the filter template, and find the average value E of the variance of all points in the filter template. Assuming the median filter weight is ω and T is the threshold to be preset, the mean filter weight is 1-ω. Adjust the weight according to E. The calculation formula is as follows:

[0083] When E≥T:

[0084] When E < T: ω = ω max ;

[0085] In the above formula, ω max and ω min Based on the pre-set weights and the formula above, if the average variance of the filter template is less than the threshold, it indicates that there is less noise within the filter template window, and the weight of the mean filter needs to be increased; conversely, the weight of the median filter needs to be increased. The formula for calculating the grayscale value of the midpoint of the filter template is as follows:

[0086] G = G avg *ω+G min *(1-ω)

[0087] Finally, the filtering template is traversed from left to right and from top to bottom throughout the entire image to complete the filtering of the cracked image of the utility pole.

[0088] The filter template is a discrete differential operator used to calculate the gradient of an image. It is obtained by approximating the image's gradient by applying the first derivatives to both the horizontal and vertical directions.

[0089] The 3x3 filter template is determined as follows:

[0090] like Figure 6 The image shows a horizontal template. This template calculates the horizontal gradient of each pixel in the image. The numbers in the template represent weighted values ​​for surrounding pixels. For example, for the center pixel, its horizontal gradient is the sum of the products of the weighted values ​​of its surrounding pixels.

[0091] like Figure 7 The image shown is a vertical template used to calculate the gradient in the vertical direction for each pixel in the image.

[0092] By using Figure 6 and Figure 7 The two templates shown perform convolution operations on the image, respectively, to obtain the gradient components in the horizontal and vertical directions. Then, the gradient magnitude and direction of each pixel can be calculated based on these gradient components.

[0093] In crack images, areas with larger gradients usually correspond to the crack's edge contour, regions with significant changes in surface texture, etc.

[0094] If a crack image has sharp edges, the gradient value at those edges will be relatively high. For example, at the boundary between the crack and the background, a large gradient will be generated due to the abrupt change in pixel size. Conversely, in non-crack areas where the color is more uniform in the crack image, the gradient value will be relatively small.

[0095] Step S104: Obtain the edge image of the crack on the utility pole after edge detection of the grayscale image.

[0096] Please refer to Figure 2 The above step S104 specifically includes:

[0097] Step S1041: Calculate the gradient and magnitude of the grayscale image, and divide the pixels of the grayscale image after non-maximum suppression into a first pixel set, a second pixel set, and a third pixel set. The first pixel set is the gradient set of non-boundary points of the crack in the grayscale image, the second pixel set is the gradient set of weak boundary points of the crack in the grayscale image, and the third pixel set is the gradient set of strong edges of the crack in the grayscale image.

[0098] Step S1042: Calculate the gradient values ​​of the first pixel set, the second pixel set, and the third pixel set respectively to obtain the maximum inter-class variance;

[0099] Step S1043: Replace the high threshold and low threshold in dual threshold detection with the maximum inter-class variance gradient value of the first pixel set and the maximum inter-class variance gradient value of the third pixel set;

[0100] Step S1044: Use the replaced high threshold and low threshold to complete the double threshold check on the grayscale image after non-maximum suppression, and obtain the edge image of the crack on the utility pole.

[0101] The calculation of gradient and magnitude involves iterating through the grayscale image using the Sobel operator (filter template). Assuming the filter template uses a 3×3 operator, such as... Figure 6 and Figure 7 As shown.

[0102] Assuming the grayscale image of the cracked utility pole after filtering is as follows: Figure 5 As shown, after the filter template traverses the grayscale image, the gradient magnitude of each point is finally obtained. Assuming the gradient of the first point of the image after calculation is P5, then: the gradient component in the x-direction is:

[0103] P5x=(p3-p1)+3(p6-p4)+(p9-p7);

[0104] The gradient components in the y-direction are:

[0105] P5y=(p7-p1)+3(p8-p2)+(p9-p3);

[0106] By analogy, the gradient magnitudes at all points are obtained. Next, the gradient direction needs to be calculated using the following formula:

[0107]

[0108] Where Gx and Gy are the magnitudes of the gradient at the first point, the gradient angle at the first point is...

[0109] Non-maximum suppression, as the name suggests, suppresses gradient values ​​that are not the largest. That is, it iterates through all pixels in the grayscale image and determines whether the current pixel is the maximum gradient value in the same direction among the surrounding pixels. If it is the maximum value, the pixel is retained; otherwise, its gradient is suppressed and set to 0. Through maximum suppression, the details of the grayscale image edges can be highlighted, making the edges of the grayscale image clearer.

[0110] After the aforementioned non-maximum suppression, the local gradient maxima of the grayscale image are identified. However, some edges are too fine, resulting in significant noise in the grayscale image. When gradient changes are not strong in certain regions of the grayscale image, a threshold needs to be determined to extract the grayscale image. Compared to using a single threshold that distinguishes between black and white, this method uses a dual threshold. If the gradient magnitude is higher than the higher threshold, it is considered an edge; if it is lower than the lower threshold, it is considered noise and discarded. If the gradient magnitude is between the maximum and minimum values ​​and is connected to a boundary, it is retained; otherwise, it is discarded. Traditional methods involve manually setting the threshold subjectively based on parameters such as image grayscale values. If the threshold is set too high, some edge information may be lost; if the threshold is set too low, some noise may be retained. Furthermore, when camera exposure is affected by weather changes or camera position changes, a fixed threshold may not be suitable for the new camera scene. This necessitates rationally selecting high or low thresholds based on the information from the image captured by the camera. This method solves these problems by automatically selecting the threshold using the maximum inter-class variance method. The improved crack detection operator can automatically select a reasonable threshold, thus saving time spent on manual threshold selection and modification. The basic idea of ​​this method is to first divide the grayscale image pixels after non-maximum suppression into a first pixel set L, a second pixel set M, and a third pixel set H, where L is the gradient set of non-boundary points in the grayscale image {p1, p2, ..., p...}. l}, M is the set of gradients of weak boundary points in the grayscale image {p l+1 ,p l+2 ,...,p m}, where H is the set of gradients for strong edges in a grayscale image {p m+1 ,p m+2 ,...,p h Let the total number of pixels in the grayscale image be N, where the gradient p i The corresponding number of pixels is n i Then the gradient value p i The probability P i for:

[0111] P i =n i / N,i=0,1,2,...,h

[0112] Calculate the expected value E for each of the three parts L, M, and H. L E M and E h :

[0113]

[0114] The between-class variance is calculated based on the maximum between-class variance:

[0115]

[0116] By iterating through the gradient values ​​in the three intervals, the maximum inter-class variance is obtained. The maximum inter-class variance gradient values ​​obtained in classes L and H are used to replace the high and low thresholds in dual threshold detection, thereby achieving adaptive thresholding.

[0117] After the final double threshold check, the edge image of the grayscale image is obtained. The output image format and size are determined, and the edge image is sent to the data buffer unit as an information stream. The host computer buffers the processed image of the cracked utility pole and finally displays it on the monitor.

[0118] In practice, Visual Studio software is installed on the host computer and the OpenCV library is added. This software is used to read images of cracks in utility poles and perform a series of processing steps. The specific processing steps are: image preprocessing in step S103, improved filtering in step S103, calculation of image gradient and magnitude in steps S1041 to S1044, non-maximum suppression, adaptive dual threshold detection, and finally, output of the results.

[0119] In summary, the OpenCV-based fast image detection method for utility pole cracks provided by this invention treats utility pole cracks as target detection in image processing and applies an OpenCV-based target detection algorithm to the detection of utility pole cracks. This detection method only requires an image or video frame as input to quickly and accurately locate and identify utility pole cracks in the image and obtain the crack width, achieving high accuracy. It better achieves real-time target identification and low-power operation under complex conditions and traditionally cumbersome procedures, and can be applied to crack identification in the daily maintenance and inspection of utility poles in the power industry.

[0120] This invention also discloses a fast image detection device for utility pole cracks based on OpenCV; please refer to [link / reference]. Figure 4 This OpenCV-based rapid image detection device for cracks in utility poles includes:

[0121] The command issuing unit is used to control the camera to take pictures of the outer surface of the utility pole, and at the same time uses an infrared detector to detect the camera's shooting area;

[0122] The data acquisition unit is used to acquire data from the camera and infrared detector, and extract the image captured by the camera when the infrared detector detects the crack signal;

[0123] The preprocessing unit is used to preprocess the image to obtain a binary image, and to create a filter template based on the binary image;

[0124] The improved filtering unit is used to adjust the first weight of median filtering and the second weight of mean filtering based on the first average of the variances of all points in the filtering template. Based on the first and second weights, the image is filtered using the filtering template to obtain a grayscale image. The first average is E, the first weight is ω, and the second weight is 1-ω. max Let ω be the first preset weight. min As the second preset weight, G avg G represents the grayscale mean of the filter template. med The median grayscale value of the filter template, when E ≥ T:

[0125] When E < T: ω = ω max ;

[0126] The edge detection unit is used to obtain the edge image of the crack on the utility pole after edge detection of the grayscale image.

[0127] The edge detection unit specifically includes:

[0128] An adaptive edge detection unit is used to calculate the gradient and magnitude of a grayscale image and divide the pixels of the grayscale image after non-maximum suppression into a first pixel set, a second pixel set, and a third pixel set. The first pixel set is the gradient set of non-boundary points of the crack in the grayscale image, the second pixel set is the gradient set of weak boundary points of the crack in the grayscale image, and the third pixel set is the gradient set of strong edges of the crack in the grayscale image.

[0129] The gradient values ​​of the first pixel set, the second pixel set, and the third pixel set are calculated respectively to obtain the maximum inter-class variance;

[0130] Replace the high and low thresholds in dual threshold detection with the maximum inter-class variance gradient values ​​of the first and third pixel sets;

[0131] Double thresholding of the grayscale image after nonmaximum suppression is performed using the replaced high and low thresholds to obtain the edge image of the crack on the utility pole.

[0132] In the adaptive edge detection unit, when performing dual threshold checks on the grayscale image after non-maximum suppression using the replaced high and low thresholds, if the magnitude of the gradient is higher than the high threshold, it is considered an edge and retained; if the magnitude of the gradient is lower than the low threshold, it is considered noise and discarded; if the magnitude of the gradient is between the maximum and minimum values ​​and is connected to the boundary, it is retained, otherwise it is discarded.

[0133] The adaptive edge detection unit calculates the gradient values ​​of the first pixel set, the second pixel set, and the third pixel set respectively to obtain the maximum inter-class variance. Specifically, this is done as follows:

[0134] Let the total number of pixels in the crack image be N, where the gradient p i The corresponding number of pixels is n i Let the first pixel set be L, the second pixel set be M, and the third pixel set be H. Then the gradient value p i The probability P i for:

[0135] P i =n i / N,i=0,1,2,...,h

[0136] Calculate the expected value E for each of the three parts L, M, and H. L E M and E h :

[0137]

[0138] The between-class variance is calculated based on the maximum between-class variance:

[0139]

[0140] After iterating through the gradient values ​​in the first pixel set, the second pixel set, and the third pixel set, the maximum inter-class variance of the first pixel set, the second pixel set, and the third pixel set is obtained respectively.

[0141] The display unit is used to determine the output image format and size, and sends the edge image to the data buffer unit in the form of an information stream. The host computer buffers the processed image of the cracked utility pole and finally displays it on the monitor.

[0142] Compared with the prior art, the beneficial effects of the OpenCV-based rapid detection device for cracked images of utility poles provided by the present invention are the same as those of the OpenCV-based rapid detection method for cracked images of utility poles described in the above technical solutions, and will not be repeated here.

[0143] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified. "Several" means one or more, unless otherwise explicitly specified.

[0144] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.

Claims

1. A method for fast detection of pole crack images based on opencv, characterized in that, The method comprises the following steps: controlling a camera to take pictures of the outer surface of a power pole while using an infrared detector to detect the picture-taking area of the camera; acquiring data of the camera and the infrared detector, and extracting the image taken by the camera when the infrared detector detects a crack signal; The binary image is obtained after the image is preprocessed, and a filter template is created according to the binary image. The first weight of median filtering and the second weight of mean filtering are adjusted according to the first average value of the variance of all points in the filter template. The image is filtered using the filter template according to the first weight and the second weight to obtain a gray image, wherein the first average value is E, the first weight is ω, the second weight is 1-ω, and ω max is the first preset weight value, and ω min is the second preset weight value, and G avg is the gray mean value of the filter template, G med is the gray median value of the filter template, and T is a threshold value that needs to be set in advance. When E > T: When E < T: ω = ω max ; obtaining an edge image of the crack on the power pole after edge detection of a gray image; the step of creating a filter template according to the binary image specifically comprises: performing first derivative approximation calculation on the horizontal and vertical directions of the binary image to obtain the filter template.

2. The opencv-based utility pole crack image rapid detection method according to claim 1, characterized in that, the step of obtaining the edge image of the crack on the power pole after edge detection of the gray image specifically comprises: calculating the gradient and amplitude of the gray image, and dividing the pixels of the gray image after non-maximum suppression into a first pixel set, a second pixel set and a third pixel set, wherein the first pixel set is the gradient set of the non-boundary points of the crack in the gray image, the second pixel set is the gradient set of the weak boundary points of the crack in the gray image, and the third pixel set is the gradient set of the strong edges of the crack in the gray image; calculating the gradient values of the first pixel set, the second pixel set and the third pixel set respectively to obtain the maximum inter-class variance; replacing the high threshold and the low threshold in the double-threshold detection with the maximum inter-class variance gradient values of the first pixel set and the third pixel set; performing double-threshold detection on the gray image after non-maximum suppression using the replaced high threshold and low threshold to obtain the edge image of the crack on the power pole.

3. The opencv-based utility pole crack image rapid detection method according to claim 2, characterized in that, when performing double-threshold detection on the gray image after non-maximum suppression using the replaced high threshold and low threshold, if the modulus value of the gradient is higher than the high threshold, it is considered as an edge and is retained; if the modulus value of the gradient is lower than the low threshold, it is considered as noise and is discarded; if the modulus value of the gradient is between the maximum value and the minimum value, if it is connected with the boundary, it is retained, otherwise it is discarded.

4. The opencv-based utility pole crack image rapid detection method according to claim 2, characterized in that, the step of calculating the gradient values of the first pixel set, the second pixel set and the third pixel set respectively to obtain the maximum inter-class variance specifically comprises: Let the total number of pixels in the crack image be N, where the gradient p i The corresponding number of pixels is n i , the first pixel set is L, the second pixel set is M, and the third pixel set is H, L is the gradient set of non-boundary points in the grayscale image {p l}, M is the gradient set of weak boundary points in the grayscale image {p l+1 , p l+2 ,..., p m}, and H is the gradient set of strong edges in the grayscale image {p m+1 , p m+2 ,..., p h}, then the probability P i of the gradient value p i is: P i = n i N,i = 0, 1, 2,..., h The expectation E is calculated for each of the three parts L, M and H L M and E h :​ calculating the inter-class variance according to the maximum inter-class variance: after continuously iterating the gradient values in the first pixel set, the second pixel set and the third pixel set, the maximum inter-class variances of the first pixel set, the second pixel set and the third pixel set are obtained respectively.

5. An opencv-based utility pole crack image rapid detection device, characterized in that, The method comprises the following steps: an instruction issuing unit is configured to control a camera to take pictures of the outer surface of a power pole while using an infrared detector to detect the picture-taking area of the camera; a data acquisition unit is configured to acquire data of the camera and the infrared detector, and extract the image taken by the camera when the infrared detector detects a crack signal; a preprocessing unit is configured to obtain a binary image after preprocessing the image, and create a filter template according to the binary image; The improved filtering unit is used for adjusting a first weight of median filtering and a second weight of mean filtering according to a first average value of variance of all points in the filtering template, and filtering an image to obtain a gray image according to the first weight and the second weight, wherein the first average value is E, the first weight is ω, the second weight is 1-ω, ω max is a first preset weight value, and ω min is a second preset weight value, and G avg is a gray mean value of the filtering template, and G med is a gray median value of the filtering template, and T is a threshold value which needs to be set in advance. When E > T: When E < T: ω = ω max ; an edge detection unit is configured to obtain an edge image of the crack on the power pole after edge detection of a gray image; the step of creating a filter template according to the binary image specifically comprises: performing first derivative approximation calculation on the horizontal and vertical directions of the binary image to obtain the filter template.

6. The opencv-based utility pole crack image rapid detection device according to claim 5, characterized in that, the edge detection unit specifically comprises: An adaptive edge detection unit is used to calculate the gradient and amplitude of the gray image, and the pixels of the gray image after non-maximum suppression are divided into a first pixel set, a second pixel set and a third pixel set, wherein the first pixel set is a gradient set of non-boundary points of the crack in the gray image, the second pixel set is a gradient set of weak boundary points of the crack in the gray image, and the third pixel set is a gradient set of strong edges of the crack in the gray image; The gradient values of the first pixel set, the second pixel set and the third pixel set are calculated respectively to obtain the maximum inter-class variance; The maximum inter-class variance gradient values of the first pixel set and the third pixel set are used to replace the high threshold and the low threshold in the double-threshold detection; The double-threshold detection of the gray image after non-maximum suppression is completed using the replaced high threshold and low threshold to obtain the edge image of the crack on the power pole.

7. The opencv-based utility pole crack image rapid detection method according to claim 6, characterized in that, In the adaptive edge detection unit, when the double-threshold detection of the gray image after non-maximum suppression is completed using the replaced high threshold and low threshold, if the modulus value of the gradient is higher than the high threshold, it is considered as an edge and is retained; if the modulus value of the gradient is lower than the low threshold, it is considered as noise and is discarded; if the modulus value of the gradient is between the maximum value and the minimum value, if it is connected with the boundary, it is retained, otherwise it is discarded.

8. The opencv-based utility pole crack image rapid detection device according to claim 6, characterized in that, The calculation of the gradient values of the first pixel set, the second pixel set and the third pixel set to obtain the maximum inter-class variance in the adaptive edge detection unit is specifically: Let the total number of pixels in the crack image be N, where the gradient p i The corresponding number of pixels is n i , the first pixel set is L, the second pixel set is M, and the third pixel set is H, L is the gradient set of non-boundary points in the grayscale image {p l}, M is the gradient set of weak boundary points in the grayscale image {p l+1 , p l+2 ,..., p m}, and H is the gradient set of strong edges in the grayscale image {p m+1 , p m+2 ,..., p h}, then the probability P i of the gradient value p i is: P i = n i N,i = 0, 1, 2,..., h The expectation E is calculated for each of the three parts L, M and H L M and E h :​ The inter-class variance is calculated according to the maximum inter-class variance as follows: After continuously iterating the gradient values in the first pixel set, the second pixel set and the third pixel set, the maximum inter-class variances of the first pixel set, the second pixel set and the third pixel set are obtained respectively.

Citation Information

Patent Citations

  • Image enhancement and feature extraction method for automatic welding

    CN115147448A

  • Weld seam image edge detection method for complex environment

    CN116977356A