## 2 Theory
### The Unscented Kalman Filter
Assume that state's mean and variance of the n-dimension state vector X at time k \(-\) 1 are \(\hat{x}_{\mathrm{k}-1}\) and P(k \(-\) 1) respectively. The state transition model and observation model are:  
\[\mathrm{x}_{k}=\mathrm{F}(\mathrm{x}_{k-1})+\mathrm{W}_{\mathrm{k}} \tag{25}\]  
\[\mathrm{y}_{k}=\mathrm{H}(\mathrm{x}_{k})+\mathrm{V}_{\mathrm{k}} \tag{26}\]  
where F is the state transition equation and H is the observation equation (specially, \(\mathrm{H}(\mathrm{x}_{k})=\mathrm{X}_{\mathrm{s}}(\mathrm{k})\) in our algorithm). W\({}_{\mathrm{k}}\) and V\({}_{\mathrm{k}}\) are the white Gaussian noise matrices of these two models (in our algorithm W\({}_{\mathrm{k}}=\Gamma\mathrm{w}_{\mathrm{k}}\) and V\({}_{\mathrm{k}}=\Sigma\mathrm{v}_{\mathrm{k}}\)), whose statistical characteristics satisfy:  
\[\mathrm{W}_{\mathrm{k}}\sim N(0,Q_{k})\quad\mathrm{V}_{\mathrm{k}}\sim N(0,R_ {k}) \tag{27}\]  
in which \(Q_{k}\) and \(R_{k}\) are the covariance matrix of two noise matrices, respectively. (1) Initialization of UKF  
\[\hat{x}_{0}=\mathrm{E}[\mathrm{x}_{0}] \tag{28}\]  
Figure 8.0  
The Sigma points can be calculated by Equations (30)-(32). Figure 8.1  
Figure 8.2  
Figure 8.3 (3 where \(W_{i}^{(m)}\) is the weight coefficient of the mean. \(W_{0}^{(m)}=\frac{\lambda}{n}+\lambda;W_{i}^{(m)}=1/[2(n+\lambda)]\), \(i=1,\ldots,2n\). (3) Observation updating equations. Take Equations (34), (36), (37) into Equations (38) and (39), compute Kalman gain by Equation (40). Figure 8.4  
Figure 8.5  
Figure 8.6  
in which \(W_{0}^{(c)}=\lambda/(n+\lambda)+(1-\alpha^{2}+\beta)\); \(W_{i}^{(c)}=W_{i}^{(m)}(i=1,\ldots 2n)\); \(\beta\geq\)0 and the value of \(\beta\) is 0 here. Particularly in our algorithm, a confidence coefficient \(\omega\) is introduced into Equation (38), which can be rewritten as:  
Figure 8.7  
If there exists little interference or shielded area of the LED in the image, in other words, \(c_{b}\approx 1\), which means \((x_{m}(k),y_{m}(k))\) can been viewed as the real centroid of the LED, let \(\omega\approx 0\) to reduce the influence of the noise matrix \(R_{k}\), meaning the original observation value is trusted. However, if the value of \(c_{b}\) is close to 0, which means most areas of the LED are occluded in the image, the outcome of MS cannot be trusted. Because the centroid of the candidate region will be viewed as the actual centroid of the LED by the mean shift algorithm, whose error is considerable. In this condition, it is necessary to give the noise matrix a bigger weight. Originally, \(c_{b}\in[0,1]\). To obtain proper weight, \(c_{b}\) will be normalized into \([-2\aleph,\aleph]\), where \(\aleph=1\) in our algorithm. Thus, \(\omega\in\left[10^{-2\aleph},10^{\aleph}\right]\). When \(c_{b}\approx 1\), \(\omega\approx 10^{-2}\) in our algorithm. The mean and variance of the state vector can then be updated after taking Kalman gain into Equations (42) and (43):  
Figure 8.8  
Figure 8.9  
Due to the uncertainty of moving targets and model, each time the target's position calculated by our proposed algorithm will be compared with its last position to update and correct the state model of unscented Kalman filter. Through introducing UKF into the mean shift algorithm, our proposed algorithm possesses the capacity to track fast moving targets because the mean shift algorithm starts searching for the candidate target from the position predicted by UKF (\(\hat{x}_{k}^{-}\), the prediction value of state equation in Equation (27)) in current frame instead of from the centroid of the target in last frame, which also reduces the number of iteration of MS. The candidate search region in the current frame was chosen reasonably by UKF, taking the priori positions of the target into consideration, thus the problem of the target's giant velocity making it move outside the candidate search region within the time of one frame has been solved. Meanwhile, because of the reduced average iteration number, the real-time ability of the algorithm was enhanced too.