A track encroachment detection method based on attention enhancement and feature pyramid
By constructing a dynamic image frame queue and a bidirectional feature pyramid network, combined with the Kalman filter algorithm, the problems of false alarms and missed detections in rail transit detection were solved, and accurate prediction and timely warning of potential intrusion limits were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHAANXI TRANSPORTATION VOCATIONAL & TECH COLLEGE
- Filing Date
- 2026-03-25
- Publication Date
- 2026-05-29
AI Technical Summary
Existing rail transit detection methods are prone to false alarms or missed detections in complex dynamic environments. They lack analysis and prediction of the movement trends of targets outside the clearance limits, resulting in delayed early warnings and insufficient time to take braking measures.
By constructing a dynamic image frame queue, extracting multi-level feature maps, generating adaptive directional suppression weights, constructing a bidirectional feature pyramid network, and combining it with the Kalman filter algorithm to estimate the target motion state, a graded risk warning signal is output.
It reduces the false alarm rate in complex backgrounds, improves the sensitivity and positioning accuracy of small target detection, enables forward-looking risk assessment of potential intrusions, and supports timely braking or scheduling intervention.
Smart Images

Figure CN121904716B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of computer vision and intelligent transportation, and relates to a track encroachment detection method based on attention enhancement and feature pyramid. Background Technology
[0002] In ensuring the safety of rail transit operations, timely and accurate detection and early warning of potential intrusions within the track area are crucial for preventing accidents. Traditional track intrusion detection methods largely rely on manual inspections or fixed sensors deployed along the line, such as infrared beam detectors, radar, or pressure sensors. These methods may have limitations in terms of deployment cost, coverage, and adaptability to complex environmental changes. With the development of computer vision technology, detection methods based on video image analysis have gradually become a research hotspot, offering richer scene information and more flexible deployment options.
[0003] Currently, the visual inspection solutions used in the industry typically utilize cameras installed beside trains or tracks to process single-frame images or short-sequence video streams. These methods mostly employ object detection algorithms such as YOLO or Faster R-CNN to directly identify pedestrians, vehicles, or obstacles in the images. To improve detection robustness, some methods introduce techniques such as background modeling or optical flow to help distinguish dynamic targets from static backgrounds, analyzing pixel-level changes or deep learning features to identify objects encroaching on the track area.
[0004] However, the track environment is subject to complex dynamic background interference, such as rapid changes in lighting, vehicle swaying, weather effects like rain, snow, and fog, and regular background motion caused by trains passing through curves. These factors may produce responses similar to actual intrusion targets at the feature level, increasing the likelihood of false alarms. Furthermore, when performing multi-scale feature fusion, existing detection networks are prone to losing low-level details of small targets in images after multiple convolutions and downsampling, potentially leading to missed detections. Most methods only assess intrusion within the current frame, lacking the ability to analyze and predict the movement trends of targets outside the boundary. In high-speed rail transit scenarios, this can result in delayed warnings, making it difficult to allow sufficient time for braking and other measures. Summary of the Invention
[0005] To address the aforementioned problems, this invention provides a track encroachment detection method based on attention enhancement and feature pyramids.
[0006] A trajectory encroachment detection method based on attention enhancement and feature pyramid includes the following steps:
[0007] S1. Acquire time-series track video data and construct a dynamic image frame queue;
[0008] S2. Extract multi-level original feature maps from the dynamic image frame queue and construct a temporal feature map queue;
[0009] S3. Analyze the dynamic patterns of background elements in the temporal feature map queue and generate adaptive directional inhibition weights;
[0010] S4. Apply adaptive directional suppression weights to the deep feature map of the current frame to perform attention suppression operation and generate a cleaned deep feature map;
[0011] S5. Construct a bidirectional feature pyramid network, input the purified deep feature map, middle feature map and shallow feature map into the network, and inject the shallow feature map into the feature fusion node through the direct connection channel to perform multi-scale feature fusion and output a multi-scale fused feature map.
[0012] S6. Generate preliminary detection boxes for the current frame based on multi-scale fusion feature maps, and construct the historical state sequence of the target;
[0013] S7. Based on the historical state sequence, a recursive algorithm is applied to estimate the three-dimensional motion state vector of the target, and the predicted intrusion time is calculated based on the vector and the three-dimensional geometric model of the track safety clearance.
[0014] S8. Output a graded risk warning signal based on the comparison results between the predicted intrusion time and the multi-level time threshold, and update the historical state sequence of the target.
[0015] A further aspect of the present invention involves constructing a dynamic image frame queue, comprising the following steps:
[0016] Activate the image acquisition equipment deployed on rail transit vehicles or facilities along the line, continuously capture video streams facing the direction of track travel, and decode to obtain continuous image frames;
[0017] Continuous image frames are stored in a first-in-first-out buffer according to the acquisition time order, and a dynamic image frame queue containing a preset number of N frames is constructed.
[0018] A further aspect of this invention involves constructing a temporal feature map queue, comprising the following steps:
[0019] Each frame of the dynamic image frame queue is input into the backbone feature extraction network, and deep feature maps, mid-level feature maps, and shallow feature maps corresponding to each frame of the image are extracted from the deep, mid-level, and shallow output nodes respectively, forming a multi-level original feature map group;
[0020] The multi-level original feature map groups corresponding to N consecutive frames of images are organized in chronological order to construct a temporal feature map queue.
[0021] A further aspect of this invention involves generating adaptive directional suppression weights, comprising the following steps:
[0022] The deep feature map sequence in the temporal feature map queue is input into the background modeling subnetwork containing recurrent neural units;
[0023] The background modeling subnetwork identifies and quantifies the morphological change trends of background elements in the horizontal and vertical directions in the deep feature map sequence. The background modeling subnetwork includes a convolutional coding module and a recurrent neural network module, which are used to learn and encode the dynamic temporal patterns of the background.
[0024] Adaptive directional inhibition weights are generated based on the morphological change trend.
[0025] A further aspect of the present invention generates a deep feature map of purification, comprising the following steps:
[0026] One-dimensional global pooling is performed on the deep feature map of the current frame along the horizontal and vertical directions respectively, and adaptive directional suppression weights are applied during the pooling process.
[0027] The one-dimensional feature vectors after weighted pooling are concatenated, nonlinearly transformed, and activated to generate an attention mask image.
[0028] The attention mask map is multiplied element-wise with the deep feature map of the current frame to generate a cleaned deep feature map.
[0029] A further aspect of this invention outputs a multi-scale fused feature map, comprising the following steps:
[0030] Construct a bidirectional feature pyramid network that includes both top-down and bottom-up paths;
[0031] The purified deep feature map and the mid-level feature map of the current frame are input into the bidirectional feature pyramid network;
[0032] Locate the feature fusion nodes in the bottom-up path of the bidirectional feature pyramid network and establish a direct connection channel from the shallow output nodes of the backbone feature extraction network to the feature fusion nodes.
[0033] The shallow feature map of the current frame is aligned by the number of channels, injected through the pass-through connection channel, and superimposed onto the feature fusion node to output a multi-scale fused feature map.
[0034] A further aspect of the present invention involves constructing a historical state sequence of the target, comprising the following steps:
[0035] The multi-scale fused feature map is input into the detection head to generate a preliminary detection box for the current frame containing the target category, confidence level, and location coordinates;
[0036] Assign an identity identifier to each independent target that appears within the field of view;
[0037] By associating the initial detection boxes of the current frame that are associated with the same identity in multiple consecutive frames in chronological order, a historical state sequence is constructed.
[0038] A further aspect of the present invention involves calculating the predicted intrusion limit time, including the following steps:
[0039] The Kalman filter algorithm is applied to the historical state sequence to estimate the three-dimensional motion state vector of the target;
[0040] The predicted motion trajectory of the target is calculated based on the three-dimensional motion state vector;
[0041] Determine whether the predicted trajectory intersects with the three-dimensional geometric model of the track safety clearance, and calculate the predicted intrusion time for targets with intersections.
[0042] A further aspect of this invention involves outputting a graded risk warning signal and updating the historical state sequence of the target, including the following steps:
[0043] The predicted intrusion time is compared with a first threshold and a second threshold, where the first threshold is greater than the second threshold;
[0044] If the predicted intrusion time is greater than the first threshold, a low-risk attention signal is output.
[0045] If the predicted intrusion time is less than or equal to the first threshold and greater than the second threshold, then a medium-risk preparation signal is output.
[0046] If the predicted intrusion time is less than or equal to the second threshold, or if the target is already within the boundary, a high-risk emergency response signal will be output.
[0047] The detection and prediction results of the current frame are stored in the historical state sequence of the corresponding target.
[0048] In a further embodiment of the present invention, the adaptive directional suppression weights include a horizontal weight vector and a vertical weight vector; during one-dimensional global pooling, the horizontal weight vector is applied when pooling along the horizontal direction, and the vertical weight vector is applied when pooling along the vertical direction.
[0049] In summary, the present invention has the following beneficial technical effects:
[0050] 1. By analyzing the background dynamic patterns in the temporal feature map and generating adaptive directional suppression weights, weighted pooling and attention suppression are then applied to the deep feature map of the current frame. This helps to suppress background feature responses that change regularly in the horizontal and vertical directions due to factors such as changes in illumination and vehicle movement, thereby reducing false alarms in complex dynamic backgrounds and improving the focus on and detection accuracy of real abnormal targets.
[0051] 2. By establishing a direct connection channel from the shallow output of the backbone network to the feature fusion node when constructing the bidirectional feature pyramid network, shallow features rich in detailed information can be directly introduced into the multi-scale feature fusion process, avoiding information loss of shallow features during transmission, thereby enhancing the representation ability of small-sized targets, helping to improve the detection sensitivity and positioning accuracy of small targets, and reducing the possibility of missed detection.
[0052] 3. By constructing a historical state sequence of the target and applying the Kalman filter algorithm to estimate its three-dimensional motion state, and combining this with the track safety clearance model to calculate and predict the time of incursion, the method extends the detection of incursions from current incursion detection to the prediction of potential incursions. This method can analyze the motion trend of targets outside the clearance and estimate the time of their entry into the clearance, thereby providing a more forward-looking risk assessment and supporting timely braking or scheduling intervention measures. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. The drawings are used to provide a further understanding of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 A flowchart illustrating an embodiment of this application is disclosed.
[0055] Figure 2 Structural schematic diagrams of embodiments of this application are disclosed. Detailed Implementation
[0056] 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. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0057] The following is in conjunction with the appendix Figures 1-2 A preferred description of the present invention is provided below.
[0058] See attached document Figure 1 This invention proposes a track encroachment detection method based on attention enhancement and feature pyramids, comprising the following steps:
[0059] S1. Acquire time-series track video data and construct a dynamic image frame queue;
[0060] S2. Extract multi-level original feature maps from the dynamic image frame queue and construct a temporal feature map queue;
[0061] S3. Analyze the dynamic patterns of background elements in the temporal feature map queue and generate adaptive directional inhibition weights;
[0062] S4. Apply adaptive directional suppression weights to the deep feature map of the current frame to perform attention suppression operation and generate a cleaned deep feature map;
[0063] S5. Construct a bidirectional feature pyramid network, input the purified deep feature map, middle feature map and shallow feature map into the network, and inject the shallow feature map into the feature fusion node through the direct connection channel to perform multi-scale feature fusion and output a multi-scale fused feature map.
[0064] S6. Generate preliminary detection boxes for the current frame based on multi-scale fusion feature maps, and construct the historical state sequence of the target;
[0065] S7. Based on the historical state sequence, a recursive algorithm is applied to estimate the three-dimensional motion state vector of the target, and the predicted intrusion time is calculated based on the vector and the three-dimensional geometric model of the track safety clearance.
[0066] S8. Output a graded risk warning signal based on the comparison results between the predicted intrusion time and the multi-level time threshold, and update the historical state sequence of the target.
[0067] In one embodiment of the present invention, step S1 includes the following steps:
[0068] Activate the image acquisition equipment deployed on rail transit vehicles or facilities along the line, continuously capture video streams facing the direction of track travel, and decode them to obtain continuous image frames; store the continuous image frames in the first-in-first-out buffer according to the acquisition time order to build a dynamic image frame queue containing a preset number of N frames.
[0069] Specifically, firstly, the image acquisition equipment, pre-deployed physically on the front of the rail transit vehicle or on fixed facilities along the line, is activated and started. It should be noted that this image acquisition equipment refers to the hardware device installed on the front of the train or on poles along the track. Its core components are an image sensor and a video encoder, whose function is to convert optical signals into continuous digital video signals. Its deployment location and lens orientation are based on the required field of view of the track area in front of the train. The device's lens faces the direction of track extension to continuously capture the video stream of the area ahead.
[0070] From the real-time video stream output by the image acquisition device, according to the inherent frame rate of the device, the decoding chip or software decoding module extracts independent and continuous two-dimensional image data frame by frame, thus obtaining continuous image frames. It should be understood that an image frame refers to a single static image decoded and separated from the continuous video stream. Its data structure is a two-dimensional pixel array, and each pixel contains the brightness values of the red, green and blue channels. The frequency of its continuous generation is determined by the frame rate parameter of the image acquisition device.
[0071] These consecutive image frames, output in timestamp order, are sequentially stored in a pre-allocated data buffer in system memory, following a first-in, first-out (FIFO) management rule. The buffer's capacity is fixed to store a preset number of N frames. When a new image frame is stored, if the buffer is full, the oldest stored frame is automatically evicted, thus ensuring the buffer always contains the latest consecutive N frames. This continuously updated data set constitutes the dynamic image frame queue, which serves as the raw input data source for subsequent processing steps. The dynamic image frame queue refers to a FIFO circular buffer data structure implemented in computer memory, functioning to temporarily store multiple consecutive images in chronological order, providing a data window for subsequent time-series analysis. The preset number of N frames is a system parameter, an integer greater than 1, typically ranging from [10, 100], preferably 25, 50, or 100. This value is set to balance the length of historical information required for time-series analysis with the system's real-time processing latency and memory usage. For example, if the frame rate of the image acquisition device is F, the queue time window length is approximately N / F seconds. Setting a longer window, such as 2 seconds when N=50 and F=25, helps capture regular dynamic patterns in the background, but increases computational latency; setting a shorter window is more conducive to real-time response. Those skilled in the art can adjust this according to the computational resources of the actual scene and the estimated frequency of background dynamics.
[0072] For example, an industrial camera with a frame rate of 25 frames per second is activated and deployed on the top of the train cab, with the lens facing the track in the direction of travel. The camera begins operation, outputting a real-time video stream. The decoding module decodes 25 image frames per second from this video stream, each image frame having a resolution of 1920 pixels by 1080 pixels. These image frames are then sequentially stored in a 50-frame first-in-first-out buffer. When the 51st image is generated and ready to be stored, the buffer automatically removes the 1st image and stores the 51st frame, thus ensuring that the buffer always contains the latest 50 consecutive image frames. This data structure constitutes a dynamic image frame queue.
[0073] In one embodiment of the present invention, step S2 includes the following steps:
[0074] Each frame in the dynamic image frame queue is input into the backbone feature extraction network. Deep feature maps, mid-level feature maps, and shallow feature maps corresponding to each frame are extracted from the deep, mid-level, and shallow output nodes, respectively, forming a multi-level raw feature map group. The multi-level raw feature maps include deep feature maps carrying high-level semantic information, mid-level feature maps carrying mid-level contextual information, and shallow feature maps carrying low-level details and positional information, extracted by the backbone feature extraction network. The multi-level raw feature map groups corresponding to N consecutive frames are organized in chronological order to construct a temporal feature map queue.
[0075] Specifically, each frame of image stored in the dynamic image frame queue is first acquired. Then, each frame is sequentially input into a pre-loaded and initialized backbone feature extraction network. It should be noted that this backbone feature extraction network is a convolutional neural network model, such as a variant of ResNet or VGG, pre-trained on a large image dataset with fixed parameter weights, serving as a general-purpose visual feature extractor. This backbone feature extraction network consists of multiple convolutional computation layers and downsampling layers stacked sequentially. Its function is to perform layer-by-layer nonlinear transformations and spatial size compression on the input two-dimensional image to extract multi-level visual information from edges, textures, and complex semantics. When a frame of image passes through the network, the network performs a series of convolution and pooling operations, reducing the spatial size of the image layer by layer while increasing the number of feature channels layer by layer. At specific processing stages of the network, feature data for that frame is read and copied from three preset output nodes:
[0076] Deep feature maps are extracted from nodes closest to the output end of the network; mid-level feature maps are extracted from nodes in the middle of the network. It should be understood that deep feature maps are feature data extracted from the main feature extraction network near the end. Their data structure is a three-dimensional tensor, containing three dimensions: width, height, and channel. Their spatial size is small, but the semantic information carried by each position is highly abstract.
[0077] Shallow feature maps are extracted from nodes that are shallower in the network, i.e. closer to the input. It should be noted that shallow feature maps are feature data extracted from the backbone network near the input layer. They are three-dimensional tensors with relatively large spatial dimensions, containing more details and location information such as edges and corners, but with a lower level of semantic abstraction.
[0078] The above operations are performed on each frame in the dynamic image frame queue, thereby generating a data set containing three different levels of feature maps for each frame, thus forming a multi-level original feature map group. Finally, in a time sequence completely consistent with the acquisition of the original images, the multi-level original feature map groups corresponding to each of the N consecutive frames are arranged and organized to construct a temporal feature map queue that is precisely synchronized with the dynamic image frame queue in the time dimension.
[0079] The mid-layer feature maps are feature data extracted from the middle section of the backbone network. They are also three-dimensional tensors, with spatial dimensions and semantic abstraction levels between deep and shallow layers. The backbone feature extraction network is a convolutional neural network model, such as ResNet-50 or a network with a similar structure, that has been pre-trained on a large general-purpose image dataset (e.g., ImageNet) and fine-tuned on a track encroachment detection dataset specific to this technology before having its parameter weights fixed. The selection of deep, mid-layer, and shallow output nodes is based on the spatial dimensions and semantic levels of the feature maps. For example, in ResNet-50, shallow feature maps can be selected from the end of the conv2 module, representing a larger spatial dimension, such as 1 / 4 downsampling of the input image; mid-layer feature maps can be selected from the end of the conv3 module, representing a medium spatial dimension, such as 1 / 8 downsampling; and deep feature maps can be selected from the end of the conv4 or conv5 module, representing a smaller spatial dimension, such as 1 / 16 or 1 / 32 downsampling. The specific selection can be optimized based on the minimum size of the target and the computational load.
[0080] A multi-level original feature map set is a data set consisting of three feature maps (deep, middle, and shallow) corresponding to the same input frame. Its function is to completely preserve the information of the image at different spatial scales and semantic levels.
[0081] The temporal feature map queue is a sequence of continuous, multi-level original feature maps arranged in time stamp order. Its data structure is a four-dimensional sequence, with the dimensions being time step, feature level, height, width, and number of channels, respectively. Its function is to provide structured multi-scale feature input for subsequent temporal modeling.
[0082] For example, the latest frame with a resolution of 1920 x 1080 is read from the dynamic image frame queue. This frame is then input into a pre-built ResNet-50 backbone feature extraction network. After forward propagation, the network extracts deep feature maps from specific layers, each with a size of 60 x 34 pixels and 2048 channels; mid-layer feature maps, each with a size of 120 x 68 pixels and 512 channels; and shallow feature maps, each with a size of 240 x 136 pixels and 256 channels. These three feature maps together constitute the multi-level raw feature map set for this frame. This process is repeated for 50 consecutive frames in the dynamic image frame queue, generating 50 multi-level raw feature map sets. Finally, these 50 sets of feature maps are organized strictly according to the temporal order of their corresponding images, forming a temporal feature map queue of length 50.
[0083] In one embodiment of the present invention, step S3 includes the following steps:
[0084] The deep feature map sequence in the temporal feature map queue is input into a background modeling subnetwork containing recurrent neural units; the background modeling subnetwork identifies and quantifies the morphological change trends of background elements in the deep feature map sequence in the horizontal and vertical directions. The background modeling subnetwork includes a convolutional coding module and a recurrent neural network module, which are used to learn and encode the dynamic temporal patterns of the background; adaptive directional inhibition weights are generated based on the morphological change trends.
[0085] Specifically, a series of deep feature maps corresponding to N consecutive frames are extracted from the temporal feature map queue, forming a deep feature map sequence. This sequence is then fed into an independently constructed background modeling sub-network. It should be understood that the background modeling sub-network is an independent, lightweight neural network module. Its structure typically involves convolutional layers initially encoding the input features, followed by recurrent neural units such as Long Short-Term Memory (LSTM) units or gated recurrent units to model temporal dependencies. Its function is specifically to learn stable change patterns of background elements in a video sequence, rather than foreground objects. This background modeling sub-network contains recurrent neural units whose function is to receive and process the temporally ordered deep feature maps, learning and modeling the dynamic evolution of the track background texture over time through its internal memory mechanism.
[0086] In the specific processing, this sub-network analyzes the input deep feature map sequence, identifies and quantifies the continuous changes in illumination angle caused by train movement, the influence of different weather conditions, or the regular changes in background elements caused by the rotation of the viewing angle when the vehicle passes through a curve. These background elements include, but are not limited to, periodically arranged sleepers and the shadows they produce, and reflective areas on the rail surface.
[0087] The background modeling subnetwork analyzes the morphological movement and intensity changes of these elements across consecutive frames, extracting their dominant change trends in the horizontal and vertical directions of the image. Finally, based on the morphological change trends obtained through real-time analysis, the background modeling subnetwork outputs a set of weight parameters for dynamically adjusting the direction of subsequent attention modules, i.e., generating adaptive directional suppression weights. These weights aim to adaptively suppress the corresponding feature responses in subsequent steps, based on the background dynamic patterns of the current frame.
[0088] The background modeling subnetwork consists of a convolutional coding module and a recurrent neural network module connected in sequence. The convolutional coding module contains two convolutional layers, which are used to perform channel dimensionality reduction and spatial feature extraction on the deep feature map of each frame. The recurrent neural network module uses a gated recurrent unit (GRU) or a long short-term memory network (LSTM) to model temporal dependencies and output hidden state vectors. After the hidden state vectors are mapped by fully connected layers, horizontal and vertical weight vectors are generated, which are adaptive directional suppression weights.
[0089] Specifically, the forward propagation process of the background modeling sub-network is as follows:
[0090] Let the input sequence be ,in Let be the deep feature map of frame t.
[0091] Convolutional coding: Output encoding features ,in This represents the number of channels after dimensionality reduction.
[0092] Space pooling into sequences: Unfold along the spatial dimension into a sequence vector And input them into the recurrent neural network module in chronological order.
[0093] Temporal modeling: ,in Let t be the hidden state at time t.
[0094] Weight generation: Take the hidden state at the last moment The weight vector is generated through two independent fully connected layers:
[0095]
[0096]
[0097] in, As trainable parameters, the Sigmoid function constrains the output to the interval [0, 1], which serves as the adaptive directional inhibition weights for the horizontal and vertical directions, respectively.
[0098] It should be noted that the recurrent neural unit is the core computational component in the background modeling subnetwork. It has internal state memory, can handle variable-length sequence inputs, and capture long-term temporal dependencies.
[0099] The morphological change trend is an intermediate result output by the background modeling sub-network analysis. It is a quantitative description of the speed, direction and other parameters of the background elements' movement or intensity change in the horizontal and vertical directions. Its data structure is a set of multi-dimensional vectors.
[0100] The adaptive directional suppression weights are a set of parameters that can be adjusted in real time, which are the final output of the background modeling subnetwork. They typically include one-dimensional weight vectors corresponding to the horizontal and vertical directions, respectively. Their function is to perform differentiated weighted suppression on different spatial locations of the feature map according to the current background dynamic mode in the subsequent attention mechanism. The basis for setting them is to train the background modeling subnetwork on massive amounts of track video data containing different lighting, weather, and curve scenes, so that it can automatically learn and generate the optimal suppression parameters that match the scene.
[0101] Specifically, the training process of the background modeling sub-network is as follows: Collect track video data containing various typical scenes, such as straight tracks, curves, tunnel entrances / exits, different lighting conditions, rain / snow, etc., ensuring that the video does not contain any intruding targets or that intruding target areas have been manually labeled and masked. After processing the video sequence according to steps S1 and S2, a temporal deep feature map sequence is obtained as the training input. The training objective is to enable the sub-network to predict the deep feature map of the next frame. During this process, the hidden states of its internal recurrent neural units (such as GRU or LSTM) learn to encode the dynamic patterns of the background. After training, the output of the last fully connected layer of the network is taken as the initial generator of the adaptive directional suppression weights. During the inference phase, for the real-time input sequence, the network directly generates a weight vector matching the current sequence. The initial values of the weight vectors are randomly initialized at the start of training, and the final values are obtained through training optimization. The value range of each element in the weight vector is typically between [0, 2], where 1 represents no suppression or enhancement, less than 1 represents suppression, and greater than 1 represents enhancement. The specific distribution is determined by the network based on the background pattern learned.
[0102] For example, a sequence of 50 consecutive deep feature maps is extracted from a temporal feature map queue of length 50. Each feature map has a size of 60 x 34 and 2048 channels. This sequence is fed into a background modeling subnetwork, which consists of convolutional layers and two gated recurrent units with a hidden layer size of 512 stacked together. The network analyzes this 50-frame sequence and identifies that as the train enters a curve, the reflective area of the rails exhibits a stable leftward shift in the image, while the width of the sleeper shadows slowly increases due to changes in illumination. Based on this, the network outputs adaptive directional suppression weights, specifically two one-dimensional vectors: a horizontal weight vector of length 60, whose numerical distribution shows a stronger suppression tendency for the left-side region features; and a vertical weight vector of length 34, whose numerical distribution shows a stronger suppression tendency for the specific row features.
[0103] In one embodiment of the present invention, step S4 includes the following steps:
[0104] One-dimensional global pooling is performed on the deep feature map of the current frame along the horizontal and vertical directions, and adaptive directional suppression weights are applied during the pooling process. The one-dimensional feature vectors after weighted pooling are concatenated, nonlinearly transformed and activated to generate an attention mask map. The attention mask map is multiplied element-wise with the deep feature map of the current frame to generate a cleaned deep feature map.
[0105] Specifically, firstly, the deep feature map corresponding to the latest time point of the image frame is located and extracted from the temporal feature map queue, and this is used as the input for the deep feature map of the current frame. Next, one-dimensional global pooling operations are performed on the deep feature map of the current frame along both the horizontal and vertical directions. During horizontal pooling, for each row in the height dimension of the feature map, the weighted average of the feature values at all positions in that row along the channel dimension is calculated. During this calculation, the feature value at each spatial position is multiplied by its corresponding weighting coefficient from the horizontal weight vector in the adaptive directional suppression weights. It should be understood that this weighting coefficient is a dimensionless value generated based on the current background dynamic pattern and used to suppress background interference in a specific direction. The calculation process can be described by the following formula:
[0106]
[0107] in, This represents the feature value of the c-th channel in the current frame's deep feature map, located in the i-th row and j-th column. Indicates the width of the feature map. It is the adaptive directional suppression weight corresponding to the horizontal direction and with a length of The weighting coefficient at the j-th position in a one-dimensional weight vector. This is the value in the one-dimensional feature vector corresponding to the c-th channel and i-th row, obtained after horizontal weighted pooling. This formula compresses the horizontal information of the feature map through weighted averaging, with weights... The larger the value, the stronger the contribution of the corresponding column position's feature value to pooling is suppressed. Similarly, weighted pooling is performed along the vertical direction, with the following formula:
[0108]
[0109] in, This indicates the height of the feature map. It is the adaptive directional suppression weight corresponding to the vertical direction and with a length of The weighting coefficient at the i-th position in a one-dimensional weight vector. This is the value in the one-dimensional feature vector corresponding to the c-th channel and j-th column, obtained after vertical weighted pooling. Subsequently, two one-dimensional feature vectors will be obtained, namely, the values from all channels. The vector composed of all channels The resulting vectors are concatenated along the channel dimension.
[0110] The concatenated vectors are processed through a lightweight transform subnetwork containing fully connected layers and non-linear activation functions. Finally, a 2D attention mask with the same spatial size as the current frame's deep feature map and values ranging from 0 to 1 is generated using a sigmoid activation function. This attention mask is then element-wise multiplied with the current frame's deep feature map, modulating the activation intensity at the corresponding location in the original feature map using each value from the mask. This results in a cleaned deep feature map with selectively suppressed background interference features.
[0111] Specifically, the lightweight transform subnetwork typically consists of 1-2 fully connected layers, using ReLU activation functions in between, and finally using a Sigmoid function to map the output to the [0, 1] interval. The function of this subnetwork is to generate a spatially adaptive attention map based on the weighted pooling global context information. Its weight parameters are learned through end-to-end training along with the entire detection model, with the training objective being to minimize the detection loss of intrusive targets. The weighting coefficients in the formula... and The adaptive directional inhibition weights generated in step S3 have values that change dynamically during inference, based on the dynamic patterns of the background in the current video segment.
[0112] The purified deep feature map is a three-dimensional tensor with the same width, height and number of channels as the input current frame deep feature map. However, its internal numerical distribution is modulated by an attention mask. Feature responses that are highly correlated with the current background dynamic pattern are reduced, while feature responses related to potential intrusive targets are relatively enhanced.
[0113] For example, a deep feature map of the current frame is extracted from the temporal feature map queue. This map has a size of 60 pixels by 34 pixels and 2048 channels. The adaptive directional suppression weights consist of a horizontal weight vector of length 60 and a vertical weight vector of length 34. Weighted pooling is performed as described in the formula. For example, for horizontal pooling, if the weight vector shows a higher coefficient in column 30, then the feature values in column 30 of all channels will be suppressed to a greater extent during the pooling calculation. The pooled result is two one-dimensional feature vectors, which are concatenated, transformed by a fully connected layer, and activated with a sigmoid function to generate a 60x34 attention mask. This mask is then multiplied element-wise with the original deep feature map to obtain a cleaned deep feature map. Verification shows that the value corresponding to the rail reflective translation region in the mask is approximately 0.3, while the average activation intensity of this region in the original feature map is 1.5. After multiplication, the average activation intensity of this region in the cleaned feature map is reduced to 0.45, effectively suppressing background interference.
[0114] In one embodiment of the present invention, step S5 includes the following steps:
[0115] Construct a bidirectional feature pyramid network containing top-down and bottom-up paths; input the purified deep feature map and the mid-level feature map of the current frame into the bidirectional feature pyramid network; locate the feature fusion nodes of the bottom-up path in the bidirectional feature pyramid network, and establish a direct connection channel from the shallow output node of the backbone feature extraction network to the feature fusion node; after aligning the shallow feature map of the current frame by the number of channels, inject it into the feature fusion node through the direct connection channel and superimpose it to output a multi-scale fused feature map.
[0116] Specifically, a bidirectional feature pyramid network with a predefined network structure is built and loaded into memory. It should be noted that this bidirectional feature pyramid network is a computationally compliant graph structure specifically designed for multi-scale feature fusion. It contains multiple stacked convolutional layers and upsampling layers, connected in a specific way to form two paths: top-down and bottom-up. Its function is to collaboratively integrate feature information at different levels of abstraction. This network has two clearly defined information transmission paths: one top-down and the other bottom-up.
[0117] Subsequently, the purified deep feature map is input into the highest level of the bidirectional feature pyramid network as the starting point for high-level semantic features. Simultaneously, the mid-level feature map of the current frame is input into the corresponding middle level of the bidirectional feature pyramid network. In the top-down path, the network processes the purified deep feature map from the top, first upsampling it to enlarge its spatial size to match that of the mid-level feature maps. Figure 1 Then, the upsampled features are added position by position to the intermediate feature map, which has undergone a one-to-one convolution to adjust the number of channels, to generate the fused intermediate feature map.
[0118] Next, a preset network layer is located in the bottom-up path. This layer is designated as a feature fusion node for fusing small-scale target information. It should be understood that this feature fusion node is a specific computational layer in the bottom-up path of the bidirectional feature pyramid network. The feature map output by this layer has a relatively large spatial size and functions as a key node for integrating high-resolution shallow detail information to enhance the representation ability of small-sized intrusive objects in the image.
[0119] To achieve high-fidelity preservation of detailed information of small targets, a direct connection channel is established from the shallow output node of the backbone feature extraction network in step S2 to the feature fusion node. It should be noted that this direct connection channel is a logical data link that directly connects from the shallow output endpoint of the backbone feature extraction network to the feature fusion node in the bidirectional feature pyramid network, bypassing other intermediate processing layers in the network. Its function is to realize fast and lossless transmission of shallow feature information.
[0120] The shallow feature map of the current frame is directly transmitted through this channel. First, a channel number alignment operation is performed through an independent 1x1 convolutional layer so that the number of output channels is exactly the same as the number of channels of the feature map at the feature fusion node. Then, the aligned shallow feature map is added element-wise to the existing feature map at the feature fusion node.
[0121] Finally, the bidirectional feature pyramid network completes all feature transfer and fusion calculations for its internal top-down and bottom-up paths, outputting a set of feature maps that integrate deep semantics, mid-level context, and shallow detail information at multiple different spatial resolutions, thus obtaining a multi-scale fused feature map.
[0122] Specifically, the structure and parameter settings of the bidirectional feature pyramid network can refer to the existing technology, but the selection of feature fusion nodes and the introduction of direct connection channels are the optimization points of this invention.
[0123] Typically, the feature fusion node is selected from the layer with the highest spatial resolution in the bottom-up path, that is, the layer that is closest to the size of the input image.
[0124] In the channel alignment operation, the number of kernels in the 1x1 convolutional layer is set to be the same as the number of channels in the feature map of the feature fusion node, for example, 256. The weights and bias parameters of this convolutional layer are learned during model training, and their function is to perform cross-channel information integration and dimensional transformation, rather than spatial downsampling.
[0125] The top-down path is the computational process within the network that propagates information from high-level, low-resolution features to low-level, high-resolution features. It mainly achieves the downward transfer of semantic information through upsampling and feature addition.
[0126] The bottom-up approach is a computational process within the network that supplements information from low-level features to high-level features, passing spatial details through operations such as convolution.
[0127] Channel alignment is a process that uses a convolutional layer with fixed weights and a 1x1 kernel to process the input feature map, changing the number of its channel dimensions. The goal is to enable it to perform arithmetic operations directly with the superimposed feature map in the channel dimension.
[0128] Multi-scale fusion feature maps are the final output of the bidirectional feature pyramid network after processing. They are a set of feature maps with a fixed number and decreasing spatial size, each of which integrates information from shallow, medium and deep layers. Their function is to provide subsequent detection heads with multi-scale feature representations that have both accurate localization of details and rich semantic understanding capabilities.
[0129] For example, the size of the deep cleansing feature map is 60 pixels by 34 pixels, with 2048 channels. The size of the mid-layer feature map in the current frame is 120 pixels by 68 pixels, with 512 channels. The size of the shallow feature map in the current frame is 240 pixels by 136 pixels, with 256 channels. The constructed bidirectional feature pyramid network upsamples the deep cleansing feature map to 120 pixels by 68 pixels and adds it to the mid-layer feature map with adjusted channels in its top-to-bottom path. The feature fusion node in the bottom-to-top path of the network sets the output feature map size to 240 pixels by 136 pixels, with 256 channels. Through pass-through channels, the shallow feature map is processed by a 1x1 convolutional layer, maintaining the number of channels at 256, and then injected into this node for stacking. Finally, the network outputs a multi-scale fused feature map, for example, containing three feature maps with sizes of 240 by 136, 120 by 68, and 60 by 34. In the 240x136 scale feature map output, the average feature activation value of the edge region corresponding to the small legacy tool next to the track is 0.85, while in the output of the traditional pyramid network without the introduction of shallow feature passthrough, the average activation value of this region is only 0.52, indicating that the effect of preserving detailed information is improved.
[0130] In one embodiment of the present invention, step S6 includes the following steps:
[0131] The multi-scale fused feature map is input into the detection head to generate a preliminary detection box for the current frame containing the target category, confidence level, and location coordinates; an identity label is assigned to an independent target appearing in the field of view; and the preliminary detection boxes of the current frame associated with the same identity label in multiple consecutive frames are associated in chronological order to construct a historical state sequence.
[0132] Specifically, the multi-scale fused feature map is input into a pre-built detection head network module. The detection head pre-defines multiple anchor boxes with different initial aspect ratios at each spatial location. Through convolution, the detection head generates two key output vectors for each anchor box: a classification score vector, representing the probability that the anchor box contains various types of intrusive targets; and a location regression vector, containing four values used to fine-tune the center coordinates, width, and height of the anchor box to more closely match the real target.
[0133] Next, the prediction results of all anchor boxes are filtered. First, based on the classification score and by applying a non-maximum suppression algorithm, a large number of redundant and highly overlapping low-quality prediction boxes are eliminated. Finally, one or more prediction boxes with the highest probability of containing the target and their information are retained. The information of each retained prediction box includes the target category label, the confidence score corresponding to the label, and the precise position coordinates of the bounding box in the original input image coordinate system after regression adjustment. This information together constitutes the preliminary detection box of the current frame. It should be understood that the preliminary detection box of the current frame is a structured data unit obtained after the detection head calculation and post-processing filtering. Its data structure is usually a tuple or dictionary, containing at least six fields: target category, confidence score, x-coordinate of the top left corner of the bounding box, y-coordinate of the top left corner, width, and height. Its function is to characterize the potential intrusive targets identified in a single frame image.
[0134] Subsequently, the target tracking and association process is initiated. Each newly appearing independent intruding target within the field of view is dynamically assigned a globally unique identifier, or ID. The initial detection bounding box of the current frame is temporally associated with existing target trajectories maintained in the system. Specifically, this is done by calculating the intersection-over-union ratio (IoU) or appearance feature similarity between the current detection bounding box and the latest detection bounding boxes of each target in the previous frame, matching the detected target bounding box in the current frame to the existing, most similar target ID. If the current detection bounding box cannot match any existing target, a new ID is assigned to it.
[0135] Through the above association, the preliminary detection boxes of the current frame associated with the same identity in multiple consecutive frames are linked together in chronological order to form a sequence describing the target's position, category, and confidence level as it changes over time. This constructs the historical state sequence of the independent target. It should be noted that this historical state sequence is a list or queue data structure composed of multiple preliminary detection boxes of the current frame associated with the same identity, arranged in chronological order. Its function is to record the target's motion trajectory and state changes over a period of time, providing a data basis for subsequent motion analysis and prediction. The length of the sequence is set based on balancing the accuracy of motion state estimation with system memory overhead.
[0136] The class probability is calculated using the Softmax function, with the following formula:
[0137]
[0138] in This is the raw score (logits) output by the detector head for category k. This function transforms the raw scores of all categories into a probability distribution that sums to 1. The bounding box position regression formula is used to convert the anchor boxes... Adjust to prediction box The calculation is as follows:
[0139]
[0140]
[0141]
[0142]
[0143] in, The coordinates of the center of the anchor point frame. and These represent the width and height of the anchor box, respectively, both in pixels. These are the four regression coefficients output by the detection head, which are dimensionless values. This represents the Sigmoid activation function, which will... and Map to a range of 0 to 1 to ensure that the predicted center point does not exceed the preset grid cells. and This is the grid size normalization coefficient corresponding to the spatial location of the feature map. It is typically set as the reciprocal of the downsampling step size corresponding to the feature map, and is a dimensionless coefficient used to convert the normalized center offset back to the coordinate scale. (Exponential function) and This ensures that the width and height adjustment factors are positive. The final calculated... These are the coordinates and dimensions in the original image's pixel coordinate system.
[0144] The identification identifier is a unique integer number assigned to each tracked target, used to distinguish and associate different targets across consecutive frames.
[0145] For example, continuing from the previous example, a multi-scale fused feature map is input into the detection head. The detection head presets anchor points on the 240x136 scale feature map, performs convolution calculations and post-processing, and outputs two preliminary detection boxes for the current frame. The first box is classified as "pedestrian" with a confidence level of 92%, and its bounding box coordinates are x=150, y=280, w=30, h=80 (unit: pixels). The second box is classified as "falling rock" with a confidence level of 85%, and its bounding box coordinates are x=500, y=320, w=45, h=45. A historical state sequence from the previous frame is available, with ID 101, and the detection box coordinates of the last frame are x=148, y=278, w=31, h=79. By calculating the intersection-union ratio (IUGR), the first box successfully matches the trajectory of ID 101, so it is associated with ID 101, and the historical state sequence of that target is updated. The second box cannot match any existing trajectory, so assign it a new ID 102 and create a new historical state sequence starting from its detection box.
[0146] In one embodiment of the present invention, step S7 includes the following steps:
[0147] The Kalman filter algorithm is applied to the historical state sequence to estimate the three-dimensional motion state vector of the target; the predicted motion trajectory of the target is calculated based on the three-dimensional motion state vector; it is determined whether the predicted motion trajectory intersects with the three-dimensional geometric model of the track safety limit, and the predicted intrusion time is calculated for targets with intersections.
[0148] Specifically, the historical state sequence of a specified target is read, containing the target's position coordinates and corresponding timestamps across multiple consecutive historical frames. Then, the Kalman filter algorithm is applied to estimate the target's motion state in real time. It should be understood that the Kalman filter is an optimal recursive algorithm for state estimation of linear systems. Here, its function is to fuse the target's motion model with noisy observations, smoothing and estimating its more accurate position, velocity, and acceleration. The Kalman filter is a recursive algorithm comprising two core steps: prediction and update, used to optimally estimate the internal state of the system in the presence of measurement noise.
[0149] In this scenario, the state is defined as a six-dimensional vector, i.e., a three-dimensional motion state vector, which is specifically composed of the x-coordinate of the center point of the target in a two-dimensional plane in the image coordinate system. and ordinate and their respective speeds and acceleration The algorithm predicts the state based on a uniform motion or uniformly accelerated motion model;
[0150] In one embodiment of the present invention, the state transition matrix Example:
[0151]
[0152] in, ;
[0153] Then, using the coordinates of the detection box in the latest frame of the historical state sequence as the observation value, the predicted state is corrected and updated, and finally the optimal estimated three-dimensional motion state vector at the current moment is output. Next, based on the currently estimated position, velocity, and acceleration, combined with the preset track safety clearance three-dimensional geometric model, the predicted motion trajectory of the target is calculated. The preset track safety clearance three-dimensional geometric model is a three-dimensional polyhedron defined in the world coordinate system, describing the physical space range on both sides and above the track that is not allowed to be intruded upon. It should be noted that the preset track safety clearance three-dimensional geometric model is a three-dimensional polyhedron defined in the world coordinate system, describing the physical space range on both sides and above the track that is not allowed to be intruded upon. Its geometry and dimensions are set according to the national or industry-issued rail transit facility safety clearance standards, and its function is to serve as a spatial reference for judging whether there is an intrusion.
[0154] During the calculation, the target's two-dimensional coordinates and estimated velocity vector in the current image are first back-projected onto the world coordinate system based on the camera calibration parameters to obtain the initial three-dimensional spatial position and velocity. Assuming the target maintains its current acceleration for a short period, its three-dimensional spatial trajectory over a future time period can be calculated using physical kinematic formulas. Finally, it is determined whether this predicted trajectory intersects with the three-dimensional geometric model of the track safety clearance. For targets outside the clearance whose predicted trajectory intersects with the clearance model, the time required to move along the predicted trajectory to the first intersection point with the clearance model from the current moment is calculated. This time value is the predicted intrusion time. It should be understood that the predicted intrusion time is a scalar value, representing the number of seconds required for the target to intrude into the track safety clearance from the current moment. Its calculation is based on the mathematical intersection of the target's world coordinate trajectory equation and the boundary surface of the clearance geometric model. The core of calculating the predicted intrusion time lies in solving the simultaneous equations of the trajectory equation and the boundary surface of the clearance model to obtain the earliest positive time solution, which is the predicted intrusion time.
[0155] The state prediction equation and state update equation of Kalman filtering are the core mathematical tools of this step. The state prediction equation describes how to estimate the current state from the state of the previous time step:
[0156]
[0157] in, It is the prior state estimate, i.e., the predicted value, based on information from time k-1 at time k-k, for example, containing... ; It is the state transition matrix, determined according to the selected motion model, such as a uniform acceleration model, whose elements correspond to time intervals. This matrix maps the state of the previous time step to the predicted state of the current time step, and the formula itself is dimensionless. This is the posterior state estimate at time k-1, i.e., the optimal estimate from the previous round. The state update equation then utilizes the new observations. That is, the center coordinates of the target box detected in the current frame. To revise the prediction:
[0158]
[0159] in, It is the observation matrix, used to map the state vector to the observation space, for example, to extract the position coordinates from the six-dimensional state; It is the Kalman gain matrix, which is dynamically calculated based on the prediction covariance and the observation noise covariance, and determines the weight of believing the prediction model or the observation. This refers to the observation residual. When calculating the predicted intrusion time, it is usually necessary to transform the pixel coordinates to the world coordinate system using camera calibration parameters. This ensures that the trajectory equation and the boundary geometry model (in meters) are correctly intersected in physical space, thus obtaining the predicted intrusion time in seconds. This coordinate transformation is based on the camera's intrinsic and extrinsic parameter matrices, which are set according to on-site measurements and calibration.
[0160] Specifically, the key parameters in the Kalman filter algorithm are set as follows: state transition matrix. Based on the uniformly accelerated motion model, assuming the time interval is... ,but It is a 6x6 matrix. The process noise covariance matrix Q and the observation noise covariance matrix R need to be tuned according to the actual system. Typically, the process noise covariance matrix Q reflects our estimate of the uncertainty of the motion model and can be set based on the maximum possible range of acceleration variation of the target; the observation noise covariance matrix R reflects the uncertainty of the detection box position and can be set based on the statistical variance of the positioning error of the target detection algorithm on the validation set. For example, initially, Q can be set as a diagonal matrix, with diagonal elements equal to... , , The parameters are directly proportional, with the proportionality coefficient adjusted based on experience or experimentation. R can be set as a diagonal matrix, with its diagonal elements set as empirical values of the variance of the detection box coordinates, such as the square of a few pixels. These parameters can be optimized and adjusted before system deployment by conducting trajectory tracking experiments on real or simulated data, with the goal of minimizing tracking error.
[0161] Among them, the three-dimensional motion state vector is the core estimation result output by the Kalman filter algorithm in this step. It is a six-dimensional column vector, and its data structure includes the target's x-coordinate, y-coordinate, x-direction velocity, y-direction velocity, x-direction acceleration, and y-direction acceleration in the image plane. Its estimation is based on the target's motion history and current observation.
[0162] For example, for a target with an ID of 101, its historical state sequence contains the location information of the most recent 5 frames. A Kalman filter algorithm is applied, and the state vector is set to six dimensions. A state transition matrix is constructed based on a frame time interval of 0.04 seconds (corresponding to 25 frames per second). After prediction and update steps, the algorithm outputs an estimated 3D motion state vector for the current moment, for example, a position of (151.2, 281.5) pixels, a velocity of (8.0, 5.0) pixels per second, and an acceleration of (0.1, 0.0) pixels per square second. Based on camera calibration parameters, this state is transformed to the world coordinate system to obtain the target's position beside the rails and its velocity toward the rails. Assuming it maintains its current acceleration, the trajectory is calculated. This trajectory intersects the side of the preset 3D geometric model of the track safety boundary (a cuboid) after 2.5 seconds. Therefore, the predicted intrusion time of the target is calculated to be 2.5 seconds.
[0163] In one embodiment of the present invention, step S8 includes the following steps:
[0164] The predicted intrusion time is compared with a first threshold and a second threshold, where the first threshold is greater than the second threshold. If the predicted intrusion time is greater than the first threshold, a low-risk concern signal is output. If the predicted intrusion time is less than or equal to the first threshold but greater than the second threshold, a medium-risk preparation signal is output. If the predicted intrusion time is less than or equal to the second threshold, or the target is already within the boundary, a high-risk emergency response signal is output. The detection and prediction results of the current frame are stored in the historical state sequence of the corresponding target.
[0165] Specifically, the system reads the scalar value calculated for each target outside the clearance limit, i.e., the predicted intrusion time. Then, this predicted intrusion time is compared with two preset time thresholds. It should be noted that these two time thresholds, namely the first threshold and the second threshold, are two pre-set time limits, both in seconds. The first threshold is usually set to a larger value, such as 10 or 15 seconds, based on the reaction time required for early warning under normal train conditions, or the time window for preventative intervention by the dispatching system. The second threshold is usually set to a smaller value, such as 3 or 5 seconds, based on the shortest time required for emergency braking of the train, or the critical time for on-site personnel to immediately take mandatory measures. Its specific value is determined comprehensively based on track conditions, train type, and operating procedures. These two thresholds are two time values stored in the system configuration file beforehand to classify risk levels, with the first threshold being greater than the second threshold.
[0166] The comparison logic follows a hierarchical judgment principle. Based on the comparison results, early warning signals with clear meanings that strictly correspond to different risk levels are generated and output. It should be understood that the early warning signals corresponding to the risk levels are instructional outputs generated based on the comparison of the predicted intrusion time with multi-level time thresholds. Their data structure can be a predefined enumeration type or a string label, and their function is to clearly convey the urgency of the current risk to monitoring personnel or automatic control systems.
[0167] The specific rules are as follows: If the predicted intrusion time is greater than the first threshold, a low-risk concern signal is generated and output. This signal indicates that the target has a potential intrusion trend but there is still sufficient time, prompting the system or personnel to maintain monitoring. If the predicted intrusion time is less than or equal to the first threshold and greater than the second threshold, a medium-risk preparation signal is generated and output. This signal indicates that the likelihood of the target intrusion is increasing and the time is shortening, prompting the need to prepare for a response. If the predicted intrusion time is less than or equal to the second threshold, or if the target has already been determined to be within the three-dimensional geometric model of the track safety clearance, a high-risk emergency response signal is generated and output. This signal indicates that an intrusion is about to occur or has already occurred, requiring timely braking, alarm, or other emergency measures.
[0168] After these signals are generated, they are transmitted externally through a system-preset interface, for example, to provide visual cues on the driver's console display or to trigger audible alarms. Simultaneously, to ensure the continuity of tracking prediction, a state update operation is performed: the detection result of the current frame, i.e., the preliminary detection box generated in step S6, along with all prediction results calculated in step S7, including the 3D motion state vector and predicted intrusion time, are appended to the end of the historical state sequence corresponding to the target as a complete state data packet. This historical state sequence is thus updated, containing the latest state information, providing the latest data foundation for a new round of motion state iterative estimation from step S6 to temporal correlation and step S7 when the next frame image arrives. It should be noted that this operation, namely updating the target tracking state, refers to the persistent recording of all data representing the latest state of the target generated in this processing cycle into the target's historical state sequence.
[0169] Specifically, the determination of the first threshold (T1) and the second threshold (T2) is based on operational safety regulations and train dynamics characteristics. T1 typically corresponds to the "warning time," providing advance notice for dispatchers or primary automated systems, and its range is generally 8 to 20 seconds. T2 typically corresponds to the "braking or emergency response critical time," taking into account factors such as the train's maximum deceleration and system response delay, and its range is generally 2 to 6 seconds. Specific values need to be determined through safety analysis calculations or simulations based on factors such as the train's operating speed, braking performance, and signal system response time for the specific line. For example, for a city's subway line, where the maximum train speed is 80 km / h and the emergency braking distance requirement is 200 meters, considering the system response time, T1 can be set to 10 seconds and T2 to 3 seconds. These thresholds are configurable parameters and are set according to the site conditions during system deployment.
[0170] For example, the predicted intrusion time limit for a target with ID 101 is read, and its value is 2.5 seconds. The preset first threshold is 5 seconds, and the second threshold is 3 seconds. A comparison is performed: 2.5 seconds is less than or equal to the second threshold of 3 seconds. According to the judgment rules, a high-risk emergency response signal is generated and output. Simultaneously, the output displays the target category as "pedestrian". In the target list maintained by the system, the corresponding historical state sequence for ID 101 is found. The latest associated preliminary detection box of the current frame (coordinates, category, confidence level), along with the calculated 3D motion state vector and the predicted intrusion time limit of 2.5 seconds, are added as a new data entry to the end of this sequence. After the sequence is updated, its length increases by one, and the data at the latest moment is ready for the Kalman filter prediction step of the next frame.
[0171] See appendix Figure 2 This invention also proposes an orbital encroachment detection system based on attention enhancement and feature pyramids, comprising the following modules:
[0172] The data acquisition module is used to acquire time-series track video data and construct a dynamic image frame queue;
[0173] The feature extraction module is used to extract multi-level raw feature maps from the dynamic image frame queue and construct a temporal feature map queue.
[0174] The background analysis module is used to analyze the dynamic patterns of background elements in the temporal feature map queue and generate adaptive directional inhibition weights.
[0175] The attention suppression module is used to apply adaptive directional suppression weights to the deep feature map of the current frame to perform attention suppression operation and generate a cleaned deep feature map.
[0176] The feature fusion module is used to construct a bidirectional feature pyramid network. It inputs the purified deep feature map, mid-level feature map and shallow feature map into the network, and injects the shallow feature map into the feature fusion node through the direct connection channel to perform multi-scale feature fusion and output a multi-scale fused feature map.
[0177] The preliminary detection module generates preliminary detection boxes for the current frame based on multi-scale fused feature maps and constructs a historical state sequence of the target.
[0178] The state estimation module estimates the target's three-dimensional motion state vector based on historical state sequences using a recursive algorithm, and calculates the predicted intrusion time based on this vector and the three-dimensional geometric model of the track safety clearance.
[0179] The risk warning module is used to output graded risk warning signals based on the comparison results between the predicted intrusion time and the multi-level time thresholds, and to update the historical state sequence of the target.
[0180] Each of the modules can be implemented in whole or in part through software, hardware, or a combination thereof. It supports hardware embedded in or independent of the processor in the computer device, and also supports software stored in the memory of the computer device, so that the processor can call and execute the operations corresponding to each of the above modules.
[0181] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. 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. Such 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, and should all be included within the protection scope of the present invention.
Claims
1. A method for detecting orbital encroachment based on attention enhancement and feature pyramids, characterized in that, Includes the following steps: S1. Acquire time-series track video data and construct a dynamic image frame queue; S2. Extracting multi-level raw feature maps from the dynamic image frame queue, including: inputting each frame image in the dynamic image frame queue into the backbone feature extraction network, extracting the deep feature map, middle feature map and shallow feature map corresponding to each frame image from the deep, middle and shallow output nodes respectively, forming a multi-level raw feature map group; organizing the multi-level raw feature map groups corresponding to multiple consecutive frames of images in chronological order to construct a temporal feature map queue; S3. Analyze the dynamic patterns of background elements in the temporal feature map queue, including: inputting the deep feature map sequence in the temporal feature map queue into a background modeling subnetwork containing recurrent neural units; identifying and quantifying the morphological change trends of background elements in the deep feature map sequence in the horizontal and vertical directions through the background modeling subnetwork, wherein the background modeling subnetwork includes a convolutional coding module and a recurrent neural network module, used to learn and encode the dynamic temporal patterns of the background; generating adaptive directional inhibition weights based on the morphological change trends; S4. Apply adaptive directional suppression weights to the deep feature map of the current frame to perform attention suppression operation, including: performing one-dimensional global pooling on the deep feature map of the current frame along the horizontal and vertical directions respectively, and applying adaptive directional suppression weights during the pooling process; wherein, the adaptive directional suppression weights include a horizontal weight vector and a vertical weight vector; during the one-dimensional global pooling process, the horizontal weight vector is applied when pooling along the horizontal direction, and the vertical weight vector is applied when pooling along the vertical direction; the one-dimensional feature vectors after weighted pooling are concatenated, nonlinearly transformed, and activated to generate an attention mask map; the attention mask map is multiplied element-wise with the deep feature map of the current frame to generate a cleaned deep feature map; S5. Construct a bidirectional feature pyramid network, input the purified deep feature map, middle feature map and shallow feature map into the network, and inject the shallow feature map into the feature fusion node through the direct connection channel to perform multi-scale feature fusion and output a multi-scale fused feature map. S6. Generate preliminary detection boxes for the current frame based on multi-scale fusion feature maps, and construct the historical state sequence of the target; S7. Based on the historical state sequence, a recursive algorithm is applied to estimate the three-dimensional motion state vector of the target, and the predicted intrusion time is calculated based on the vector and the three-dimensional geometric model of the track safety clearance. S8. Output a graded risk warning signal based on the comparison results between the predicted intrusion time and the multi-level time threshold, and update the historical state sequence of the target.
2. The orbital encroachment detection method based on attention enhancement and feature pyramid according to claim 1, characterized in that, Constructing a dynamic image frame queue includes the following steps: Activate the image acquisition equipment deployed on rail transit vehicles or facilities along the line, continuously capture video streams facing the direction of track travel, and decode to obtain continuous image frames; Continuous image frames are stored in a first-in-first-out buffer according to the acquisition time order, and a dynamic image frame queue containing a preset number of N frames is constructed.
3. The orbital encroachment detection method based on attention enhancement and feature pyramid according to claim 1, characterized in that, Outputting a multi-scale fused feature map includes the following steps: Construct a bidirectional feature pyramid network that includes both top-down and bottom-up paths; The purified deep feature map and the mid-level feature map of the current frame are input into the bidirectional feature pyramid network; Locate the feature fusion nodes in the bottom-up path of the bidirectional feature pyramid network and establish a direct connection channel from the shallow output nodes of the backbone feature extraction network to the feature fusion nodes. The shallow feature map of the current frame is aligned by the number of channels, injected through the pass-through connection channel, and superimposed onto the feature fusion node to output a multi-scale fused feature map.
4. The orbital encroachment detection method based on attention enhancement and feature pyramid according to claim 1, characterized in that, Constructing the historical state sequence of the target includes the following steps: The multi-scale fused feature map is input into the detection head to generate a preliminary detection box for the current frame containing the target category, confidence level, and location coordinates; Assign an identity identifier to each independent target that appears within the field of view; By associating the initial detection boxes of the current frame that are associated with the same identity in multiple consecutive frames in chronological order, a historical state sequence is constructed.
5. The orbital encroachment detection method based on attention enhancement and feature pyramid according to claim 1, characterized in that, Calculating the predicted intrusion limit time includes the following steps: The Kalman filter algorithm is applied to the historical state sequence to estimate the three-dimensional motion state vector of the target; The predicted motion trajectory of the target is calculated based on the three-dimensional motion state vector; Determine whether the predicted trajectory intersects with the three-dimensional geometric model of the track safety clearance, and calculate the predicted intrusion time for targets with intersections.
6. The orbital encroachment detection method based on attention enhancement and feature pyramid according to claim 1, characterized in that, Output graded risk warning signals and update the historical state sequence of the target, including the following steps: The predicted intrusion time is compared with a first threshold and a second threshold, where the first threshold is greater than the second threshold; If the predicted intrusion time is greater than the first threshold, a low-risk attention signal is output. If the predicted intrusion time is less than or equal to the first threshold and greater than the second threshold, then a medium-risk preparation signal is output. If the predicted intrusion time is less than or equal to the second threshold, or if the target is already within the boundary, a high-risk emergency response signal will be output. The detection and prediction results of the current frame are stored in the historical state sequence of the corresponding target.