# Multi-Vehicle Tracking Based on Monocular Camera in Driver View
## 3 Proposed Algorithm
### Motion Model
Now \(Q_{k-1}\) can be obtained as:  
\[Q_{k-1}=\begin{bmatrix}\frac{\delta t^{4}}{4}\sigma_{w_{x}}^{2}&0&\frac{ \delta t^{3}}{2}\sigma_{w_{x}}^{2}&0&0&0&0&0\\ 0&\frac{\delta t^{4}}{4}\sigma_{w_{y}}^{2}&0&\frac{\delta t^{3}}{2}\sigma_{w _{y}}^{2}&0&0&0&0\\ \frac{\delta t^{3}}{2}\sigma_{w_{x}}^{2}&0&\delta t^{2}\sigma_{w_{x}}^{2}&0&0&0& 0&0\\ 0&\frac{\delta t^{3}}{2}\sigma_{w_{y}}^{2}&0&\delta t^{2}\sigma_{w_{y}}^{2}&0& 0&0&0\\ 0&0&0&\frac{\delta t^{4}}{4}\sigma_{w_{x}}^{2}&0&\frac{\delta t^{3}}{2}\sigma_{ w_{x}}^{2}&0\\ 0&0&0&0&\frac{\delta t^{3}}{4}\sigma_{w_{x}}^{2}&0&\frac{\delta t^{3}}{2}\sigma_{ w_{x}}^{2}\\ 0&0&0&0&\frac{\delta t^{3}}{2}\sigma_{w_{x}}^{2}&0&\delta t^There are two significant ideas in the derivation of \(Q_{k-1}\):  
* \(E[w_{x,k-1}w_{x,k-1}]=\sigma_{w_{x}}^{2}\). Meanwhile, \(E[w_{y,k-1}w_{y,k-1}]=\sigma_{w_{y}}^{2}\), \(E[w_{a,k-1}w_{a,k-1}]=\sigma_{w_{a}}^{2}\), and \(E[w_{h,k-1}w_{h,k-1}]=\sigma_{w_{h}}^{2}\) where \(\sigma_{w_{x}}^{2}\) is variance (\(\sigma_{w_{x}}=\)\(\sqrt{\sigma_{w_{x}}^{2}}\)is the standard deviation). * \(E[w_{x,k-1}w_{y,k-1}]=0\) since between the x-axis and y-axis, there is no correlation. Similarly, \(E[w_{x,k-1}w_{a,k-1}]=0\), \(E[w_{a,k-1}w_{h,k-1}]=0\), etc. This completes the derivation for \(F_{k-1}\) and \(Q_{k-1}\). We set the different values for the variance (\(\sigma_{w_{x}}^{2}\), \(\sigma_{w_{y}}^{2}\), \(\sigma_{w_{a}}^{2}\), and \(\sigma_{w_{h}}^{2}\)) after tuning them individually during our experiments. To speed up the operation, the observations at time \(k\) can be represented by the following state space model in vector matrix form. \[\underbrace{ \begin{bmatrix}z_{x,k}\\ z_{y,k}\\ z_{a,k}\\ z_{h,k}\end{bmatrix} }_{Z_{k}}=\underbrace{ \begin{bmatrix}1&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0\\ 0&0&0&0&1&0&0&0\\ 0&0&0&0&0&1&0&0\end{bmatrix} }_{H_{k}}\underbrace{ \begin{bmatrix}x_{b,k}\\ y_{b,k}\\ \hat{x}_{b,k}\\ \hat{y}_{b,k}\\ \hat{y}_{b,k}\\ \hat{a}_{b,k}\\ \hat{b}_{b,k}\\ \hat{b}_{b,k}\\ \hat{x}_{k}\end{bmatrix} }_{X_{k}}+\underbrace{ \begin{bmatrix}v_{x,k}\\ v_{y,k}\\ v_{y,k}\\ v_{y,k}\\ v_{h,k}\\ \hat{v}_{k}\end{bmatrix} }_{V_{k}}\] (12) where (\(z_{x,k},z_{y,k}\)) are the center points of a detection box at time \(k\). \(z_{a,k}\) and \(z_{h,k}\) are the aspect ratio and height of a detection box in image coordinates at time \(k\). \(v_{x,k}\), \(v_{y,k}\), \(v_{a,k}\), and \(v_{h,k}\) are observation noises corresponding to \(z_{x,k}\), \(z_{y,k}\), \(z_{a,k}\), and \(z_{h,k}\), respectively, which are basically zero-mean Gaussian white noises. For instance, \(v_{x,k}\sim\mathcal{N}(0,\sigma_{z_{x,k}}^{2})\). The measurement matrix \(H_{k}\) projects the state space to the observation space and Equation (12) can also be represented as \[Z_{k}=H_{k}X_{k}+V_{k}\] (13) where the value of \(H_{k}\) is given in Equation (12) and \(V_{k}\sim\mathcal{N}(0,R_{k})\). Thus, the value of \(R_{k}\) can be obtained by computing the covariance of \(V_{k}\) as: \[R_{k}=Cov(V_{k})=E[V_{k}V_{k}^{T}]\] (14) Here, the covariance matrix of the measurement noise \(R_{k}\) is expressed as: \[R_{k-1}= \begin{bmatrix}\sigma_{v_{x}}^{2}&0&0&0\\ 0&\sigma_{v_{y}}^{2}&0&0\\ 0&0&\sigma_{v_{h}}^{2}&0\\ 0&0&0&\sigma_{v_{h}}^{2}\end{bmatrix} \] (15) where \(E[v_{x,k}v_{a,k}]=0\), \(E[v_{x,k}v_{y,k}]=0\), \(E[v_{a,k}v_{h,k}]=0\) and so on, since there is not any correlation between each other. This completes the derivation for \(H_{k}\) and \(R_{k}\). We set the different values for the variance (\(\sigma_{v_{x}}^{2}\), \(\sigma_{v_{y}}^{2}\), \(\sigma_{v_{x}}^{2}\), and \(\sigma_{v_{h}}^{2}\)) after tuning them individually during our experiments. Then, every track is assigned a filter and follows the prediction and update process to acquire an estimated state. To some extent, the speed of the tracking phase depends on the number of objects being tracked. 1. Kalman Filter Prediction The predicted state \(\hat{X}_{k|k-1}\) is \[\hat{X}_{k|k-1}=F_{k}\hat{X}_{k-1|k-1}.\] (16) The predicted estimate covariance \(P_{k|k-1}\) is \[P_{k|k-1}=F_{k}P_{k-1|k-1}F_{k}^{T}+Q_{k}.\] (17)2.