Target tracking method based on Kalman filtering and Camshift algorithm

By combining the Kalman filter and Camshift algorithm, the shortcomings of target tracking in the case of occlusion and color interference are solved, and real-time and accurate tracking of vehicles is achieved, adapting to complex environments.

CN118608567APending Publication Date: 2024-09-06GUANGZHOU INST OF RAILWAY TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410792939.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Existing target tracking algorithms are difficult to achieve effective tracking under occlusion or color interference, especially in vehicle tracking, where real-time performance and accuracy are insufficient.

Method used

Combining Kalman filtering and Camshift algorithm, by obtaining the search window of the initial frame image and updating its size and position, the interference situation is judged, and the tracking window is adjusted according to the interference situation to ensure real-time and accurate tracking of the target.

Benefits of technology

It improves the accuracy and robustness of target tracking, adapts to complex environments, and especially achieves effective tracking in vehicle tracking on the road.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118608567A
    Figure CN118608567A
Patent Text Reader

Abstract

The invention relates to a target tracking method based on Kalman filtering and a Camshift algorithm, and the method combines a Kalman filter and a Camshift tracking algorithm, can comprehensively consider the real-time performance, accuracy and robustness of the target tracking algorithm, and achieves the purpose of real-time and accurate tracking of a target. According to the method, the shielding condition of the target and the color interference condition of the target are fully considered, and the subsequent tracking window is determined according to the interference condition, so that the influence of the environment on the target tracking is greatly reduced, and the target tracking accuracy is improved. The method is especially suitable for tracking the vehicle, can adapt to a complex environment on a road, and achieves the effective tracking of the vehicle on the road.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target tracking, and in particular to a target tracking method based on Kalman filtering and Camshift algorithm. Background Art

[0002] Since the beginning of the 21st century, machine vision technology has become one of the hottest topics in the fields of computer science, image processing, pattern recognition, artificial intelligence, etc. Among them, target tracking technology is an important topic and research hotspot in the field of machine vision. Whether in civil security or military defense, this technology has broad application prospects. This technology has been widely used in intelligent video surveillance, automatic driving, military defense, intelligent transportation systems, drones and other fields, especially in the field of intelligent transportation systems. The intelligent transportation system combines target tracking and detection technology, can track and detect vehicles in real time, and can automatically obtain important information such as road congestion, vehicle speed, traffic density, and traffic volume. It plays a vital role in traffic scheduling and improving traffic conditions. Therefore, it is of great significance to study the target tracking method based on machine vision.

[0003] In the field of machine vision, the target tracking task is performed in a video sequence. First, the moving object to be tracked in the video is detected by machine vision technology or the target of interest in the first frame of the video is selected manually by the mouse, and the size and position information of the tracked target is obtained, and the appearance model of the target is constructed. The size and position information of the target in the future frame is predicted by the tracking algorithm, and the possible motion trajectory of the target in the subsequent frame is determined. At the same time, it is marked in the video with a rectangular frame. The selected target is the object to be tracked, so as to complete the effective tracking of the target. The target tracking algorithm determines the real-time and accuracy of target tracking, but the target tracking algorithm based on deep learning cannot meet the real-time requirements and has a slow detection speed. The Continuously Adaptive Mean-Shift algorithm (Camshift algorithm) is simple and easy to implement, with low computational complexity, and can ensure the real-time performance of vehicle tracking. The algorithm mainly achieves the purpose of tracking through the color information of the moving object in the video image, and can adaptively adjust the size of the search window according to the shape change of the tracked target during the motion process. It is a practical algorithm for calculating the local optimal solution. However, this algorithm is difficult to effectively track the target when the target is occluded or has color interference or other moving conditions. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a target tracking method based on Kalman filtering and Camshift algorithm.

[0005] The technical solution of the present invention to solve the above technical problems is as follows: a target tracking method based on Kalman filtering and Camshift algorithm, comprising:

[0006] S1, obtaining a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure for determining the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are respectively used as a first search window size and a first search window center position, and executing S2;

[0007] S2. Based on the first search window size and the first search window center position, update the first search window size and the first search window center position by using a Camshift algorithm to obtain a new search window size and a new search window center position;

[0008] S3, based on the new search window size and the new search window center position, determining the interference situation of the target to be tracked, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color;

[0009] S4. According to the interference situation, a tracking window, a tracking window size and a tracking window center position of the tracking window, and a search window size and a search window center position of a next frame image of the image corresponding to the tracking window are obtained through a Kalman filter; the tracking window is a frame-shaped structure for tracking the target to be tracked;

[0010] S5, marking the tracking window in the image corresponding to the tracking window, and executing S6;

[0011] S6. Determine whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, target tracking is completed; otherwise, use the search window size and search window center position of the next frame image of the image corresponding to the tracking window as the new first search window size and the new first search window center position, respectively, and execute S2 to S6 until the image corresponding to the tracking window is the last frame image of the video sequence.

[0012] The beneficial effects of the present invention are as follows: the present invention combines the Kalman filter and the Camshift tracking algorithm, and can comprehensively consider the real-time, accuracy and robustness of the target tracking algorithm to achieve the purpose of real-time and accurate tracking of the target. The present invention fully considers the situation that the target is blocked and the situation that the target is interfered with by color, and determines the subsequent tracking window according to the interference situation, which greatly reduces the impact of the environment on target tracking and improves the accuracy of target tracking. The present invention is particularly suitable for tracking vehicles, can adapt to complex environments on the road, and realizes effective tracking of vehicles on the road.

[0013] Based on the above technical solution, the present invention can also be improved as follows.

[0014] Further, the updating the first search window size and the first search window center position by using a Camshift algorithm based on the first search window size and the first search window center position to obtain a new search window size and a new search window center position includes:

[0015] S21, based on the first search window size and the first search window center position, obtaining a candidate window, as well as the candidate window centroid position and the candidate window size of the candidate window through a Camshift algorithm; the candidate window is a frame structure predicted to contain the target to be tracked;

[0016] S22, moving the center position of the first search window to the centroid position of the candidate window, adjusting the size of the first search window to be equal to the size of the candidate window, and obtaining the center position of the second search window and the second search window size;

[0017] S23, calculating a moving distance for moving the center position of the first search window to the centroid position of the candidate window;

[0018] S24. Determine whether the moving distance is less than a preset distance threshold. If so, use the second search window center position and the second search window size as the new search window center position and the new search window size respectively. If not, use the second search window center position and the second search window size as the new first search window center position and the new first search window size respectively, and execute S21 to S24 until the moving distance is less than the preset distance threshold.

[0019] Further, the situation that the target to be tracked is blocked is determined by:

[0020] Calculating the similarity between the new search window and the candidate window according to the center position of the new search window and the centroid position of the candidate window;

[0021] Determine a Bhattacharyya distance according to the similarity, wherein the Bhattacharyya distance represents the degree of distance between the center position of the new search window and the centroid position of the candidate window;

[0022] Calculating a first parameter according to the new search window size and the search window size of the initial frame image, wherein the first parameter represents a scaling degree of the new search window relative to the search window of the initial frame image;

[0023] It is determined whether the Bhattacharyya distance is greater than a preset first threshold, and whether the first parameter is less than a preset second threshold. If the Bhattacharyya distance is greater than the first threshold or the first parameter is less than the second threshold, it is determined that the interference situation is a situation where the target to be tracked is blocked; otherwise, it is determined that the situation where the target to be tracked is blocked is a situation where the target to be tracked is not blocked, and it is determined that the target to be tracked is interfered by color, and an interference situation is generated.

[0024] Further, determining whether the target to be tracked is blocked is whether the target to be tracked is not blocked, and determining whether the target to be tracked is interfered by color, and generating an interference condition, includes:

[0025] Calculating a second parameter according to the new search window size and the search window size of the previous frame of the image corresponding to the new search window, wherein the second parameter represents a scaling degree of the new search window relative to the search window of the previous frame of the image corresponding to the new search window;

[0026] Determine whether the second parameter is greater than a preset third threshold value. If the second parameter is greater than the third threshold value, determine that the interference situation is that the target to be tracked is not obstructed but is interfered by color; otherwise, determine that the interference situation is that the target to be tracked is not obstructed and is not interfered by color.

[0027] Further, when the interference situation is that the target to be tracked is blocked, the obtaining of the tracking window, the tracking window size and the tracking window center position of the tracking window, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0028] adjusting a target state variable in the Kalman filter;

[0029] Calculate the Kalman observation value according to the adjusted target state variable;

[0030] According to the Kalman observation value, the tracking window size and the tracking window center position are calculated by using the state optimization estimation equation of the Kalman filter;

[0031] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0032] Further, when the interference situation is that the target to be tracked is not blocked but is interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0033] Obtaining the search window center position and search window size of the previous frame of the image corresponding to the new search window;

[0034] Calculate the tracking window size and the tracking window center position according to the search window center position and the search window size of the previous frame image corresponding to the new search window by using the state optimization estimation equation of the Kalman filter;

[0035] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0036] Further, when the interference situation is that the target to be tracked is not blocked and not interfered by color, the step of obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0037] Determine the new search window center position as the tracking window center position, and determine the new search window size as the tracking window size;

[0038] According to the tracking window center position and the tracking window size, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are calculated through the state optimization estimation equation of the Kalman filter.

[0039] In order to solve the above technical problems, the present invention also provides a target tracking system based on Kalman filtering and Camshift algorithm, comprising:

[0040] A search window initialization module is used to obtain a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure used to determine the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are used as a first search window size and a first search window center position, respectively, and a search window update module is executed;

[0041] A search window updating module, configured to update the first search window size and the first search window center position by a Camshift algorithm based on the first search window size and the first search window center position, to obtain a new search window size and a new search window center position;

[0042] An interference judgment module, used to determine the interference situation of the target to be tracked based on the new search window size and the new search window center position, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color;

[0043] A prediction module, used for obtaining a tracking window, a tracking window size and a tracking window center position of the tracking window, a search window size and a search window center position of a next frame image of an image corresponding to the tracking window through a Kalman filter according to the interference situation; the tracking window is a frame-shaped structure used to track the target to be tracked;

[0044] A tracking module, marking the tracking window in the image corresponding to the tracking window, and executing a termination judgment module;

[0045] A termination judgment module is used to judge whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, the target tracking is completed; otherwise, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are used as the new first search window size and the new first search window center position respectively, and the search window update module is executed to the termination judgment module until the image corresponding to the tracking window is the last frame image of the video sequence.

[0046] In order to solve the above technical problems, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the target tracking method based on Kalman filtering and Camshift algorithm as described above is implemented.

[0047] In order to solve the above technical problems, the present invention also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the target tracking method based on Kalman filtering and Camshift algorithm as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A schematic diagram of a target tracking method based on Kalman filtering and Camshift algorithm of the present invention;

[0049] Figure 2 This is a flow chart of a target tracking method based on Kalman filtering and Camshift algorithm of the present invention;

[0050] Figure 3 This is a schematic diagram of a target tracking system based on Kalman filtering and Camshift algorithm of the present invention. DETAILED DESCRIPTION

[0051] The principles and features of the present invention are described below. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.

[0052] Embodiment 1

[0053] like Figure 1 and Figure 2 As shown, this embodiment provides a target tracking method based on Kalman filtering and Camshift algorithm, including:

[0054] S1, obtaining a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure for determining the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are respectively used as a first search window size and a first search window center position, and executing S2;

[0055] S2. Based on the first search window size and the first search window center position, update the first search window size and the first search window center position by using a Camshift algorithm to obtain a new search window size and a new search window center position;

[0056] S3, based on the new search window size and the new search window center position, determining the interference situation of the target to be tracked, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color;

[0057] S4. According to the interference situation, a tracking window, a tracking window size and a tracking window center position of the tracking window, and a search window size and a search window center position of a next frame image of the image corresponding to the tracking window are obtained through a Kalman filter; the tracking window is a frame-shaped structure for tracking the target to be tracked;

[0058] S5, marking the tracking window in the image corresponding to the tracking window, and executing S6;

[0059] S6. Determine whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, target tracking is completed; otherwise, use the search window size and search window center position of the next frame image of the image corresponding to the tracking window as the new first search window size and the new first search window center position, respectively, and execute S2 to S6 until the image corresponding to the tracking window is the last frame image of the video sequence.

[0060] This embodiment combines the Kalman filter and the Camshift tracking algorithm, and can comprehensively consider the real-time, accuracy and robustness of the target tracking algorithm to achieve the purpose of real-time and accurate tracking of the target. This embodiment fully considers the situation where the target is blocked and the situation where the target is interfered with by color, and determines the subsequent tracking window according to the interference situation, which greatly reduces the impact of the environment on target tracking and improves the accuracy of target tracking. This embodiment is particularly suitable for tracking vehicles, can adapt to complex environments on the road, and can achieve effective tracking of vehicles on the road.

[0061] Before target tracking, the search window of the target to be tracked is selected in the initial frame of the video sequence by using the mouse through human-computer interaction, and the area size and center point coordinates of the area are returned to initialize the search window size and search window center position of the initial frame image.

[0062] Before S2, the Kalman filter is initialized, and the expression of the target state variable of the Kalman filter is:

[0063]

[0064] Among them, X(k) is the position of the target on the X axis at time k, Y(k) is the position of the target on the Y axis at time k, a(k) is the aspect ratio of the target at time k, and h(k) is the height of the target at time k. is the rate of change of the target position on the X axis, is the rate of change of the target position on the Y axis, is the target aspect ratio change rate, is the target altitude change rate.

[0065] Specifically, the calculation formula of the Kalman filter includes:

[0066] System state prediction equation:

[0067] Observation equation:

[0068] Covariance equation under forecast state:

[0069] Filter gain equation:

[0070] State optimization estimation equation:

[0071] Covariance equation for state optimization estimation:

[0072] In the formula, They represent the prior state estimate at time k, the posterior state estimate at time k-1, and the posterior state estimate at time k respectively; A represents the state transfer matrix; B represents the control variable matrix; represents the state control vector at time k-1; W k-1 is the noise of the control system, which follows the Gaussian distribution W k-1 ~N(0,Q); Q is the process excitation noise covariance; Z k represents the observed variable; H is the conversion matrix that converts the state variable to the observed variable; V k is the observation noise, which follows the Gaussian distribution V k ~N(0,R); R is the measurement noise covariance; P k-1 , P k They represent the prior estimated covariance at time k, the posterior estimated covariance at time k-1, and the posterior estimated covariance at time k respectively; A K represents the state transfer matrix; K k is the filter gain matrix.

[0073] The target state vector in the original Kalman filter equation only considers the target position and the speed information of the image coordinate system corresponding to the target position. This embodiment expands the dimension of the target state variable of the original equation to 8 dimensions, that is, adds the target aspect ratio, target height and the speed information of the image coordinate system corresponding to each. The image coordinate system is a plane coordinate system established with the upper left corner of the current image as the origin, the right as the positive direction of the X axis, and the downward as the positive direction of the Y axis. They are obtained by subtracting the next frame parameters of the corresponding current frame from the previous frame parameters of the current frame.

[0074] Target observed variable Z k=[X z (k), Y z (k), a, h] T , X z (k), Y z (k), a, and h represent the target position on the X-axis, the target position on the Y-axis, the target aspect ratio, and the target height after the state vector is converted into a measurement vector. The original 2-dimensional target observation variable is expanded to 4 dimensions, that is, the target aspect ratio and target height are added.

[0075] The state transfer matrix A, the observation matrix H, the system process noise covariance matrix Q, the observation noise covariance matrix R, the initial time prior estimation error covariance matrix P 0 , respectively, from the original dimension to 8×8 dimension, 4×8 dimension, 8×8 dimension, 4×4 dimension, 8×8 dimension. In addition, since the target height h is easy to change during target tracking, in this embodiment, the covariance matrix representing the uncertainty of the state estimation value in the Kalman filter equation is associated with the target height h to dynamically change the uncertainty of the state estimation value, as shown below:

[0076] The system observation matrix H is:

[0077]

[0078] The system state transfer matrix A is:

[0079]

[0080] The system process noise covariance matrix Q is:

[0081]

[0082] The covariance matrix R of the system observation noise is:

[0083]

[0084] Set the Kalman filter prior estimation error covariance matrix P at the initial time 0 for:

[0085]

[0086] Optionally, in an embodiment, the updating the first search window size and the first search window center position by using a Camshift algorithm based on the first search window size and the first search window center position to obtain a new search window size and a new search window center position includes:

[0087] S21, based on the first search window size and the first search window center position, obtaining a candidate window, as well as the candidate window centroid position and the candidate window size of the candidate window through a Camshift algorithm; the candidate window is a frame structure predicted to contain the target to be tracked;

[0088] S22, moving the center position of the first search window to the centroid position of the candidate window, adjusting the size of the first search window to be equal to the size of the candidate window, and obtaining the center position of the second search window and the second search window size;

[0089] S23, calculating a moving distance for moving the center position of the first search window to the centroid position of the candidate window;

[0090] S24. Determine whether the moving distance is less than a preset distance threshold. If so, use the second search window center position and the second search window size as the new search window center position and the new search window size respectively. If not, use the second search window center position and the second search window size as the new first search window center position and the new first search window size respectively, and execute S21 to S24 until the moving distance is less than the preset distance threshold.

[0091] The distance threshold is determined through multiple experiments, and the threshold that achieves the best tracking effect is selected as the distance threshold that is finally set. In this embodiment, the distance threshold is set to 1.

[0092] Before obtaining the candidate window through the Camshift algorithm, the color of the current frame image is converted from RGB space to HSV space. The main formula for converting RGB color space to HSV color space and calculating the H component value is:

[0093] V = max(R, G, B);

[0094]

[0095]

[0096] Based on the size of the first search window and the center position of the first search window, a candidate window is obtained by using the Camshift algorithm, including: calculating a color histogram of the H channel in the first search window, and performing reverse projection on the color histogram to obtain a probability distribution diagram of the H channel; and using the MeanShift algorithm to search the first search window to find a candidate window. The specific process is as follows:

[0097] Let the position of the center pixel of the first search window be x 0 , where there are n pixels x i, i = 1 to n. Then in the first search window, the probability of the uth eigenvalue is:

[0098]

[0099] In the formula, the kernel function k(x) can be used to set different weights for the observations in the area containing the target, setting a larger weight for the observations close to the center of the moving target and a smaller weight for the observations farther from the center of the moving target. δ is the unit impulse function; h 1 is the bandwidth of the kernel function, C is the normalization constant,

[0100]

[0101] Make b(Xi) is the characteristic quantization value, δ(b(x i )-u) is used to determine whether the feature quantization value is the feature value of u. If the value is 1, it means that b(x i ) is u, otherwise it is 0.

[0102] Let the coordinate of the center pixel of the candidate window be y, and the observation value in the area be {x i , i=1,…n h} means that the probability of the u-th eigenvalue of the candidate window is:

[0103]

[0104] In the formula, the normalization constant

[0105] The Bhattacharya coefficient (BH coefficient) is used to calculate the similarity between the first search window and the candidate window. The calculation formula is:

[0106]

[0107] In the formula, is the candidate window histogram, is the search window histogram, The value range is between 0 and 1. The larger the value, the more similar the first search window is to the candidate window.

[0108] Will Function in Taylor expands, The approximate expression is:

[0109]

[0110] in,

[0111] The possible new position of the target is calculated according to the following formula:

[0112]

[0113] Where g(x) = -k′(x), the MeanShift target tracking algorithm starts from the search window center position y of the previous frame 0 At the beginning, in each iteration, the algorithm estimates the probability density gradient by calculating the weighted average of the weights, and moves the first search window in the direction of this gradient to find the local maximum of the probability density function and calculate the new center point y 1 After that, MeanShift will be based on y 1 Histogram of position updates Used for next iteration or final target position determination.

[0114] Then calculate the similarity

[0115]

[0116] if This indicates that the new position is not moving in a way that increases the probability density. To adjust the direction, update y 1 :

[0117]

[0118] Continue to calculate ρ[p u (y 1 ), q u ] to compare until

[0119] Then check whether the change in position is less than the set threshold ε. If ||y 1 -y 0 ||<ε, the target position is considered to be found, and the iteration is stopped. 1 is the center position of the most matching candidate window; otherwise, y 0 =y 1 Repeat this step until the center position y of the best matching candidate window is obtained 1 The Meanshift algorithm is applied to each frame of the video to find the new position of the target and achieve target tracking.

[0120] The specific method of calculating the candidate window centroid position and the candidate window size of the candidate window is as follows: according to the first search window size and the first search window center position, using the zero-order moment M of the search window 00 and the first moment (M 10 , M 01) to obtain the candidate window centroid position (x c ,y c ) and the candidate window size, the centroid position and the candidate window size are calculated as:

[0121] Center of mass location

[0122] Candidate window size:

[0123] The zero-order moment M 00 =∑ x ∑ y I(x, y), first-order moment M 10 =∑ x ∑ y xI(x,y),M 01 =∑ x ∑ y yI(x, y), I(x, y) is the pixel value at (x, y) in the probability distribution graph.

[0124] Optionally, in an embodiment, the situation that the target to be tracked is blocked is determined by:

[0125] Calculating the similarity between the new search window and the candidate window according to the center position of the new search window and the centroid position of the candidate window;

[0126] Determine a Bhattacharyya distance according to the similarity, wherein the Bhattacharyya distance represents the degree of distance between the center position of the new search window and the centroid position of the candidate window;

[0127] Calculating a first parameter according to the new search window size and the search window size of the initial frame image, wherein the first parameter represents a scaling degree of the new search window relative to the search window of the initial frame image;

[0128] It is determined whether the Bhattacharyya distance is greater than a preset first threshold, and whether the first parameter is less than a preset second threshold. If the Bhattacharyya distance is greater than the first threshold or the first parameter is less than the second threshold, it is determined that the interference situation is a situation where the target to be tracked is blocked; otherwise, it is determined that the situation where the target to be tracked is blocked is a situation where the target to be tracked is not blocked, and it is determined that the target to be tracked is interfered by color, and an interference situation is generated.

[0129] The specific calculation formula of Bhattacharyya distance and the first parameter is:

[0130]

[0131] α=Current_area / Origin_area;

[0132] Wherein, d(y) is the Bhattacharyya distance, ρ(y) is the similarity between the new search window and the candidate window; Current_area is the new search window size, Origin_area is the search window size of the initial frame image, and α represents the first parameter.

[0133] The Bhattacharyya distance is inversely proportional to the degree of similarity, and a larger value indicates that the new search window is less similar to the candidate window position. The first threshold and the second threshold are both pre-set values. In this embodiment, the first threshold is set to 0.6, and the second threshold is set to 0.3.

[0134] Optionally, in an embodiment, determining that the target to be tracked is blocked is a case where the target to be tracked is not blocked, and determining that the target to be tracked is interfered by color, and generating an interference situation, includes:

[0135] Calculating a second parameter according to the new search window size and the search window size of the previous frame of the image corresponding to the new search window, wherein the second parameter represents a scaling degree of the new search window relative to the search window of the previous frame of the image corresponding to the new search window;

[0136] Determine whether the second parameter is greater than a preset third threshold value. If the second parameter is greater than the third threshold value, determine that the interference situation is that the target to be tracked is not obstructed but is interfered by color; otherwise, determine that the interference situation is that the target to be tracked is not obstructed and is not interfered by color.

[0137] The calculation formula for the second parameter is:

[0138] β=Current_area / Last_area;

[0139] Wherein, Last_area is the search window size of the previous frame of the image corresponding to the new search window, and β is the second parameter. The third threshold is a value set in advance. In this embodiment, the third threshold is set to 2.

[0140] Optionally, in an embodiment, when the interference situation is that the target to be tracked is blocked, the step of obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0141] adjusting a target state variable in the Kalman filter;

[0142] Calculate the Kalman observation value according to the adjusted target state variable;

[0143] According to the Kalman observation value, the tracking window size and the tracking window center position are calculated by using the state optimization estimation equation of the Kalman filter;

[0144] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0145] During the tracking process, when the target is blocked, the search window output by the Camshift algorithm will become smaller. Therefore, the Kalman filter is used to adaptively change the system state prediction equation according to the new search window size. The target aspect ratio and target height parameters in are used to adjust the prediction box size, thereby predicting the position state at the next moment. The state transfer matrix A and the adjusted target state variable at the previous moment are Substitute into the system state prediction equation Predict the state vector of the target at the current k moment That is the Kalman prediction value. The predicted state vector Substitute into the system observation equation In the prediction, the target observation vector Zk at the current k moment is predicted, that is, the Kalman observation value. The observation variable Zk, the observation matrix H, and the covariance matrix of the predicted output are Q, R, and predicted state variables Substitute the filter gain equation into the formula State Optimization Estimation Equation The updated optimal state estimation value is obtained, and a tracking window is generated and marked in the video image. The next frame search window size and the search window center position of the image corresponding to the tracking window are initialized with this value, that is, the next frame search window size is equal to the tracking window size, and the next frame search window center position is equal to the tracking window center position.

[0146] Optionally, in an embodiment, when the interference situation is that the target to be tracked is not blocked but is interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0147] Obtaining the search window center position and search window size of the previous frame of the image corresponding to the new search window;

[0148] Calculate the tracking window size and the tracking window center position according to the search window center position and the search window size of the previous frame image corresponding to the new search window by using the state optimization estimation equation of the Kalman filter;

[0149] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0150] That is, the search window size of the next frame image is equal to the tracking window size, and the center position of the search window of the next frame image is the same as the center position of the tracking window.

[0151] Optionally, in an embodiment, when the interference situation is that the target to be tracked is not blocked and not interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0152] Determine the new search window center position as the tracking window center position, and determine the new search window size as the tracking window size;

[0153] According to the tracking window center position and the tracking window size, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are calculated through the state optimization estimation equation of the Kalman filter.

[0154] Embodiment 2

[0155] like Figure 3 As shown, this embodiment provides a target tracking system based on Kalman filtering and Camshift algorithm, including:

[0156] A search window initialization module is used to obtain a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure used to determine the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are used as a first search window size and a first search window center position, respectively, and a search window update module is executed;

[0157] A search window updating module, configured to update the first search window size and the first search window center position by a Camshift algorithm based on the first search window size and the first search window center position, to obtain a new search window size and a new search window center position;

[0158] An interference judgment module, used to determine the interference situation of the target to be tracked based on the new search window size and the new search window center position, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color;

[0159] A prediction module, used for obtaining a tracking window, a tracking window size and a tracking window center position of the tracking window, a search window size and a search window center position of a next frame image of an image corresponding to the tracking window through a Kalman filter according to the interference situation; the tracking window is a frame-shaped structure used to track the target to be tracked;

[0160] A tracking module, used for marking the tracking window in the image corresponding to the tracking window and executing a termination judgment module;

[0161] A termination judgment module is used to judge whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, the target tracking is completed; otherwise, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are used as the new first search window size and the new first search window center position respectively, and the search window update module is executed to the termination judgment module until the image corresponding to the tracking window is the last frame image of the video sequence.

[0162] Search window update module, including:

[0163] A candidate window determination unit, configured to obtain a candidate window, a candidate window centroid position and a candidate window size of the candidate window by using a Camshift algorithm based on the first search window size and the first search window center position; the candidate window is a frame structure predicted to contain the target to be tracked;

[0164] An adjusting unit, configured to move the center position of the first search window to the centroid position of the candidate window, and adjust the size of the first search window to be equal to the size of the candidate window, so as to obtain the center position of the second search window and the second search window size;

[0165] a distance calculation unit, used for calculating a moving distance for moving the center position of the first search window to the centroid position of the candidate window;

[0166] A distance judgment unit is used to judge whether the moving distance is less than a preset distance threshold. If so, the second search window center position and the second search window size are used as the new search window center position and the new search window size respectively; if not, the second search window center position and the second search window size are used as the new first search window center position and the new first search window size respectively, and the candidate window determination unit to the distance judgment unit are executed until the moving distance is less than the preset distance threshold.

[0167] The interference judgment module includes an occlusion judgment unit, and the occlusion judgment unit includes:

[0168] A similarity calculation subunit, used to calculate the similarity between the new search window and the candidate window according to the center position of the new search window and the centroid position of the candidate window;

[0169] A Bhattacharyya distance determination subunit, used to determine a Bhattacharyya distance according to the similarity, wherein the Bhattacharyya distance represents the degree of distance between the center position of the new search window and the centroid position of the candidate window;

[0170] A first parameter determination subunit, configured to calculate a first parameter according to the new search window size and the search window size of the initial frame image, wherein the first parameter represents a scaling degree of the new search window relative to the search window of the initial frame image;

[0171] The first judgment subunit is used to judge whether the Bhattacharyya distance is greater than a preset first threshold value, and to judge whether the first parameter is less than a preset second threshold value. If the Bhattacharyya distance is greater than the first threshold value or the first parameter is less than the second threshold value, then the interference situation is judged to be a situation where the target to be tracked is blocked; otherwise, the situation where the target to be tracked is blocked is judged to be a situation where the target to be tracked is not blocked, and the situation where the target to be tracked is interfered by color is judged to generate an interference situation.

[0172] The interference judgment module also includes a color judgment unit, which includes:

[0173] a second parameter determination subunit, configured to calculate a second parameter according to the new search window size and the search window size of a previous frame of the image corresponding to the new search window, wherein the second parameter represents a scaling degree of the new search window relative to the search window of the previous frame of the image corresponding to the new search window;

[0174] The second judgment subunit is used to judge whether the second parameter is greater than a preset third threshold value. If the second parameter is greater than the third threshold value, the interference situation is judged as the target to be tracked is not obstructed but is interfered by color; otherwise, the interference situation is judged as the target to be tracked is not obstructed and is not interfered by color.

[0175] When the interference situation is that the target to be tracked is blocked, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0176] adjusting a target state variable in the Kalman filter;

[0177] Calculate the Kalman observation value according to the adjusted target state variable;

[0178] According to the Kalman observation value, the tracking window size and the tracking window center position are calculated by using the state optimization estimation equation of the Kalman filter;

[0179] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0180] When the interference situation is that the target to be tracked is not blocked but is interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0181] Obtaining the search window center position and search window size of the previous frame of the image corresponding to the new search window;

[0182] Calculate the tracking window size and the tracking window center position according to the search window center position and the search window size of the previous frame image corresponding to the new search window by using the state optimization estimation equation of the Kalman filter;

[0183] The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

[0184] When the interference condition is that the target to be tracked is not blocked and not interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes:

[0185] Determine the new search window center position as the tracking window center position, and determine the new search window size as the tracking window size;

[0186] According to the tracking window center position and the tracking window size, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are calculated through the state optimization estimation equation of the Kalman filter.

[0187] Embodiment 3

[0188] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the target tracking method based on Kalman filtering and Camshift algorithm as described in Embodiment 1 is implemented.

[0189] Embodiment 4

[0190] This embodiment provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the target tracking method based on Kalman filtering and Camshift algorithm as described in Example 1.

[0191] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.

[0192] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0193] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0194] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.

[0195] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0196] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A target tracking method based on Kalman filtering and Camsh ift algorithm, It is characterized in that include: S1, obtaining a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure for determining the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are respectively used as a first search window size and a first search window center position, and executing S2; S2. Based on the first search window size and the first search window center position, update the first search window size and the first search window center position by using a Camshift algorithm to obtain a new search window size and a new search window center position; S3, based on the new search window size and the new search window center position, determining the interference situation of the target to be tracked, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color; S4. According to the interference situation, a tracking window, a tracking window size and a tracking window center position of the tracking window, and a search window size and a search window center position of a next frame image of the image corresponding to the tracking window are obtained through a Kalman filter; The tracking window is a frame-shaped structure used to track the target to be tracked; S5, marking the tracking window in the image corresponding to the tracking window, and executing S6; S6. Determine whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, target tracking is completed; otherwise, use the search window size and search window center position of the next frame image of the image corresponding to the tracking window as the new first search window size and the new first search window center position, respectively, and execute S2 to S6 until the image corresponding to the tracking window is the last frame image of the video sequence.

2. According to the target tracking method based on Kalman filtering and Camshift algorithm according to claim 1, It is characterized in that The updating of the first search window size and the first search window center position by using a Camshift algorithm based on the first search window size and the first search window center position to obtain a new search window size and a new search window center position includes: S21, based on the first search window size and the first search window center position, obtaining a candidate window, as well as the candidate window centroid position and the candidate window size of the candidate window through a Camshift algorithm; the candidate window is a frame structure predicted to contain the target to be tracked; S22, moving the center position of the first search window to the centroid position of the candidate window, adjusting the size of the first search window to be equal to the size of the candidate window, and obtaining the center position of the second search window and the second search window size; S23, calculating a moving distance for moving the center position of the first search window to the centroid position of the candidate window; S24. Determine whether the moving distance is less than a preset distance threshold. If so, use the second search window center position and the second search window size as the new search window center position and the new search window size respectively. If not, use the second search window center position and the second search window size as the new first search window center position and the new first search window size respectively, and execute S21 to S24 until the moving distance is less than the preset distance threshold.

3. According to the target tracking method based on Kalman filtering and Camshift algorithm as claimed in claim 2, It is characterized in that The situation that the target to be tracked is blocked is determined by: Calculating the similarity between the new search window and the candidate window according to the center position of the new search window and the centroid position of the candidate window; Determine a Bhattacharyya distance according to the similarity, wherein the Bhattacharyya distance represents the degree of distance between the center position of the new search window and the centroid position of the candidate window; Calculating a first parameter according to the new search window size and the search window size of the initial frame image, wherein the first parameter represents a scaling degree of the new search window relative to the search window of the initial frame image; It is determined whether the Bhattacharyya distance is greater than a preset first threshold, and whether the first parameter is less than a preset second threshold. If the Bhattacharyya distance is greater than the first threshold or the first parameter is less than the second threshold, it is determined that the interference situation is a situation where the target to be tracked is blocked; otherwise, it is determined that the situation where the target to be tracked is blocked is a situation where the target to be tracked is not blocked, and it is determined that the target to be tracked is interfered by color, and an interference situation is generated.

4. According to the target tracking method based on Kalman filtering and Camshift algorithm as claimed in claim 3, It is characterized in that The method of determining whether the target to be tracked is blocked or not blocked, and determining whether the target to be tracked is interfered by color, and generating an interference condition, includes: Calculating a second parameter according to the new search window size and the search window size of the previous frame of the image corresponding to the new search window, wherein the second parameter represents a scaling degree of the new search window relative to the search window of the previous frame of the image corresponding to the new search window; Determine whether the second parameter is greater than a preset third threshold value. If the second parameter is greater than the third threshold value, determine that the interference situation is that the target to be tracked is not obstructed but is interfered by color; otherwise, determine that the interference situation is that the target to be tracked is not obstructed and is not interfered by color.

5. According to the target tracking method based on Kalman filtering and Camshift algorithm as claimed in claim 3, It is characterized in that When the interference situation is that the target to be tracked is blocked, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes: adjusting a target state variable in the Kalman filter; Calculate the Kalman observation value according to the adjusted target state variable; According to the Kalman observation value, the tracking window size and the tracking window center position are calculated by using the state optimization estimation equation of the Kalman filter; The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

6. According to the target tracking method based on Kalman filtering and Camshift algorithm as claimed in claim 4, It is characterized in that When the interference situation is that the target to be tracked is not blocked but is interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes: Obtaining the search window center position and search window size of the previous frame of the image corresponding to the new search window; Calculate the tracking window size and the tracking window center position according to the search window center position and the search window size of the previous frame image corresponding to the new search window by using the state optimization estimation equation of the Kalman filter; The search window size and the search window center position of the next frame image of the image corresponding to the tracking window are determined according to the tracking window size and the tracking window center position.

7. The target tracking method based on Kalman filtering and Camshift algorithm according to claim 4, It is characterized in that When the interference condition is that the target to be tracked is not blocked and not interfered by color, obtaining the tracking window, the tracking window size and the tracking window center position of the tracking window, and the search window size and the search window center position of the next frame image of the image corresponding to the tracking window through the Kalman filter includes: Determine the new search window center position as the tracking window center position, and determine the new search window size as the tracking window size; According to the tracking window center position and the tracking window size, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are calculated through the state optimization estimation equation of the Kalman filter.

8. A target tracking system based on Kalman filter and Camshift algorithm, It is characterized in that include: A search window initialization module is used to obtain a search window of an initial frame image of a video sequence containing a target to be tracked, and a search window size and a search window center position of the search window of the initial frame image; the search window is a frame-shaped structure used to determine the target to be tracked; the search window size and the search window center position of the search window of the initial frame image are used as a first search window size and a first search window center position, respectively, and a search window update module is executed; A search window updating module, configured to update the first search window size and the first search window center position by a Camshift algorithm based on the first search window size and the first search window center position, to obtain a new search window size and a new search window center position; An interference judgment module, used to determine the interference situation of the target to be tracked based on the new search window size and the new search window center position, wherein the interference situation includes the situation that the target to be tracked is blocked and the situation that the target to be tracked is interfered by color; A prediction module, used for obtaining a tracking window, a tracking window size and a tracking window center position of the tracking window, and a search window size and a search window center position of a next frame image of an image corresponding to the tracking window through a Kalman filter according to the interference situation; The tracking window is a frame-shaped structure used to track the target to be tracked; A tracking module, marking the tracking window in the image corresponding to the tracking window, and executing a termination judgment module; A termination judgment module is used to judge whether the image corresponding to the tracking window is the last frame image of the video sequence. If so, the target tracking is completed; otherwise, the search window size and the search window center position of the next frame image of the image corresponding to the tracking window are used as the new first search window size and the new first search window center position respectively, and the search window update module is executed to the termination judgment module until the image corresponding to the tracking window is the last frame image of the video sequence.

9. An electronic device, It is characterized in that It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the target tracking method based on Kalman filtering and Camshift algorithm as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, It is characterized in that The computer instructions are used to enable a computer to execute the target tracking method based on Kalman filtering and Camshift algorithm as described in any one of claims 1 to 7.