Moving target detection method, device, equipment and medium based on background modeling and decision tree
By combining background modeling and decision tree methods, the problems of low accuracy and high false alarm rate in the prior art motion object detection in complex backgrounds are solved, and higher detection accuracy and lower false alarm rate are achieved Rate.
Patent Information
- Application Number
- CN202411274362.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The existing motion object detection methods are low in accuracy when dealing with complex backgrounds, are susceptible to light changes and interference, and are difficult to meet the real-time requirements.
The motion object detection method based on background modeling and decision tree is adopted, and the detection box is obtained through Gaussian background modeling, Kalman filtering is used for prediction and tracking, and interference is identified through the decision tree, and the object detection box that meets expectations is retained.
It improves the accuracy of motion target detection, reduces the false alarm rate, can better deal with interference in complex backgrounds, and meets real-time requirements.
Smart Images

Figure CN118799357B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of video processing, and in particular to a moving target detection method, device, equipment and storage medium based on background modeling and decision tree. Background Art
[0002] Motion target detection is an important topic in the field of computer vision and pattern recognition. It is a process of detecting and identifying targets in image sequences based on dynamic image analysis combined with image pattern recognition and image tracking methods. It detects and tracks moving target objects from videos or images and is widely used in monitoring systems and analysis systems such as video surveillance.
[0003] There are currently three commonly used methods for detecting moving targets using a static camera, namely the frame difference method, the optical flow method, and the background modeling method. Among them, the frame difference method is to determine the change in the corresponding pixel value through the differential operation of adjacent frames of the video, so as to extract the moving target; the optical flow method studies the relationship between the temporal change of the grayscale image and the structure and movement of the object in the scene, and then distinguishes the moving target according to the speed vector characteristics of the pixel point by establishing a motion vector field; the background modeling method is to make a difference between each frame of the video and the constructed background model, and regard the pixel area with a large difference as a moving target. This method is simple and has a wider range of applications.
[0004] All of the above methods have certain defects. The frame difference method is sensitive to changes in illumination, easily affected by background interference, and difficult to handle occlusion, which can easily lead to "holes" in the detection process. The optical flow method has high computational complexity and is time-consuming, which generally makes it difficult to meet the real-time requirements of target detection. Although the algorithm of the background modeling method has low complexity, it has a large amount of calculation and poor adaptability to changes in illumination in the background. In the case of complex backgrounds, such as fluctuating water surfaces, lingering smoke, swaying branches, moving elevators, or floating clouds in the sky, this method cannot eliminate interference well.
[0005] The above-mentioned deficiencies are what those skilled in the art expect to overcome. Summary of the invention
[0006] 1. Technical issues to be resolved
[0007] In order to solve the above problems in the prior art, the present disclosure provides a moving target detection method, device, equipment and storage medium based on background modeling and decision tree, which solves the problem of low accuracy of moving target detection in the prior art.
[0008] (II) Technical solution
[0009] In order to achieve the above objectives, the main technical solutions adopted by this disclosure include:
[0010] In a first aspect, the present disclosure provides a moving target detection method based on background modeling and decision tree, comprising:
[0011] Gaussian background modeling is performed based on the video image to obtain a detection frame for the moving target;
[0012] Based on the detection frame, the prediction frame is obtained through Kalman filter prediction to predict and track the moving target;
[0013] Extract features and train the prediction box based on the training samples to construct a decision tree;
[0014] A decision tree is used to identify whether there is interference in the predicted and tracked moving target, and to retain the target detection frame that meets the expectations.
[0015] In an exemplary embodiment of the present disclosure, performing Gaussian background modeling according to the video image to obtain a detection frame for the moving target includes:
[0016] Obtaining an image sequence from a video image;
[0017] Gaussian mixture model is established using Gaussian probability density function;
[0018] Based on the Gaussian mixture model, the foreground and background in the image sequence are classified to obtain a Gaussian background model;
[0019] The circumscribed rectangle information of the moving target is obtained through the Gaussian background model to obtain the detection frame.
[0020] In an exemplary embodiment of the present disclosure, establishing a Gaussian mixture model using a Gaussian probability density function includes:
[0021] Use Gaussian probability density function to build a probability model for each different category;
[0022] Taking the features of different categories as random results of the probability model;
[0023] According to the matching situation between the pixel points of the image to be identified and the probability model, a distribution subset is selected to represent the current background image;
[0024] When the pixel to be identified satisfies the matching formula, it is judged to be a background pixel. If the pixel does not satisfy all Gaussian distributions, the Gaussian distribution must be reintroduced.
[0025] In an exemplary embodiment of the present disclosure, obtaining a predicted frame through Kalman filtering prediction based on the detection frame includes:
[0026] Based on the detection frame, Kalman filtering is used to perform prediction to obtain a prediction frame; wherein the prediction frame is used to predict the position and speed of the moving target in the next frame image.
[0027] In an exemplary embodiment of the present disclosure, after obtaining the prediction frame through Kalman filter prediction, the method further includes:
[0028] The prediction box obtained by Kalman filtering is updated using the Hungarian algorithm.
[0029] In an exemplary embodiment of the present disclosure, the prediction frame obtained by updating the Kalman filter using the Hungarian algorithm includes:
[0030] Based on the Hungarian algorithm, the prediction box and the detection box are matched to obtain a matching solution;
[0031] According to the matching scheme, the distance between the detection box and all the predicted boxes of the existing target is calculated as the allocation cost matrix;
[0032] When the target overlap detected by the detection box is less than the preset minimum intersection-over-union ratio, the allocation cost matrix less than the threshold is set to 0 to reject the allocation;
[0033] If the discrimination condition is met, it means that the tracking is unique, and the tracking frame greater than the threshold is true, where the discrimination condition is that the intersection and union ratio of the tracking frame only with the detection frame is greater than the threshold, and the intersection and union ratio of each detection frame with only one tracking frame is greater than the threshold;
[0034] If the discrimination condition is not met, each detection box is matched with the tracking box at the minimum intersection-union cost based on the Hungarian linear task assignment algorithm, and the successful matches are screened to obtain the matching solution.
[0035] In an exemplary embodiment of the present disclosure, extracting features and training the prediction box according to the training samples to construct a decision tree includes:
[0036] Get training sample videos;
[0037] Perform feature selection and extraction on the images read frame by frame from the training sample video to obtain feature values;
[0038] Classify based on feature values into positive samples and negative samples;
[0039] The classification of the target detection box is retained, and the training set of the decision tree is obtained based on the variable information;
[0040] Train a decision tree based on the training set.
[0041] In a second aspect, the present disclosure further provides a moving target detection device based on background modeling and decision tree, comprising:
[0042] A background modeling module is used to perform Gaussian background modeling based on the video image to obtain a detection frame for the moving target;
[0043] The target prediction module is used to predict and track the moving target based on the detection frame and obtain the prediction frame through Kalman filter prediction;
[0044] The decision tree module is used to extract and train the prediction box features based on the training samples and construct a decision tree;
[0045] The target detection module is used to use a decision tree to identify whether there is interference in the predicted and tracked moving target and retain the target detection frame that meets the expectations.
[0046] In a third aspect, the present disclosure further provides an electronic device, including:
[0047] one or more processors;
[0048] A storage device for storing one or more programs;
[0049] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the above methods.
[0050] In a fourth aspect, the present disclosure further provides a computer-readable medium having a computer program stored thereon, wherein the program implements any of the above methods when executed by a processor.
[0051] (III) Beneficial effects
[0052] The beneficial effect of the embodiments of the present disclosure is that a method, device, equipment and storage medium for motion target detection based on background modeling and decision tree are provided, which eliminates interference caused by, for example, fluctuating water surface, lingering smoke, swaying branches, floating clouds in the sky, etc., thereby improving the accuracy of the target detection algorithm and reducing the false alarm rate of detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A flowchart of a method for detecting a moving target based on background modeling and decision tree provided in one embodiment of the present disclosure;
[0054] Figure 2 For the embodiment of the present disclosure Figure 1 The step flow chart of step S110;
[0055] Figure 3 For the embodiment of the present disclosure Figure 1 A flowchart of the steps of updating the prediction frame obtained by Kalman filtering using the Hungarian algorithm in step S120;
[0056] Figure 4 For the embodiment of the present disclosure Figure 1 The step flow chart of step S130;
[0057] Figure 5 A schematic diagram of the structure of the CART decision tree used in the embodiments of the present disclosure;
[0058] Figure 6 The structure diagram of the decision tree after training in the embodiment of the present disclosure is
[0059] Figure 7 It is a flow chart of an algorithm used in the detection of moving targets based on background modeling and decision tree in an embodiment of the present disclosure;
[0060] Figure 8 It is a schematic diagram of the detection effect before adding the decision tree to the detection video 1 in the disclosed embodiment;
[0061] Fig. 9 The detection effect after adding the decision tree to the detection video 1 in the disclosed embodiment;
[0062] Fig.10 The comparison table is the detection effect data of detection video 1;
[0063] Fig.11 It is a schematic diagram of the detection effect before adding the decision tree to the detection video 2 in the disclosed embodiment;
[0064] Fig.12 The detection effect after adding the decision tree to the detection video 2 in the disclosed embodiment;
[0065] Fig.13 The comparison table is the detection effect data of detection video 2;
[0066] Fig.14 A schematic diagram of the composition of a moving target detection device based on background modeling and decision tree provided in another embodiment is disclosed;
[0067] Fig.15 A schematic diagram of the internal structure of a computer system of an electronic device provided by yet another embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to better explain the present disclosure and facilitate understanding, the present disclosure is described in detail below through specific implementation methods in conjunction with the accompanying drawings.
[0069] All technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present disclosure. The terms used herein in the specification of the present disclosure are only for the purpose of describing specific embodiments and are not intended to limit the present disclosure. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0070] In the relevant embodiments of the present disclosure, visual background extraction and Gaussian Mixture Model (GMM) are both classic background modeling methods, among which the visual background extraction method can establish a sample set of pixel points, and judge whether the new pixel point value belongs to the background by matching the sample set. The background is the stationary scenery in the scene.
[0071] The Gaussian mixture model is an unsupervised clustering algorithm that models each background pixel by mixing multiple Gaussian distributions. It uses multiple (usually 3 to 5) Gaussian models to characterize the features of each pixel in the image. Each pixel is matched with the mixed Gaussian model. If successful, it is determined to be a background point, otherwise it is a foreground point. This model can be used to classify the foreground and background of video sequence images, and then background subtraction can be used to detect moving targets. This algorithm alone can overcome the effects of lighting changes, shaking branches, etc., but can only detect partial contours of moving targets.
[0072] In view of the above defects, the present invention provides a moving target detection method, device, equipment and storage medium based on background modeling and decision tree. The traditional mixed background modeling is combined with the decision tree to eliminate interference caused by, for example, fluctuating water surface, lingering smoke, swaying branches, floating clouds in the sky, etc., to improve the accuracy of the target detection algorithm and reduce the false alarm rate of detection.
[0073] Figure 1 FIG. 1 is a flow chart of a method for detecting a moving target based on background modeling and a decision tree provided in an embodiment of the present disclosure. Figure 1 As shown, the method comprises the following steps:
[0074] Step S110: Gaussian background modeling is performed according to the video image to obtain a detection frame for the moving target.
[0075] Step S120: Based on the detection frame, a prediction frame is obtained through Kalman filtering prediction, and the moving target is predicted and tracked.
[0076] Step S130: extract features and train the prediction box according to the training samples to construct a decision tree.
[0077] Step S140: Use a decision tree to identify whether there is interference in the predicted and tracked moving target, and retain the target detection frame that meets the expectations.
[0078] Based on the method provided by the above steps S110~S140, on the one hand, the embodiment of the present disclosure uses a Kalman filter to model and predict the movement of the target, and combines the Hungarian matching algorithm to track and update the moving target; on the other hand, by adding a decision tree and eliminating interference, it is possible to avoid detecting the shaking of tree branches as a moving target, and only retain the moving targets that are truly desired to be detected, thereby significantly improving the accuracy of moving target detection and reducing the false alarm rate.
[0079] The specific steps of the moving target detection method based on background modeling and decision tree are introduced below in conjunction with the embodiments.
[0080] like Figure 1 As shown, in step S110, Gaussian background modeling is performed based on the video image to obtain a detection frame for the moving target.
[0081] In this step, a probability model is established for each different category using the Gaussian probability density function. According to the matching between the pixel point and the probability model, a distribution subset is selected to represent the current background image. According to the matching result between the pixel point and the probability model, the pixel point is judged as a background pixel point, or the Gaussian distribution is reintroduced.
[0082] Figure 2 For the embodiment of the present disclosure Figure 1 The step flow chart of step S110 is as follows: Figure 2 As shown, the following steps are included:
[0083] like Figure 2 As shown, in step S111, an image sequence in a video image is acquired.
[0084] like Figure 2 As shown, in step S112, a Gaussian mixture model is established using a Gaussian probability density function. In this step, a probability model is established for each different category using a Gaussian probability density function; the features of different categories are used as random results of the probability model; and then, according to the matching between the pixel points of the image to be identified and the probability model, a distribution subset is selected to characterize the current background image. When the pixel point to be identified satisfies the matching formula, it is judged to be a background pixel point. If the pixel point does not satisfy all Gaussian distributions, the Gaussian distribution must be reintroduced to continue matching.
[0085] like Figure 2 As shown, in step S113, the foreground and background in the image sequence are classified based on the Gaussian mixture model to obtain a Gaussian background model.
[0086] like Figure 2 As shown, in step S114, the circumscribed rectangle information of the moving target is obtained through the Gaussian background model to obtain a detection frame.
[0087] Based on the above steps S111 to S114, the circumscribed rectangle information of the moving target, i.e., the detection frame, can be obtained through Gaussian background modeling. The detection frame information is represented as a 4-dimensional vector, including the x-axis coordinate of the upper left corner of the detection frame, the y-axis coordinate of the upper left corner of the detection frame, the x-axis coordinate of the lower right corner of the detection frame, and the y-axis coordinate of the lower right corner of the detection frame. In this way, the x-axis coordinate of the center point of the detection frame, the y-axis coordinate of the center point of the detection frame, the area of the detection frame, and the aspect ratio can be calculated based on the detection frame information.
[0088] like Figure 1 As shown, in step S120, based on the detection frame, a prediction frame is obtained through Kalman filtering prediction, and the moving target is predicted and tracked.
[0089] In an exemplary embodiment of the present disclosure, in this step, a prediction is performed based on the detection frame using Kalman filtering to obtain a prediction frame; wherein the prediction frame is used to predict the position and speed of the moving target in the next frame image.
[0090] The predicted frame is obtained from the detected frame in this step through a prediction system based on Kalman filtering. Kalman filtering is a recursive time-domain filter that can calculate the estimated background value of the current frame by knowing the background value of the previous frame and the measured value of the current frame, without collecting image information before measurement and prediction.
[0091] Kalman filtering mainly consists of two steps: prediction step and update step.
[0092] First, the prediction step: According to the dynamic model of the system, the state estimation and control input of the previous moment are used to predict the state and state covariance of the system at the next moment, including the state prediction of the following formula (1) and the covariance prediction of formula (2):
[0093] The state prediction equation is:
[0094] X(k) = AX(k-1) + BU(k) (1)
[0095] Among them, X(k) is the state vector at time k, which is a 9-dimensional vector, including the x-axis coordinate of the center point of the detection box, the y-axis coordinate of the center point of the detection box, the area of the detection box, the aspect ratio, the speed on the x-axis, the speed on the y-axis, the rate of change of the area, the acceleration on the x-axis, and the acceleration on the y-axis. X(k-1) is the state at time k-1 (that is, the previous moment), the vector U(k) is the controlled vector at time k, A is the system state transfer matrix, and B is the control input matrix.
[0096] The error covariance of the prediction equation is:
[0097] P(k) = AP(k-1)AT +Q (2)
[0098] Where P(k) is the error covariance at time k, P(k-1) is the error covariance at time k-1 (that is, the previous time), and A T is the transposed matrix of the system state transfer matrix A, Q is the covariance of the average Gaussian noise signal, and Q does not change with the system state.
[0099] Secondly, the update step: by comparing the observed value and predicted value of the system, combined with the observation noise and the uncertainty of the system model, the state estimate and covariance of the system are updated, including the gain calculation of formula (3), the state update of formula (4) and the covariance update of formula (5).
[0100] The Kalman gain coefficient equation is:
[0101] K g (k) = P(k)H T (HP(k)H T ) -1 (3)
[0102] The state update equation is:
[0103] X(k) = X(k-1) + K g (k) (Z(k)-X(k-1)) (4)
[0104] The covariance update equation is:
[0105] (5)
[0106] I is the identity matrix, H is the observation matrix, H T is the transposed matrix of the observation matrix H, Z(k) is the measurement value at time k, which is a 4-dimensional vector containing the x-axis coordinate, y-axis coordinate, area of the detection box, and aspect ratio.
[0107] Based on the above process, we can use Kalman filtering to predict the state vector X(k) based on Gaussian background modeling, and the following information of the state vector is used as the information of the prediction box: the x-axis coordinate of the center point of the detection box, the y-axis coordinate of the center point of the detection box, the area of the detection box, and the aspect ratio.
[0108] In an exemplary embodiment of the present disclosure, after obtaining the prediction frame through Kalman filter prediction, the method further includes:
[0109] The prediction box obtained by Kalman filtering is updated using the Hungarian algorithm.
[0110] After obtaining the prediction frame through the above Kalman filter, the Hungarian algorithm is used to connect the signals from the same object at different times along the time axis, match the prediction frame and detection frame of the Kalman filter, and realize data association.
[0111] Hungarian algorithm steps:
[0112] Step A1: Assign each row of the cost matrix minus the minimum value of that row.
[0113] Step A2: Assign each column of the cost matrix minus the minimum value of that row.
[0114] Step A3: Cover all zeros in the matrix with as few lines as possible, and determine whether the number of lines is less than the number of matrix rows.
[0115] Step A4: If the number of lines is less than the number of matrix rows, it is necessary to continue subtracting. The rows or columns not covered by the lines continue to subtract the uncovered minimum value. The rows or columns covered once by the lines are not included in the subtraction, and the rows or columns covered twice by the lines are added with the minimum value.
[0116] Step A5: Repeat the above step A4 until the number of lines is equal to the number of matrix rows, and obtain the final matching solution according to the position of the 0 element in the matrix.
[0117] Figure 3 For the embodiment of the present disclosure Figure 1 The flowchart of the steps of updating the prediction frame obtained by Kalman filtering using the Hungarian algorithm in step S120 is as follows: Figure 3 As shown, the following steps are included:
[0118] like Figure 3 As shown, in step S121, the Hungarian algorithm matches the prediction box and the detection box to obtain a matching solution.
[0119] like Figure 3 As shown, in step S122, the distance of the intersection-and-union ratio between the detection box and all the prediction boxes of the existing targets is calculated according to the matching scheme as the allocation cost matrix.
[0120] like Figure 3 As shown, in step S123, when the target overlap detected by the detection box is less than the preset minimum intersection-over-union ratio, the allocation cost matrix less than the threshold is set to 0 to reject the allocation.
[0121] like Figure 3 As shown, in step S124, if the discrimination condition is met, it means that the tracking is unique, and the tracking frame greater than the threshold is true, wherein the discrimination condition is that the intersection and union ratio of the tracking frame only with the detection frame is greater than the threshold, and the intersection and union ratio of each detection frame with only one tracking frame is greater than the threshold.
[0122] like Figure 3 As shown, in step S125, if the discrimination condition is not met, each detection frame is matched with the tracking frame at a minimum intersection-over-union cost based on the Hungarian linear task assignment algorithm, and the successfully matched ones are screened to obtain a matching solution.
[0123] Based on the above steps, this embodiment combines the Kalman filter with the Hungarian matching target tracking algorithm to update the Kalman filter prediction frame using the detection frame.
[0124] like Figure 1 As shown, in step S130, feature extraction and training are performed on the prediction box according to the training samples to construct a decision tree.
[0125] In this step, the decision tree can be implemented using the CART (Classification And Regression Tree) decision tree, and the prediction purpose can be achieved by constructing a binary tree. After detection through mixed Gaussian background modeling and Kalman filter tracking, the detection frame obtained is classified by the CART decision tree algorithm to obtain the desired target detection frame (described in detail later), so a decision tree needs to be constructed.
[0126] Figure 4 For the embodiment of the present disclosure Figure 1 The step flow chart of step S130 is as follows: Figure 4 As shown, the following steps are included:
[0127] like Figure 4 As shown, in step S131, a training sample video is obtained;
[0128] like Figure 4 As shown, in step S132, feature selection and extraction are performed on the images read frame by frame from the training sample video to obtain feature values;
[0129] like Figure 4 As shown, in step S133, classification is performed based on the feature values into positive samples and negative samples;
[0130] like Figure 4 As shown, in step S134, the classification of the target detection box is retained, and training is performed based on the variable information to obtain a training set of the decision tree;
[0131] like Figure 4 As shown, in step S135, the decision tree is trained based on the training set.
[0132] Taking the CART decision tree as an example, Figure 5Schematic diagram of the structure of the CART decision tree used in the embodiments of the present disclosure, each node represents a test of a feature attribute, each branch represents the result of the test, and each leaf node corresponds to an output value.
[0133] Combination Figure 5 The decision tree structure shown in the figure, the construction process of the CART tree is as follows:
[0134] First, according to the principle of maximum Gini gain, a threshold is found from a certain feature dimension to divide the data into two clusters. After sorting from small to large, the median of each two adjacent numbers is taken as the segmentation threshold, and all segmentation thresholds are traversed to find the threshold with the largest Gini gain to divide the data into two clusters.
[0135] Four features were selected for target detection this time: the number of frames in which the target appears continuously, the time the target is not tracked, the moving distance of the target in adjacent frames, and the area change rate of the target. Each feature has 532 continuous values, and the continuous values of each feature are sorted from small to large. There are 531 split points for 532 values. Each split point is used to discretely divide the continuous values into two categories. The node data set is divided into two subsets D1 and D2 according to the split point. All features are divided according to the above rules, and then the corresponding Gini index of each feature is calculated at each split point. All Gini indexes are compared, and the feature with the smallest value and its corresponding split point are selected as the optimal feature and the optimal split point. Generate two child nodes from the current node in turn, and distribute the training data set to the two child nodes according to the features.
[0136] Then, the decision tree is recursively established until the sample type in the leaf node is single, or the number of samples in the leaf node is less than the threshold. When the sample category in the leaf node is not single, the category with the most node samples is selected and output as the leaf node label.
[0137] like Figure 1 As shown, in step S140, a decision tree is used to identify whether there is interference in the predicted and tracked moving target, and the target detection frame that meets the expectations is retained.
[0138] After detection through mixed Gaussian background modeling and Kalman filter tracking, the detection frame is classified by the decision tree algorithm to distinguish the detected objects such as the shaking of leaves from the moving targets that we want to detect. When the decision tree outputs the result of 'YES', that is, the current detection frame is the moving target that we want to detect, the detection frame is retained. When the decision tree outputs the result of 'NO', that is, the current detection frame is not the moving target that we want to detect, the detection frame is not drawn. In this way, the detection frame that meets our expectations is retained, and the interference caused by the detection of shaking leaves is eliminated again.
[0139] In this embodiment, in order to obtain the most suitable decision tree training set, first find a video with the most interference, print out the IDs of all detection boxes and four decision tree feature values after Gaussian background modeling, and then compare the printed information according to the video. If it is a target detection box, add a label 'YES' after the printed information column. If it is not a target detection box, add a label 'NO' after the printed information column. In this way, the detection box information is output frame by frame and then labeled to make the original training set of the decision tree.
[0140] Figure 6 is a diagram of a decision tree structure after training in an embodiment of the present disclosure, such as Figure 6 As shown in FIG. 1 , the four decision tree feature values used are the number of frames in which the target appears continuously, the number of frames in which the target is not tracked, the moving distance of the target in adjacent frames, and the area change rate of the target.
[0141] Figure 7 FIG. 1 is a flow chart of an algorithm used in the motion target detection based on background modeling and decision tree in an embodiment of the present disclosure, such as Figure 7 As shown, the specific steps include:
[0142] In step S711, a video is input.
[0143] In step S712, the input video to be detected is read frame by frame.
[0144] In step S713, background modeling is used as a detector to detect the position and bounding box of the target in each frame. For example, a Gaussian mixture model is used for background modeling.
[0145] In step S714, Kalman filtering is combined with Hungarian matching, wherein the motion of the target is modeled and predicted by the Kalman filter. The Kalman filter combines the current state of the target with the motion model to estimate the position and speed of the target in the next frame.
[0146] Further, through Hungarian matching, an association relationship between the target is established between the current frame and the previous frame. The target in the current frame and the tracked target in the previous frame are matched by minimizing the association cost. Each frame detection will give each detection box an ID representing the identity. If a match is found, the ID will not be updated. If there is no match, it will be set as a new tracking target and given a new ID representing the identity, thereby determining the target's identity (that is, the identity ID) and trajectory.
[0147] In step S715, feature selection and extraction are performed, and the obtained tracking frame is classified and judged by the trained decision tree to further eliminate interference.
[0148] The process of decision tree training includes:
[0149] In step S721, a training sample video is obtained.
[0150] In step S722, the images are read frame by frame, and features are selected and extracted to screen out positive samples and negative samples.
[0151] In step S723 , feature selection and extraction are performed again based on the positive samples and the negative samples.
[0152] In step S724, the selected features are used for training to obtain a decision tree.
[0153] After the decision tree is obtained, in step S724, classification is performed based on the decision tree to obtain a detection box.
[0154] In an exemplary embodiment of the present disclosure, when making a sample training set for a decision tree, the first step is to select appropriate feature values. Feature extraction is an important step in target detection, and the most appropriate features need to be selected based on the research object and the environment in which the object is located. After analyzing the characteristics of the detection target, the following four features are selected: the number of frames in which the detection target appears continuously, the time when the target is not tracked, the moving distance of the target in adjacent frames, and the area change rate of the detection target.
[0155] Since the training set of the decision tree determines the ability of the decision tree to eliminate interference, in this embodiment, in order to obtain the most suitable training set, first find a video with the most interference, print out the center coordinate information of all detection frames and four decision tree eigenvalues after Gaussian background modeling, generate a video with detection frames with the center coordinates of each detection frame, and then compare the printed information according to the video. If it is a target detection frame, add a label 'YES' after the printed information column, if it is not a target detection frame, add a label 'NO' after the printed information column, retain the variable information of the four decision tree eigenvalues of the target detection frame, and make it into a training set for the decision tree.
[0156] After training the decision tree with the training set, the test set is used to compare the detection effect before and after the decision tree is added.
[0157] According to the method provided in the above embodiment, the two detection videos are combined to further analyze the impact of the addition of the decision tree on the effect of target detection, measured from the five data of precision (Pr), recall rate (Rec), false alarm rate (FA), missed detection rate (MIS) and detection time. Both detection videos 1 and 2 are videos with complex backgrounds and strong interference.
[0158] Figure 8 This is a schematic diagram of the detection effect before adding the decision tree to the detection video 1 in the disclosed embodiment. Fig. 9 This is the detection effect after adding the decision tree to the detection video 1 in the disclosed embodiment. Fig.10 The comparison table is the detection effect data of detection video 1. Fig.11This is a schematic diagram of the detection effect before adding the decision tree to the detection video 2 in the disclosed embodiment. Fig.12 This is the detection effect after adding the decision tree to the detection video 2 in the disclosed embodiment. Fig.13 The comparison table is the detection effect data of detection video 2.
[0159] In the case of complex background, the impact of misdetecting interference as a target is more serious than the impact of missing the target, so the accuracy and false alarm rate are often more important. The measured data table and detection effect diagram are shown below. Analysis of the detection result data shows that before adding the decision tree, the shaking of the branches will be judged as the detection target, resulting in misdetection and false alarm. Figure 8 Targets 2, 3, 4, and 5 in the detection video 1 are all false detections and are not expected to be detected. Using the method provided by this application, after adding the decision tree, the shaking of the branches will not be detected, and only the targets that are expected to be detected will be retained, such as Fig.11 Goal 1, Fig.12 The detection accuracy is significantly improved and the false alarm rate is significantly reduced. In this case, the detection time is long and the missed detection rate is slightly increased, which is within the allowable range. In general, the detection effect of adding decision trees is better than that of not adding them. Fig.10 and Fig.13 As shown in the figure, after adding the decision tree, the accuracy of target recognition is improved and the false alarm rate is greatly reduced.
[0160] Through the above, the motion target detection method based on background modeling and decision tree provided by the present invention has the following effects: by combining the traditional background modeling method with the decision tree, the algorithm can effectively improve the accuracy of motion target detection and reduce the false alarm rate of detection, and better solve the problem of low detection accuracy and high false alarm rate of motion target by traditional detection methods when the background is complex.
[0161] The present disclosure also provides a moving target detection device based on background modeling and decision tree, Fig.14 FIG. 1 is a schematic diagram of a moving target detection device based on background modeling and decision tree provided in another embodiment of the present disclosure. Fig.14 As shown, the device 1400 includes: a background modeling module 1410, a target prediction module 1420, a decision tree module 1430 and a target detection module 1440.
[0162] Among them, the background modeling module 1410 is used to perform Gaussian background modeling based on the video image to obtain a detection frame for the moving target; the target prediction module 1420 is used to obtain a prediction frame based on the detection frame through Kalman filtering prediction, and predictively track the moving target; the decision tree module 1430 is used to extract and train the prediction frame based on the training samples to construct a decision tree; the target detection module 1440 is used to use the decision tree to identify whether there is interference in the predicted and tracked moving target, and retain the target detection frame that meets the expectations.
[0163] Reference below Fig.15 , which shows a schematic diagram of the structure of a computer system 400 suitable for implementing an electronic device of an embodiment of the present application. Fig.15 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0164] like Fig.15 As shown, the computer system 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 407 to a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the system 400 are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0165] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed, so that a computer program read therefrom is installed into the storage section 408 as needed.
[0166] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 409, and / or installed from a removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, the above-mentioned functions defined in the system of the present application are executed.
[0167] It should be noted that the storage medium shown in the present application may be a computer-readable signal medium or a computer-readable medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0168] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0169] The units involved in the embodiments described in this application may be implemented by software or hardware. The units described may also be arranged in a processor, wherein the names of these units do not constitute limitations on the units themselves in certain circumstances.
[0170] On the other hand, the present disclosure further provides a storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above storage medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device includes the following method steps:
[0171] Gaussian background modeling is performed based on the video image to obtain a detection frame for the moving target;
[0172] Based on the detection frame, the prediction frame is obtained through Kalman filter prediction to predict and track the moving target;
[0173] Extract features and train the prediction box based on the training samples to construct a decision tree;
[0174] A decision tree is used to identify whether there is interference in the predicted and tracked moving target, and to retain the target detection frame that meets the expectations.
[0175] It should be understood that the above description of the specific embodiments of the present invention is only for illustrating the technical route and features of the present invention, and its purpose is to enable those skilled in the art to understand the content of the present invention and implement it accordingly, but the present invention is not limited to the above specific implementation methods. Any changes or modifications made within the scope of the claims of the present invention should be included in the protection scope of the present invention.
Claims
1. A moving target detection method based on background modeling and decision tree, characterized in that: include: Gaussian background modeling is performed based on the video image to obtain a detection frame for the moving target; Based on the detection frame, the prediction frame is obtained through Kalman filter prediction to predict and track the moving target; Extract features and train the prediction box based on the training samples to construct a decision tree; Use decision trees to identify whether there is interference in the predicted and tracked moving target, and retain the target detection frame that meets the expectations; After the prediction frame is obtained through Kalman filter prediction, it also includes: Use the Hungarian algorithm to update the prediction box obtained by the Kalman filter; The step of updating the prediction frame obtained by Kalman filtering using the Hungarian algorithm includes: Based on the Hungarian algorithm, the prediction box and the detection box are matched to obtain a matching solution; According to the matching scheme, the distance between the detection box and all the predicted boxes of the existing target is calculated as the allocation cost matrix; When the target overlap detected by the detection box is less than the preset minimum intersection-over-union ratio, the allocation cost matrix less than the threshold is set to 0 to reject the allocation; If the discrimination condition is met, it means that the tracking is unique, and the tracking frame greater than the threshold is true, where the discrimination condition is that the intersection and union ratio of the tracking frame only with the detection frame is greater than the threshold, and the intersection and union ratio of each detection frame with only one tracking frame is greater than the threshold; If the discrimination condition is not met, each detection frame is matched with the tracking frame at the minimum intersection-union cost based on the Hungarian linear task assignment algorithm, and the successful matches are screened to obtain the matching solution; The steps of extracting features and training the prediction box according to the training samples and constructing a decision tree include: Get training sample videos; Perform feature selection and extraction on the images read frame by frame from the training sample video to obtain feature values; Classify based on feature values into positive samples and negative samples; The classification of the target detection box is retained, and the training set of the decision tree is obtained based on the variable information; Train a decision tree based on the training set; The step of obtaining a training set of a decision tree through training based on variable information comprises: First, find a video with the most interference, print out the center coordinate information of all detection frames and four decision tree eigenvalues after Gaussian background modeling, and generate a video with detection frames and the center coordinates of each detection frame; Then, the printed information is compared with the video. If it is a target detection frame, a label 'YES' is added to the end of the printed information column. If it is not a target detection frame, a label 'NO' is added to the end of the printed information column. The variable information of the four decision tree feature values of the target detection frame is retained to make a training set for the decision tree.
2. The moving target detection method based on background modeling and decision tree according to claim 1, characterized in that: The Gaussian background modeling is performed according to the video image to obtain a detection frame for the moving target, including: Obtaining an image sequence from a video image; Gaussian mixture model is established using Gaussian probability density function; Based on the Gaussian mixture model, the foreground and background in the image sequence are classified to obtain a Gaussian background model; The circumscribed rectangle information of the moving target is obtained through the Gaussian background model to obtain the detection frame.
3. The moving target detection method based on background modeling and decision tree as claimed in claim 2, characterized in that: The Gaussian mixture model established by using Gaussian probability density function comprises: Use Gaussian probability density function to build a probability model for each different category; Taking the features of different categories as random results of the probability model; According to the matching situation between the pixel points of the image to be identified and the probability model, a distribution subset is selected to represent the current background image; When the pixel to be identified satisfies the matching formula, it is judged to be a background pixel. If the pixel does not satisfy all Gaussian distributions, the Gaussian distribution must be reintroduced.
4. The moving target detection method based on background modeling and decision tree as claimed in claim 2, characterized in that: The prediction frame obtained by Kalman filtering based on the detection frame includes: Based on the detection frame, Kalman filtering is used to perform prediction to obtain a prediction frame; wherein the prediction frame is used to predict the position and speed of the moving target in the next frame image.
5. A moving target detection device based on background modeling and decision tree, characterized in that: include: A background modeling module is used to perform Gaussian background modeling based on the video image to obtain a detection frame for the moving target; The target prediction module is used to predict and track the moving target based on the detection frame and obtain the prediction frame through Kalman filtering; The decision tree module is used to extract and train the prediction box features based on the training samples and construct a decision tree; The target detection module is used to use a decision tree to identify whether there is interference in the predicted and tracked moving target and retain the target detection frame that meets the expectations; After the target prediction module obtains the prediction frame through Kalman filter prediction, it also includes: Used to update the prediction box obtained by Kalman filtering using the Hungarian algorithm; The step of updating the prediction frame obtained by Kalman filtering using the Hungarian algorithm includes: Based on the Hungarian algorithm, the prediction box and the detection box are matched to obtain a matching solution; According to the matching scheme, the distance between the detection box and all the predicted boxes of the existing target is calculated as the allocation cost matrix; When the target overlap detected by the detection box is less than the preset minimum intersection-over-union ratio, the allocation cost matrix less than the threshold is set to 0 to reject the allocation; If the discrimination condition is met, it means that the tracking is unique, and the tracking frame greater than the threshold is true, where the discrimination condition is that the intersection and union ratio of the tracking frame only with the detection frame is greater than the threshold, and the intersection and union ratio of each detection frame with only one tracking frame is greater than the threshold; If the discrimination condition is not met, each detection frame is matched with the tracking frame at the minimum intersection-union cost based on the Hungarian linear task assignment algorithm, and the successful matches are screened to obtain the matching solution; The steps of extracting features and training the prediction box according to the training samples and constructing a decision tree include: Get training sample videos; Perform feature selection and extraction on the images read frame by frame from the training sample video to obtain feature values; Classify based on feature values into positive samples and negative samples; The classification of the target detection box is retained, and the training set of the decision tree is obtained based on the variable information; Train a decision tree based on the training set; The step of obtaining a training set of a decision tree through training based on variable information comprises: First, find a video with the most interference, print out the center coordinate information of all detection frames and four decision tree eigenvalues after Gaussian background modeling, and generate a video with detection frames and the center coordinates of each detection frame; Then, the printed information is compared with the video. If it is a target detection frame, a label 'YES' is added to the end of the printed information column. If it is not a target detection frame, a label 'NO' is added to the end of the printed information column. The variable information of the four decision tree feature values of the target detection frame is retained to make a training set for the decision tree.
6. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Low-altitude unmanned aerial vehicle video tracking method
CN115410097A
Target tracking method, device and equipment
CN117333509A