## 2 Proposed Vehicle Detection and Tracking System
### Headlight and Taillight Tracking  
To refine the detection results and facilitate the vehicle light pairing and vehicle tracking steps, this section presents a vehicle light tracking mechanism by considering spatiotemporal information in consecutive images. After performing the headlight and taillight classification, a headlight set and a taillight set that include the positions of bounding boxes surrounding vehicle lights are retrieved. Although the results of the previous step still contain false positives, they are going to be eliminated in subsequent steps. Because the light tracking, light pairing, and vehicle tracking mechanisms are all applied equally to both headlights and taillights, the term \"vehicle lights\" is used and implicitly understood as headlights and taillights. To depict the light tracking process, the following terms are first defined:  
Figure 8: Result of classification process on input image. Figure 7: Subimage extraction from input RGB image. 1. \(L_{i}^{t}\) (\(i=1,2,...,n_{t}\)) and \(n_{t}\) denote the \(i\)th vehicle light in the ROI and the number of detected vehicle lights in frame \(t\), respectively. 2. \(t(L_{i}^{t})\), \(l(L_{i}^{t})\), \(b(L_{i}^{t})\), \(r(L_{i}^{t})\) denote the location of vehicle light \(L_{i}^{t}\), and are the top, left, bottom, and right coordinates of the bounding box enclosing \(L_{i}^{t}\), respectively. 3. The width and height of vehicle light \(L_{i}^{t}\) are denoted as \(W(L_{i}^{t})\) and \(H(L_{i}^{t})\), respectively. 4. The horizontal distance \(D_{h}\) and vertical distance \(D_{v}\) between two vehicle lights \(L_{i}^{t}\) and \(L_{j}^{t}\) in frame \(t\) are defined as \[D_{h}(L_{i}^{t},L_{j}^{t})=max\{l(L_{i}^{t}),l(L_{j}^{t})\}-min\{r(L_{i}^{t}),r (L_{j}^{t})\}\] (1) \[D_{v}(L_{i}^{t},L_{j}^{t})=max\{t(L_{i}^{t}),t(L_{j}^{t})\}-min\{b(L_{i}^{t}), b(L_{j}^{t})\}\] (2) The value of the distance is negative if two vehicle lights are overlapped in the horizontal or vertical projection. 5. The degrees of overlap between the horizontal projections or vertical projections of two vehicle lights \(L_{i}^{t}\) and \(L_{j}^{t}\) in frame \(t\) are \[O_{h}(L_{i}^{t},L_{j}^{t})=\frac{-D_{h}(L_{i}^{t},L_{j}^{t})}{min\{W(L_{i}^{t} ),W(L_{j}^{t})\}}\] (3) \[O_{v}(L_{i}^{t},L_{j}^{t})=\frac{-D_{v}(L_{i}^{t},L_{j}^{t})}{min\{H(L_{i}^{t} ),H(L_{j}^{t})\}}\] (4) The defined terms are illustrated in Figure 9.  
To obtain information including the position, size, and velocity of the same vehicle light in subsequent frames, a light tracker is initialized if a vehicle light appears for the first time in the ROI. Let \(TL_{i}^{t}=<L_{i}^{1},L_{i}^{2},...,L_{i}^{t}>\) denote the light tracker representing for the trajectory of \(L_{i}^{t}\). The light tracker \(TL_{i}^{t}\) tracks the vehicle light \(L_{i}^{t}\) appearing from the first frame to frame \(t\). \(\mathbf{L^{t}}\) denotes the set of detected vehicle lights in frame \(t\). \(\mathbf{TL^{t-1}}\) denotes the set of light trackers in frame \(t-1\). Based on the condition in the study [6], which tracks vehicle headlights in a traffic surveillance system, two detected vehicle lights in two consecutive frames belong to one light tracker if their bounding boxes overlap to each other. Applying this condition for tracking vehicle taillights, the system is still able to track taillights, whether the preceding vehicles are moving at high or low speed. However, applying the condition for tracking vehicle headlights, the system may fail when the oncoming vehicle's velocity is higher than 50 km/h. Therefore, a modified version of the tracking mechanism in the study [3] is presented in this section. First, the overlapping score \(S_{0}\) of two vehicle lights (two bounding boxes) \(L_{i}^{t}\) and \(L_{j}^{t^{\prime}}\) is defined, where these lights are detected in different frames \(t\) and \(t^{\prime}\). \[S_{0}(L_{i}^{t},L_{j}^{t^{\prime}})=\frac{A(L_{i}^{t}\cap L_{j}^{t^{\prime}})} {max\{A(L_{i}^{t}),A(L_{j}^{t^{\prime}})\}} \tag{5}\]  
Figure 9: Illustration of the defined terms.