# DeepSOCIAL: Social Distancing Monitoring and Infection Risk Assessment in COVID-19 Pandemic
## 3 Methodology
### Inter-Distance Estimation  
Stereo-vision is a popular technique for distance estimation such as in [105]; however, this is not a feasible approach in our research when we aim at the integration of an efficient solution, applicable in all public places using only a basic CCTV camera. Therefore we adhere to a monocular solution. On the other hand, by using a single camera, the projection of a 3-D world scene into a 2-D perspective image plane leads to unrealistic pixel-distances between the objects. This is called perspective effect, in which we can not perceive uniform distribution of distances in the entire image. For example, parallel lines intersect at the horizon and farther people to the camera seem much shorter than the people who are closer to the camera coordinate centre. In 3-dimensional space, the centre or the reference point of each bounding box is associated with three parameters \((x,y,z)\), while in the image received from the camera, the original 3D space is reduced to two-dimensions of \((x,y)\), and the depth parameter \((z)\) is not available. In such a lowered-dimensional space, the direct use of the Euclidean distance criterion to measure inter-people distance estimation would be erroneous. In order to apply a calibrated IPM transition, we first need to have a camera calibration by setting \(z=0\) to eliminate the perspective effect. We also need to know the camera location, its height, angle of view, as well as the optics specifications (i.e., the camera intrinsic parameters) [104]. By applying the IMP, the 2D pixel points \((u,v)\) will be mapped to the corresponding world coordinate points \((X_{w},Y_{w},Z_{w})\):  
\[[u\;\;v\;\;1]^{T}=KRT[X_{w}\;\;Y_{w}\;\;Z_{w}\;\;1]^{T} \tag{12}\]  
where \(R\) is the rotation matrix:  
\[R= \begin{bmatrix}1&0&0&0\\ 0&\cos\theta&-\sin\theta&0\\ 0&\sin\theta&\cos\theta&0\\ 0&0&0&1\end{bmatrix} , \tag{13}\]  
\(T\) is the translation matrix:  
\[T= \begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&-\frac{h}{\sin\theta}\\ 0&0&0&1\end{bmatrix} , \tag{14}\]  
and \(K\), the intrinsic parameters of the camera are shown by the following matrix:  
\[K= \begin{bmatrix}f*ku&s&c_{x}&0\\ 0&f*kv&c_{y}&0\\ 0&0&1&0\end{bmatrix}  \tag{15}\]  
where \(h\) is the camera height, \(f\) is focal length, and \(ku\) and \(kv\) are the measured calibration coefficient values in horizontal and vertical pixel units, respectively. \((c_{x},c_{y})\) is the principal point shifts that corrects the optical axis of the image plane. The camera creates an image with a projection of three-dimensional points in the world coordinate that falls on a retina plane. Using homogeneous coordinates, the relationship between three-dimensional points and the resulting image points of projection can be shown as follows:  
\[ \begin{bmatrix}u\\ (v)\\ 1\end{bmatrix} = \begin{bmatrix}m_{11}&m_{12}&m_{13}&m_{14}\\ m_{21}&m_{22}&m_{23}&m_{24}\\ m_{31}&m_{32}&m_{33}&m_{34}\end{bmatrix}\begin{bmatrix}X_{w}\\ \left[\begin{matrix}Y_{w}\\ Z_{w}\end{matrix}\right]\\ 1\end{bmatrix}  \tag{16}\]  
where \(M\in\mathbb{R}^{3\times 4}\) is the transformation matrix with \(m_{ij}\) elements in Equation (16), that maps the world coordinate points into the image points based on the camera location and the reference frame, provided by the Camera Intrinsic Matrix \(K\) (Equation (15)), Rotation Matrix \(R\) (Equation (13)) and the Translation Matrix \(T\) (Equation (14)). Considering the camera image plane perpendicular to the \(Z\) access in the world coordinate system (i.e., \(z=0\)) the dimensions of the above equation can be reduced to the following form:  
\[ \begin{bmatrix}u\\ (v)\\ 1\end{bmatrix} = \begin{bmatrix}m_{11}&m_{12}&m_{13}\\ m_{21}&m_{22}&m_{23}\\ m_{31}&m_{32}&m_{33}\end{bmatrix}\begin{bmatrix}X_{w}\\ \left(Y_{w}\right)\\ 1\end{bmatrix}  \tag{17}\]  
and finally transferring from the perspective space to inverse perspective space (BEV) can also be expressed in the following scalar form:  
\[