## 2 System Principle
### Double-Light Positioning Algorithm  
Based on the above LED-ID image recognition, this section mainly introduces the double-light positioning algorithm in the positioning system. To the best of our knowledge, in the existing reports, only [PERSON] et al. [14] realized VLC positioning on the base of two LEDs with one camera. However, unfortunately, the authors of [14] did not describe their proposed positioning scheme properly. Thus, we propose a new double-light positioning algorithm, as shown below:  
The system model of the proposed double-light positioning algorithm is shown in Figure 3. The coordinates of LEDs are (x1, y1, z1), (x2, y2, z2) and, in general, the ceiling height is the same throughout, thus z1 = z2. Point P is the midpoint of the lens in the image sensor, which is estimated for the 3-D coordinate of the terminal. The distances from P to the LED anchors are \(d_{kP},\ k=1,\ 2\) for the two LED lamps. \(d_{kP}\) is calculated by the geometrical relationship between the focal length of the lens and the position of the LED pixel on the image sensor. Geometric relationship of the proposed double-light positioning scheme is detailed in Figure 3. The focal length of the lens \(f\) is the intrinsic parameter of the camera. The distance between the center of the LED pixel and the center of the image sensors is \(p_{k},\ k=1,\ 2\) for the two LED lamps. The pixel coordinate system and image coordinate system are both located on the imaging plane of image sensor, but they have different origin and different units of measurement. The relationship between the pixel coordinate system and image coordinate system is presented in Figure 4.  
Figure 2: The process of the LED-ID detection and recognition base on machine learning. The origin of image coordinate system is the point of intersection of camera's optical axis and the image sensor imaging plane, i.e., the center of midpoint of the image sensor imaging plane. The unit of the mentioned image coordinate system is mm, which belongs to physical unit. The unit of the pixel coordinate is pixel, which is described by its row and line. Firstly, after obtaining the pixel coordinates of the two LEDs, according to the relationship between the pixel coordinate system and the image coordinate system, the coordinates of the two LEDs in the image coordinate system can be calculated:  
\[u=\frac{i}{di}+u_{0} \tag{1}\]  
\[v=\frac{j}{dj}+v_{0} \tag{2}\]  
Equations (1) and (2) can be rewritten in matrix form as:  
\[\left[ \begin{array}{c}u\\ v\\ 1\end{array} \right]=\left[ \begin{array}{ccc}\frac{1}{di}&0&u_{0}\\ 0&\frac{1}{dj}&v_{0}\\ 0&0&1\end{array} \right]\left[ \begin{array}{c}i\\ j\\ 1\end{array} \right] \tag{3}\]  
where \(di\) and \(dj\) represent the unit conversion of two coordinate system, i.e., 1 pixel = \(dj\) mm, \(i\), \(j\) is the coordinate in the image coordinate system, \(u\), \(v\) is the coordinate in the pixel coordinate system, and \((u_{0},v_{0})\) is the midpoint of image sensor's imaging plane in pixel coordinate system. Therefore, we can obtain the conversion of the image coordinate system and the pixel coordinate system. Furthermore, we can get the distance between the midpoint of image sensor and the image of LED on the sensor \(p_{k}\):  
Figure 4: (\(x\), \(y\)) is the pixel coordinate system, (\(u\), \(v\)) is the Image coordinate system, (\(X_{c}\), \(Y_{c}\)) is the Camera coordinate system and (\(X_{w}\), \(Y_{w}\), \(Z_{w}\)) is the world coordinate system. Figure 3: Double-light positioning system model.