# Identification of Location and Camera Parameters for Public Live Streaming Web Cameras
## 4 Formulation of the Problem and Its Solution Algorithm
### Solution Algorithm
#### 4.1.3 Obtain the Camera Orientation (Matrix \(R\) )  
To determine the camera orientation, we use the point \(O\) and the point \(G\) given in the coordinates \(F_{emu}\) (Figure 1). Unit vector  
\[\vec{\mathbf{e}}_{zc}=OG/|OG|=(\vec{e}_{x}^{zc},e_{y}^{zc},e_{z}^{zc})_{emu} \tag{20}\]  
gives direction to axis \(Z_{c}\) of frame \(F_{c}\). \(\vec{\mathbf{e}}_{zc}\), and \(O\) determines the plane of points \(x\), for which the vector \(\vec{O}x\) is perpendicular to \(\vec{\mathbf{e}}_{zc}\). In this plane, lie the axes \(X_{c}\) and \(Y_{c}\) of coordinate frame \(F_{c}\). Unit vector \(\vec{\mathbf{e}}_{d}=(0,0,-1)_{emu}\) is downward. Let \(F_{v}\) be camera coordinates with the same optical axis \(Z_{c}\) as \(F_{c}\), but the \(F_{v}\) has zero horizon tilt. Axis \(X_{v}\) of the frame is perpendicular to \(\vec{\mathbf{e}}_{d}\) as far as \(X_{v}\) is parallel to the horizontal plane. We can find axes directions \(Y_{v}\) and \(X_{v}\) of the frame \(F_{v}\):  
\[\begin{array}{l}\vec{\mathbf{n}}_{yo}=\vec{\mathbf{e}}_{d}-(\vec{\mathbf{e}}_ {d}\cdot\vec{\mathbf{e}}_{zc})\vec{\mathbf{e}}_{zc}=\vec{\mathbf{e}}_{d}+e_{z}^ {zc}\vec{\mathbf{e}}_{zc}\\ \vec{\mathbf{e}}_{yo}=\vec{\mathbf{n}}_{yo}/|\vec{\mathbf{n}}_{yo}|\\ \vec{\mathbf{e}}_{xv}=\vec{\mathbf{e}}_{yo}\times\vec{\mathbf{e}}_{zc}\end{array}. \tag{21}\]Vectors (21) form the orthonormal basis, which allows us to construct a rotation matrix \(R_{v2e}\) for transition from \(F_{v}\) to \(F_{emu}\):  
\[R_{v2e}=\begin{bmatrix}e_{v}^{xv}&e_{v}^{yv}&e_{v}^{zv}\\ e_{v}^{yv}&e_{v}^{yv}&e_{v}^{zv}\\ e_{z}^{zv}&e_{z}^{yv}&e_{z}^{zv}\end{bmatrix}=\begin{bmatrix}\bar{\mathbf{e}}_{xv}& \bar{\mathbf{e}}_{yv}&\bar{\mathbf{e}}_{zc}\end{bmatrix}. \tag{22}\]  
If \(R_{v2e}\) is a rotation matrix, the following equations hold:  
\[R_{v2e}=R_{v2e}^{-1}=R_{v2e}^{T}. \tag{23}\]  
From Clause 4 of the problem statement, there is a line segment in the artificial image \(\hat{\Phi}\) with a known slope in space. It is possible to compare the segment slope in the image \(\hat{\Phi}\) and the slope of its source in space. So, we can estimate the camera horizon tilt angle (denote it as \(\gamma\)) and rotate the plane with the axes \(X_{v}\) and \(Y_{v}\) around the optical axis \(Z_{c}\) at this angle. The resulting system of coordinates \(F_{c}\) corresponds to the actual camera orientation. To pass from the camera coordinates \(F_{c}\) to \(F_{emu}\), we can first go from \(F_{c}\) to \(F_{v}\) by rotation with the angle \(\gamma\) around the optical axis \(Z_{c}\) using the rotation matrix  
\[\Gamma=\begin{bmatrix}\cos\gamma&-\sin\gamma&0\\ \sin\gamma&\cos\gamma&0\\ 0&0&1\end{bmatrix}. \tag{24}\]  
We can describe the transition from \(F_{c}\) to \(F_{emu}\) (without origin displacement) as a combination of rotations by the matrix  
\[R_{v2e}=R_{v2e}\Gamma, \tag{25}\]  
which is also a rotation matrix. The matrix that we have already designated \(R\) (2) gives the inverse transition from \(F_{emu}\) to the coordinates of the camera frame \(F_{c}\) :  
\[R=R_{c2e}^{T} \tag{26}\]  
and the shift \(t\), which in the coordinates \(F_{c}\) characterizes the transition from the beginning of the coordinates of \(F_{emu}\) to the point of installation of the camera \(O\). The \(t\) is often more easily expressed through the coordinates \(O_{emu}\) given in \(F_{emu}\), see (3). To convert the coordinates of a \(P_{emu}\) from \(F_{emu}\) to \(P_{c}\) coordinates for the \(F_{c}\) camera frame, use the following expressions:  
\[P_{c}=R(P_{emu}-O)=RP_{emu}+t. \tag{27}\]  
Typically, an operator aims to set a camera with zero horizon tilt.