A method and system for detecting surface defects of a railway contact wire

By introducing a combination of spatiotemporal matching weights and local affine transformation, the method for detecting surface defects on railway contact lines is optimized. This solves the problem of insufficient global homography transformation, generates high-quality two-dimensional unfolded images, and adopts an adaptive judgment threshold, thereby improving the accuracy and robustness of detection.

CN121120645BActive Publication Date: 2026-02-03JIANGYIN ELECTRICAL ALLOY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511658788.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-13
Publication Date
2026-02-03
Estimated Expiration
2045-11-13

AI Technical Summary

Technical Problem

In existing technologies, the detection of surface defects in railway contact wires suffers from poor accuracy. This is mainly because global homography transformation is insufficient to describe the non-rigid deformation of the contact wire, resulting in local stretching, twisting, and other distortions after image correction, which affects the accuracy and robustness of the detection.

Method used

By introducing spatiotemporal matching weights to optimize feature point selection, and combining local affine transformation to perform segmented correction on the contact line, a high-quality two-dimensional unfolded image is generated. In the defect confirmation stage, an adaptive judgment threshold is used to distinguish between false features caused by geometric distortion and real defects.

Benefits of technology

It improves the accuracy and reliability of defect detection under complex motion and deformation conditions, reduces the false alarm rate, and enhances the robustness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121120645B_ABST
    Figure CN121120645B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of defect detection, in particular to a railway contact line surface defect detection method and system. The method comprises: acquiring a sequence image; calculating a space-time matching weight based on the tracking duration and normal distance of a feature point pair, obtaining a global homography matrix through a weighted random sample consensus algorithm for preliminary correction; calculating a local affine transformation matrix and a distortion factor for the segmented image, and generating a two-dimensional development map through splicing; projecting the candidate defect area segmented on the development map back to the original image, calculating the gradient direction entropy ratio, and determining the real defect based on the adaptive threshold determined by the distortion factor. That is, the scheme of the present application can compensate for the non-rigid deformation of the contact line, adaptively distinguish between geometric distortion and real defects, and improve detection accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology. More specifically, this invention relates to a method and system for detecting surface defects in railway contact wires. Background Technology

[0002] As a core component supplying power to electric locomotives, the surface condition of the railway contact wire directly impacts the safety and stability of the entire railway transportation system. Traditional contact wire inspection relies primarily on manual labor, which is inefficient, labor-intensive, and high-risk. To address this, automated inspection technology based on machine vision has emerged. By mounting inspection equipment on high-speed trains for real-time monitoring, it has become a crucial technical means to ensure the safe operation of the contact wire. However, in practical applications, due to the combined effects of vehicle vibration, camera shake, and the contact wire's own swaying, the acquired contact wire image sequences generally exhibit severe geometric jitter and perspective changes. These instabilities pose significant challenges to subsequent defect analysis.

[0003] To address the aforementioned image instability issue, existing techniques typically involve registering and stabilizing the acquired image sequence. Specifically, this involves extracting local feature points from consecutive image frames using Scale Invariant Feature Transform (SIFT) or Speed-Up Robust Feature Transform (SURF), and then combining this with the Random Sample Consensus (RANSAC) algorithm to estimate a global homography matrix. This matrix is ​​then used to correct the overall motion between images, thus achieving initial stabilization of the image sequence. This method can align images to a certain extent, providing a foundation for subsequent generation of two-dimensional unfolded maps of the contact line and defect identification.

[0004] However, the aforementioned correction methods based on global homography transformation suffer from significant technical bottlenecks in practical applications. On one hand, the contact line is essentially a flexible object in three-dimensional space, and its projection onto a two-dimensional image produces complex non-rigid deformations. A single global homography transformation model is insufficient to accurately describe these deformations, resulting in residual distortions such as local stretching and warping in the corrected image. Simultaneously, the traditional RANSAC algorithm treats all matching point pairs equally, making it susceptible to interference from dynamic objects or spurious features in the background, thus affecting the estimation accuracy of the global transformation matrix. On the other hand, these residual geometric distortions significantly alter the visual characteristics of the contact line surface. For example, local stretching may cause crack-like artifacts on normal surfaces, while local compression may weaken the contrast of real defects. In this situation, if subsequent defect detection uses fixed thresholds based on gradient, texture, or deep learning features, it is highly likely that normal textures in deformed areas will be misclassified as defects, or real defects will be missed due to distortion suppression, leading to high false alarm and false negative rates, severely impacting the accuracy and robustness of detection. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for detecting surface defects of railway contact wires, in order to solve the problem of poor accuracy in the detection of surface defects of contact wires in the prior art; to this end, this invention provides solutions in the following two aspects.

[0006] In a first aspect, the present invention provides a method for detecting surface defects in railway contact wires, comprising the following steps:

[0007] Acquire the original sequence images of the railway contact line to be inspected; extract feature point pairs between consecutive frames, and calculate the spatiotemporal matching weight based on the tracking time of the feature point pairs and their normal distance to the central axis of the contact line; use the spatiotemporal matching weight to calculate the global homography matrix using a weighted random sampling consensus algorithm; apply the global homography matrix to the original sequence images to generate a preliminary corrected image; segment the preliminary corrected image along the contact line direction, calculate the local affine transformation matrix for each segment, and determine the distortion factor representing the degree of non-rigid deformation of the segment based on the ratio of the maximum to the minimum singular value of the local affine transformation matrix; apply the local affine transformation matrix of each segment to the preliminary corrected image. The positive image is transformed, and the transformed segments are stitched together to generate a two-dimensional unfolded image. Candidate defect regions are segmented on the two-dimensional unfolded image. For each candidate defect region, the inverse of the local affine transformation matrix and the inverse of the global homography matrix of the segment containing the region are applied sequentially to project the region's contour back onto the original image, obtaining the original mapped region. The ratio of the gradient direction entropy of the pixels within the original mapped region to the gradient direction entropy of the neighboring background pixels is calculated. Based on the distortion factor corresponding to the segment containing the candidate defect region, an adaptive judgment threshold is determined using a preset monotonically increasing function. When the ratio exceeds the adaptive judgment threshold, the candidate defect region is determined to be a real defect.

[0008] Preferably, the extraction of feature point pairs between consecutive frames includes: using the SURF algorithm to detect feature points in each frame of the image, and using the KLT optical flow method to track the feature points between consecutive frames to establish the feature point pairs.

[0009] Preferably, the step of calculating the spatiotemporal matching weights includes: recording the number of consecutive frames in which each feature point is successfully tracked as its tracking duration. Determine the central axis of the contact line in each frame of the image, and calculate the vertical Euclidean distance from each feature point to the central axis as the normal distance. ; through formula Calculate the spatiotemporal matching weights for each feature point pair ,in and For preset positive numbers, This is the normal distance.

[0010] Preferably, the step of calculating the global homography matrix using the spatiotemporal matching weights through a weighted random sampling consensus algorithm includes: in each iteration, performing probabilistic sampling based on the spatiotemporal matching weights of each feature point pair, selecting four feature point pairs, with the higher the weight of the point pair, the higher the probability of being selected; calculating a candidate homography matrix using the selected four feature point pairs; applying the candidate homography matrix to all feature point pairs, calculating the reprojection error, and classifying feature point pairs with errors less than a preset pixel threshold as inlier sets; calculating the total weight of the current inlier set, i.e., the sum of the spatiotemporal matching weights of all feature point pairs in the set; repeating the above steps a specified number of times, and selecting the homography matrix corresponding to the inlier set with the largest total weight as the global homography matrix.

[0011] Preferably, the step of generating the preliminary corrected image includes: selecting the first frame of the sequence image as the reference frame; for each subsequent frame image, multiplying it by the global homography matrix between all consecutive frames between it and the reference frame to obtain the cumulative global homography matrix of that frame relative to the reference frame; applying the cumulative global homography matrix to the corresponding original sequence image to generate the preliminary corrected image aligned with the reference frame.

[0012] Preferably, the step of segmenting the preliminary corrected image along the contact line direction, calculating a local affine transformation matrix for each segment, and determining a distortion factor representing the degree of non-rigid deformation of the segment based on the ratio of the maximum to the minimum singular values ​​of the local affine transformation matrix, includes: dividing the preliminary corrected image into multiple image segments with a preset width and overlap along the horizontal direction of the contact line; for each image segment, establishing a correspondence between the feature points transformed into the segment and the preset target positions of the segment in the two-dimensional unfolded image, calculating a local affine transformation matrix A using the least squares method; and performing singular value decomposition on matrix A to obtain the maximum singular value. and minimum singular value ; Calculate the distortion factor of the segments. .

[0013] Preferably, the step of segmenting candidate defect regions on the two-dimensional unfolded image includes: applying a medium filter to smooth and denoise the two-dimensional unfolded image; using the Otsu algorithm to calculate a global binarization threshold, and identifying regions in the image with pixel values ​​lower than the global binarization threshold as potential defect regions; performing morphological closing operations on the binarized image to fill the holes inside the potential defect regions and connect adjacent regions; and performing connected component analysis on the processed image to mark connected components with areas within a preset range as candidate defect regions.

[0014] Preferably, calculating the ratio of the gradient direction entropy of pixels within the original mapping region to the gradient direction entropy of neighboring background pixels includes: calculating the gradient magnitude and gradient direction of all pixels within the original mapping region using the Sobel operator; quantizing the gradient direction into multiple intervals, counting the number of gradients falling into each interval, constructing a gradient direction histogram, and calculating the information entropy. Expand the minimum bounding rectangle of the original mapping region outward by a preset pixel width to obtain this expanded annular region as the neighborhood background; calculate the gradient direction entropy of the neighborhood background using the same steps as calculating the information entropy. ; Calculate the ratio .

[0015] Preferably, the step of determining the adaptive judgment threshold based on the distortion factor corresponding to the segment where the candidate defect region is located, using a preset monotonically increasing function, includes:

[0016] The distortion factor of the segment containing the candidate defect region is obtained as follows: ,in The preset monotonically increasing function is: ,in, Based on the threshold, This is the sensitivity coefficient; the value calculated in the previous step... As an adaptive decision threshold.

[0017] In a second aspect, a railway contact wire surface defect detection system includes:

[0018] The system includes a processor and a memory storing computer instructions for detecting surface defects in railway contact wires, which, when executed by the processor, cause the system to perform the aforementioned method for detecting surface defects in railway contact wires.

[0019] The beneficial effects of this invention are as follows: By introducing spatiotemporal matching weights, stable feature points strongly correlated with the contact line are preferentially selected, improving the calculation accuracy and anti-interference capability of the global homography matrix. Based on the introduction of spatiotemporal matching weights, the contact line is finely corrected segmentally by combining local affine transformation, compensating for the non-rigid deformation of the flexible contact line during the imaging process, and generating a higher-quality two-dimensional unfolded image with less residual distortion. In the defect confirmation stage, this invention correlates the judgment threshold with the degree of non-rigid deformation of each image segment. For areas with large deformation, a more stringent judgment standard is adopted, which can distinguish between false features caused by geometric distortion and real surface defects, reducing the false alarm rate and improving the accuracy and reliability of defect detection under complex motion and deformation conditions. Attached Figure Description

[0020] Figure 1The flowchart illustrating the steps of the railway contact wire surface defect detection method in this embodiment is shown in the schematic diagram.

[0021] Figure 2 The schematic diagram illustrates the structural block diagram of the railway contact wire surface defect detection system in this embodiment. Detailed Implementation

[0022] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0023] like Figure 1 As shown in this embodiment, a method for detecting surface defects in railway contact wires includes the following steps:

[0024] Step S1: Obtain the original sequence image of the railway contact line to be detected; extract feature point pairs between consecutive frames; calculate the spatiotemporal matching weight based on the tracking time of the feature point pairs and their normal distance from the center axis of the contact line; and use the spatiotemporal matching weight to calculate the global homography matrix through a weighted random sampling consensus algorithm.

[0025] A high-speed line array camera is mounted on the roof of the inspection train, with the camera lens vertically aligned directly below the contact line. As the train travels at high speed, it continuously captures images of the bottom surface of the contact line at a frequency of 2000 frames per second, obtaining raw sequence images with high frame rate and high resolution.

[0026] The ORB algorithm is used to detect feature points and extract binary descriptors in two adjacent image frames. Initial matching point pairs are selected through Hamming distance calculation and cross-matching. For each feature point, the KLT optical flow tracking algorithm is used to track it in subsequent consecutive frames, and the total number of frames in which the feature point can be stably tracked is recorded as the tracking duration. Simultaneously, the equation of the central axis of the contact line in each image frame is determined using Canny edge detection and line fitting algorithms, and the vertical distance from each feature point to the central axis is calculated as the normal distance. The spatiotemporal matching weight of a feature point pair is obtained by multiplying an exponential function of the tracking duration by a negative exponential function of the normal distance, resulting in higher weights for point pairs that have been tracked longer and are closer to the center of the contact line.

[0027] The spatiotemporal matching weights calculated in the previous step are integrated into the sampling stage of the Random Sampling Consensus (RANSAC) algorithm. In each iteration, instead of randomly selecting four feature point pairs with equal probability to estimate the homography matrix model, sampling is performed based on the weights, meaning that point pairs with higher weights have a higher probability of being selected. Through a preset number of iterations, the homography matrix model that minimizes the sum of the weighted projection errors of all feature point pairs is selected as the global homography matrix representing the overall motion between two frames.

[0028] In an optional embodiment, the step of calculating the spatiotemporal matching weights includes:

[0029] The number of consecutive frames in which each feature point is successfully tracked is recorded as its tracking duration. Determine the central axis of the contact line in each frame of the image, and calculate the vertical Euclidean distance from each feature point to the central axis as the normal distance. ; through formula Calculate the spatiotemporal matching weights for each feature point pair ,in and For preset positive numbers, This is the normal distance.

[0030] Specifically, consecutive image frames are processed, such as frame 1 and frame 2. In frame 1, the SURF algorithm is used to identify hundreds of salient feature points, such as corner points or blobs. For each feature point detected in frame 1, the KLT optical flow method searches for the most likely new location in frame 2, establishing a tracking pair. The process continues continuously; for example, if a feature point is successfully tracked from frame 1 to frame 10 but is lost in frame 11, then its tracking time is... This is recorded as 10. Simultaneously, in each frame of the image, the equation of the central axis of the contact line is determined through edge detection and fitting algorithms; for example, it is a straight line. For each feature point, the perpendicular distance from the feature point's coordinates to this central axis is calculated. For example, if a point is 5 pixels away from the axis, then the normal distance is... It is 5.

[0031] A preset formula is used to comprehensively evaluate the reliability of each feature point pair. In this embodiment, the preset parameters are... It is 0.1. It is 0.02. For a tracking duration... For 15 frames, normal distance For 4-pixel feature point pairs, spatiotemporal matching weights The weight is approximately 3.25. In contrast, another point pair with a tracking duration of only 5 frames and a normal distance of 10 pixels has a weight of only approximately 0.22. In this way, feature point pairs that are stably tracked for a long time on the contact line body are given higher weights, providing a more reliable basis for subsequent motion estimation.

[0032] In an optional embodiment, the global homography matrix is ​​calculated using the spatiotemporal matching weights through a weighted random sampling consensus algorithm, including:

[0033] In each iteration, probabilistic sampling is performed based on the spatiotemporal matching weights of each feature point pair to select four feature point pairs. The higher the weight of the feature point pair, the higher the probability of it being selected. A candidate homography matrix is ​​calculated using the four selected feature point pairs. The candidate homography matrix is ​​applied to all feature point pairs to calculate the reprojection error. Feature point pairs with errors less than a preset pixel threshold are classified as inliers. The total weight of the current inlier set is calculated, which is the sum of the spatiotemporal matching weights of all feature point pairs in the set. The above steps are repeated a specified number of times, and the homography matrix corresponding to the inlier set with the largest total weight is selected as the global homography matrix.

[0034] Specifically, a homography matrix representing the overall motion is robustly estimated from data containing a large number of feature point pairs. In a single iteration of the algorithm, instead of randomly and equally selecting four point pairs, the selection is based on previously calculated spatiotemporal matching weights. Sampling is performed. For example, a point pair with a weight of 3.0 is three times more likely to be selected than a point pair with a weight of 1.0. This weighted sampling mechanism makes the algorithm more likely to build the model starting from the most reliable point pairs. Using the four selected point pairs mentioned above, a solution can be obtained through the direct linear transformation algorithm. The candidate homography matrix H.

[0035] Subsequently, the candidate matrix H obtained above is used to examine all feature point pairs. For each point pair, the point coordinates in the first frame are transformed through matrix H to obtain a predicted coordinate in the second frame. The Euclidean distance between this predicted coordinate and the actual observed coordinate of the point in the second frame is calculated, i.e., the reprojection error. Assuming a pixel threshold of 2 is set, all point pairs with a reprojection error less than 2 pixels are considered inliers, i.e., they conform to the motion model represented by the current candidate matrix. The weights of all point pairs in this set of inliers are then assigned... The scores are summed to obtain a total weight score. This process is repeated thousands of times, each time generating a new candidate matrix and a corresponding total weight score. The candidate homography matrix that obtains the highest total weight score is selected as the global homography matrix because it represents the mainstream motion supported by the most reliable feature points.

[0036] Step S2: Apply the global homography matrix to the original sequence image to generate a preliminary corrected image; divide the preliminary corrected image into segments along the contact line direction, calculate the local affine transformation matrix for each segment, and determine the distortion factor representing the degree of non-rigid deformation of the segment based on the ratio of the maximum to the minimum singular value of the local affine transformation matrix.

[0037] Specifically, the first frame of the image sequence is selected as the reference frame. For each subsequent frame, the cumulative transformation matrix of that frame relative to the reference frame is obtained by multiplying the global homography matrices of all consecutive frames from the first frame to the current frame. The cumulative transformation matrix is ​​then applied to the current frame to perform a perspective transformation, and bilinear interpolation is used to fill pixels, aligning all images to the coordinate system of the reference frame. This eliminates global motion caused by camera shake and other factors, resulting in a series of pre-aligned corrected images.

[0038] In the initial corrected image, the image is divided into multiple segments with a width of 300 pixels and an overlap of 50 pixels along the central axis of the contact line. For each segment, feature point pairs that completely fall within this region are collected, and an optimal local affine transformation matrix is ​​calculated using the least squares method with these point pairs. The linear transformation part of the local affine transformation matrix is ​​a... Perform singular value decomposition on the matrix to obtain the maximum singular value and the minimum singular value. The ratio of the two is the distortion factor of the piecewise segment.

[0039] In an optional embodiment, the preliminary corrected image is segmented along the contact line direction, a local affine transformation matrix is ​​calculated for each segment, and a distortion factor representing the degree of non-rigid deformation of the segment is determined based on the ratio of the maximum to the minimum singular values ​​of the local affine transformation matrix, including:

[0040] Along the horizontal direction of the contact line, the preliminary corrected image is divided into multiple image segments with preset widths and overlaps. For each image segment, the feature points transformed into the segment are correlated with the preset target positions of the segment in the two-dimensional unfolded image. A local affine transformation matrix A is calculated using the least squares method. Singular value decomposition is performed on matrix A to obtain the maximum singular value. and minimum singular value ; Calculate the distortion factor of the segments. .

[0041] Specifically, while the image corrected by the global homography matrix is ​​generally flat, non-rigid deformations may still exist locally. To quantify these deformations, the elongated image is divided into multiple overlapping segments along its length. For example, a 2000-pixel long image can be divided into multiple 200-pixel wide segments, with a 50-pixel overlap between each segment to ensure continuity of analysis. For one segment, all feature points falling within the overlapping area are identified. The current coordinates of these feature points are known, and their target coordinates on an ideal, completely distortion-free two-dimensional plane are also pre-obtained.

[0042] Next, using the correspondence between these current coordinates and target coordinates, an optimal local affine transformation matrix A is calculated using the least squares method. This local affine transformation matrix represents how to map points within a segment from their current state to their ideal state. Singular value decomposition is then performed on this matrix A, yielding two singular values ​​and one maximum value. and a minimum value The two values ​​represent the maximum and minimum stretching or compression ratios of the image along the two principal directions within the segment under the transformation. The ratio of the maximum to the minimum value is used as the distortion factor of the segment, resulting in a quantitative index. For example, if the maximum singular value is 1.2 and the minimum singular value is 0.8, then the distortion factor is 1.5. The larger the distortion factor value, the more uneven the deformation of the segment and the higher the degree of non-rigid distortion.

[0043] Step S3: Apply the local affine transformation matrix of each segment to transform the preliminary corrected image, and stitch the transformed segments together to generate a two-dimensional unfolded image; on the two-dimensional unfolded image, segment out the candidate defect region; for each candidate defect region, sequentially apply the inverse matrix of the local affine transformation matrix of the segment where the region is located and the inverse matrix of the global homography matrix to project the contour of the region back to the original image to obtain the original mapped region.

[0044] Specifically, a blank long canvas is created, and all segments of the initially corrected image from the first frame are placed sequentially at the beginning of the canvas. Starting from the second frame, each segment undergoes a geometric transformation using its corresponding local affine transformation matrix, ensuring precise alignment with the corresponding segment from the previous frame. The transformed segments are then stitched together on the canvas adjacent to the previous frame image, with a linear gradient blending algorithm used to eliminate seams in the overlapping areas. This process is repeated until all image frames have been processed, resulting in a seamless, complete two-dimensional unfolded image of the contact line surface.

[0045] Next, median filtering is applied to the 2D unfolded image to smooth the background texture and suppress random noise. The Otsu algorithm (also known as the Otsu method) is used to calculate the globally optimal threshold, and the image is binarized to obtain a black-and-white binary image. Morphological closing operations are performed on the binary image to fill the tiny holes inside the defects and connect the broken parts. Then, a connected component labeling algorithm is used to identify each independent white region as a candidate defect region.

[0046] Based on the position of the candidate defect region on the 2D unfolded image, it is determined that it was generated by the j-th segment of the k-th frame of the original sequence image. The coordinates of the contour points of the candidate defect region are first multiplied by the inverse of the local affine transformation matrix of the j-th segment to transform back to the coordinate system of the preliminary corrected image. Then, the new coordinates are multiplied by the inverse of the cumulative global homography matrix of the k-th frame relative to the reference frame, and the contour points are accurately projected back onto the original k-th frame image. The area enclosed by these projected points is the original mapped area.

[0047] In an optional embodiment, the step of segmenting candidate defect regions on the two-dimensional unfolded image includes:

[0048] The two-dimensional unfolded image is smoothed and denoised using a medium filter; the Otsu algorithm is used to calculate the global binarization threshold, and regions with pixel values ​​below the global binarization threshold are identified as potential defect regions; morphological closing operations are performed on the binarized image to fill the holes inside the potential defect regions and connect the adjacent regions; connected component analysis is performed on the processed image, and connected components with areas within a preset range are marked as candidate defect regions.

[0049] Specifically, the process involves identifying potential defect areas from a two-dimensional unfolded image. The first step is to apply a median filter to the image to effectively remove isolated noise points generated by the sensor or environment, while preserving the edge information of the defects. The second step uses Otsu's algorithm to analyze the grayscale histogram of the entire image, automatically finding a grayscale threshold that best distinguishes the foreground from the background. All pixels in the image with grayscale values ​​below this threshold are marked as black, representing potential defects, while the remaining pixels are marked as white.

[0050] The third step involves performing a morphological closing operation on the black-and-white binary image. This operation first dilates and then erodes, effectively filling in small white holes that might exist within potential defect areas and connecting adjacent black regions that are disconnected due to noise but actually belong to the same defect, making the defect area more complete. The final step is to perform connected component analysis on the processed image to identify all interconnected black pixel clumps. The pixel area of ​​each clump is calculated and filtered according to a preset size range. For example, an area range of 30 to 2000 pixels is selected. Any tiny black dots with an area smaller than 30 pixels are considered noise and ignored, while extremely large dark areas with an area greater than 2000 pixels are not likely to be defects and are also excluded. The remaining black clumps with areas within the specified range are officially marked as candidate defect areas, awaiting further verification.

[0051] Step S4: Calculate the ratio of the gradient direction entropy of the pixels inside the original mapping area to the gradient direction entropy of the neighboring background pixels; determine the adaptive judgment threshold by using a preset monotonically increasing function based on the distortion factor corresponding to the segment where the candidate defect region is located; when the ratio exceeds the adaptive judgment threshold, the candidate defect region is determined to be a real defect.

[0052] Specifically, calculating the ratio of the gradient direction entropy of pixels within the original mapping region to the gradient direction entropy of neighboring background pixels includes:

[0053] For all pixels within the original mapping region, the Sobel operator is used to calculate the gradient magnitude and gradient direction of each pixel; the gradient direction is quantized into multiple intervals, the number of gradients falling into each interval is counted, a gradient direction histogram is constructed, and the information entropy is calculated. Expand the minimum bounding rectangle of the original mapping region outward by a preset pixel width to obtain this expanded annular region as the neighborhood background; calculate the gradient direction entropy of the neighborhood background using the same steps as calculating the information entropy. ; Calculate the ratio .

[0054] Specifically, to verify the authenticity of a candidate defect, the texture complexity of the candidate defect in the original image is analyzed. The candidate defect region found on the 2D unfolded image is mapped back to its position in the original video frame; this region is called the original mapping region. The Sobel operator is applied to each pixel within the region to calculate the gradient direction, for example, from 0 to 359 degrees. All possible gradient directions are divided into 16 equally wide intervals, each 22.5 degrees. The number of pixels falling into each direction interval is counted, forming a 16-bar gradient direction histogram. Based on the probability distribution of this histogram, the information entropy is calculated. A realistic defect with a chaotic texture, such as a crack, will have a wide variety of gradient directions, resulting in a high entropy value.

[0055] For comparison, it's necessary to analyze the normal background texture surrounding the defect. Find the smallest bounding rectangle of the original mapped area, and extend the rectangle's boundary outwards by 15 pixels to form a ring. This ring region, excluding the defect itself, is taken as the neighborhood background. Perform the same operation on this background region: calculate the gradient direction of all pixels, construct a histogram of 16 intervals, and calculate the gradient direction entropy of the background. Typically, the surface texture of a normal contact line is relatively uniform, with concentrated gradient directions, resulting in a lower background entropy value. (Calculate defect entropy) With background entropy The ratio. For example, if the entropy of a defective region is 4.2, while the background entropy of the region is only 1.5, then the ratio is... The ratio is 2.8. A higher ratio indicates that the texture complexity of the region is significantly higher than that of the surrounding environment, and the region is more likely to be a real defect.

[0056] Based on the distortion factor corresponding to the segment where the candidate defect region is located, an adaptive judgment threshold is determined through a preset monotonically increasing function, including:

[0057] The distortion factor of the segment containing the candidate defect region is obtained as follows: ,in ;

[0058] The preset monotonically increasing function is ,in, Based on the threshold, This is the sensitivity coefficient;

[0059] The calculation obtained in the previous step As an adaptive decision threshold.

[0060] Specifically, the criteria for determining whether a defect is real are dynamically adjusted based on the degree of local geometric distortion in the image to reduce false alarms. When a candidate defect is detected, its location within a specific segment of the image is determined. A distortion factor for each segment has already been calculated in a previous step. ,For example It equals 1.8. A higher distortion factor means that the image of the region has been significantly stretched or distorted during the correction process. This geometric deformation itself may produce complex textures similar to defects, interfering with the judgment.

[0061] To compensate for this effect, a pre-defined linear function is used to generate an adaptive decision threshold. Assume the obtained base threshold... The sensitivity coefficient is 2.5. It is 0.8. For the distortion factor... For regions with a threshold of 1.8, the adaptive threshold for region determination is set. The value is 3.14. However, for another region located in a very small distortion area, for example... The threshold is 1.1, and the adaptive decision threshold is 2.58. That is, in areas with severe distortion, the gradient direction entropy ratio of candidate defects needs to reach a higher threshold, such as 3.14, to be identified as a true defect, while in areas with less distortion, a lower threshold, such as 2.58, is sufficient. This adaptive mechanism ensures consistent reliability of detection across different image quality regions.

[0062] Finally, for each candidate defect region, the gradient direction entropy ratio calculated in the previous step is... With the distortion factor based on the location Calculated adaptive threshold Compare. If Greater than If the candidate region is identified as a genuine defect, it is considered a real defect; otherwise, it is considered an artifact caused by image distortion and is discarded.

[0063] This invention also provides a system for detecting surface defects in railway contact wires. For example... Figure 2 As shown, the system includes a processor and a memory, the memory storing computer program instructions, which, when executed by the processor, implement the railway contact wire surface defect detection method described above according to the present invention.

[0064] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and therefore will not be described in detail here.

[0065] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device. Any application or module described in this invention can be implemented by computer-readable / executable instructions stored or otherwise maintained on such a computer-readable medium.

[0066] In the description of this specification, "multiple" means at least two, such as two, three or more, etc., unless otherwise expressly and specifically defined.

[0067] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.

Claims

1. A method for detecting surface defects in railway contact wires, characterized in that, Includes the following steps: Acquire the original sequence images of the railway contact line to be detected; extract feature point pairs between consecutive frames, and calculate the spatiotemporal matching weight based on the tracking duration of the feature point pairs and their normal distance from the central axis of the contact line; Using the aforementioned spatiotemporal matching weights, a global homography matrix is ​​calculated through a weighted random sampling consensus algorithm, including: in each iteration, probabilistic sampling is performed based on the spatiotemporal matching weights of each feature point pair, selecting four feature point pairs, with higher weights indicating a higher probability of selection; a candidate homography matrix is ​​calculated using the selected four feature point pairs; the candidate homography matrix is ​​applied to all feature point pairs, the reprojection error is calculated, and feature point pairs with errors less than a preset pixel threshold are classified as inlier sets; the total weight of the current inlier set is calculated, which is the sum of the spatiotemporal matching weights of all feature point pairs within the set; the above steps are repeated a specified number of times, and the homography matrix corresponding to the inlier set with the largest total weight is selected as the global homography matrix; The global homography matrix is ​​applied to the original sequence image to generate a preliminary corrected image; the preliminary corrected image is segmented along the contact line direction, and a local affine transformation matrix is ​​calculated for each segment. Based on the ratio of the maximum to the minimum singular value of the local affine transformation matrix, a distortion factor representing the degree of non-rigid deformation of the segment is determined. The preliminary corrected image is transformed by applying the local affine transformation matrix of each segment, and the transformed segments are stitched together to generate a two-dimensional unfolded image. Candidate defect regions are segmented on the two-dimensional unfolded image. For each candidate defect region, the inverse matrix of the local affine transformation matrix of the segment where the region is located and the inverse matrix of the global homography matrix are applied in sequence to project the contour of the region back to the original image to obtain the original mapped region. Calculate the ratio of the gradient direction entropy of the pixels inside the original mapping area to the gradient direction entropy of the neighboring background pixels; determine an adaptive judgment threshold based on the distortion factor corresponding to the segment where the candidate defect region is located through a preset monotonically increasing function; when the ratio exceeds the adaptive judgment threshold, the candidate defect region is determined to be a real defect. The steps for calculating the spatiotemporal matching weights include: recording the number of consecutive frames in which each feature point is successfully tracked as its tracking duration. Determine the central axis of the contact line in each frame of the image, and calculate the vertical Euclidean distance from each feature point to the central axis as the normal distance. ; through formula Calculate the spatiotemporal matching weights for each feature point pair ,in and For preset positive numbers, This is the normal distance.

2. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The extraction of feature point pairs between consecutive frames includes: The SURF algorithm is used to detect feature points in each frame of the image, and the KLT optical flow method is used to track feature points between consecutive frames to establish the feature point pairs.

3. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The step of generating the preliminary corrected image includes: The first frame of the image sequence is selected as the reference frame; For each subsequent frame, multiply it by the global homography matrix of all consecutive frames between the frame and the reference frame to obtain the cumulative global homography matrix of that frame relative to the reference frame. The cumulative global homography matrix is ​​applied to the corresponding original sequence image to generate the preliminary corrected image aligned with the reference frame.

4. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The preliminary corrected image is segmented along the contact line direction, and a local affine transformation matrix is ​​calculated for each segment. Based on the ratio of the maximum to the minimum singular value of the local affine transformation matrix, a distortion factor representing the degree of non-rigid deformation of the segment is determined, including: Along the horizontal direction of the contact line, the preliminary corrected image is divided into multiple image segments with preset width and overlap. For each image segment, the feature points that have been transformed into the segment are correlated with the preset target positions of the segment in the two-dimensional unfolded image. A local affine transformation matrix A is calculated by the least squares method. Perform singular value decomposition on matrix A to obtain the maximum singular value. and minimum singular value ; Calculate the distortion factor of the segment. .

5. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The step of segmenting the candidate defect region on the two-dimensional unfolded image includes: Apply a medium-value filter to smooth and denoise two-dimensional unfolded images; The Otsu algorithm is used to calculate the global binarization threshold, and regions in the image with pixel values ​​lower than the global binarization threshold are identified as potential defect regions. Morphological closing operations are performed on the binarized image to fill the holes inside the potential defect area and connect the adjacent areas; Connectivity analysis is performed on the processed image, and connected regions with areas within a preset range are marked as candidate defect regions.

6. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The calculation of the ratio of the gradient direction entropy of the pixels within the original mapping region to the gradient direction entropy of the neighboring background pixels includes: For all pixels within the original mapping region, the Sobel operator is used to calculate the gradient magnitude and gradient direction of each pixel; the gradient direction is quantized into multiple intervals, the number of gradients falling into each interval is counted, a gradient direction histogram is constructed, and the information entropy is calculated. ; Expand the minimum bounding rectangle of the original mapping area outward by a preset pixel width, and obtain this expanded ring area as the neighborhood background. The gradient direction entropy of the neighborhood background is calculated using the same steps as those used to calculate the information entropy. ; Calculate the ratio .

7. The method for detecting surface defects in railway contact wires according to claim 1, characterized in that, The step of determining the adaptive judgment threshold based on the distortion factor corresponding to the segment where the candidate defect region is located, through a preset monotonically increasing function, includes: The distortion factor of the segment containing the candidate defect region is obtained as follows: ,in ; The preset monotonically increasing function is ,in, Based on the threshold, This is the sensitivity coefficient; The calculation obtained in the previous step As an adaptive decision threshold.

8. A system for detecting surface defects in railway contact wires, characterized in that, include: processor; A memory storing computer instructions for detecting surface defects in railway contact wires, which, when executed by the processor, cause the system to perform the railway contact wire surface defect detection method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Power transmission line insulator defect detection system based on multispectral imaging

    CN119985495A

  • Defect detection method and system for flexible circuit board based on image recognition model

    CN120070453A