{'fraction_non_alphanumeric': 0.02219409282700422, 'fraction_numerical': 0.005991561181434599, 'mean_word_length': 5.071209016393443, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Target motion detection algorithm based on dynamic threshold

Realizing moving target detection through visual algorithms is a major branch of computer technology. Moving target detection has a wide range of applications in many fields such as video surveillance, unmanned driving, and behavior research. The current algorithm has been able to achieve moving target detection well in a static background, but the detection of multiple moving targets in a dynamic background is still a challenging research area. The main pain points are complex background, light changes, noise interference and Occlusion and real-time detection requirements, etc. Aiming at the detection of moving targets in complex scenes, a moving target detection algorithm based on dynamic threshold is proposed. The algorithm first uses the gray difference gradient of three adjacent frames of the video sequence to calculate the segmentation threshold of foreground moving targets to realize the dynamic threshold. Then use dynamic thresholds to achieve multi-target motion detection in complex backgrounds or scenes with changing lighting. Because the gradient change of adjacent frames of the scene is considered in the process of moving target detection and segmentation, and the gradient change is converted into a dynamic threshold to participate in moving target detection and segmentation, the algorithm can adapt to scenes with changing lighting. Experiments show that this algorithm is feasible for moving target detection in complex scenes, and has a lower error rate than that of traditional algorithms, and is more suitable for to complex or changing lighting scenes.


Introduction
Moving target detection has a wide range of applications in life, such as enviromental monitoring, unmanned driving, behavior analysis and other fields. The traditional target motion detection algorithm mainly builds a pixel model for the background, and solves the area of the foreground moving target through the difference between the current frame and the background model. For example, the moving target detection algorithm based on the Gaussian mixture model is proposed and applied [1][2][3] . Literature [1] proposed a method of using the Gaussian mixture method to model the background. By modeling and continuously updating the background of the real scene, the Gaussian mixture method can effectively overcome the tiny disturbance noise caused by camera shake. The Gaussian mixture method is widely used to detect moving targets in video sequences [2][3], but the Gaussian mixture method has the disadvantage of being sensitive to rapid illumination changes. Most scenes in life change over time. For example, there is camera shake to capture the scene, weather changes, occlusion and lighting changes cause the captured scene to have a dynamic background, which cause more difficult to detect moving objects. Literature [4] proposed a moving target detection method combining the continuous frame difference method and the background difference method. The algorithm uses linear adaptive filtering and nonlinear median filtering to differentiate the obtained background image. At the same time, the threshold segmentation technology is used to achieve the enhancement of the moving target, so as to effectively solve the phenomenon that the target can not be detected in the background difference method and the inter-frame difference method. Literature [5] proposed a moving target detection algorithm that fused difference method and vibe algorithm. The algorithm realizes the elimination of ghost image pixels by judging the temporal changes of two consecutive frames of foreground and background pixels. Literature [6] proposed a moving target detection algorithm based on the smooth three-frame difference method fusion RPCA. The algorithm uses the RPCA algorithm to extract the background of the current frame as the intermediate frame of the smooth frame difference method, thereby eliminating the "hole" phenomenon and greatly reducing noise. Literature [7] proposed a moving target detection algorithm based on pixel spatial sample difference consensus. The algorithm compares the values of two pixels occupying the same position in adjacent frames to determine the moving object area, sets a spatial sample set for each pixel, and defines the spatial sample difference consensus (SSDC), which represents the change of stable spatial relationship , By calculating the SSDC between two adjacent frames to subtract the moving object, so as to achieve a better moving target detection effect. Literature [8][9][10] show the practical application of moving target detection algorithm in dynamic background. This paper presents an adaptive threshold multi-target motion detection algorithm. By introducing the gradient change of the pixel difference between adjacent frames into the segmentation threshold calculation of moving target detection, the algorithm can adapt to the changes of the environment, camera shake and the lighting changes of the scene.

Algorithm
In computer vision, the main difficulty of moving target detection algorithms is how to eliminate noise interference in the scene, such as camera shake, light changes, environmental changes. In complex scenes, it is a challenging task to distinguish the foreground moving target from the background through a single threshold. The algorithm proposed in this paper participates in the calculation of the threshold through the gradient of the pixel difference between adjacent frames, and divides the moving target from the background through the dynamic threshold to achieve the target motion detection with a much smaller error rate.

Background model generation
When the algorithm is initialized, it is necessary to first convert the input frame into a gray image Grayb, and solve its corresponding binary image BGrayb. When there is no moving target in the scene or the moving target is not moving in a short period of time, the gradient of the gray level difference between adjacent frames is close to zero. The position of the moving target cannot be determined by gradient changes, but this problem can be solved by constructing a static background model and allowing it to participate in dynamic threshold calculation.

The gray difference of adjacent 3 frames
Let Num_Frame be the number of video frames, the algorithm starts from the second frame to obtain the gray-scale pictures of each frame in turn, and formula (1) represents the gray-scale pictures of all frames.
(1) Among them, Grayf is the grayscale picture of the current frame f, row is the number of rows in the picture, and col is the number of columns in the picture.
The gray level difference of the adjacent 3 frames is del1, del2, del3, and the method of obtaining it is formula (2)

Dynamic threshold solution
Participate in the dynamic threshold calculation of the gray difference gradient value of adjacent frames, and solve the dynamic threshold Threshold_image=Threshold(del1, del2)

Step 1, Solve &
Before obtaining the dynamic threshold, the algorithm in this paper will use the current frame to initialize an initial threshold. The method of obtaining it is shown in formula (3) Among them, del1 is the gray level difference between the current frame and the previous frame, row is the number of rows in the picture, and col is the number of columns in the picture.

Solve the Threshold_image of adjacent frames
If & is not equal to 0, there are moving targets in the scene at this time. Solve the Threshold_image of adjacent frames by formula (4) and formula (5).
Among them, del1 is the gray level difference between the current frame and the previous frame, del2 is the gray level difference between the current frame and the next frame, row is the number of rows in the picture, and col is the number of columns in the picture.
If & is equal to 0, there is no moving target in the scene at this time, or the moving target has not moved in a short time. Solve the Threshold_image of adjacent frames by formula (6) and formula (7).
Among them, del2 is the gray level difference between the current frame and the next frame, row is the number of rows in the picture, and col is the number of columns in the picture.

Solve the dynamic threshold of the current frame
Solving the dynamic threshold of the current frame is divided into 4 steps. Firstly, the dynamic threshold of the current frame and the background model is solved; secondly, the result of step 1 is combined with the gray difference of the previous frame to optimize the dynamic threshold; third, the result of step 1 is combined with the gray difference of the next frame to further optimize the dynamic threshold. Finally, the maximum value of the results of steps 1-3 is used as the dynamic threshold of the current frame. See equations (8), (9) Among them, Bgrayb is the binarized picture of the background picture, del1 is the gray level difference between the current frame and the previous frame, del2 is the gray level difference between the current frame and the next frame, and del3 is the gray level difference between the current frame and the background picture.

Experimental results and analysis
The data set used in this article is from "Laboratory for Intelligent & Safe Automobiles". The indoor scenes "Intelligent room" and "Laboratory" and outdoor scenes "Campus" are used to verify the algorithm proposed in this article, and compared with the current commonly used algorithms. The experiment program is written in python3.6 language and runs on a PC with Windows 10 64-bit operating system.

Feasibility
The data set used in this article comes from "Laboratory for Intelligent & Safe Automobiles". The indoor scene "Intelligent room" and the outdoor scene "Campus" are used to verify the algorithm proposed in this paper, and compared with the current commonly used algorithms. The experiment program is written in python3.6 language and runs on a PC with Windows 10 64-bit operating system. Among them, the sub-picture (a) in Figure 1-2 is the 100th frame in the video sequence "Intelligent room" and the 63th frame in the video sequence "Campus". The sub-pictures (b), (c) and (d) are the running results of the frame difference method, the running results of the Gaussian mixture model algorithm and the running results of the algorithm, respectively.

Accuracy
This paper uses two indicators to evaluate and compare the performance of the algorithm, namely the recognition rate (TPR) and the false detection rate (FPR). The calculation method is formula (12) and formula (13  Table 1, we can conclude that the algorithm proposed in this paper has a higher recognition rate and a lower false detection rate than other algorithms in the table 1. This is mainly because the algorithm in this paper uses dynamic thresholds to filter moving targets, which can adapt to complex environments or changing lighting environments, and overcome the interference of complex environmental noises on moving target detection algorithms.

Conclusion
This paper proposes a moving target detection algorithm based on dynamic threshold. By taking the gray difference gradients of three adjacent frames of the video sequence into the foreground moving target segmentation threshold calculation, the dynamic threshold is realized, and the dynamic threshold is used to realize the multi-target motion detection under the complex background or the scene of changing illumination. This article uses the public data set, including indoor environment and outdoor environment to compare the proposed algorithm with other algorithms. It is verified by experiments that the algorithm proposed in this paper has a lower false detection rate and higher accuracy than other algorithms, and can better realize moving target detection in a real environment.