# Experimental Solution for Estimating Pedestrian Locations from UAV Imagery
## 4 Materials and Methods
### Pedestrian Localization from Video  
Object detection performed by the YOLO algorithm [8] resulted in an output of rectangular bounding boxes. The bounding boxes represent video frame segments containing certain objects, e.g., pedestrians. However, these data are insufficient for providing the real-world locations of people on their own. Suppose we have (x, y) coordinates of each detected person within an image frame. To transform these coordinates into real-world geographical locations, the following steps must be performed:  
1. Calculation of the offset position relative to the image center (in pixels). 2. Conversion of all offsets into angles in degrees. 3. Acquisition of horizontal and vertical camera angles. 4. Calculation of the direction of a detected person. 5. Calculation of the \"flat\" distance between a person and the camera. 6. Conversion of meters into geographic distances. 7. Calculation of latitude and longitude. An important factor for successful calculations is the knowledge of the field of view (FOV) of the camera, as well as the resolutions of the video recordings. A typical example could be a FOV of 90 degrees and a resolution of 1920 \(\times\) 1080 pixels. Additionally, there is a distinction between horizontal and vertical FOV. Both of these values are required for accurate localization (from a video). However, it is common practice to only include the  
Figure 2: Component diagram of the designed system. information about a horizontal FOV, which is why our implementation uses this method for calculating vertical FOV from horizontal FOV:  
\[vFOV_{rad}=atan(\frac{x}{y}\times tan(\frac{hFOV_{rad}}{2})) \tag{1}\]  
where \(vFOV_{rad}\) is a vertical FOV in radians (See Figure 3), \(hFOV_{rad}\) is a horizontal FOV in radians, and \(\frac{x}{y}\) represents the camera resolution. Additionally, it is necessary to convert this value to degrees; this is done by calculating horizontal and vertical offsets of points relative to the center of the image frame. This ensures that all resulting angles in the later calculations will be relative to the camera center. With the knowledge of the vertical and horizontal fields of view and the relative offsets, the degree angles of the offsets can be calculated. The calculations of horizontal and vertical angles are as follows:  
\[O_{hor}=\frac{dx}{w}\times hFOV \tag{2}\]  
\[O_{vor}=\frac{-dy}{h}\times vFOV \tag{3}\]  
where \(O_{hor}\) and \(O_{ver}\) represent the horizontal and vertical offsets in degrees, \(dx\) and \(dy\) are the horizontal and vertical offsets in pixels, \(w\) is the width, and \(h\) is the height of the video frame. Additionally, the vertical angle is flipped. This ensures that positive vertical values will face up, whereas negative vertical values will face down; thus, the detected objects will be below the camera's center, as opposed to the default orientation in OpenCV. Calculating the geographic coordinates of a person is impossible without the knowledge of the latitude, longitude, altitude, and camera rotation in the vertical and horizontal directions. When using a video recording from a UAV, it is necessary to acquire the data per frame, as the pedestrian is not stationary and the values change. As per camera rotation, we assume the knowledge of the global horizontal and vertical orientation of the camera. We define 0 degrees as the vertical angle of the horizon, negative values as facing down, and positive values as facing up. The horizontal angle is relative to the north, which is represented as 0 degrees. The values change from 0 to 360 degrees in the clockwise direction on a map. Given the knowledge of camera angles as well as the angle offsets of the detected  
Figure 3: Vertical angles. people, it is possible to calculate their global angles, these are acquired as follows (see Figure 4):  
\[G_{hor}=O_{hor}+C_{hor} \tag{4}\]  
\[G_{ver}=O_{ver}+C_{ver} \tag{5}\]  
where \(G_{hor}\) and \(G_{ver}\), in degrees, represent the global horizontal and vertical angles of a person relative to the UAV.