# Highly Accurate Deep Learning Models for Estimating Traffic Characteristics from Video Data
## 3 Methodology
### Vehicle Speed Calculation
 \tag{7}\]  
The camera parameters can then be determined as [36]:  
\[f=\frac{\gamma(B,D)Cosy\,Cosp}{\beta(B,D)Siny\,Cosr-\beta(B,D)Cosy\,Sinp\,Sinr +\alpha(B,D)Siny\,Sinr+} \tag{8}\]  
\[\alpha(B,D)Cosy\,Sinp Cosr\]  
\[tany=\frac{Sinp*(Sinr*(\beta(B,D)\gamma(A,C)-\beta(A,C)\gamma(B,D))+Coss*( \alpha(A,C)\gamma(B,D)-\alpha(A,C)\gamma(B,D)}{Sinr*(\alpha(B,D)\gamma(A,C)- \alpha(A,C)\gamma(B,D))+Cosr*(\beta(B,D)\gamma(A,C)-\beta(A,C)\gamma(B,D))} \tag{9}\]  
\[l=\frac{\omega(fSinp+X_{A}CospSinr+Y_{A}CospCosr)*(fSinp+X_{C}CospSinr+Y_{C} CospCosr}{-(fSinp+X_{A}CospSinr+Y_{A}CospCosr)*(X_{C}CosySinr-X_{C}SinyinpCosr+Y_{C} CosyCosr+Y_{C}SinySinr)} \tag{10}\]  
\[\begin{array}{c}-\beta(A,B)\beta(A,C)\gamma(B,C)\alpha(C,D)+\beta(A,C) \alpha(B,D)\beta(A,B)\gamma(C,D)\\ +\beta(C,D)\gamma(A,B)\beta(B,D)\alpha(A,C)-\beta(A,B)\gamma(C,D)\beta(B,D) \alpha(A,D)\\ -\beta(C  
The speed calculation of vehicles is hindered by positional inconsistencies induced by inaccuracies due to object detection and tracking. More specifically, vehicle orientation and missing frames in vehicle detection are the primary problems.  
One influential factor is the oscillation of bounding boxes formed during the prediction from the mFairMOT network [7]. Since the FairMOT prediction is independent of the preceding and succeeding frames during the prediction, there is no penalty imposed regarding the geometric consistency of the predicted bounding boxes, inducing the noise in the vehicle's positioning data.  
In addition, mFairMOT experiences difficulties in detection involving complex spatial interactions, occlusions, and obscure object borders. This problem manifests mainly on road segments that are not in parallel with the camera frustum's forward vector, where vehicles occasionally become obstructed by other objects or nearby vehicles, resulting in frames where the vehicle is not registered by the object detector. While this is sporadic, losing such frames results in significant inaccuracies in footage featuring the aforementioned road type.  
To alleviate this deficiency, a custom interpolation filter _Fi_ is incorporated to adapt to bounding box oscillations and frame skips for vehicle \(i\). Each vehicle is assigned to a data tracker during its lifetime (exposure as an object in the footage). In evaluating speed \(S\) at the current frame, \(\sigma\) denotes the generalised kernel function for interpolating between two (often adjacent) footage frames:  
\[S=\sigma_{F}(i,C_{world},\Delta t_{i}) \tag{12}\]  
\(\Delta t_{i}\) denotes the time since the previous frame where the vehicle is detectable and imposes no distinction between delay from frame rate and delay of skipped frames. Speed per second is computed with \(\text{abs}\big{(}C_{i}-F_{i,preve}\big{)}/\Delta t_{i}\) (approximating with a linear interpolation over a missing frame) and transformed with a proportional-integral-derivative (PID) controller to reduce positional noise generated by the object detector. A PID controller is usually used in automatic control, but when applied to computer vision, it can accelerate the optimisation convergence process by reducing the overshoot problem in stochastic gradient descent (SGD) momentum of weights updating [10]. PID has three components, which need to be specified beforehand as \(O_{P}\), \(O_{I}\), and \(O_{D}\). Specifications for the controller in this study are as follows:  
\[ \begin{array}{c}O_{P}=0.51\\ O_{I}=0\\ O_{D}=0.103\end{array}  \tag{13}\]  
The PID controller in this context is incorporated as a filter for speed updating instead of as a 'control' algorithm. The controller output specifies the internal adjusted speed of a vehicle in the context frame, while the set point (SP) and process variable (PV) are the estimated vehicle speed (inputted from the projection transformation) and the internally predicted speed from the previous frame. Since the SP experiences shifts throughout the process, the integral component (\(O_{I}\)) is mostly irrelevant.