I have 2 sequences:
- One is a videoclip with the image taken by a drone's camera
- The other is a file with a list of chronological data from the sensors
time 0: speed_x=1, latitude=0.001, longitude=0.2, altitude=40 time 112: speed_x=3, latitude=0.0021, longitude=0.221, altitude=30 time 232: speed_x=3, latitude=0.0021, longitude=0.221, altitude=35 time 425: speed_x=3.1, latitude=0.0024, longitude=0.222, altitude=40 …
*time comes in milliseconds
I have created an application that plays the video (that's the easy part) but I want to display information about the flight at a given position of the video.
The problem is that, in order to display the sensor data at a given position of the video (at a given time), I would have to traverse the list of sensor data in order to find the sensor data that is closer to that position
If the video is showing the frame at 150 milliseconds, and in the list of sensor data I have these items in the list of the sensor data:
time 0: time 90: … time 120: … time 200: … time 230: …
Then, I should choose to show the sensor data at the item with
time=120, because it's the one that is closer to 150 ms.
I can do a lookup algorithm to do the lookup, but I will be really inefficient to traverse the whole list of data from the sensors calculating distances and choosing the one with the minimum distance.
So, I thought about creating some kind of dictionary/hash table that, given a position in the video, it would retrieve the appropriate sensor data.
However, I have never created suck lookup data structure. I don't even know it it's feasible! I have used dictionaries and hash tables that given a discrete key, a result is obtained. But in my case, I have a virtually infinite set of values that will result in the same item.
Can you, please, tell me how to solve this problem?