# Mono Camera-Based Optical Vehicular Communication for an Advanced Driver Assistance System
## 3 Proposed Scheme
### Receiver
#### 3.3.2 Vehicle Localization  
The distance and angular position of the FWVs were determined via the Cartesian or polar coordinates of the LEDs on the IS. In this regard, the IS was envisioned as a two-dimensional (2D) coordinate system wherein the 3D camera coordinates were converted into a 2D matrix or vector. The LED coordinates were continuously changing over time, making precise distance measurement challenging. Thus, the shapes of the rear LEDs were compared to determine the direction of movement of the FWVs. If the FWVs were moving straight, the size of the rear LEDs on the IS in the FLV's front camera was the same. The FWVs turning to the left or right could be detected from the rear LED shapes owing to their dissimilar appearance on the IS. The projected image of the left LED appeared larger compared with that of the right LED when the FWVs turned left, and vice versa. In particular, after the OCC link was established, the distance between the two rear LEDs was forwarded from the FWVs to the FLVs. If the distance of the LED and its projected image from the camera lens was \(O\) and \(o\), respectively, the general lens equation for an IS with a focal length of \(f\) was presented as follows  
\[\frac{1}{O}+\frac{1}{o}=\frac{1}{f}, \tag{1}\]  
\[\frac{o}{O}=\frac{f}{O-f}. \tag{2}\]  
The magnification factor is used to relate the ratio of the projected area of the LED on the IS, \(s_{ij}\), and the actual size of the LED, \(S_{ij}\), with the ratio of the distance of the LED from  
Figure 5: A CNN-based vehicular taillight detection scheme. the lens, \(D\), and the distance of the projected image on the IS, \(d\), from the lens. It is written as follows  
\[m=\sqrt{\frac{s_{ij}}{S_{ij}}}=\frac{d}{D}. \tag{3}\]  
If the \(f\ll D\) condition is satisfied, the preceding two equations are combined to measure the distance (\(D\)) directly as  
\[D=f\sqrt{\frac{S_{ij}}{s_{ij}}}, \tag{4}\]  
\[D=\frac{f}{a}\sqrt{\frac{S_{ij}}{N_{C}}}, \tag{5}\]  
where \(a\) is the unit pixel length and \(N_{C}\) is the number of pixels of the projected image on the IS. The absolute value of all parameters had to be taken to avoid the negative value of distance. Therefore, the distance of the vehicle was directly proportional to the square root of the actual LED size and inversely proportional to the square root of the number of pixels of the projected image on the IS. Measurement of the distance from FLV to FWV is challenging and often accompanied by a significant amount of inaccuracy owing to the vehicles' high-mobility. Thus, the distance measurement of an FWV from any fixed point is impossible. Therefore, in this work, the FWV distance was measured from the IS of the FLV. Cartesian, polar, or any other coordinate systems could be used for the localization. After detecting the rear LEDs of the FWV, the distance between the FLV and FWV was calculated via photogrammetry. The projected image areas of the rear LEDs of the FWV were decreased as the distance from the FLV was increased. When the front vehicle was on the right side of the FLV and the distances of the left and right rear LEDs of the FWV from the FLV were \(D_{L}\) and \(D_{R}\), respectively, Equations (6) and (7) could be written according to the Pythagorean theorem as  
\[D_{R}^{2}=\left(D_{LR}+C\right)^{2}+D^{2}, \tag{6}\]  
\[D_{L}^{2}=C^{2}+D^{2}, \tag{7}\]  
where \(D_{LR}\) is the distance between the left and right rear LEDs of the FWV, and \(C\) is the horizontal distance of the nearest rear LED of the FWV perpendicular to the vertical distance, which could be expressed as  
\[C=\frac{(D_{R}^{2}-D_{L}^{2})}{2D}. \tag{8}\]  
Subsequently, the perpendicular distance (\(D\)) was calculated using Equations (6)-(8). \[D=\sqrt{D_{L}^{2}-\left\{\frac{(D_{R}-D_{L})^{2}-D_{LR}^{2}}{D_{LR}}\right\}^ {2}}. \tag{9}\]  
Two axes were used to find the center of the plane to determine the lateral position of the FWVs with respect to the FLVs.