# Identification of Location and Camera Parameters for Public Live Streaming Web Cameras
## 2 Coordinate Systems, Models
\begin{bmatrix}x_{c}/z_{c}\\ y_{c}/z_{c}\\ 1\end{bmatrix} = \begin{bmatrix}f_{u}x_{c}/z_{c}+c_{u}\\ f_{v}y_{c}/z_{c}+c_{v}\\ 1\end{bmatrix} , \tag{6}\]  
where \(P_{im}^{h}\) are homogeneous coordinates of \(P_{im}\). If \(f_{u}\
eq 0\) and \(f_{v}\
eq 0\), the pixel \((u,v)\) defines the relations \(x_{c}/z_{c},y_{c}/z_{c}\) (5). However, we need to know the value \(z_{c}(u,v)\) (\"depth  
Figure 1: Coordinate frames \(F_{c}\), \(F_{im}\). \(P_{im}\) are the image of the 3D point \(P\). Axis \(Z_{c}\) follows the camera optical axis. The camera forms a real image on the image sensor behind aperture \(O\) in the plane \(z=-f\); however, the equivalent virtual image in the plane \(z=f\) is preferable in illustrations. Figure 2: Virtual and real images for a camera with aperture \(O\). The scene is projected on the plane \(XZ\) of frame \(F_{c}\). The coordinates of the point \(P\) in \(F_{c}\) are denoted by \(x_{c},z_{c}\), and the \(u,c_{u}\) are coordinates of points \(P,C\) on the axis \(U\) of frame \(F_{im}\). map\") to recover original 3D coordinates \(x_{x},y_{c}\), and \(z_{c}\) from the pixel coordinates \((u,v)\). Additional information about the scene is needed to build the depth map \(z_{c}(u,v)\) for some range of pixels \((u,v)\). Perspective projection preserves straight lines. A wide-angle lens, used by most street public cameras, introduces perspective distortion described by the pinhole camera model and substantial radial distortion. Usually, the radial distortion is easily detectable, especially on \"straight\" lines near the edges of the image. An extended model was used to take it into account. A popular quadratic model of radial distortion ([6] (pp. 63-66), [7] (pp. 189-193), [5]) changes the pinhole camera model (6) as follows:  
\[r^{2}=(x_{c}/z_{c})^{2}+(y_{c}/z_{c})^{2}, \tag{7}\]  
\[ \begin{bmatrix}\hat{x}\\ \hat{y}\end{bmatrix} =(1+k_{1}r^{2}+k_{2}r^{4}) \begin{bmatrix}x_{c}/z_{c}\\ y_{c}/z_{c}\end{bmatrix} , \tag{8}\]  
\[P_{im}^{h}= \begin{bmatrix}u\\ v\\ 1\end{bmatrix} =A \begin{bmatrix}\hat{x}\\ \hat{y}\\ 1\end{bmatrix} = \begin{bmatrix}f_{u}\hat{x}+c_{u}\\ f_{v}\hat{y}+c_{v}\\ 1\end{bmatrix} , \tag{9}\]  
where \(k_{1}\) and \(k_{2}\) are radial distortion coefficients. In addition to the quadratic, more complex polynomials and models of other types are used ([5], [6] (pp. 63-66, 691-692), [7] (pp. 189-193)). Let the coefficients \(f_{u},f_{v},c_{u},c_{v},k_{1}\), and \(k_{2}\) be selected so that the formation of images from the camera is sufficiently well described by (7)-(9). To construct the artificial image on which the radial distortion \(k_{1}\) and \(k_{2}\) is eliminated, we must for each pair of relations \((x_{c}/z_{c},y_{c}/z_{c})\) obtain new positions of pixels \((\hat{u},\hat{v})\) according to the pinhole camera model:  
\[ \begin{bmatrix}\hat{u}\\ \hat{v}\end{bmatrix} = \begin{bmatrix}f_{u}x_{c}/z_{c}+c_{u}\\ f_{v}y_{c}/z_{c}+c_{v}\end{bmatrix} . \tag{10}\]  
To do this, we need all values \((x_{c}/z_{c},y_{c}/z_{c})\) (coordinates in \(F_{c}\)), which form the original image. To obtain the relations from an image, you have the image pixel coordinates \((u,v)\) and equations (follows from (7)-(9))  
\[Q(u,v)=\frac{f_{v}(u-c_{u})}{f_{u}(v-c_{v})},\,D(u,v)=Q^{2}+1, \tag{11}\]  
\[x_{c}/z_{c}=Q(u,v)y_{c}/z_{c}, \tag{12}\]  
\[k_{2}D(u,v)^{2}(y_{c}/z_{c})^{5}+k_{1}D(u,v)(y_{c}/z_{c})^{3}+y_{c}/z_{c}+ \frac{c_{v}-v}{f_{v}}=0, \tag{13}\]  
if \(v\
eq c_{v}\). Similar equations are valid for \(v=c_{v}\) and \(u\
eq c_{u}\). Equation (13) has five roots (complex, generally speaking), so we need an additional condition to select one root. We can select the real root nearest to \((v-c_{v})/f_{v}\). The artificial image will not be a rectangle, but we can select a rectangle part of it (see figures of Example 2). Note that the mapping \((u,v)\rightarrow(\hat{u},\hat{v})\) is determined by the camera parameters \(f_{u},f_{v},c_{u},c_{v},k_{1}\), and \(k_{2}\). It does not change from frame to frame and can be computed once and used before the parameters are changed.