Railway turnout spacing detection method and system based on image data
Through the railway switch spacing detection method based on image data, the structural template library is used to automatically match and key point positioning, the problem of low accuracy of traditional detection efficiency is solved, high-precision switch structure detection and long-term change trend monitoring is realized, and the safety and management efficiency of railway switch operation and maintenance are improved.
Patent Information
- Application Number
- CN202510455201.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-07-22
AI Technical Summary
Traditional railway switch spacing detection efficiency and insufficient accuracy, which cannot meet the needs of modern railway automation operation and maintenance and real-time safety monitoring.
The railway switch spacing detection method based on image data is adopted. By acquiring the switch image data, image processing and structural feature extraction are performed, a pre-constructed structural template library is used for matching and coordinate transformation, key points are located, and the actual physical distance is calculated based on the scale factor.
It realizes high-precision and highly automated switch structure inspection, improves detection efficiency and accuracy, has on-site adaptability, can monitor the long-term change trend of switch structure, and improves the safety and management efficiency of railway switch operation and maintenance.
Smart Images

Figure CN120355684A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of railway track safety detection, and more specifically, to a method and system for detecting the spacing of railway turnouts based on image data. Background Art
[0002] Railway turnouts are one of the crucial devices in the railway rail transit system. Their main function is to guide trains to transfer from one track line to another, realizing the conversion of train operation routes. The internal structure of turnouts includes multiple key structural units such as switch rails, stock rails, and crossing rails. The spacing parameters between these structural units are one of the key indicators to ensure the safe and stable operation of trains. However, due to reasons such as long-term operation, equipment aging, external environmental impacts, and construction errors, the spacing between the key structures of turnouts may shift or deform, thereby leading to unstable train operation, vibrations, wear, and even serious derailment accidents. Currently, traditional railway turnout spacing detection mainly relies on manual inspections and manual measuring tools, with low efficiency and unable to guarantee accuracy, making it difficult to meet the requirements of modern railway automated operation and maintenance and real-time safety monitoring. Although some image recognition technologies have been introduced in the prior art to assist in detection, there are still defects such as complex scale calibration, low recognition accuracy, and inability to automatically monitor structural changes in the long term, which restrict the further improvement of the maintenance level of railway turnouts. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method and system for detecting the spacing of railway turnouts based on image data to solve the problems mentioned in the background art.
[0004] To achieve the above object, the present invention adopts the following technical solutions:
[0005] A method for detecting the spacing of railway turnouts based on image data, comprising the following steps:
[0006] Obtain turnout image data, perform image processing on the turnout image data to determine the turnout area and extract image structure features;
[0007] According to the image structure features, select a matching structure template from a pre-established structure template library, and perform coordinate transformation on the structure template to map it into the turnout area;
[0008] Based on the mapped structure template, perform key point localization in the local area corresponding to the turnout area to obtain the image coordinates of each structural key point;
[0009] According to the image coordinates of each structural key point and the scale factor, convert the image pixel distance between key points into the actual physical distance to calculate the structural spacing of the turnout.
[0010] Optionally, the method for determining the scale factor is specifically as follows: select a first key point and a second key point with known actual physical distances in the structure template; identify the image coordinates of the first key point and the second key point in the turnout area image, and calculate the pixel distance between the first key point and the second key point; determine the scale factor by using the ratio of the actual physical distance to the pixel distance between the first key point and the second key point.
[0011] Optionally, the specific method for selecting a matching structure template from the structure template library is as follows:
[0012] Based on the image structure features extracted from the turnout image data, select the top N structure templates with the highest similarity from the structure template library, perform coordinate transformation on each of them and map them to the turnout area;
[0013] Determine N groups of candidate coordinates of structure key points according to each of the above N mapped structure templates respectively;
[0014] Perform fusion voting on the N groups of candidate coordinates of structure key points. The voting method is to calculate the average coordinates of each group of candidate coordinates of key points or calculate the weighted average coordinates according to the similarity weights of the structure templates, so as to obtain the final image coordinates of each structure key point.
[0015] Optionally, the method further includes a step of analyzing the deviation trend of the turnout structure key points, which specifically includes:
[0016] Record the offset amount between the image coordinates obtained each time when identifying the turnout structure key points and the standard coordinates in the corresponding structure template, and establish a time series of key point offset amounts;
[0017] Adopt a trend fitting method to analyze the time series of key point offset amounts to determine whether there is a continuous deviation trend of the key points; the trend fitting method satisfies the following formula:
[0018] ΔX(t)=k x t + c x , ΔY(t)=k y t + c y ;
[0019] In the formula, ΔX(t) and ΔY(t) respectively represent the horizontal and vertical direction offset amounts of the key point at the t-th detection, k x , k i respectively represent the offset rates in the horizontal and vertical directions, c x , c y respectively represent the initial offset constants in the horizontal and vertical directions.
[0020] Optionally, the method for constructing the structure template is specifically as follows:
[0021] Collect image samples of multiple target types of turnouts and complete the annotation of multiple structural key points in each image;
[0022] Unify the key point data of all image samples under the standard coordinate system and perform vectorized expression;
[0023] Use a clustering algorithm to cluster all key point vectors to obtain several subsets with similar structures;
[0024] Select representative key point configurations as structural templates in each subset to form a multi-structural template set, and store them in the structural template library for subsequent matching use.
[0025] Optionally, the method for determining the turnout area includes the following steps:
[0026] Use Gaussian filtering or median filtering method to denoise the image;
[0027] Extract the track edge through an edge detection algorithm;
[0028] Use the Hough transform or a deep learning convolutional neural network model to determine the specific range of the turnout area.
[0029] Optionally, the specific method for key point positioning is:
[0030] Taking the key point positions in the mapped structural template as the center, delimit a local window in the turnout area image;
[0031] Use a corner detection algorithm based on gradient intensity or a CNN heatmap regression algorithm in the local window to determine the sub-pixel coordinate positions of the key points.
[0032] Optionally, the calculation method for the similarity of the structural template is:
[0033] Extract the SIFT, SURF or ORB feature vectors of the image and the template, and use the cosine similarity or Euclidean distance calculation method to determine the similarity values between the image and each template and sort them.
[0034] The present invention also discloses a railway turnout spacing detection system based on image data, including an image acquisition module, an image processing module, a structural template library module, a template matching module, a key point positioning module and a spacing calculation module;
[0035] The image acquisition module is used to acquire image data of the railway turnout area;
[0036] The image processing module is connected to the image acquisition module and is used to process the image data, determine the turnout area and extract the image structure features of the turnout area;
[0037] The structure template library module is used to pre-store the structure templates of multiple railway switches, and multiple structure key points and their corresponding standard physical positions are predefined in each structure template;
[0038] The template matching module is respectively connected to the image processing module and the structure template library module, and is used to calculate the similarity between the image structure features of the switch area and the templates in the structure template library, and select the matching structure template;
[0039] The key point positioning module is connected to the template matching module, and is used to perform coordinate transformation and actual positioning of key points in the switch area image based on the matched structure template;
[0040] The spacing calculation module is connected to the key point positioning module, and is used to calculate the actual physical spacing between key points according to the image coordinate positions of the key points determined by the key point positioning module and in combination with the scale factor.
[0041] Optionally, the system further includes a trend analysis module and an anomaly warning module;
[0042] The trend analysis module is connected to the key point positioning module, and is used to record and store the offset data between the actual image coordinates of the key points detected each time and the standard positions of the structure templates, establish an offset time series, and use the trend fitting analysis method to determine whether there is a continuous offset trend in the key point positions;
[0043] The anomaly warning module is connected to the trend analysis module, and is used to generate and output corresponding anomaly warning information when the offset trend of the key points exceeds a preset threshold according to the continuous offset trend determined by the trend analysis module.
[0044] The advantages of the present invention over the prior art are that the present invention provides a method and system for detecting the spacing of railway switches based on image data. By pre-constructing a structure template library and automatically matching and mapping the structure templates with the on-site images, it can automatically identify and measure the spacing of the switch structure key points with high precision, significantly improving the accuracy and automation level of switch detection. At the same time, the present invention designs a self-scale calibration method without manual scales, making the system have stronger on-site adaptability and further improving the ranging efficiency and accuracy. The multi-template fusion voting mechanism in the present invention effectively solves the problem of poor adaptability of a single template to structural variations, improving the stability and accuracy of the system in complex scenarios. The further introduced function of analyzing the offset trend of structure key points can automatically monitor the long-term change trend of the switch structure, identify the aging or abnormal changes of the switch structure in advance, provide reliable data support for the preventive maintenance of railway switches, and effectively improve the safety and management efficiency of railway switch operation and maintenance. Description of the Drawings
[0045] Figure 1 is the specific flowchart of the method of the present invention;
[0046] Figure 2 is the flowchart for constructing the structure template of the method of the present invention;
[0047] Figure 3 is the flowchart for obtaining the scale factor of the present invention;
[0048] Figure 4 is the schematic diagram of the system of the present invention. Specific embodiments
[0049] The specific embodiments of the present invention will be described below with reference to the accompanying drawings.
[0050] The core of the present invention lies in constructing a structure template library. By comparing the existing photos with the structure template library, the position of key points can be obtained more accurately, and further the size information can be obtained according to the ratio.
[0051] As Figure 1 shown, the present invention specifically includes the following steps:
[0052] Obtain turnout image data, perform image processing on the turnout image data, determine the turnout area and extract image structure features;
[0053] According to the image structure features, select a matching structure template from the pre-established structure template library, and perform coordinate transformation on the structure template to map it into the turnout area;
[0054] Based on the mapped structure template, perform key point positioning in the corresponding local area of the turnout area to obtain the image coordinates of each structure key point;
[0055] According to the image coordinates of each structure key point and the scale factor, convert the image pixel distance between key points into the actual physical distance to calculate the structure spacing of the turnout.
[0056] Among them, for the turnout image data. In specific implementation, the turnout area of the railway site can be photographed by an industrial camera or a high-definition imaging device carried by a drone to obtain the original image containing the complete structure of the turnout. The image acquisition angle is preferably top-down or nearly top-down to avoid large-angle inclination to reduce perspective distortion.
[0057] After obtaining the original image data, image processing is performed on the image to clearly extract the turnout area. The specific steps include: using Gaussian filtering or median filtering methods to reduce the noise interference of the image; then detecting the track edge features through an edge detection operator (such as the Canny operator); using the Hough transform or a convolutional neural network structure to identify the track straight line features, and finally obtaining an accurate turnout area image and extracting clear image structure features from it. These structure features include, but are not limited to, obvious geometric feature points such as the starting point of the switch rail, the end point of the switch rail, the intersection point of the stock rails, the top of the crossing rail, etc., as well as structural information such as the track edge line and the sleeper contour line.
[0058] As Figure 2 shown, the construction of the structure template specifically includes the following steps:
[0059] First, multiple groups of image samples of this type of turnout in the actual line need to be collected. These images should meet the requirements of being clear and complete and containing the entire turnout structure area. When shooting, try to keep the top-down or near-top-down angle as much as possible to reduce perspective distortion. The number of collected images should be sufficient to cover the geometric variation range of this type of turnout. Usually, it is recommended to have no less than 50 image samples.
[0060] After the image collection is completed, each image is labeled with structure key points. The selection of key points should include control points that can completely describe the main structure shape of the turnout, such as the starting point of the switch rail, the end point of the switch rail, the intersection points of the left and right stock rails, the leading and trailing edges of the crossing rail, and the end points of the guard rail. After each image is labeled, a set of two-dimensional coordinate points is formed, and this point set is vectorized and expressed as a one-dimensional coordinate vector.
[0061] To eliminate the interference caused by shooting angle, scale, or position deviation, all coordinate vectors need to be normalized. The normalization methods can include centering, scale standardization, or principal component alignment to make the key point configurations in different images comparable.
[0062] The normalized set of key point vectors is input into a clustering algorithm for structure analysis. The clustering method can be selected according to actual needs, such as K-means, mean shift, Gaussian mixture model, or density-based clustering method, to discover subsets of samples that are structurally close.
[0063] After clustering, a representative key point configuration is selected within each cluster as the representative structure template of the cluster. The selection criterion for the representative sample can be the sample with the smallest Euclidean distance from the cluster center vector in this class, or the composite template obtained by taking the mean of all sample coordinates and then restoring it to the actual coordinate system. The multiple templates finally generated are uniformly stored in the structure template library, and their corresponding structure feature categories, reference image resolutions, and key point definition methods are marked for use in the subsequent image matching stage.
[0064] The structure template constructed by the above method can not only accurately reflect the typical geometric features of different turnout structure variants, but also has strong adaptability and generalization ability, and is suitable for automatic matching and key point guiding and positioning in actual detection systems.
[0065] In the turnout image detection and ranging tasks, due to differences in shooting conditions, camera equipment, and on-site environment, there may be obvious variations in the actual scale of each image. Therefore, a reliable scale factor is required to calibrate the conversion of the pixel distance measured in the image to the real physical distance. Traditional distance measurement usually requires placing additional artificial scales or special calibration equipment during image shooting. However, in railway field operations, especially in the case of unmanned or automated detection, this way of manually arranging scales obviously lacks the convenience of engineering implementation. Therefore, to achieve automatic and reliable ranging, this method adopts a self-scale calibration method without artificial scales, that is, two structural key points with known actual physical distances are selected from the existing structure template, and the automatic calibration scale factor is determined by using these two key points and their corresponding points in the image.
[0066] As Figure 3 shown, the method is as follows:
[0067] Select the first key point and the second key point with known actual physical distances in the structure template;
[0068] Identify the image coordinates of the first key point and the second key point in the turnout area image, and calculate the pixel distance between the first key point and the second key point;
[0069] Determine the scale factor by using the ratio of the actual physical distance to the pixel distance of the first key point and the second key point.
[0070] More specifically: First, a pair of key points with stable and standard physical distances need to be selected in the pre-established structure template as scale points. These key points usually select the most standardized and stable distance indicators in the railway turnout structure, such as the inner edge points of the two basic rails with a railway standard gauge of 1435mm, or the fixed length between the starting end and the ending end of the switch rail. The reason for selecting the standard gauge as the scale point is that this distance is the most stable and unified standard in the railway industry, and is not easily affected by installation errors, structural aging, or wear and deformation, which can ensure the long-term stability and accuracy of the measurement scale. Of course, in different railway turnout scenarios, other stable distances on the structure can also be selected according to actual needs, such as the distance between the switch rail and the heart rail or the sleeper spacing, provided that these distances should meet the standard lengths clearly given in the railway specifications.
[0071] After determining the first key point and the second key point in the structural template, the next step is to accurately identify and locate the image coordinate positions of the first key point and the second key point corresponding to the structural template in the actually collected turnout area image. In actual engineering implementation, the combined method of template mapping and local feature detection can be used to determine the accurate positions of these two key points. The specific method is to first map the structural template into the actual image through affine transformation or perspective transformation. The mapped template can indicate the approximate position areas of the first key point and the second key point in the image. Subsequently, local image analysis is performed within an appropriate range (such as a 40×40 pixel window) in this indicated area. Corner detection algorithms (such as Harris corner detection, Shi-Tomasi corner detection) can be used, or a pre-trained deep learning CNN network can be used to predict the heat map of the local area to obtain the sub-pixel accuracy image coordinates of these two key points. The recommended range of the actual local window size can be 30 to 60 pixels. If it is too small, key features are likely to be missed. If it is too large, irrelevant interference features may be introduced.
[0072] After obtaining the pixel coordinates of the first key point and the second key point in the image, next, calculate the image pixel distance between these two points. The calculation method is relatively straightforward, that is, the Euclidean distance formula is used for calculation, and the formula is:
[0073]
[0074] In the formula, (x1, y1) and (x2, y2) are respectively the image coordinate positions of the first key point and the second key point identified in the image. In the actual calculation process, in order to further improve the calculation efficiency, integer or floating-point operations can also be directly used instead of square root operations for approximate estimation. If high precision is required, then perform square root calculation to balance speed and accuracy.
[0075] Finally, using the ratio of the pre-determined actual physical distance between the two key points in the structural template to the above-calculated image pixel distance, the scale factor r corresponding to the current image can be obtained. The calculation formula of the scale factor has been described above as:
[0076]
[0077] where r is the scale factor to be calculated, L r is the standard physical distance between any two key points with known actual physical distances in the structural template, and L p is the pixel distance between the corresponding positions of the above two key points in the current image.
[0078] Through the scale factor r, the pixel distances between all subsequent identified key points in the image can be uniformly converted into actual physical distances, ensuring the unity and accuracy of the distance measurement results.
[0079] For example, if the standard actual distance between two key points selected from the template is 1435 mm, and the pixel distance between the corresponding points measured in the actual image is 574 pixels, then the calculated scale factor r is approximately 2.5 mm / pixel. If the subsequently measured pixel distance between the switch rail and the stock rail in the image is 20 pixels, then the actual physical distance can be calculated using the scale factor r as 20 pixels × 2.5 mm / pixel = 50 mm.
[0080] In addition, in the actual railway field environment, there are a large number of switch structures with different models, specifications, and even states. Due to historical installation, use, and maintenance reasons, some switches may have slight structural deformations or modifications, making it impossible for a single template in the structure template library to match precisely. If a single template is used for matching, it may result in recognition deviations or an inability to accurately determine the key point positions, seriously affecting the ranging accuracy and the accuracy of structural anomaly detection. Therefore, to improve the system's adaptability to different or variant switch structures, this method selects multiple structure templates with the highest similarity from the structure template library, performs matching and coordinate mapping on these templates simultaneously, and then fuses the positioning results of multiple templates to determine the final key point image coordinate positions. This method effectively solves the problem of insufficient adaptability of a single template to complex or ambiguous structures, greatly improving the stability and accuracy of recognition.
[0081] In the specific implementation process, it is first necessary to extract clear and stable image structure features based on the switch image data. These features can include track line segments, sleeper edge lines, geometric features or corner information at the intersection of the switch rail and the crossing rail. Generally, low-level image features such as grayscale, gradient, and edge information can be used, or CNN deep learning features can be combined for comprehensive extraction. The specific extraction method of image structure features can use common image feature extraction algorithms, such as SIFT, SURF, or ORB feature extraction methods, or a pre-trained CNN network can be used to extract global feature vectors to comprehensively represent the image structure information. Generally, it is recommended to set the length of the extracted feature vector between 128 and 512 dimensions to ensure both recognition accuracy and operation efficiency.
[0082] Subsequently, by calculating the similarity between the extracted image structure features and the feature vectors of each template in the pre-built structure template library, the top N templates with the similarity to the current image structure features are selected from the template library for subsequent processing. The specific similarity calculation method can use cosine similarity, Euclidean distance or nearest neighbor retrieval method for matching, all of which are suitable for quickly determining the similarity ranking of templates. In actual selection, the number N of similar templates can be set to 3 to 5, and the specific selection depends on the complexity of the actual detection scene. If the scene environment is complex and the structure varies a lot, a relatively large N value can be selected to ensure the richness of the candidate templates, while the N value can be appropriately reduced in scenes with simple scene environments and less variation to improve computational efficiency.
[0083] After determining the N most similar templates, coordinate transformation is performed on each template to accurately map it to the current turnout area image. The specific coordinate transformation process uses affine transformation or perspective transformation. The method is to select several stable anchor points in the current image (such as the intersection of the track or the intersection of the center line of the sleeper) to establish the correspondence between the image coordinates and the coordinates of each structural template, so as to achieve accurate mapping of each structural template. This coordinate transformation step can be assisted by classic image alignment algorithms, such as the least squares method or RANSAC algorithm-based registration method, to ensure that the template mapping accuracy reaches the pixel level or sub-pixel level.
[0084] For each mapped structural template, the coordinate positions of the structural key points contained therein in the turnout image are determined respectively, thereby obtaining N sets of candidate coordinates of structural key points. The method for determining the candidate coordinates can be based on the position area indicated by each mapped template to perform a fine analysis and search of the local area. Specifically, a gradient-based or local corner point detection method (such as Harris corner point detection algorithm) can be used for accurate position determination, or CNN heat map regression technology can be used to predict the key point position to ensure that the candidate key point positioning achieves a high accuracy.
[0085] After determining the candidate coordinates of N groups of key points, the next step is to perform fusion voting to determine the final coordinates of the key points. The fusion voting method specifically includes two ways: one is the simple average coordinate fusion method, that is, calculating the arithmetic mean of all N candidate coordinates; the other is the weighted average fusion method based on the structural template similarity, that is, using the similarity value or matching confidence obtained during the previous template matching as the weight, and performing weighted summation on each candidate coordinate to determine the final coordinate position of the key point. In specific implementation, if the similarities of N candidate templates are relatively close, the average coordinate method can be directly adopted. If there are obvious similarity differences (for example, the similarity of the first-ranked template is significantly higher than other templates), it is more reasonable to use the weighted average method. In addition, in practice, the commonly selected weight setting scheme is to normalize the template similarity value as the weighted coefficient of each template to ensure that the position of the fused key point is more biased towards the prediction result of the template with a higher similarity.
[0086] Take a practical example. Suppose the templates with the top three similarities obtained after calculating the template similarity of the current image are Template A, Template B, and Template C, and the template similarities are 0.8, 0.6, and 0.5 respectively. After performing coordinate transformation and key point positioning on these three templates respectively, the three candidate coordinate positions of a certain key point in the image are obtained as (100, 150), (102, 149), and (98, 151). If the weighted fusion method is adopted, the similarities are first normalized to obtain weights 0.42, 0.32, and 0.26 respectively. Then, the three coordinates are weighted and calculated, that is, (100×0.42 + 102×0.32 + 98×0.26, 150×0.42 + 149×0.32 + 151×0.26), and the calculated final key point image coordinates are the fused accurate coordinate results.
[0087] The specific implementation of the above fusion voting method can be carried out with the help of conventional data calculation platforms or image analysis tools, such as the OpenCV, Python, or MATLAB environment, and the number of similar templates and the parameter settings of the fusion method can be flexibly adjusted according to the actual railway site conditions or the degree of difference in the turnout structure to ensure the optimal effect of key point recognition.
[0088] In the actual operation and maintenance management of railway turnouts, only detecting the position and spacing of the key points of the turnout structure at a certain moment often can only reflect the turnout structure state at that time, and cannot reflect the change trend of the turnout structure over time, such as progressive problems like slow displacement, subsidence, and structural aging. Therefore, it is necessary to establish a long-term trend analysis mechanism, that is, continuously monitor the trend of the offset of the key points of the turnout structure relative to the standard position over time, so as to detect slowly developing structural problems or deformation trends in advance, and to guide subsequent maintenance decisions and improve the safety and service life of the turnout.
[0089] To achieve this goal, the present invention further sets a step for analyzing the offset trend of the key points of the turnout structure, that is, when performing the tasks of identifying and measuring the distances of the key points of the turnout structure each time, the difference between the image coordinates of the identified key points and the standard positions of the key points in the mapped structure template is calculated, so as to record the offset data of the key points, and a time series database of the key point offsets is established according to the detection time sequence. The specific implementation method is as follows: when performing the turnout detection task for the first time, taking the standard position of the structure template as the initial reference, calculating the horizontal offset ΔX and vertical offset ΔY between the actually identified key point position and the template standard position, and storing them in the database, while recording the corresponding detection date and time stamp; after each subsequent turnout key point identification, the above offset calculation process is repeated, and the latest calculated offset data is appended to the database, so as to form a continuous offset sequence of each key point changing with time. This process can be realized by using common data storage methods in engineering practice, such as recording the offset data of each key point based on a relational database (such as MySQL, SQLite) or a time series database (such as InfluxDB, TimeScaleDB), so as to facilitate subsequent data analysis and trend determination.
[0090] After obtaining the above-mentioned time series of key point offsets, it is necessary to perform trend fitting analysis on these sequences to determine whether there is a continuous structural offset trend for each structural key point. The specific trend analysis adopts a linear fitting method, that is, a first-order linear regression is used to fit the law of the key point offset changing with time, and analyze whether it has an obvious offset tendency, satisfying the following formula:
[0091] ΔX(t) = k x t + c x , ΔY(t) = k y t + c y ;
[0092] In the formula, ΔX(t) and ΔY(t) respectively represent the horizontal and vertical offset amounts of the key point at the t-th detection, k x , k i respectively represent the offset rates in the horizontal and vertical directions, c x , c y respectively represent the initial offset constants in the horizontal and vertical directions.
[0093] In specific implementation, the least squares method can be used for linear regression fitting calculation, that is, solving a system of linear equations based on historical offset data to obtain the best fitting straight line, and determining the offset rate and trend direction of the key point position accordingly.
[0094] In practical engineering applications, common data analysis and statistical calculation tools can be used to implement the trend analysis method, such as the Scipy or Statsmodels libraries in Python, the fitting toolbox of MATLAB, or the data analysis function of Excel. These tools all have the computing power required to achieve trend fitting. In terms of parameter selection, it is usually recommended to use no less than 5 historical detection data for trend analysis to ensure the stability and reliability of trend analysis; for critical turnouts, the amount of data for trend analysis can be increased to 10 times or more to improve the accuracy of trend determination. In addition, the significance judgment of trend fitting can also be evaluated through R 2 (coefficient of determination) or residual analysis of trend fitting. Generally, when the R 2 value is greater than 0.7, it can be considered that the trend fitting is effective, and the structural state of the turnout can be reasonably evaluated accordingly.
[0095] Illustrated by a specific example, for example, at the end key point of the switch rail of a turnout, the offset amounts relative to the standard position at the first detection are ΔX(1) = 1.5 mm and ΔY(1) = 0.8 mm; at the subsequent second to fifth detections, the offset amounts are recorded as (1.8 mm, 1.0 mm), (2.1 mm, 1.3 mm), (2.5 mm, 1.6 mm), and (2.9 mm, 1.9 mm) respectively. After linear fitting calculation, the offset trend fitting formulas are obtained as ΔX(t) = 0.35t + 1.15 and ΔY(t) = 0.275t + 0.55, where k x = 0.35 mm / detection, k y = 0.275 mm / detection, indicating that there is an obvious continuous offset trend at this key point, and it shows an increasing trend successively, indicating that there may be a risk of gradually deteriorating structural deformation at this part of the turnout. At this time, maintenance personnel can take maintenance measures in advance according to this trend to avoid serious failures or safety hazards of the turnout.
[0096] Through the above-described steps of analyzing the offset trend of the key points of the turnout structure in detail, the present invention can not only timely detect the abnormal state of the turnout structure, but also predict the long-term change trend of the structure in advance, thereby providing scientific data support and decision-making basis for railway equipment maintenance, comprehensively improving the safety, reliability, and operation efficiency of railway turnouts. Moreover, the implementation details and parameter selection involved in the above solution can be flexibly adjusted according to the actual railway scenario and maintenance requirements to adapt to different application needs and accuracy requirements.
[0097] As Figure 4 shown, the present invention correspondingly discloses a system corresponding to the above method, including an image acquisition module, an image processing module, a structure template library module, a template matching module, a key point positioning module, and a spacing calculation module;
[0098] The image acquisition module is used to acquire image data of the railway turnout area;
[0099] The image processing module is connected to the image acquisition module and is used to process the image data to determine the turnout area and extract the image structure features of the turnout area;
[0100] The structure template library module is used to pre-store the structure templates of multiple railway turnouts. Multiple structure key points and their corresponding standard physical positions are predefined in each structure template;
[0101] The template matching module is respectively connected to the image processing module and the structure template library module and is used to calculate the similarity between the image structure features of the turnout area and the templates in the structure template library and select the matching structure template;
[0102] The key point positioning module is connected to the template matching module and is used to perform coordinate transformation and actual positioning of the key points in the turnout area image based on the matched structure template;
[0103] The spacing calculation module is connected to the key point positioning module and is used to calculate the actual physical spacing between the key points according to the image coordinate positions of the key points determined by the key point positioning module and in combination with the scale factor.
[0104] In a more specific embodiment, the system further includes a trend analysis module and an anomaly warning module;
[0105] The trend analysis module is connected to the key point positioning module and is used to record and store the offset data between the actual image coordinates of the key points detected each time and the standard positions of the structure templates, establish an offset time series, and use the trend fitting analysis method to determine whether there is a continuous offset trend in the key point positions;
[0106] The anomaly warning module is connected to the trend analysis module and is used to generate and output corresponding anomaly warning information when the offset trend of the key points exceeds a preset threshold according to the continuous offset trend determined by the trend analysis module.
[0107] As mentioned above, it is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution of the present invention and its inventive concept, makes equivalent substitutions or changes, and all should be covered within the protection scope of the present invention.
Claims
1. A method for detecting the spacing of railway turnouts based on image data, characterized in that, It includes the following steps: Obtain turnout image data, perform image processing on the turnout image data, determine the turnout area, and extract image structure features; According to the image structure features, select a matching structure template from a pre-established structure template library, and perform coordinate transformation on the structure template to map it into the turnout area; Based on the mapped structure template, perform key point localization in the local area corresponding to the turnout area to obtain the image coordinates of each structure key point; According to the image coordinates of each structure key point and the scale factor, convert the image pixel distance between key points into the actual physical distance to calculate the structure spacing of the turnout.
2. The method according to claim 1, wherein The specific method for determining the scale factor is as follows: Select a first key point and a second key point with known actual physical distances in the structure template; Identify the image coordinates of the first key point and the second key point in the turnout area image, and calculate the pixel distance between the first key point and the second key point; Use the ratio of the actual physical distance to the pixel distance between the first key point and the second key point to determine the scale factor.
3. The method according to claim 1, wherein The specific method for selecting a matching structure template from the structure template library is as follows: Based on the image structure features extracted from the turnout image data, select the top N structure templates with the highest similarity rankings from the structure template library, perform coordinate transformation on each of them respectively, and map them into the turnout area; Determine N groups of candidate coordinates of structure key points respectively according to the above N mapped structure templates; Perform fusion voting on the N groups of candidate coordinates of structure key points. The voting method is to calculate the average coordinates of each group of candidate coordinates of key points or calculate the weighted average coordinates according to the similarity weights of the structure templates to obtain the final image coordinates of each structure key point.
4. The method according to claim 1, wherein The method further includes a step of analyzing the offset trend of the turnout structure key points, specifically including: Record the offset amount between the image coordinates obtained each time the turnout structure key points are recognized and the standard coordinates in the corresponding structure template, and establish a time series of key point offset amounts; Use a trend fitting method to analyze the time series of key point offset amounts to determine whether there is a continuous offset trend of the key points; The trend fitting method satisfies the following formula: ΔX(t) = k x t + c x , ΔY(t) = k y t + c y ; Where, ΔX(t) and ΔY(t) respectively represent the horizontal and vertical direction offset amounts of the key point at the t-th detection, k x , k i respectively represent the offset rates in the horizontal and vertical directions, c x , c y respectively represent the initial offset constants in the horizontal and vertical directions.
5. The method according to claim 1, wherein The specific method for constructing the structure template is as follows: Collect image samples of multiple target model turnouts, and complete the annotation of multiple structure key points in each image; Unify the key point data of all image samples into the standard coordinate system and perform vectorization expression; Use a clustering algorithm to perform clustering processing on all key point vectors to obtain several subsets with similar structures; Select a representative key point configuration as a structure template in each subset to form a multi-structure template set, and store it in the structure template library for subsequent matching use.
6. The method according to claim 1, wherein The method for determining the turnout area includes the following steps: Use a Gaussian filter or a median filter method to denoise the image; Extract the track edge through an edge detection algorithm; Use the Hough transform or a deep learning convolutional neural network model to determine the specific range of the turnout area.
7. The method according to claim 1, wherein The specific method for key point localization is as follows: Take the key point position in the mapped structure template as the center, and delimit a local window in the turnout area image; Use a corner detection algorithm based on gradient intensity or a CNN heat map regression algorithm in the local window to determine the sub-pixel coordinate position of the key point.
8. The method according to claim 3, characterized in that, The calculation method for the similarity of the structure template is as follows: Extract the SIFT, SURF or ORB feature vectors of the image and the template, and use the cosine similarity or Euclidean distance calculation method to determine the similarity values between the image and each template and sort them.
9. A railway switch spacing detection system based on image data, characterized in that, It includes an image acquisition module, an image processing module, a structure template library module, a template matching module, a key point positioning module, and a spacing calculation module; The image acquisition module is used to acquire image data of the railway turnout area; The image processing module is connected to the image acquisition module and is used to process the image data to determine the turnout area and extract the image structure features of the turnout area; The structure template library module is used to pre-store the structure templates of multiple railway turnouts. Multiple structure key points and their corresponding standard physical positions are predefined in each structure template; The template matching module is respectively connected to the image processing module and the structure template library module, and is used to calculate the similarity between the image structure features of the turnout area and the templates in the structure template library, and select the matching structure template; The key point positioning module is connected to the template matching module and is used to perform coordinate transformation and actual positioning of key points in the turnout area image based on the matched structure template; The spacing calculation module is connected to the key point positioning module and is used to calculate the actual physical spacing between key points according to the key point image coordinate positions determined by the key point positioning module and in combination with the scale factor.
10. The system according to claim 9, wherein The system further includes a trend analysis module and an anomaly warning module; The trend analysis module is connected to the key point positioning module and is used to record and store the offset data of the actual image coordinates of the key points detected each time from the standard positions of the structure templates, establish an offset time series, and use the trend fitting analysis method to determine whether there is a continuous offset trend in the key point positions; The anomaly warning module is connected to the trend analysis module and is used to generate and output corresponding anomaly warning information when the offset trend of the key points exceeds the preset threshold according to the continuous offset trend determined by the trend analysis module.