## 3 Materials and Methods
### Trajectory Reconstruction  
To create the trajectory of a moving object, it is necessary to have access to the movement data of that object. Typically, the movement data is related to GPS points that are recorded during the movement of the object. In our solution, we reconstructed raw trajectories using geo-tagged photos taken by drones during their mission (flight), as they provide us with suitable data/metadata for the reconstruction process. The trajectory reconstruction process consists of two parts. In the first part, the related metadata is extracted from geo-tagged photos, and in the second part, the photos are resized to make them easier to manage in later stages of analysis and visualization.  
The ReconTraj4 Drones framework uses a set of geo-tagged photos as input. Each photo is characterized as a (recording) point of the trajectory, providing information about the latitude, longitude, and timestamp of that point (position). Subsequently, putting these photos in chronological order, the drone's trajectory can be reconstructed. The number and the time interval between these photos define the accuracy of the reconstructed trajectory. Typically, a geo-tagged photo not only provides spatiotemporal data (latitude, longitude, timestamp), but may also provide further valuable information about the altitude of the drone, the maker and the model of the carried camera, its focal length, etc. To acquire the drone's movement data, we extracted the spatiotemporal data that are necessary for the reconstruction of raw trajectories. We also extracted data about the altitude at each point (photo), the file itself, such as its title, storage path, size, and format, and finally, the data about the drone's camera, such as the maker and the model. The latter gave us more information about the flight and were used in the next stages of trajectory analytics  
Figure 3: High-level architectural design of ReconTraj4 Drones framework.  
and visualization. Because MovingPandas handles trajectories as DataFrames, these were stored as a DataFrame as well. Figure 4 depicts the form of a DataFrame.  
Part of the reconstruction phase concerns the compression of the input data (photos). Typically, drones are equipped with high-resolution cameras that take high-quality photos during their flights. As a result, the size of the photos is quite large, making them difficult to use in the trajectory visualization phase. Moreover, the use of such large photos makes the visualization unreadable for the end users. To solve this problem, we resized the input photos to dimensions equal to 250 px \(\times\) 250 px. Algorithm 1 outlines the logic of the trajectory reconstruction module.  
Having extracted the necessary movement data from the photos, it is possible to create the raw trajectory using the functionality provided by MovingPandas. Then, it is possible to use the additional functionalities of MovingPandas, such as visualization, stop detection, trajectory smoother, etc. Last, but not least, it is possible to export the extracted metadata in the form of a CSV file. Thus, taking advantage of the corresponding functionality of MovingPandas, in the future, we can create the same trajectory using the CSV file without repeating the whole reconstruction process.  
```
0: a set (folder) of geo-tagged images and a selection of data exported to csv
0: a (raw) trajectory and a csv file
1:traj_data = []
2:images = get_images(folder_name)
3:forachimage \(\in\) imagesdo
4:point = extract the metadata of the image
5: transform the coordinates in decimal degree format
6: append the point into traj_data;
7:endfor
8:resize_images(images)
9:ifextract_to_csv = True then
10:create_csv(traj_data)
11:endif
12:df = create a DataFrame(traj_data) using Pandas
13:geo_df = create a GeoDataFrame(df) using geoPandas
14:trajectory = create a Trajectory(geo_df, 1) using MovingPandas
15:return trajectory
```  
**Algorithm 1**Trajectory Reconstruction