# Dynamic Queries through Augmented Reality for Intelligent Video Systems
## 3 Querying Trajectories  
Query information is a process in which we seek to know the similarity between a reference and a data repository that allows us to simplify analysis in search of patterns or behaviors of interest. The process for performing the trajectory query depends on three essential factors: the trajectory that serves as a reference, the data repository that contains historical information, and a similarity measure.  
In this work, to carry out queries, the generation of reference trajectories was compared with a data repository to determine the most similar ones and to be able to visualize them.  
The generation of the reference trajectories was carried out from an augmented reality application in the global space. In this sense, a user generates a temporal trajectory from the application installed on a device (in this case, a tablet gadget); however, it is not exclusive to that device since devices with API 5.0 of the Android operating system or higher can run the application.  
The application was developed in Unity3D, where all the trajectories of the moving objects were mapped to global space. Figure 7 shows, in a general way, how the application works. First, the reference trajectory was created in global space, as shown in Figure 8, and then the trajectory information was sent to a central unit that contains the data repository of the homogenized trajectories. In the same main unit, all the processing was carried out to calculate the similarity between the trajectories and to send the resulting information back to the application for viewing in the space where the information was acquired, that is, a client-server model was generated to send the data from the application to the central unit in both directions.  
It is necessary to take into account the different aspects of carrying out querying and displaying the results through augmented reality, the first of which is that all the information obtained is in a known space where the information can be recovered. This allows for the creation of temporal reference information and a metric through which to estimate the similarity between the information.  
By generating a global space where homogenized trajectories are represented, it is possible to propose a new metric to obtain similarities. For this, you can define a three-tuple as follows:  
\[R=\{GlobalSpace,Reference,Metric\},\]  
where \(GlobalSpace\) contains all the trajectories, in real coordinates, and is expressed in centimeters. \(Reference\) is the reference trajectory created from the global space generated. This is temporary information that is used for comparison with all the trajectories stored  
Figure 6: The trajectories in global space. The colored dots represent the different real trajectories generated by the objects of interest mapped to the global space.  
in the data repository with those that define the similarity. \(Metric\) is the metric applied to order the information contained in the data repository in order to visualize the results that are more similar to the reference. Finally, \(R\) is a matrix that includes the trajectories sorted to start from the reference and the applied metric.