MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / associate

Function associate

eval_code/recons/datasets/preprocess/prepare_tum.py:30–61  ·  view source on GitHub ↗

Associate two dictionaries of (stamp, data). As the time stamps never match exactly, we aim to find the closest match for every input tuple. Input: first_list -- first dictionary of (stamp, data) tuples second_list -- second dictionary of (stamp, data) tuples offset --

(first_list, second_list, offset, max_difference)

Source from the content-addressed store, hash-verified

28 return dict(list)
29
30def associate(first_list, second_list, offset, max_difference):
31 """
32 Associate two dictionaries of (stamp, data). As the time stamps never match exactly, we aim
33 to find the closest match for every input tuple.
34
35 Input:
36 first_list -- first dictionary of (stamp, data) tuples
37 second_list -- second dictionary of (stamp, data) tuples
38 offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
39 max_difference -- search radius for candidate generation
40
41 Output:
42 matches -- list of matched tuples ((stamp1, data1), (stamp2, data2))
43 """
44 # Convert keys to sets for efficient removal
45 first_keys = set(first_list.keys())
46 second_keys = set(second_list.keys())
47
48 potential_matches = [(abs(a - (b + offset)), a, b)
49 for a in first_keys
50 for b in second_keys
51 if abs(a - (b + offset)) < max_difference]
52 potential_matches.sort()
53 matches = []
54 for diff, a, b in potential_matches:
55 if a in first_keys and b in second_keys:
56 first_keys.remove(a)
57 second_keys.remove(b)
58 matches.append((a, b))
59
60 matches.sort()
61 return matches
62
63dirs = glob.glob("data/tum/*/")
64dirs = sorted(dirs)

Callers 1

prepare_tum.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected