A method for continuous identification of the current train running path in railway shunting scenarios
By constructing a temporal path recognition model for railway shunting scenarios, and employing track ROI cropping, random boundary perturbation, and image enhancement, combined with single-frame regression and temporal constraints, the accuracy and stability issues of identifying the current running path of trains in railway shunting scenarios are solved, and path recognition is realized in complex environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIHANG UNIV
- Filing Date
- 2026-05-25
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies struggle to accurately identify the current train path in railway shunting scenarios, especially in complex environments with numerous switches, where path ambiguity and state transitions are prone to occur, and stable temporal continuity constraints are lacking.
A temporal path recognition model for railway shunting scenarios is constructed. By building a temporal operation path dataset, track ROI cropping, random boundary perturbation, and image enhancement are adopted. Combined with an end-to-end framework of single-frame regression and temporal constraints, historical frame mask gating and geometrically feasible region suppression are used to improve the accuracy and stability of path recognition.
To improve the accuracy of path determination in complex scenarios with multiple turnouts, suppress abrupt changes in path identification results, enhance robustness in complex environments such as obstruction, rain, and fog, and provide stable identification results of the current train running path, facilitating safety warnings and shunting auxiliary decision-making.
Smart Images

Figure CN122493413A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of train path identification, and in particular to a method for continuous identification of the current running path of a train in a railway shunting scenario. Background Technology
[0002] As transportation organization becomes increasingly sophisticated and intelligent, higher demands are being placed on the accuracy, continuity, and verifiability of train route information in areas such as train operation organization, station arrival and departure, inter-station train operation, and dispatching command. Train route identification refers to the determination and output of information such as the lines a train traverses within a certain time frame, the branching choices at turnouts, the direction of travel, and the timing of route segment transitions. This information can be used in scenarios such as automated dispatching assistance, intelligent operation and maintenance, event backtracking and evidence collection, and operational safety assurance.
[0003] In railway yards, especially in shunting operations, the track structure is typically complex, with densely packed switches in the station throat area, parallel tracks, and diverse connections. Trains may pass through multiple sets of switches and switch tracks multiple times within a short distance. Simultaneously, the environment may present interference factors such as obstructions, drastic changes in lighting, rain, snow, fog, dust, dirt, and motion blur, making it highly difficult to reliably identify the train's actual running path based on limited observational information. In current engineering practice, train running path information typically comes from multiple sources, including signaling systems, interlocking systems, CTC (Circuit Toll Collection), ATS (Automatic Train Protection) records, track circuits, axle counting, transponders, and onboard positioning. However, these information sources suffer from interface heterogeneity, time synchronization difficulties, and varying availability across different lines and system architectures. Furthermore, some information is more control- and recording-oriented, limiting its independent verification capability of the actual on-site conditions. To enhance the perception and verification capabilities of on-site conditions, existing technologies are beginning to incorporate vehicle-mounted or field-end video. Computer vision is used to identify targets such as trains, rails, sleepers, key turnout components, signals, and signs. Based on geometric relationships or map priors, the train's location, turnout direction, and short-term travel path are inferred. These image-based methods typically employ models such as object detection, semantic segmentation, and key point or line feature extraction and tracking to extract track and turnout structural information from the video. This information is then combined with perspective geometry, monocular depth estimation, or ranging and registration methods based on known scale and scene calibration to estimate relative positional relationships, thereby completing track identification and turnout branch selection.
[0004] Other existing solutions introduce station track topology maps or geometric maps as priors, matching visually observed track alignments, turnout geometric features, or landmarks with the map, and performing time-series inference under topological constraints to output path segment sequences and their confidence scores. To meet real-time requirements, engineering implementations typically employ lightweight networks, limited regions of interest (ROIs), and rule-based thresholding strategies. However, the aforementioned vision-based path recognition methods still have significant shortcomings in railway shunting scenarios, mainly in the following aspects:
[0005] In scenarios with multiple turnouts and dense traffic flow, path topology ambiguity is significant.
[0006] In a shunting yard, there are many turnouts, complex branching patterns, and parallel tracks with dense connections. Trains pass through multiple sets of turnouts and switch tracks multiple times in a short distance, which can easily lead to path ambiguity in visual observation within a single frame or short time window.
[0007] Misjudgment and sudden changes are prone to occur under complex environmental conditions.
[0008] Factors such as occlusion, changes in viewing angle, similar local textures, similar appearances of multiple turnouts, and similar rail alignment can further amplify the ambiguity of path recognition, making the system prone to confusion in judging the "current path," resulting in path segment switching errors, path state jumps, or even swinging back and forth between multiple candidate paths.
[0009] Existing methods are mostly based on single-frame judgment and lack stable temporal continuity constraints.
[0010] Existing visual recognition methods mostly focus on identifying tracks or lines in a single frame image, lacking joint constraints on track continuity, motion consistency, and geometrically feasible regions between adjacent frames. This makes it difficult to continuously and stably output the current train running path in complex shunting scenarios.
[0011] Therefore, existing technologies lack a recognition method for railway shunting scenarios that can utilize visual temporal information and geometric priors to resolve path ambiguities under multi-turnout conditions, suppress path state jumps, and stably output the current train running path. Summary of the Invention
[0012] In view of this, the purpose of this invention is to provide a method for continuous identification of the current train running path in railway shunting scenarios. By constructing a time-series path identification model for railway shunting scenarios, the method resolves topological ambiguities in scenarios with multiple parallel tracks, multiple turnouts, and short-term path switching, thereby improving the accuracy of identifying the current train running path.
[0013] The present invention solves the technical problem by adopting the following technical solution:
[0014] A method for continuous identification of the current train running path in railway shunting scenarios includes the following steps:
[0015] Step S1: Construct a time-series operation path dataset for shunting scenarios. Collect forward-looking video data of the train and perform frame extraction and annotation processing on the collected video data to obtain a time-series operation path dataset for shunting scenarios.
[0016] Step S2: Perform online data augmentation based on the track region. The online augmentation strategy of track ROI cropping, random boundary perturbation and conventional image enhancement is used to enhance the online data of the track region.
[0017] Step S3: End-to-end path recognition based on single-frame regression and temporal constraints. An end-to-end framework of single-frame regression, temporal prior constraints, and geometrically feasible region suppression is adopted. Taking the current frame image as input, multi-scale features are extracted through the detection network and the coordinates of the left and right rail points and the visible termination position are obtained through regression. Then, the regression results of historical frames are rasterized to generate a historical track mask, which is then multiplied and gated with the shallow features of the current frame to introduce temporal consistency. At the same time, a slope feasible region mask is constructed according to the geometric perspective of the track, and areas where the track cannot appear are blackened to suppress it.
[0018] Step S4, ROI setting during inference stage: In the inference stage, ROI is set for the input image, retaining only the effective field of view related to the current running path / track region;
[0019] Step S5: Output the current train running path identification result.
[0020] Furthermore, in step S1, the specific method for constructing a time-series operation path dataset for shunting scenarios includes:
[0021] A monocular visible light camera is installed at the front of the train to collect forward-looking video data in actual railway stations and shunting scenarios. The video data covers typical shunting conditions such as straight tracks, curves, switches, and multiple tracks merging, as well as daytime, nighttime, and complex environmental conditions such as rain and fog.
[0022] The acquired video data is frame-sampling at fixed intervals to obtain image sequences, reducing redundancy between adjacent frames and enhancing motion change information within the sequence; the resulting image sequences are divided into training and testing sets, ensuring coverage of different scenes, environmental conditions, and orbital patterns in both sets;
[0023] During the annotation phase, the current travelable path of the train is manually annotated in the form of a centerline. When annotating, the global structure of the scene and the temporal clues provided by adjacent frames or historical images are combined. Even when the track is partially occluded, interfered with by reflections, or blurred in the distance, the path is still continuously annotated along a reasonable extension direction, so that the model learns the continuity of track topology and the consistency of direction.
[0024] Furthermore, in step S2, the specific method for performing online data augmentation based on the orbital region includes:
[0025] For each frame of the image, the set of labeled polyline points of the known track / vehicle path is... First, take its bounding rectangle as the basic ROI: ; ;in, To label the minimum horizontal pixel coordinates of all points in the polyline point set, To label the maximum horizontal pixel coordinates of all points in the polyline point set, To label the minimum vertical pixel coordinates of all points in the polyline point set, To label the maximum vertical pixel coordinate of all points in the polyline point set, The basic region of interest is obtained by the bounding rectangle of the labeled polyline point set;
[0026] Considering that the track may be slightly to the left or right in the image, and that some contextual information needs to be preserved, the basic ROI is first expanded to obtain... Then, add predefined margins to get In engineering implementation, this is represented by fixed pixels or relative proportion margins. ;in, Preset margins This refers to the region of interest obtained after extending the boundaries of the basic ROI. The region of interest that will ultimately be used for training, cropping, or detection;
[0027] To simulate the positional changes of the track within the image during actual operation, random perturbations are introduced to the left, right, and top boundaries of the ROI. These perturbations follow a normal distribution. ;in, Let be the random perturbation acting on the left boundary of the ROI. Let be the random perturbation acting on the right boundary of the ROI. Let be the random perturbation acting on the upper boundary of the ROI. The standard deviation of the left boundary disturbance. The standard deviation of the right boundary disturbance. The standard deviation of the upper boundary disturbance;
[0028] And obtain the enhanced ROI: ;in for The boundaries of the enhanced ROI; where the enhanced ROI must satisfy the following boundary constraints: Where W and H represent the width and height of the original image, respectively;
[0029] After obtaining the enhanced ROI, the image is cropped and then enhanced with brightness, contrast, saturation, and hue appearance enhancements.
[0030] Furthermore, in step S2, the enhancement process is performed online, so that the same original image generates different enhanced samples in different training rounds.
[0031] Further, in step S3, the detection network includes an encoder backbone network and a regression prediction head; the encoder backbone network uses a ResNet-18 convolutional neural network to extract high-dimensional semantic features from the cropped input image; the ResNet-18 convolutional neural network includes an initial convolutional layer and a max-pooling layer connected in sequence, as well as four-stage feature extraction layers composed of residual blocks. Each stage achieves cross-layer feature transfer and gradient stable propagation through residual connections, thereby obtaining an effective representation of the track structure texture with low parameter and computational cost; a channel compression layer is set at the output of the encoder backbone network, and the channel compression layer is... Convolutional pooling layers are used to reduce the number of channels in the feature map output by the encoder backbone network. The feature map is then flattened into a one-dimensional vector and fed into a regression prediction head consisting of several fully connected layers. The regression prediction head outputs a vector with a dimension of... ,in The preset number of horizontal anchor points.
[0032] Furthermore, in step S3, the method of performing dot product gating with the shallow features of the current frame to introduce temporal consistency includes:
[0033] The current frame is At that time, the network regression output point set is first determined based on the previous frame. Connect the points in the anchor point sequence to form the left and right boundaries and then fill them to obtain the track region mask of the previous frame. : Where h is the height of the mask at the original image scale, and w is the width of the mask at the original image scale;
[0034] The mask is either a binary mask or a continuous-value mask obtained through boundary smoothing and dilation to enhance tolerance to slight displacements and jitter. The mask from the previous frame is used for dot-multiplication gating of the shallow features of the current frame; let the output feature maps of the first two layers of the encoder backbone be: ;in, This represents the number of channels in the first shallow feature map. The height of the first shallow feature map. The width of the first shallow feature map. This represents the number of channels in the second shallow feature map. The height of the second shallow feature map. The width of the second shallow feature map;
[0035] Will By mapping to the corresponding scale through interpolation or downsampling, we obtain: ;in, This is a size matching operator; subsequently, pointwise multiplication gating is performed on the first two feature maps of the current frame: ;in, This indicates element-wise dot product in the spatial dimension and that the mask is broadcast in the channel dimension;
[0036] After gating The input continues to subsequent layers of the encoder and the regression prediction head to achieve temporal stability by guiding the feature extraction of the current frame from the track region of the previous frame, reducing the interference of non-track region textures on the shallow features of the network; during inference initialization, if the mask of the first frame or the previous frame is unavailable, let The matrix is set to all 1s, causing the network to degenerate into a pure single-frame regression. When the previous frame prediction is detected to be invalid, it also reverts to an all-1 mask to avoid false suppression caused by mask collapse.
[0037] Furthermore, in step S3, the method for constructing a slope feasible region mask based on the geometric perspective rules of the track includes:
[0038] Considering the significant geometric regularity of the orbit under perspective imaging, a slope feasible region mask is constructed. This is used to suppress areas where tracks are impossible by blackening; the slope feasible region is constructed based on the current frame's predicted point set or the historical fused point set; an approximate function is obtained by fitting the left and right track point sets: ;in, This represents the horizontal pixel coordinates corresponding to the left edge of the image when the y-coordinate is 0. This represents the horizontal pixel coordinates corresponding to the right edge boundary when the image's vertical coordinate is y. The slope of the fitted line to the left boundary is given by [the slope of the line]. The intercept of the fitted line to the left boundary is... The slope of the fitted line to the right boundary is given by [the slope of the line]. The intercept of the line fitted to the right boundary;
[0039] And this defines the feasible corridor area. : ;in, The boundary margin function varies with the longitudinal position; thus, a binary or continuous slope mask is obtained: ;
[0040] A slope mask is applied to the input image or a shallow feature map; then... Combined with historical masks to form the final gating mask: ;in, This is the feature map after being gated by a slope feasible region mask. This is the shallow feature map of the network in the current frame;
[0041] The input image is blackened to suppress pixel information in infeasible regions, thereby reducing the interference of obfuscated paths on network feature extraction.
[0042] Furthermore, in step S3, the loss function of the ResNet-18 convolutional neural network is constructed as follows:
[0043] For the track / vehicle path detection task, a training objective function consisting of two parts is constructed: the first is the main task loss, used to ensure the fitting accuracy of the single-frame prediction result to the annotation; the second is the trajectory continuity loss, used to constrain the consistency of the predicted trajectory in the temporal dimension between adjacent frames, thereby reducing output jitter and improving stability in video sequence scenarios; the total training loss is obtained by weighted summation of the two. ;
[0044] in, Loss to the main task To introduce DILATE continuity loss, For continuity loss weighting coefficients; It includes two items: trajectory loss With y-limit loss The trajectory loss measures the deviation between the predicted left and right track lateral coordinates and the labeled values at the preset horizontal anchor points; the y-limit loss measures the deviation between the predicted highest determinable position of the vehicle path and the labeled values; the main task loss is expressed as: ;in, The weight of the y-limit term;
[0045] Trajectory loss Set the image to be common settings The horizontal anchor point, at the... At each anchor point, the network outputs the predicted lateral coordinates of the left and right tracks and compares them with the corresponding labeled values. To enhance robustness, the single-point error is calculated using the SmoothL1 method, and weighted and masked at the anchor point dimension. The trajectory loss is defined as: ;in, Indicates the first The sum of the lateral coordinate errors of the left and right rails at each anchor point; two types of modulation factors are introduced for different anchor points, with width weighting. and effective mask Among them, width-weighted Inversely proportional to track gauge, with an upper limit set. This design is used to compensate for perspective effects; effective mask. Anchor points located above the end of the vehicle path typically lack stable semantics or labeling significance, therefore their loss contribution is set to zero; and in the denominator... Normalization is performed to ensure that the losses are still comparable even when the visible trajectory lengths of different samples are different.
[0046] y-limit loss is used to supervise the network's response to termination parameters. The regression was calculated using SmoothL1: ;in, For smoothing parameters;
[0047] To calculate inter-frame consistency, the output left and right track point sequences are first converted into centerline trajectories: the centerline point is obtained by averaging the left and right track points at each anchor point; let the predicted centerline trajectory of the current frame be... The predicted trajectory of the centerline in the previous frame is ,in For sequence length, Let t be the centerline point in the predicted centerline trajectory of the previous frame. Let be the t-th centerline point in the predicted centerline trajectory of the current frame, and To achieve the goal of stopping gradient propagation in the previous frame prediction, in order to avoid training instability caused by backpropagation across frames;
[0048] Construct the quadratic distance cost matrix between the two sequences: ;
[0049] DILATE continuity loss It consists of two parts: shape item : Soft-DTW is used to measure the shape difference between two trajectories under conditions that allow for nonlinear alignment; time term Based on the soft-aligned path weight matrix obtained by Soft-DTW, alignments deviating from the diagonal are penalized to suppress excessive temporal distortion, making the correspondence of anchor point sequences more stable. A continuity loss is obtained through two linear fusions. ;in, The smoothing parameter of Soft-DTW is taken as the fusion coefficient. ;
[0050] Therefore, the loss function during the training phase is as follows: .
[0051] Furthermore, in step S4, since path truth labels are usually unavailable during the inference phase, ROI coordinates are obtained through two methods: preset fixed ROI or adaptive dynamic ROI, as detailed below:
[0052] 1) Fixed ROI
[0053] For specific vehicle-mounted camera configurations or fixed video sequences, the position of the offline path within the frame is usually stable. A fixed cropping window is obtained manually or offline, and the entire frame is uniformly cropped. Let the original image size be... A fixed ROI is represented as: ;in, For fixed ROI regions;
[0054] The fixed ROI should cover all areas that may appear along the path, and try to remove the sky and the far-field background on both sides to improve the effective pixel ratio and inference efficiency.
[0055] 2) Adaptive Dynamic ROI
[0056] When the path drifts significantly on the screen or it is inconvenient to preset a fixed ROI, adaptive clipping is used: the ROI is updated online with the model centered on the current predicted path, so that the clipping window adjusts as the path changes, thereby improving accuracy. Specific methods include:
[0057] (1) Initialization: In the initial stage, the entire image or a larger window is taken as the ROI. ;
[0058] (2) Update hypothesis based on predicted ROI Frame model output prediction path First, calculate its bounding box. Then, a smooth running average is introduced to suppress jitter: ;in For smoothing coefficients, This represents the smoothed bounding box;
[0059] (3) Add margins and trim, in The final ROI is obtained by adding margins to the base: ;in Set the preset margins and clip the ROI boundaries to the valid range. ;
[0060] 3) Anti-collapse mechanism
[0061] To prevent the ROI from continuously shrinking and eventually collapsing into an excessively narrow window, leading to path loss, when prediction is unstable in individual frames, an anti-collapse constraint is introduced, which integrates a minimum window lower bound to keep the ROI at a usable size and with sufficient context. ;in, The current ROI width and height; This represents the minimum width and height.
[0062] Furthermore, in step S5, the identification results include: the centerline or left and right rail boundaries of the current running path, the position of the current path in the image and its visible termination area, the path segment change information in continuous time sequence, the confidence level or stable state of the current path identification result, and the region mask of the current running path of the train in the current frame.
[0063] The present invention discloses a method for continuous identification of the current train running path in railway shunting scenarios, which has the following beneficial effects:
[0064] 1. Improve the accuracy of path determination in complex scenarios with multiple turnouts.
[0065] By constructing a time-series path recognition model for railway shunting scenarios, topological ambiguities in scenarios involving multiple parallel tracks, multiple turnouts, and short-term path switching are resolved, thereby improving the accuracy of identifying the current train running path.
[0066] 2. Suppress abrupt changes in path recognition results.
[0067] By introducing historical path mask gating and DILATE-based continuity loss, we can impose temporal constraints on path changes between adjacent frames, reduce path segmentation errors and state jumps, and improve the stability of the output results.
[0068] 3. Improve robustness in complex environments.
[0069] Through adaptive enhancement of the track region, geometric feasible region constraints, and dynamic ROI clipping, this invention can still reliably identify the current running path under conditions such as occlusion, rain and fog, nighttime, changes in viewing angle, and similar local textures.
[0070] 4. Facilitates project deployment and integration with upper-level applications.
[0071] This invention employs a lightweight backbone network and an end-to-end identification framework, which facilitates deployment in actual railway shunting scenarios and provides reliable path identification for applications such as safety early warning, shunting auxiliary decision-making, path verification, and event tracing. Attached Figure Description
[0072] Figure 1 This is a flowchart of the method of the present invention;
[0073] Figure 2 This is a diagram illustrating the effect of the data augmentation method of the present invention;
[0074] Figure 3 This is a diagram of the ResNet-18 convolutional neural network.
[0075] Figure 4 This is a path definition diagram of the method of the present invention;
[0076] Figure 5 This is the result of using the method of the present invention. Figure 1 ;
[0077] Figure 6 This is the result of using the method of the present invention. Figure 2 . Detailed Implementation
[0078] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0079] To address the problems existing in the prior art, the technical problems to be solved by this invention mainly include: how to accurately identify the current train running path under conditions of multiple turnouts, multiple parallel tracks, and frequent track switching in railway shunting scenarios; how to suppress jumps in path identification results between multiple candidate paths under complex conditions such as occlusion, changes in lighting, rain, fog, and similar local textures; and how to improve the continuity, stability, and engineering usability of the current train running path output through temporal prior constraints, historical path guidance, and geometric feasible region constraints.
[0080] Therefore, this invention provides a method for continuous identification of the current train running path in railway shunting scenarios. This method is based on onboard forward monocular vision images. By constructing a temporal path dataset for shunting scenarios, and combining track region of interest enhancement, single-frame regression network, historical mask gating, geometrically feasible region suppression, and trajectory continuity loss, the method continuously identifies and stably outputs the current train running path.
[0081] refer to Figure 1 The method of the present invention includes the following steps:
[0082] Step S1: Construct a time-series operation path dataset for shunting scenarios. Collect forward-looking video data of the train and perform frame extraction and annotation processing on the collected video data to obtain a time-series operation path dataset for shunting scenarios.
[0083] Specific methods for constructing a time-series running path dataset for shunting scenarios include:
[0084] A monocular visible light camera was installed at the front of the train to collect forward-looking video data in actual railway stations and shunting scenarios. The video data covered typical shunting conditions such as straight tracks, curves, switches, and multiple tracks merging, as well as complex environmental conditions such as daytime, nighttime, and rain and fog, to improve the diversity and challenge of the dataset.
[0085] The acquired video data is frame-sampling at fixed intervals to obtain image sequences, reducing redundancy between adjacent frames and enhancing motion change information within the sequence; the resulting image sequences are divided into training and testing sets, ensuring coverage of different scenes, environmental conditions, and orbital patterns in both sets;
[0086] During the annotation phase, the current travelable path of the train is manually annotated in the form of a centerline. When annotating, the global structure of the scene and the temporal clues provided by adjacent frames or historical images are combined. Even when the track is partially occluded, interfered with by reflections, or blurred in the distance, the path is still continuously annotated along a reasonable extension direction, so that the model learns the continuity of track topology and the consistency of direction.
[0087] Step S2 involves performing online data augmentation based on the track region. To improve the model's adaptability to different track offsets, curved scenes, and differences in camera field of view, while reducing interference from track-independent areas in the image, an online augmentation strategy combining track ROI cropping, random boundary perturbation, and conventional image enhancement is used to augment the online data in the track region. Figure 2 As shown, a basic ROI (yellow box) is constructed based on the labeled vehicle travel path / track centerline (green broken line in the figure), and then expanded and random boundary changes are introduced (orange and red boxes) to generate diverse training samples.
[0088] Specific methods for performing online data augmentation based on orbital regions include:
[0089] For each frame of the image, the set of labeled polyline points of the known track / vehicle path is... First, take its bounding rectangle as the basic ROI: ; ;in, To label the minimum horizontal pixel coordinates of all points in the polyline point set, To label the maximum horizontal pixel coordinates of all points in the polyline point set, To label the minimum vertical pixel coordinates of all points in the polyline point set, To label the maximum vertical pixel coordinate of all points in the polyline point set, The basic region of interest is obtained by the bounding rectangle of the labeled polyline point set;
[0090] This ROI ensures coverage of the main visible area of the track while minimizing the proportion of irrelevant background. Considering that the track may be slightly to the left or right in the image, and that some contextual information needs to be preserved, the basic ROI is first expanded to obtain... Then, add predefined margins to get In engineering implementation, this can be represented using fixed pixels or relative proportional margins. ;in, Preset margins (can be set according to the image aspect ratio to adapt to different resolutions). This refers to the region of interest obtained after extending the boundaries of the basic ROI. The region of interest that will ultimately be used for training, cropping, or detection;
[0091] To simulate the positional changes of the track within the image during actual operation, random perturbations are introduced to the left, right, and top boundaries of the ROI. These perturbations follow a normal distribution. ;in, Let be the random perturbation acting on the left boundary of the ROI. Let be the random perturbation acting on the right boundary of the ROI. Let be the random perturbation acting on the upper boundary of the ROI. The standard deviation of the left boundary disturbance. The standard deviation of the right boundary disturbance. The standard deviation of the upper boundary disturbance;
[0092] And obtain the enhanced ROI: ;in for To prevent disturbances from clipping critical areas of the track, constraints must be added to ensure that the enhanced ROI completely encompasses the bottom / critical area of the track. The enhanced ROI must satisfy the following boundary constraints: Where W and H represent the width and height of the original image, respectively;
[0093] After obtaining the enhanced ROI, the image is cropped and then subjected to conventional appearance enhancement operations such as brightness, contrast, saturation, and hue.
[0094] As a preferred embodiment, the enhancement process is performed online, which generates different enhanced samples for the same original image in different training rounds, thereby improving the model's generalization ability.
[0095] Step S3: End-to-end path recognition based on single-frame regression and temporal constraints. An end-to-end framework of single-frame regression, temporal prior constraints, and geometric feasible region suppression is adopted. Taking the current frame image as input, multi-scale features are extracted through the detection network and the point set coordinates and visible termination position (y-limit) of the left and right rails are obtained by regression. Then, the regression results of historical frames are rasterized to generate a historical track mask, which is multiplied and gated with the shallow features of the current frame to introduce temporal consistency. At the same time, a slope feasible region mask is constructed according to the geometric perspective of the track, and areas where the track cannot appear are blackened to suppress it, thereby reducing multi-track interference, false detection of guard rail / fence textures, and output jitter in the uncertain stage of turnout.
[0096] The detection network includes an encoder backbone network and a regression prediction head; the encoder backbone network uses a ResNet-18 convolutional neural network to extract high-dimensional semantic features from the cropped input image; wherein, for example... Figure 2 As shown, the ResNet-18 convolutional neural network includes an initial convolutional layer and a max-pooling layer connected in sequence, as well as four-stage feature extraction layers (stage1~stage4) composed of residual blocks. Each stage achieves cross-layer feature transfer and gradient stable propagation through residual connections, thereby obtaining an effective representation of the track structure texture with relatively low parameter and computational costs. Furthermore, to achieve lightweighting of the subsequent regression prediction head, a channel compression layer is set at the output of the encoder backbone network. The channel compression layer is... Convolutional pooling layers are used to reduce the number of channels in the feature map output by the encoder backbone network. The feature map is then flattened into a one-dimensional vector and fed into a regression prediction head consisting of several fully connected layers. The regression prediction head outputs a vector with a dimension of... ,in This is the preset number of horizontal anchor points. The output vector is as follows: Figure 3 As shown, the left rail is in The horizontal coordinates of each anchor point The right rail is The horizontal coordinates of each anchor point , and a termination parameter used to represent the highest point where the vehicle track can be determined in the image. .in By constraining the lateral coordinates of the left and right rails within the normalized range of [0,1] using the Sigmoid function, no boundary constraints are imposed, allowing the rail trend to still be represented by the network outside the cropped view, thereby improving the fitting stability of the distant perspective area.
[0097] Methods for introducing temporal consistency by performing dot product gating with shallow features of the current frame include:
[0098] To introduce temporal prior constraints without significantly increasing computational cost, this scheme only maintains the vehicle track region mask from the previous frame. The current frame is At that time, the network regression output point set is first determined based on the previous frame. Connect the points in the anchor point sequence to form the left and right boundaries and then fill them to obtain the track region mask of the previous frame. : Where h is the height of the mask at the original image scale, and w is the width of the mask at the original image scale;
[0099] The mask is either a binary mask or a continuous-value mask obtained through boundary smoothing and dilation to enhance tolerance to slight displacements and jitter. The mask from the previous frame is used for dot-multiplication gating of the shallow features of the current frame; let the output feature maps of the first two layers of the encoder backbone be: ;in, This represents the number of channels in the first shallow feature map. The height of the first shallow feature map. The width of the first shallow feature map. This represents the number of channels in the second shallow feature map. The height of the second shallow feature map. The width of the second shallow feature map;
[0100] Will By mapping to the corresponding scale through interpolation or downsampling, we obtain: ;in, This is a size matching operator; subsequently, pointwise multiplication gating is performed on the first two feature maps of the current frame: ;in, This indicates element-wise dot product in the spatial dimension and that the mask is broadcast in the channel dimension;
[0101] After gating The input continues to subsequent layers of the encoder and the regression prediction head to achieve temporal stability by guiding the feature extraction of the current frame from the track region of the previous frame, reducing the interference of non-track region textures on the shallow features of the network; during inference initialization, if the mask of the first frame or the previous frame is unavailable, let The matrix is set to all 1s, causing the network to degenerate into a pure single-frame regression. When the previous frame prediction is detected to be invalid, it also reverts to an all-1 mask to avoid false suppression caused by mask collapse.
[0102] Methods for constructing slope feasible region masks based on the geometric perspective of the orbit include:
[0103] Considering that the orbits exhibit significant geometric regularities under perspective imaging (e.g., the left and right orbits generally form a continuous curve converging towards the vanishing point over a short period of time, without abrupt changes in any direction in the image), a slope feasible region mask is constructed. This is used to suppress areas where tracks are impossible by blackening; the slope feasible region is constructed based on the current frame's predicted point set or the historical fused point set; an approximate function is obtained by fitting the left and right track point sets: ;in, This represents the horizontal pixel coordinates corresponding to the left edge of the image when the y-coordinate is 0. This represents the horizontal pixel coordinates corresponding to the right edge boundary when the image's vertical coordinate is y. The slope of the fitted line to the left boundary is given by [the slope of the line]. The intercept of the fitted line to the left boundary is... The slope of the fitted line to the right boundary is given by [the slope of the line]. The intercept of the line fitted to the right boundary;
[0104] And this defines the feasible corridor area. (follow) Adaptive dilation to match perspective differences ( ;in, The boundary margin function varies with the longitudinal position; thus, a binary or continuous slope mask is obtained: ;
[0105] A slope mask is applied to the input image or a shallow feature map; then... Combined with historical masks to form the final gating mask: ;in, This is the feature map after being gated by a slope feasible region mask. This is the shallow feature map of the network in the current frame;
[0106] The input image is blackened to suppress pixel information in infeasible regions, thereby reducing the interference of obfuscated paths on network feature extraction.
[0107] The loss function of the ResNet-18 convolutional neural network is constructed as follows:
[0108] For the track / vehicle path detection task, a training objective function consisting of two parts is constructed: the first is the main task loss, used to ensure the fitting accuracy of the single-frame prediction result to the annotation; the second is the trajectory continuity loss, used to constrain the consistency of the predicted trajectory in the temporal dimension between adjacent frames, thereby reducing output jitter and improving stability in video sequence scenarios; the total training loss is obtained by weighted summation of the two. ;in, Loss to the main task To introduce DILATE continuity loss, For continuity loss weighting coefficients; It includes two items: trajectory loss With y-limit loss The trajectory loss measures the deviation between the predicted left and right track lateral coordinates and the labeled values at the preset horizontal anchor points; the y-limit loss measures the highest determinable position (termination parameter) of the predicted vehicle path. The deviation between the stated value and the labeled value; the main task loss is expressed as: ;in, The weight of the y-limit term;
[0109] Trajectory loss Set the image to be common settings The horizontal anchor point, at the... At each anchor point, the network outputs the predicted lateral coordinates of the left and right tracks and compares them with the corresponding labeled values. To enhance robustness, the single-point error is calculated using the SmoothL1 method, and weighted and masked at the anchor point dimension. The trajectory loss is defined as: ;in, Indicates the first The sum of the lateral coordinate errors of the left and right rails at each anchor point; to make the loss more consistent with the actual imaging law and avoid interference from invalid annotations, this invention introduces two types of modulation factors for different anchor points, width-weighted. and effective mask Among them, width-weighted Inversely proportional to track gauge, with an upper limit set. This design is used to compensate for perspective effects; effective mask. Anchor points located above the y-limit (the end point of the vehicle path) typically lack stable semantics or labeling significance, therefore their loss contribution is set to zero; and in the denominator... Normalization is performed to ensure that the losses are still comparable even when the visible trajectory lengths of different samples are different.
[0110] y-limit loss is used to supervise the network's response to termination parameters. The regression was calculated using SmoothL1: ;in, For smoothing parameters, take To adapt to the error distribution characteristics caused by image blurring and higher annotation uncertainty near the vanishing point;
[0111] To improve the stability of video sequence inference, this invention introduces a continuity constraint based on DILATE in addition to the main task loss. The prediction results of two adjacent frames are represented as a sequence of trajectory points. The shape difference is measured while allowing a certain degree of nonlinear alignment, and unreasonable spatiotemporal distortion is further suppressed, so that the trajectory changes more smoothly and consistently over time.
[0112] To calculate inter-frame consistency, the output left and right track point sequences are first converted into centerline trajectories: the centerline point is obtained by averaging the left and right track points at each anchor point; let the predicted centerline trajectory of the current frame be... The predicted trajectory of the centerline in the previous frame is ,in For sequence length, Let t be the centerline point in the predicted centerline trajectory of the previous frame. Let be the t-th centerline point in the predicted centerline trajectory of the current frame, and To achieve the goal of stopping gradient propagation in the previous frame prediction, in order to avoid training instability caused by backpropagation across frames;
[0113] Construct the quadratic distance cost matrix between the two sequences: ;
[0114] DILATE continuity loss It consists of two parts: shape item : Soft-DTW is used to measure the shape difference between two trajectories under conditions that allow for nonlinear alignment; time term Based on the soft-aligned path weight matrix obtained by Soft-DTW, alignments deviating from the diagonal are penalized to suppress excessive temporal distortion, making the correspondence of anchor point sequences more stable. A continuity loss is obtained through two linear fusions. ;in, The smoothing parameter of Soft-DTW is taken as the fusion coefficient. ;
[0115] Therefore, the loss function during the training phase is as follows: .
[0116] Step S4, ROI setting during inference stage: In order to improve path recognition accuracy and reduce invalid background interference in video inference or real-time operation, this method sets ROI for the input image during the inference stage, retaining only the effective field of view related to the current running path / track area.
[0117] Since truth line annotations are typically unavailable during the inference phase, ROI coordinates are obtained using either a pre-defined fixed ROI or an adaptive dynamic ROI, as detailed below:
[0118] 1) Fixed ROI
[0119] For specific vehicle-mounted camera configurations or fixed video sequences, the position of the offline path within the frame is usually stable. A fixed cropping window is obtained manually or offline, and the entire frame is uniformly cropped. Let the original image size be... A fixed ROI is represented as: ;in, For fixed ROI regions;
[0120] The fixed ROI should cover all areas that may appear along the path, and try to remove the sky and the far-field background on both sides to improve the effective pixel ratio and inference efficiency.
[0121] 2) Adaptive dynamic ROI (suitable for changing operating conditions or cross-line generalization)
[0122] When the path drifts significantly on the screen or it is inconvenient to preset a fixed ROI, adaptive clipping is used: the ROI is updated online with the model centered on the current predicted path, so that the clipping window adjusts as the path changes, thereby improving accuracy. Specific methods include:
[0123] (1) Initialization: In the initial stage, the entire image or a larger window is taken as the ROI. ;
[0124] (2) ROI Update Based on Prediction (Running Average) Assumption 1 The frame model outputs the predicted path (polyline / pixel set). First, calculate its bounding box. (Minimum bounding rectangle), then introduce a smooth running average to suppress jitter: ;
[0125] in For smoothing coefficients, This represents the smoothed bounding box (corresponding to the core region of the ROI).
[0126] (3) Add margins and trim, in The final ROI is obtained by adding margins to the base:
[0127] in Set the preset margins (which can be set according to the image aspect ratio) and crop the ROI boundaries to the valid range. ;
[0128] 3) Anti-collapse mechanism
[0129] To prevent the ROI from continuously shrinking and eventually collapsing into an excessively narrow window, leading to path loss, when prediction is unstable in individual frames, an anti-collapse constraint is introduced, which integrates a minimum window lower bound to keep the ROI at a usable size and with sufficient context. ;in, The current ROI width and height; This represents the minimum width and height (or minimum area threshold).
[0130] Step S5: Output the current train running path identification result.
[0131] The recognition results include: the centerline or left and right boundary of the current running path, the position of the current path in the image and its visible termination area, the path segment change information in continuous time series, and the confidence or stable state of the current path recognition result.
[0132] In one embodiment, a mask for the current running path region can be constructed based on the detected centerline or left and right rail boundaries, and further output as follows: Among them, M path This represents the region mask of the train's current running path in the current frame.
[0133] The identification results can be further provided to shunting operation auxiliary decision-making, route verification, safety early warning, event backtracking and other upper-level application modules.
[0134] This invention addresses shunting operations, specifically designed to handle the challenges of dense turnouts, frequent track switching, and rapid track topology changes. Existing algorithms, primarily designed for relatively regular railway lines like subways, often rely on single-frame visual information for track / path identification. In shunting scenarios, these algorithms are susceptible to turnout bifurcation, occlusion, and changes in perspective, making it difficult to reliably distinguish the currently drivable track path. This leads to inconsistent results and reduces the reliability of subsequent warning, positioning, and control tasks. Therefore, this invention introduces a temporal reasoning approach. Utilizing the motion and trajectory continuity information of adjacent frames, it constrains and disambiguates candidate track paths, enabling more accurate and stable reasoning about the train's current actual running track. This provides a reliable reference for subsequent safety warnings and operational decisions.
[0135] Step S6: Display of Training and Inference Results
[0136] In the implementation provided by this invention, the parameters of a ResNet-18 network pre-trained on the publicly available large-scale image dataset ImageNet are used as the backbone network for transfer learning initialization. Specifically, the classification output layer of the ResNet-18 is removed or replaced, and a prediction head adapted to the task of this invention is constructed after its high-level feature output. The parameters of the backbone network are initialized by pre-trained weights; the parameters of the newly constructed prediction head are initialized randomly or according to a preset distribution.
[0137] In the subsequent training process, a relatively low learning rate was used to fine-tune the network parameters, especially focusing on training the randomly initialized prediction head part, so that the network could gradually adapt to the track vehicle path detection task in the railway line scenario, and finally complete the model training and convergence.
[0138] After model training, the model's prediction accuracy is quantitatively evaluated. To calculate IoU, the predicted ego-path, represented by a polyline trajectory of points, is converted into a binary mask: the points constituting the predicted path are connected sequentially with straight lines, and the resulting regions are filled to obtain the prediction mask. Target mask It is generated directly from the labeled points to ensure maximum accuracy; at the same time, the predicted mask is scaled and aligned to ensure that it has the same spatial dimensions as the target mask. IoU is defined as: ;
[0139] It should be noted that the IoU index does not explicitly consider the linear perspective effect during evaluation. However, due to its simple definition and wide application in computer vision tasks (including railway track detection), this embodiment selects IoU as the main evaluation index. When IoU>0.5, the sample is recorded as a true positive (TP).
[0140] ; ; ; ;
[0141] Where Acc is accuracy, representing the proportion of all samples correctly classified by the model; Pre is precision, representing the proportion of samples predicted as positive by the model that are actually positive; Rec is recall, representing the proportion of all true positive samples correctly detected by the model; F1 is the F1 score, a combined evaluation metric of precision and recall; TP is true positive, representing the number of samples that are both true positive and predicted as positive by the model; FP is false positive, representing the number of samples that are true negative but incorrectly predicted as positive by the model; FN is false negative, representing the number of samples that are true positive but incorrectly predicted as negative by the model; and TN is true negative, representing the number of samples that are both true negative and predicted as negative by the model.
[0142] The following hyperparameters were used during model training, and the hyperparameter table is shown in Table 1:
[0143]
[0144] Table 1
[0145] The following hyperparameter settings were used during model training: batch size of 8, learning rate of 0.001, and input size of 540×540; the training process showed convergence. The training process of this invention was completed on an NVIDIA RTX 4090 GPU, and all experiments were implemented based on the PyTorch deep learning framework. During the training phase, network parameters were continuously iterated and updated until the loss function reached stability and convergence. The model training used the Adam optimizer, and the data augmentation method in step S2 was used to improve generalization ability. After training, the model performance was evaluated using test set images. The accuracy of the model was evaluated using test set images. The training evaluation results are shown in Table 2.
[0146]
[0147] Table 2
[0148] On the test set, the model's accuracy was quantitatively evaluated using metrics such as IoU / F1. The evaluation results are as follows: mIoU=0.87424, F1@0.5=0.929, F1@0.75=0.895, mF1=0.76, mAcc=0.675, mPre=0.758. These results indicate that the model constructed in this invention achieves high region overlap and good overall detection performance on the test set. The overall segmentation / detection effect meets expectations. Examples of prediction results can be found in [link to example]. Figure 5 and Figure 6 .
[0149] To enable those skilled in the art to more clearly understand the technical solution of this application, the following description, in conjunction with an embodiment of an actual railway line, further illustrates this application. To verify the feasibility and engineering applicability of the method of this application, experimental verification was conducted using data collected from an actual railway line, and consistency comparisons and parameter corrections were performed under simulation and real-vehicle scenarios. For example... Figure 1 The diagram shown is a flowchart of the overall algorithm for the recognition method of this application. This process takes image data as input, performs data preprocessing and model inference, and outputs target recognition results, thus providing a basis for the subsequent early warning module. Figure 2 As shown, this application employs a data augmentation method. During the training phase, the input images / samples are augmented to expand the sample distribution, improve the model's robustness to different lighting conditions, viewing angles, and complex backgrounds, reduce the risk of overfitting, and enhance generalization performance. For example... Figure 3 The diagram shown is a schematic of the ResNet-18 network structure used in a preferred embodiment of this application. Figure 4 The diagram shown is the algorithm path definition graph. This application tables the vehicle path / track region according to preset rules, and uses this table to complete training supervision and result output, ensuring that the model output is consistent with the path definition in engineering applications. Figures 5-6 The diagram shown is a typical recognition result of the algorithm on the test sample, demonstrating the detection effect of the method in this application on the target area / vehicle path in the railway line scenario. It can be used to intuitively verify the correspondence between the recognition result and the real scene.
[0150] The present invention discloses a method for continuous identification of the current train running path in railway shunting scenarios, which has the following beneficial effects:
[0151] 1. Improve the accuracy of path determination in complex scenarios with multiple turnouts.
[0152] By constructing a time-series path recognition model for railway shunting scenarios, topological ambiguities in scenarios involving multiple parallel tracks, multiple turnouts, and short-term path switching are resolved, thereby improving the accuracy of identifying the current train running path.
[0153] 2. Suppress abrupt changes in path recognition results.
[0154] By introducing historical path mask gating and DILATE-based continuity loss, we can impose temporal constraints on path changes between adjacent frames, reduce path segmentation errors and state jumps, and improve the stability of the output results.
[0155] 3. Improve robustness in complex environments.
[0156] Through adaptive enhancement of the track region, geometric feasible region constraints, and dynamic ROI clipping, this invention can still reliably identify the current running path under conditions such as occlusion, rain and fog, nighttime, changes in viewing angle, and similar local textures.
[0157] 4. Facilitates project deployment and integration with upper-level applications.
[0158] This invention employs a lightweight backbone network and an end-to-end identification framework, which facilitates deployment in actual railway shunting scenarios and provides reliable path identification for applications such as safety early warning, shunting auxiliary decision-making, path verification, and event tracing.
[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for continuous identification of the current train running path in railway shunting scenarios, characterized in that, Includes the following steps: Step S1: Construct a time-series operation path dataset for shunting scenarios. Collect forward-looking video data of the train and perform frame extraction and annotation processing on the collected video data to obtain a time-series operation path dataset for shunting scenarios. Step S2: Perform online data augmentation based on the track region. The online augmentation strategy of track ROI cropping, random boundary perturbation and conventional image enhancement is used to enhance the online data of the track region. Step S3: End-to-end path recognition based on single-frame regression and temporal constraints. An end-to-end framework of single-frame regression, temporal prior constraints, and geometrically feasible region suppression is adopted. Taking the current frame image as input, multi-scale features are extracted through the detection network and the coordinates of the left and right rail points and the visible termination position are obtained through regression. Then, the regression results of historical frames are rasterized to generate a historical track mask, which is then multiplied and gated with the shallow features of the current frame to introduce temporal consistency. At the same time, a slope feasible region mask is constructed according to the geometric perspective of the track, and areas where the track cannot appear are blackened to suppress it. Step S4, ROI setting during inference stage: In the inference stage, ROI is set for the input image, retaining only the effective field of view related to the current running path / track region; Step S5: Output the current train running path identification result.
2. The method for continuous identification of the current train running path in railway shunting scenarios according to claim 1, characterized in that, In step S1, the specific method for constructing a time-series running path dataset for shunting scenarios includes: A monocular visible light camera is installed at the front of the train to collect forward-looking video data in actual railway stations and shunting scenarios. The video data covers typical shunting conditions such as straight tracks, curves, switches, and multiple tracks merging, as well as daytime, nighttime, and complex environmental conditions such as rain and fog. The acquired video data is frame-sampling at fixed intervals to obtain image sequences, reducing redundancy between adjacent frames and enhancing motion change information within the sequence; the resulting image sequences are divided into training and testing sets, ensuring coverage of different scenes, environmental conditions, and orbital patterns in both sets; During the annotation phase, the current travelable path of the train is manually annotated in the form of a centerline. When annotating, the global structure of the scene and the temporal clues provided by adjacent frames or historical images are combined. Even when the track is partially occluded, interfered with by reflections, or blurred in the distance, the path is still continuously annotated along a reasonable extension direction, so that the model learns the continuity of track topology and the consistency of direction.
3. The method for continuous identification of the current train running path in railway shunting scenarios according to claim 2, characterized in that, In step S2, the specific method for performing online data augmentation based on the orbital region includes: For each frame of the image, the set of labeled polyline points of the known track / vehicle path is... First, take its bounding rectangle as the basic ROI: ; ;in, To label the minimum horizontal pixel coordinates of all points in the polyline point set, To label the maximum horizontal pixel coordinates of all points in the polyline point set, To label the minimum vertical pixel coordinates of all points in the polyline point set, To label the maximum vertical pixel coordinate of all points in the polyline point set, The basic region of interest is obtained by the bounding rectangle of the labeled polyline point set; Considering that the track may be slightly to the left or right in the image, and that some contextual information needs to be preserved, the basic ROI is first expanded to obtain... Then, add predefined margins to get In engineering implementation, this is represented by fixed pixels or relative proportion margins. ;in, Preset margins This refers to the region of interest obtained after extending the boundaries of the basic ROI. The region of interest that will ultimately be used for training, cropping, or detection; To simulate the positional changes of the track within the image during actual operation, random perturbations are introduced to the left, right, and top boundaries of the ROI. These perturbations follow a normal distribution. ;in, Let be the random perturbation acting on the left boundary of the ROI. Let be the random perturbation acting on the right boundary of the ROI. Let be the random perturbation acting on the upper boundary of the ROI. The standard deviation of the left boundary disturbance. The standard deviation of the right boundary disturbance. The standard deviation of the upper boundary disturbance; And obtain the enhanced ROI: ;in for The boundaries of the enhanced ROI; where the enhanced ROI must satisfy the following boundary constraints: Where W and H represent the width and height of the original image, respectively; After obtaining the enhanced ROI, the image is cropped and then enhanced with brightness, contrast, saturation, and hue appearance enhancements.
4. The method for continuous identification of the current train running path in railway shunting scenarios according to claim 3, characterized in that, In step S2, the enhancement process is performed online, so that the same original image generates different enhanced samples in different training rounds.
5. A method for continuous identification of the current train running path in a railway shunting scenario according to claim 3 or 4, characterized in that, In step S3, the detection network includes an encoder backbone network and a regression prediction head. The encoder backbone network uses a ResNet-18 convolutional neural network to extract high-dimensional semantic features from the cropped input image. The ResNet-18 convolutional neural network includes an initial convolutional layer and a max-pooling layer connected in sequence, as well as four-stage feature extraction layers composed of residual blocks. Each stage achieves cross-layer feature transfer and gradient stable propagation through residual connections, thereby obtaining an effective representation of the track structure texture with low parameter and computational cost. A channel compression layer is set at the output of the encoder backbone network. Convolutional pooling layers are used to reduce the number of channels in the feature map output by the encoder backbone network. The feature map is then flattened into a one-dimensional vector and fed into a regression prediction head consisting of several fully connected layers. The regression prediction head outputs a vector with a dimension of... ,in The preset number of horizontal anchor points.
6. A method for continuous identification of the current train running path in a railway shunting scenario according to claim 5, characterized in that, In step S3, the method of performing dot product gating with the shallow features of the current frame to introduce temporal consistency includes: The current frame is At that time, the network regression output point set is first determined based on the previous frame. Connect the points in the anchor point sequence to form the left and right boundaries and then fill them to obtain the track region mask of the previous frame. : Where h is the height of the mask at the original image scale, and w is the width of the mask at the original image scale; The mask is either a binary mask or a continuous-value mask obtained through boundary smoothing and dilation to enhance tolerance to slight displacements and jitter; the mask from the previous frame is used for dot product gating of the shallow features of the current frame; let the output feature maps of the first two layers of the encoder backbone be: ;in, This represents the number of channels in the first shallow feature map. The height of the first shallow feature map. The width of the first shallow feature map. This represents the number of channels in the second shallow feature map. The height of the second shallow feature map. The width of the second shallow feature map; Will By mapping to the corresponding scale through interpolation or downsampling, we obtain: ;in, This is a size matching operator; subsequently, pointwise multiplication gating is performed on the first two feature maps of the current frame: ;in, This indicates element-wise dot product in the spatial dimension and that the mask is broadcast in the channel dimension; After gating The input continues to subsequent layers of the encoder and the regression prediction head to achieve temporal stability by guiding the feature extraction of the current frame from the track region of the previous frame, reducing the interference of non-track region textures on the shallow features of the network; during inference initialization, if the mask of the first frame or the previous frame is unavailable, let The matrix is set to all 1s, causing the network to degenerate into a pure single-frame regression. When the previous frame prediction is detected to be invalid, it also reverts to an all-1 mask to avoid false suppression caused by mask collapse.
7. The method for continuous identification of the current train running path in a railway shunting scenario according to claim 6, characterized in that, In step S3, the method for constructing a slope feasible region mask based on the geometric perspective rules of the track includes: Considering the significant geometric regularity of the orbit under perspective imaging, a slope feasible region mask is constructed. This is used to suppress areas where tracks are impossible by blackening; the slope feasible region is constructed based on the current frame's predicted point set or the historical fused point set; an approximate function is obtained by fitting the left and right track point sets: ;in, This represents the horizontal pixel coordinates corresponding to the left edge of the image when the y-coordinate is 0. This represents the horizontal pixel coordinates corresponding to the right edge boundary when the image's vertical coordinate is y. The slope of the fitted line to the left boundary is given by [the slope of the line]. The intercept of the fitted line to the left boundary is... The slope of the fitted line to the right boundary is given by [the slope of the line]. The intercept of the line fitted to the right boundary; And this defines the feasible corridor area. : ;in, The boundary margin function varies with the longitudinal position; thus, a binary or continuous slope mask is obtained: ; The slope mask is applied to the shallow feature map; then... Combined with historical masks to form the final gating mask: ;in, This is the feature map after being gated by a slope feasible region mask. This is the shallow feature map of the network in the current frame; The input image is blackened to suppress pixel information in infeasible regions, thereby reducing the interference of obfuscated paths on network feature extraction.
8. A method for continuous identification of the current train running path in a railway shunting scenario according to claim 7, characterized in that, In step S3, the loss function of the ResNet-18 convolutional neural network is constructed as follows: For the track / vehicle path detection task, a training objective function consisting of two parts is constructed: the first is the main task loss, used to ensure the fitting accuracy of the single-frame prediction result to the annotation; the second is the trajectory continuity loss, used to constrain the consistency of the predicted trajectory in the temporal dimension between adjacent frames, thereby reducing output jitter and improving stability in video sequence scenarios; the total training loss is obtained by weighted summation of the two. ;in, Loss to the main task To introduce DILATE continuity loss, For continuity loss weighting coefficients; It includes two items: trajectory loss With y-limit loss The trajectory loss measures the deviation between the predicted left and right track lateral coordinates and the labeled values at the preset horizontal anchor points; the y-limit loss measures the deviation between the predicted highest determinable position of the vehicle path and the labeled values; the main task loss is expressed as: ;in, The weight of the y-limit term; Trajectory loss Let the image be set in Chinese The horizontal anchor point, at the... At each anchor point, the network outputs the predicted lateral coordinates of the left and right tracks and compares them with the corresponding labeled values. To enhance robustness, the single-point error is calculated using the SmoothL1 method, and weighted and masked at the anchor point dimension. The trajectory loss is defined as: ;in, Indicates the first The sum of the lateral coordinate errors of the left and right rails at each anchor point; two types of modulation factors are introduced for different anchor points, with width weighting. and effective mask Among them, width-weighted Inversely proportional to track gauge, with an upper limit set. This design is used to compensate for perspective effects; effective mask. Anchor points located above the end of the vehicle path typically lack stable semantics or labeling significance, therefore their loss contribution is set to zero; and in the denominator... Normalization is performed to ensure that the losses are still comparable even when the visible trajectory lengths of different samples are different. y-limit loss is used to supervise the network's response to termination parameters. The regression was calculated using SmoothL1: ;in, For smoothing parameters; To calculate inter-frame consistency, the output left and right track point sequences are first converted into centerline trajectories: the centerline point is obtained by averaging the left and right track points at each anchor point; let the predicted centerline trajectory of the current frame be... The predicted trajectory of the centerline in the previous frame is ,in For sequence length, Let t be the centerline point in the predicted centerline trajectory of the previous frame. Let be the t-th centerline point in the predicted centerline trajectory of the current frame, and To achieve the goal of stopping gradient propagation in the previous frame prediction, in order to avoid training instability caused by backpropagation across frames; Construct the quadratic distance cost matrix between the two sequences: ; DILATE continuity loss It consists of two parts: shape item : Soft-DTW is used to measure the shape difference between two trajectories under conditions that allow for nonlinear alignment; time term Based on the soft-aligned path weight matrix obtained by Soft-DTW, alignments deviating from the diagonal are penalized to suppress excessive temporal distortion, making the correspondence of anchor point sequences more stable; two linear fusions yield the continuity loss. ;in, The smoothing parameter of Soft-DTW is taken as the fusion coefficient. ; Therefore, the loss function during the training phase is as follows: .
9. A method for continuous identification of the current train running path in a railway shunting scenario according to claim 8, characterized in that, In step S4, since path truth labels are usually unavailable during the inference phase, ROI coordinates are obtained through two methods: preset fixed ROI or adaptive dynamic ROI, as detailed below: 1) Fixed ROI For specific vehicle-mounted camera configurations or fixed video sequences, the position of the offline path within the frame is usually stable. A fixed cropping window is obtained manually or offline, and the entire frame is uniformly cropped. Let the original image size be... A fixed ROI is represented as: ;in, For fixed ROI regions; The fixed ROI should cover all areas that may appear along the path, and try to remove the sky and the far-field background on both sides to improve the effective pixel ratio and inference efficiency. 2) Adaptive Dynamic ROI When the path drifts significantly on the screen or it is inconvenient to preset a fixed ROI, adaptive clipping is used: the ROI is updated online with the model centered on the current predicted path, so that the clipping window adjusts as the path changes, thereby improving accuracy. Specific methods include: (1) Initialization: In the initial stage, the entire image or a larger window is taken as the ROI. ; (2) Update hypothesis based on predicted ROI Frame model output prediction path First, calculate its bounding box. Then, a smooth running average is introduced to suppress jitter: ; in For smoothing coefficients, This represents the smoothed bounding box; (3) Add margins and trim, in The final ROI is obtained by adding margins to the base: ; in Set the preset margins and clip the ROI boundaries to the valid range. ; 3) Anti-collapse mechanism To prevent the ROI from continuously shrinking and eventually collapsing into an excessively narrow window, leading to path loss, when prediction is unstable in individual frames, an anti-collapse constraint is introduced, which integrates a minimum window lower bound to keep the ROI at a usable size and with sufficient context. ;in, The current ROI width and height; This represents the minimum width and height.
10. A method for continuous identification of the current train running path in a railway shunting scenario according to claim 9, characterized in that, In step S5, the recognition results include: the centerline or left and right rail boundaries of the current running path, the position of the current path in the image and its visible termination area, the path segment change information in continuous time sequence, the confidence level or stable state of the current path recognition result, and the region mask of the current running path of the train in the current frame.