Track light bright and real foreign invasion judgment method, electronic equipment and medium
By combining the DISOpticalFlow and the improved GMFlow optical flow detection algorithm, and using the TeLU activation function and polynomial fitting, the problem of distinguishing between foreign object intrusion and bright light in the orbit was solved, improving the accuracy and robustness of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG ZHIYANG HUITONG DIGITAL TECH CO LTD
- Filing Date
- 2026-04-22
- Publication Date
- 2026-07-24
AI Technical Summary
Existing technologies are unable to effectively distinguish between foreign object intrusions in the orbit and sudden bright lights, leading to false alarms and missed alarms.
By combining the DISOpticalFlow fast optical flow detection algorithm with the improved GMFlow optical flow detection algorithm, the fitted trajectory is calculated using optical flow information. The hyperbolic tangent exponential linear unit TeLU activation function is used, combined with the polynomial fitted trajectory, to generate a new target box and perform clustering scoring, ultimately determining the true foreign object intrusion.
It improves the accuracy and robustness of track intrusion detection, effectively distinguishing between foreign object intrusion and light interference, and reducing false alarms and missed alarms.
Smart Images

Figure CN122454518A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of foreign object intrusion detection, and more specifically, relates to a method, electronic device and medium for judging the difference between orbital illumination and actual foreign object intrusion. Background Technology
[0002] With the increasing demands for safety in railway transportation, track intrusion detection has become a crucial link in ensuring safe train operation. However, the actual track environment is complex and ever-changing, with various forms of intrusion events, among which foreign object intrusion and sudden strong light interference are particularly challenging. Although some AI-based intrusion detection algorithms have been applied to track safety monitoring, they still have shortcomings in distinguishing between "changes in foreign object trajectories" and "sudden bright light interference" in real-world scenarios. For example, sudden bright light usually appears abruptly within a short period of time, without a fixed movement path, and is characterized by high brightness and high contrast, making it easy to be misidentified as an intrusion target; while foreign object intrusion is usually accompanied by continuous spatial trajectory changes, and its trajectory has a certain degree of fitability, which can be determined through temporal modeling. If general target detection or segmentation methods are directly used for analysis, it is often impossible to effectively distinguish between these two types of phenomena, easily leading to false alarms and missed alarms. Therefore, there is an urgent need for an intelligent identification method that can combine spatial trajectory features and temporal continuity information to improve the robustness and accuracy of track intrusion detection.
[0003] Chinese patent document CN119851225A proposes a low-light track foreign object intrusion detection method based on an improved YOLOv8n. First, an adaptive enhancement module is used to enhance the contrast, perform gamma correction, and sharpen the low-light image, improving the quality of the input image and increasing the accuracy of subsequent target detection. Second, the SPPF module in YOLOv8n is replaced with an RWSPPF module, and a spatial awareness attention mechanism is introduced to improve the detection accuracy of foreign objects. An improved loss function and Adam optimizer are used to improve training efficiency and accuracy. While this method effectively enhances the recognition rate of track foreign object intrusions, it cannot effectively distinguish sudden bright spots or large light spots on the track from real foreign objects. Summary of the Invention
[0004] The present invention aims to overcome at least one of the defects of the prior art and provide a method for judging track illumination and actual foreign object intrusion, so as to solve the problem that the prior art cannot effectively distinguish between foreign object intrusion and sudden illumination in the track.
[0005] The detailed technical solution of this invention is as follows: A method for distinguishing between orbital illumination and actual foreign object intrusion, the method comprising: S1. Acquire real-time video stream at the testing site; S2. The edge box reads the video stream in real time and performs frame extraction to obtain a video frame sequence. ; S3. The extracted images are processed by a detection system to obtain initial bounding boxes whose categories cannot be accurately determined. ; S4. Based on the initial target bounding box and the video frame extraction sequence, read two adjacent images from back to front, expand the initial target bounding box, and use the expanded box to crop the current image and its previous frame image to obtain... and Optical flow is detected to obtain optical flow information; The optical flow detection first uses the DISOpticalFlow fast optical flow detection algorithm to calculate optical flow information for all images and calculates the fitted trajectory. If the fitting fails, the improved GMFlow optical flow detection algorithm is used to calculate optical flow information for all images and calculate the fitted trajectory. S5. Obtain reasonable velocity points based on optical flow information, calculate clustering score, and generate new target boxes. Repeat this operation until the video frame extraction sequence is processed and all target boxes are obtained. S6. Use the center point of each target box as a point set to fit the trajectory and determine whether it meets the fitting standard. If it meets the fitting standard, it is a real foreign object intrusion; otherwise, it is judged as light interference. Finally, the real foreign object intrusion is displayed on the alarm platform.
[0006] According to a preferred embodiment of the present invention, in step S4, the initial target box is expanded using the following formula:
[0007]
[0008]
[0009]
[0010] in, The coordinates of the top-left corner of the expanded target box. The coordinates of the bottom right corner of the expanded target box. and This represents the height and width of the image. It is the vertical expansion scaling factor, which controls the vertical expansion. It is the horizontal expansion scaling factor, which controls the horizontal expansion. and These are the width and height of the initial target bounding box, respectively. The coordinates are the top-left corner coordinates of the initial target bounding box.
[0011] According to a preferred embodiment of the present invention, in step S4, the formula for calculating optical flow information for all images using the DISOpticalFlow fast optical flow detection algorithm is as follows:
[0012] The improved GMFlow optical flow detection algorithm refers to replacing the ReLU activation function in the GMFlow algorithm with the hyperbolic tangent exponential linear unit TeLU. The formula for calculating the TeLU activation function is shown below:
[0013] Where x represents the input value of the activation function, The input signal is rapidly amplified in the positive region to simulate the linear growth characteristics of ReLU; tanh is the hyperbolic tangent function, which saturates and limits the exponential output. The formula for calculating optical flow information for all images using the improved GMFlow optical flow detection algorithm is as follows: .
[0014] According to a preferred embodiment of the present invention, the specific steps of S5 are as follows: S51. The obtained optical flow map or The process involves calculating the square of the optical flow mode length for each pixel, constructing a velocity threshold mask to filter reasonable velocity points, and finally obtaining the effective optical flow information mask. The calculation formula is as follows:
[0015]
[0016] in, Let (i,j) be the horizontal displacement of pixel (i,j) in the optical flow map. Let be the vertical displacement of pixel (i,j) in the optical flow map. Let (i,j) be the sum of squares of the optical flow modes. To set a minimum speed threshold, excluding stationary points, Maximum speed threshold, excluding high-speed points or background noise. , representing the velocity threshold filtering value of pixel (i,j) in the optical flow map, is used to determine whether the optical flow velocity of this pixel is within a reasonable range. When =1, it indicates that the pixel is a reasonable velocity point and belongs to valid optical flow information. =0 indicates that the pixel is an invalid optical flow point and needs to be filtered. S52. After obtaining reasonable speed points, count the number of motion points and then continue to calculate the aggregation score. S53. If the clustering score meets the preset threshold, the updated valid point coordinates are calculated based on optical flow, and the new location distribution range and center of all valid points are calculated. The box center is further optimized by combining the clustering center to generate a new target box. The specific calculation formula is as follows:
[0017]
[0018] in, The coordinates of the top left corner of the initial target bounding box. These are the local coordinates of the valid pixels within the initial target bounding box. and The horizontal and vertical optical flow displacements at corresponding points This refers to the new coordinates of the valid pixel across the entire image after the update.
[0019]
[0020]
[0021] Where N is the number of valid points after the update. For the centroid positions of all points, and Define the width and height of the newly generated target bounding box.
[0022]
[0023]
[0024] in, The coordinates of the top-left corner of the newly generated target bounding box; Finally, the updated box is obtained. The image frame number is then expanded as described in step S4 and used to crop the next two images. The image frame number is stored while the target box is updated. This process is repeated to complete the processing of all images, resulting in a list of image frame numbers, a list of frames, and a set of frame center points C.
[0025] According to a preferred embodiment of the present invention, in step S52, the calculation of the clustering score is specifically as follows: S521, the obtained Preprocessing operations are performed, and the preprocessing calculation formula is shown below:
[0026] in For effective optical flow information masking, MorphOpen is the opening operation, and kernel is an elliptical structuring element whose size is determined by ksize. This is the preprocessed optical flow information mask; S522, Apply the preprocessed mask Extract all external connected regions, and calculate the area and center of the outline of each connected region. The calculation formula is shown below:
[0027]
[0028] Where (x, y) are the coordinates of each point in the contour of the connected region. The outline of the i-th connected region. This describes the method for calculating the area of a region in OpenCV. Let be the area of the outline of the connected region. The center point of the outline region; S523. Normalize all areas and calculate the average area ratio of the 1-2 largest regions as the clustering score. The calculation formula is as follows:
[0029]
[0030] in, The normalized area ratio is given, and k represents the k largest regions. S524. Filter all externally connected regions. If the number of regions with an area greater than 200 is greater than 10, it is considered that there is too much noise interference, and the clustering score is set to a negative value. Calculate the proportion of non-zero pixels in the mask. If it occupies more than 50% of the image, the region is too widely distributed, and the clustering score is also set to a negative value.
[0031] According to a preferred embodiment of the present invention, in step S6, the trajectory fitting is divided into two parts: fitting the overall trajectory and fitting the maximum continuous trajectory. The fitting and judgment of the two trajectories are performed simultaneously. First, each effective segment of the overall trajectory is extracted to obtain the maximum and continuous trajectory and then fitted. Finally, all effective segments are combined to form the overall trajectory, and then the overall trajectory is fitted. The main steps are as follows: First, continuous frame intervals are extracted in segments. The image frame number list is traversed, and continuous frame number segments are extracted with a maximum interval of 1 as the standard. Then, valid segments are selected based on the segment length being greater than a threshold. Trajectory fitting and error evaluation are performed on each valid segment. The processing flow for each valid segment is as follows: The first step is to extract the trajectory sequence: determine the main direction of motion, and fit the trajectory using a quadratic polynomial based on the direction of motion. If the x-axis direction is dominant, then the fitting model is... If the y-axis direction is dominant, then the fitting model... Parameter a determines the opening direction and the curvature of the curve, parameter b determines the horizontal offset of the vertex position, and parameter c determines the vertical position of the curve. The second step is to calculate the fitting error indices, which mainly include the coefficient of determination R², the normalized root mean square error, and the trajectory length. The calculation formulas are shown below:
[0032]
[0033]
[0034]
[0035] in, To fit the predicted values, The mean of y is used to fit the model. For the sum of squared residuals, For the total variation, For each point on the trajectory;
[0036] Where the numerator is the root mean square error, and the denominator is... The mean of the trajectory coordinates.
[0037] In another aspect of the invention, an electronic device is also provided, comprising: At least one processor; and The memory stores instructions that, when executed by the at least one processor, cause the at least one processor to perform the method for determining orbital light intensity and actual foreign object intrusion as described above.
[0038] In another aspect of the invention, a machine-readable storage medium is also provided, which stores executable instructions that, when executed, cause the machine to perform the method for determining orbital light and actual foreign object intrusion as described above.
[0039] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) This invention combines the traditional DISOpticalFlow fast optical flow detection method with the GMFlow deep learning detection method, which improves the detection accuracy and trajectory fitting precision while performing fast detection on images.
[0040] (2) The present invention uses the hyperbolic tangent exponential linear unit TeLU to replace the ReLU activation function in the GMFlow algorithm, avoiding the problem of dead neurons while retaining the fast convergence characteristic, thereby enhancing the robustness of the algorithm.
[0041] (3) In the trajectory fitting part of the present invention, polynomial fitting is used to fit the overall trajectory and the maximum trajectory, ensuring the accuracy of trajectory fitting, comprehensively considering the global trend and local optimal trajectory features, and improving the system's judgment ability for continuously moving intrusion targets. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 is a flowchart of the method for judging the track brightness and real foreign object intrusion described in the present invention.
[0043] Figure 2 is the detection effect diagram during the day described in Embodiment 1 of the present invention.
[0044] Figure 3 is the output result diagram corresponding to the detection effect during the day described in Embodiment 1 of the present invention.
[0045] Figure 4 is the detection effect diagram at night described in Embodiment 1 of the present invention.
[0046] Figure 5 is the output result diagram corresponding to the detection effect at night described in Embodiment 1 of the present invention.
[0047] Figure 6 is the detection effect diagram under the light interference scenario described in Embodiment 1 of the present invention.
[0048] Figure 7 is the output result diagram corresponding to the detection effect under the light interference scenario described in Embodiment 1 of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] The following further describes the present disclosure in conjunction with the drawings and embodiments.
[0050] Embodiment 1, Refer Figure 1 , this embodiment provides a method for judging track brightness and real foreign object intrusion, and the method includes: S1. Obtain a real-time video stream at the detection site; S2. The edge box reads the video stream in real time and performs a frame extraction operation to obtain a video frame extraction sequence ; S3. Pass the frame-extracted picture through the detection system to obtain an initial target box whose category cannot be accurately judged ; S4. Based on the initial target bounding box and the video frame extraction sequence, read two adjacent images from back to front, expand the initial target bounding box, and use the expanded box to crop the current image and its previous frame image to obtain... and Optical flow is detected to obtain optical flow information; S5. Generate new target boxes based on optical flow information. Repeat this operation until the video frame extraction sequence is processed and all target boxes are obtained. S6. Use the center point of each target box as a point set to fit the trajectory and determine whether it meets the fitting standard. If it meets the fitting standard, it is a real foreign object intrusion; otherwise, it is judged as light interference. Finally, the real foreign object intrusion is displayed on the alarm platform.
[0051] The expansion of the initial target bounding box described in S4 is to facilitate finding the optical flow information between changing targets in two images. The specific formula is as follows:
[0052]
[0053]
[0054]
[0055] in, The coordinates of the top-left corner of the expanded target box. The coordinates of the bottom right corner of the expanded target box. and This represents the height and width of the image. It is the vertical expansion scaling factor, which controls the vertical expansion. It is the horizontal expansion scaling factor, which controls the horizontal expansion. and These are the width and height of the initial target bounding box, respectively. The coordinates are the top-left corner coordinates of the initial target bounding box.
[0056] The optical flow detection described in S4 first uses the DISOpticalFlow fast optical flow detection algorithm to calculate optical flow information for all images and calculates the fitted trajectory. If the fitting fails, the improved GMFlow optical flow detection algorithm is used to calculate optical flow information for all images and calculate the fitted trajectory. The formula for calculating optical flow information for all images using the DISOpticalFlow fast optical flow detection algorithm is as follows:
[0057] The improved GMFlow optical flow detection algorithm uses the hyperbolic tangent exponential linear unit (TeLU) instead of the ReLU activation function in the GMFlow algorithm. This retains the fast convergence characteristics while avoiding the problem of dead neurons, thereby enhancing the robustness of the algorithm. The ReLU activation function is most commonly used in the GMFlow algorithm. While ReLU is computationally simple and efficient, its discontinuity at zero can lead to unstable gradient propagation and limited expressive power. Existing smooth activation functions such as GELU and Swish, while improving model performance, have high computational costs, making them difficult to deploy in resource-constrained scenarios. Therefore, the TeLU activation function is used to replace the ReLU activation function in the GMFlow algorithm. The calculation formula for the TeLU activation function is shown below:
[0058] in, The input signal is rapidly amplified in the positive region to simulate the linear growth characteristics of ReLU. The hyperbolic tangent function tanh saturates and limits the exponential output to avoid gradient explosion while preserving nonlinear characteristics.
[0059] To balance computational efficiency and expressive power, this paper proposes replacing ReLU in the GMFlow algorithm with the TeLU activation function. While ReLU is simple and efficient, it suffers from problems such as discontinuity and unstable gradient propagation. On the other hand, smooth activations such as GELU and Swish, although offering performance improvements, rely on complex computations and incur significant overhead, making them unsuitable for deployment on resource-constrained devices.
[0060] In contrast, TeLU grows approximately linearly in the positive interval, retaining the fast response characteristics of ReLU. Simultaneously, it uses tanh to saturate and suppress the exponential term, avoiding gradient explosion and enhancing nonlinear expressiveness. TeLU involves only one exponential and one hyperbolic tangent operation, resulting in lower computational complexity. Without sacrificing model accuracy, it significantly improves numerical stability and training convergence.
[0061] Therefore, TeLU is particularly suitable for deployment at the edge or in environments with limited computing power, enabling efficient, stable and accurate model inference with limited hardware resources; The formula for calculating optical flow information for all images using the improved GMFlow optical flow detection algorithm is as follows: .
[0062] The specific steps for S5 are as follows: S51. The obtained optical flow map or The process involves calculating the square of the optical flow mode length for each pixel, constructing a velocity threshold mask to filter reasonable velocity points, and finally obtaining the effective optical flow information mask. The calculation formula is as follows:
[0063]
[0064] in, Let (i,j) be the horizontal displacement of pixel (i,j) in the optical flow map. Let be the vertical displacement of pixel (i,j) in the optical flow map. Let (i,j) be the sum of squares of the optical flow modes. To set a minimum speed threshold, excluding stationary points, Maximum speed threshold, excluding high-speed points or background noise. , representing the velocity threshold filtering value of pixel (i,j) in the optical flow map, is used to determine whether the optical flow velocity of this pixel is within a reasonable range. When =1, it indicates that the pixel is a reasonable velocity point and belongs to valid optical flow information. =0 indicates that the pixel is an invalid optical flow point and needs to be filtered. S52. After obtaining reasonable speed points, count the number of motion points and then continue to calculate the aggregation score. The calculation of the clustering score is as follows: S521. To prevent the optical flow information from being too scattered in fast optical flow calculations, the obtained... Preprocessing operations are performed, and the preprocessing calculation formula is shown below:
[0065] in For effective optical flow information masking, MorphOpen is the opening operation, and kernel is an elliptical structuring element whose size is determined by ksize. This is the preprocessed optical flow information mask; S522, Apply the preprocessed mask Extract all external connected regions, and calculate the area and center of the outline of each connected region. The calculation formula is shown below:
[0066]
[0067] Where (x, y) are the coordinates of each point in the contour of the connected region. The outline of the i-th connected region. This describes the method for calculating the area of a region in OpenCV. Let be the area of the outline of the connected region. The center point of the outline region; S523. Normalize all areas and calculate the average area ratio of the 1-2 largest regions as the clustering score. The calculation formula is as follows:
[0068]
[0069] in, Let i be the area of the i-th region. The normalized area ratio is given, and k represents the k largest regions. S524. Filter all externally connected regions. If the number of regions with an area greater than 200 is greater than 10, it is considered that there is too much noise interference, and the clustering score is set to a negative value. Calculate the proportion of non-zero pixels in the mask. If it occupies more than 50% of the image, the region is too widely distributed, and the clustering score is also set to a negative value. S53. If the clustering score meets the preset threshold, the updated valid point coordinates are calculated based on optical flow, and the new location distribution range and center of all valid points are calculated. The box center is further optimized by combining the clustering center to generate a new target box. The specific calculation formula is as follows:
[0070]
[0071] in, The coordinates of the top left corner of the initial target bounding box. These are the local coordinates of the valid pixels within the initial target bounding box. and The horizontal and vertical optical flow displacements at corresponding points This refers to the new coordinates of the valid pixel across the entire image after the update.
[0072]
[0073]
[0074] Where N is the number of valid points after the update. For the centroid positions of all points, and Define the width and height of the newly generated target bounding box.
[0075]
[0076]
[0077] in, The coordinates of the top-left corner of the newly generated target bounding box; Finally, the updated box is obtained. The image frame number is then expanded as described in step S4 and used to crop the next two images. The image frame number is stored while the target box is updated. This process is repeated to complete the processing of all images, resulting in a list of image frame numbers, a list of frames, and a set of frame center points C.
[0078] The trajectory fitting in step S6 is mainly divided into two parts: fitting the overall trajectory and fitting the maximum continuous trajectory. The fitting and judgment of the two trajectories are performed simultaneously. First, each valid segment of the overall trajectory is extracted to obtain the maximum and continuous trajectory and then fitted. Finally, all valid segments are combined to form the overall trajectory, and then the overall trajectory is fitted. The main steps are as follows: First, continuous frame intervals are extracted in segments. The image frame number list is traversed, and continuous frame number segments are extracted with a maximum interval of 1 as the standard. Then, "valid segments" are selected based on the segment length being greater than a threshold (e.g., 3 frames). Trajectory fitting and error evaluation are performed on each valid segment. The processing flow for each valid segment is as follows: The first step is to extract the trajectory sequence: determine the main direction of motion (horizontal or vertical). Fit the trajectory using a quadratic polynomial based on the direction of motion. If the x-axis direction is dominant, then the fitting model... If the y-axis direction is dominant, then the fitting model... Parameter a determines the opening direction and the curvature of the curve, parameter b determines the horizontal offset of the vertex position, and parameter c determines the vertical position of the curve.
[0079] The second step is to calculate the fitting error metrics, which mainly include the coefficient of determination R², the normalized root mean square error (RMSE), and the trajectory length (normalized). The calculation formulas are shown below:
[0080]
[0081]
[0082]
[0083] in, To fit the predicted values, The mean of y is used to fit the model. For the sum of squared residuals, For the total variation, For each point on the trajectory;
[0084] Where the numerator is the root mean square error, and the denominator is... The mean of the trajectory coordinates.
[0085] Finally, by combining all segments, the overall trajectory is evaluated, and the segment with the best fit (the longest trajectory segment) is selected to determine whether the trajectory validity is satisfied. This is combined with a temporal continuity evaluation, considering the proportion of trajectory detection time and the proportion of the longest single segment time. When all conditions are met, the target is considered a genuine foreign object intrusion.
[0086] The solution described in this embodiment was tested under daytime, nighttime, and light interference scenarios: Daytime detection results Figure 2 As shown, the set of detection boxes and the set of box center points are visualized, and the blue line represents the trajectory. Figure 3 for Figure 2 The detection output results; Nighttime detection results Figure 4 As shown, the green boxes represent the detection box set, and the blue lines represent the trajectory route. Figure 5 for Figure 4 The detection output results, as shown in the figure, indicate that the model is conforming. The output result is 1, which means that the trajectory fitting was successful.
[0087] Detection performance under lighting interference scenarios, such as Figure 6 As shown in the figure, it is easy to see that only one original detection box is visualized, meaning that no tracking results were obtained. Figure 7 for Figure 6 The final output is -1, indicating that the trajectory fitting failed and was judged as interference.
[0088] Example 2 This embodiment also provides an electronic device, including: At least one processor; and The memory stores instructions that, when executed by the at least one processor, cause the at least one processor to perform the method for determining orbital light intensity and actual foreign object intrusion as described above.
[0089] In this embodiment, the electronic device may include, but is not limited to: personal computer, server computer, workstation, desktop computer, laptop computer, notebook computer, mobile computing device, smartphone, tablet computer, cellular phone, personal digital assistant (PDA), handheld device, messaging device, wearable computing device, consumer electronic device, etc.
[0090] Example 3 This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, cause the machine to perform the method for judging track light and actual foreign object intrusion as described above.
[0091] Specifically, a system or apparatus equipped with a readable storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer or processor of the system or apparatus can read and execute the instructions stored in the readable storage medium.
[0092] In this case, the program code read from the readable medium itself can perform the functions of any of the above embodiments, and therefore the machine-readable code and the readable storage medium storing the machine-readable code constitute a part of this specification.
[0093] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer or the cloud via a communication network.
[0094] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.
Claims
1. A method for determining the difference between orbital illumination and actual foreign object intrusion, characterized in that, The method includes: S1. Acquire real-time video stream at the testing site; S2. The edge box reads the video stream in real time and performs frame extraction to obtain a video frame sequence. ; S3. The extracted images are processed by a detection system to obtain initial bounding boxes whose categories cannot be accurately determined. ; S4. Based on the initial target bounding box and the video frame extraction sequence, read two adjacent images from back to front, expand the initial target bounding box, and use the expanded box to crop the current image and its previous frame image to obtain... and Optical flow is detected to obtain optical flow information; The optical flow detection first uses the DISOpticalFlow fast optical flow detection algorithm to calculate optical flow information for all images and calculates the fitted trajectory. If the fitting fails, the improved GMFlow optical flow detection algorithm is used to calculate optical flow information for all images and calculate the fitted trajectory. S5. Obtain reasonable velocity points based on optical flow information, calculate clustering score, and generate new target boxes. Repeat this operation until the video frame extraction sequence is processed and all target boxes are obtained. S6. Use the center point of each target box as a point set to fit the trajectory and determine whether it meets the fitting standard. If it meets the fitting standard, it is a real foreign object intrusion; otherwise, it is judged as light interference. Finally, the real foreign object intrusion is displayed on the alarm platform.
2. The method for determining the difference between track illumination and actual foreign object intrusion according to claim 1, characterized in that, In step S4, the initial target box is expanded using the following formula: in, The coordinates of the top-left corner of the expanded target box. The coordinates of the bottom right corner of the expanded target box. and This represents the height and width of the image. It is the vertical expansion scaling factor, which controls the vertical expansion. It is the horizontal expansion scaling factor, which controls the horizontal expansion. and These are the width and height of the initial target bounding box, respectively. The coordinates are the top-left corner coordinates of the initial target bounding box.
3. The method for determining the difference between track illumination and actual foreign object intrusion according to claim 1, characterized in that, In step S4, the formula for calculating optical flow information for all images using the DISOpticalFlow fast optical flow detection algorithm is as follows: The improved GMFlow optical flow detection algorithm refers to replacing the ReLU activation function in the GMFlow algorithm with the hyperbolic tangent exponential linear unit TeLU. The formula for calculating the TeLU activation function is shown below: Where x represents the input value of the activation function, The input signal is rapidly amplified in the positive region to simulate the linear growth characteristics of ReLU; tanh is the hyperbolic tangent function, which saturates and limits the exponential output. The formula for calculating optical flow information for all images using the improved GMFlow optical flow detection algorithm is as follows: 。 4. The method for determining the difference between track illumination and actual foreign object intrusion according to claim 3, characterized in that, The specific steps for S5 are as follows: S51. The obtained optical flow map or The process involves calculating the square of the optical flow mode length for each pixel, constructing a velocity threshold mask to filter reasonable velocity points, and finally obtaining the effective optical flow information mask. The calculation formula is as follows: in, Let (i,j) be the horizontal displacement of pixel (i,j) in the optical flow map. Let be the vertical displacement of pixel (i,j) in the optical flow map. Let (i,j) be the sum of squares of the optical flow modes. To set a minimum speed threshold, excluding stationary points, Maximum speed threshold, excluding high-speed points or background noise. , representing the velocity threshold filtering value of pixel (i,j) in the optical flow map, is used to determine whether the optical flow velocity of this pixel is within a reasonable range. When =1, it indicates that the pixel is a reasonable velocity point and belongs to valid optical flow information. =0 indicates that the pixel is an invalid optical flow point and needs to be filtered. S52. After obtaining reasonable speed points, count the number of motion points and then continue to calculate the aggregation score. S53. If the clustering score meets the preset threshold, the updated valid point coordinates are calculated based on optical flow, and the new location distribution range and center of all valid points are calculated. The box center is further optimized by combining the clustering center to generate a new target box. The specific calculation formula is as follows: in, The coordinates of the top left corner of the initial target bounding box. These are the local coordinates of the valid pixels within the initial target bounding box. and The horizontal and vertical optical flow displacements at corresponding points This refers to the new coordinates of the valid pixel across the entire image after the update. Where N is the number of valid points after the update. For the centroid positions of all points, and Define the width and height of the newly generated target bounding box; in, The coordinates of the top-left corner of the newly generated target bounding box; Finally, the updated box is obtained. The image frame number is then expanded as described in step S4 and used to crop the next two images. The image frame number is stored while the target box is updated. This process is repeated to complete the processing of all images, resulting in a list of image frame numbers, a list of frames, and a set of frame center points C.
5. The method for determining the difference between track illumination and actual foreign object intrusion according to claim 4, characterized in that, In step S52, the calculation of the clustering score is as follows: S521, the obtained Preprocessing operations are performed, and the preprocessing calculation formula is shown below: in For effective optical flow information masking, MorphOpen is the opening operation, and kernel is an elliptical structuring element whose size is determined by ksize. This is the preprocessed optical flow information mask; S522, Apply the preprocessed mask Extract all external connected regions, and calculate the area and center of the outline of each connected region. The calculation formula is shown below: Where (x, y) are the coordinates of each point in the contour of the connected region. The outline of the i-th connected region. This describes the method for calculating the area of a region in OpenCV. Let be the area of the outline of the connected region. The center point of the outline region; S523. Normalize all areas and calculate the average area ratio of the 1-2 largest regions as the clustering score. The calculation formula is as follows: in, The normalized area ratio is given, and k represents the k largest regions. S524. Filter all externally connected regions. If the number of regions with an area greater than 200 is greater than 10, it is considered that there is too much noise interference, and the clustering score is set to a negative value. Calculate the proportion of non-zero pixels in the mask. If it occupies more than 50% of the image, the region is too widely distributed, and the clustering score is also set to a negative value.
6. The method for determining the difference between track illumination and actual foreign object intrusion according to claim 1, characterized in that, In step S6, the trajectory fitting is divided into two parts: fitting the overall trajectory and fitting the maximum continuous trajectory. The two trajectory fitting and judgment are performed simultaneously. First, each valid segment of the overall trajectory is extracted to obtain the maximum and continuous trajectory and then fitted. Finally, all valid segments are combined to form the overall trajectory, and then the overall trajectory is fitted. The main steps are as follows: First, continuous frame intervals are extracted in segments. The image frame number list is traversed, and continuous frame number segments are extracted with a maximum interval of 1 as the standard. Then, valid segments are selected based on the segment length being greater than a threshold. Trajectory fitting and error evaluation are performed on each valid segment. The processing flow for each valid segment is as follows: The first step is to extract the trajectory sequence: determine the main direction of motion, and fit the trajectory using a quadratic polynomial based on the direction of motion. If the x-axis direction is dominant, then the fitting model is... If the y-axis direction is dominant, then the fitting model... Parameter a determines the opening direction and the curvature of the curve, parameter b determines the horizontal offset of the vertex position, and parameter c determines the vertical position of the curve. The second step is to calculate the fitting error indices, which mainly include the coefficient of determination R², the normalized root mean square error, and the trajectory length. The calculation formulas are shown below: in, To fit the predicted values, The mean of y is used to fit the model. For the sum of squared residuals, For the total variation, For each point on the trajectory; Where the numerator is the root mean square error, and the denominator is... The mean of the trajectory coordinates.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory that stores instructions, which, when executed by the at least one processor, cause the at least one processor to perform the method for determining orbital brightness and actual foreign object intrusion as described in any one of claims 1 to 6.
8. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores executable instructions that, when executed, cause the machine to perform the method for determining orbital illumination and actual foreign object intrusion as described in any one of claims 1 to 6.