## 3 Methods
### Kalman Filter Tracking  
Object tracking is a very important phase for CAS. There are many object tracking methods in literature [4; 18]. One of the most common method is Kalman Filter tracking [6; 7; 41]. Kalman Filter provides a recursive solution to the optimal filtering problem and it can be applied to stationary as well as nonstationary environments.  
In this study, the position of detected segments is tracked over time using the Kalman Filter. The tracking algorithm estimates the position and velocities of objects from current observation and state predicted.  
Kalman Filter consists of two main stages. In the first stage, the state of the process is predicted. In the second stage, predictions are corrected or updated by using measurements. Prediction and update equations of discrete-time Kalman Filter are as below:  
1. Predict: For each time step t, the predicted state at this time step \(\hat{\text{x}}_{\text{t}}^{-}\) is given by; \[\hat{\text{x}}_{\text{t}}=\text{F}_{\text{t}}\hat{\text{x}}_{\text{t-1}}+\text {B}_{\text{t}}\text{u}_{\text{t}},\] (8) \[\hat{\text{x}}_{\text{t}}=\Big{[}\begin{array}{ccc}\text{x}&\text{y}&\text {V}_{\text{x}}&\text{V}_{\text{y}}\end{array}\Big{]},\] (9) where x and y represent the coordinates of the object and V\({}_{\text{x}}\) and V\({}_{\text{y}}\) represent the objects velocity. To use Kalman Filter, the objects are considered moving at constant velocity and constant acceleration.  
The transition matrix F is:  
\[\text{F}=\left[\begin{array}{cccc}1&0&\Delta\text{t}&0\\ 0&1&0&\Delta\text{t}\\ 0&0&1&0\\ 0&0&0&1\end{array}\right] \tag{10}\]  
Converting u\({}_{\text{t}}\) into state space matrix B is:  
\[\text{B}=\ \Big{[}\begin{array}{cccc}1&0&0&0\end{array}\Big{]}, \tag{11}\]  
For concluding Kalman Filter prediction, P\({}_{\text{t}}^{-}\) error covariance matrix forward one-time step:  
\[\text{P}_{\text{t}}^{-}=\text{F}_{\text{t}}\text{P}_{\text{t-1}}\text{F}_{ \text{t}}^{\text{T}}+\text{Q}_{\text{t}}, \tag{12}\]  
where P is the matrix representing error covariance in the state prediction and Q is the process noise covariance.  
2. Update: After predicting the state \(\hat{\text{x}}_{\text{t}}^{-}\), the Kalman Filter computes Kalman Gain to correct the state estimate \(\hat{\text{x}}_{\text{t}}^{-}\). Kalman Gain is calculated as below:\[\mathrm{K_{t}}=\mathrm{P_{t}^{-}H_{t}^{T}(H_{t}P_{t}^{-}H_{t}^{T}+R_{t})^{-1}}, \tag{13}\]  
where R is measurement noise covariance.  
\[\mathrm{R}=\left[\begin{array}{cc}\sigma_{m}^{2}&0\\ 0&\sigma_{m}^{2}\end{array}\right], \tag{14}\]  
After predicting the state \(\mathrm{\hat{x}_{t}^{-}}\) and its error covariance at time \(t\) using the time update steps, the Kalman Filter can update the state estimate using Kalman Gain and measurements that are derived from the laser scanner:  
\[\mathrm{\hat{x}_{t}}=\mathrm{\hat{x}_{t}^{-}}+\mathrm{K_{t}}\big{(}y_{t}-H_{t }\mathrm{\hat{x}_{t}^{-}}\big{)}, \tag{15}\]  
where y is the measurement derived from the laser scanner. It contains two dimensions (x and y coordinates) and it has the form for all of the different tracking algorithms for n tracking algorithm as below:  
\[\left[\begin{array}{cc}\mathrm{x}_{0},y_{0}&\mathrm{x}_{1},\mathrm{y}_{1} \ldots&\mathrm{x}_{n-1},\mathrm{y}_{n-1}\end{array}\right], \tag{16}\]  
As a result, the H matrix (observation matrix), which is the matrix of converting state space into measurement space, has the form;  
\[\mathrm{H}=\left[\begin{array}{cccc}1&0&0&0\\ 0&1&0&0\end{array}\right], \tag{17}\]  
Finally, Kalman Filter updates error covariance \(\mathrm{P_{t}^{-}}\) into \(\mathrm{P_{t}}\):  
\[\mathrm{P_{t}}=(\mathrm{I-K_{t}H_{t}})\mathrm{P_{t}^{-}}, \tag{18}\]  
Although Kalman Filter is a powerful tool for tracking, there is a difficulty in combining arbitrary tracking algorithms, as measurements come from computing the Kalman Gain. Normally, the measurement noise covariance matrix, R is difficult to determine, but thanks to laser scanners' highly accurate measurement, a small noise covariance is sufficient for position measurement.