MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / checklandmarks

Function checklandmarks

utils/checkconnection.py:15–89  ·  view source on GitHub ↗
(edges, landmarks, weights, rgbs, N, M)

Source from the content-addressed store, hash-verified

13 return max_frame, num_valid_frames, frame_index
14
15def checklandmarks(edges, landmarks, weights, rgbs, N, M):
16 # delete and reindex the frames that contains zero landmarks
17 # Note: change the thereshold higher if you do not get good result, e.g. IMC gate
18 max_frame, N, indices_frame = delete_thereshold(10, N, edges[:,0]-1)
19
20 # exchange the first frame
21 if indices_frame[max_frame] != 0:
22 indices_frame[indices_frame == 0] = indices_frame[max_frame]
23 indices_frame[max_frame] = 0
24
25 indices_all = indices_frame.copy()
26 edges[:,0] = indices_frame[edges[:,0]-1].copy() + 1
27 # delete the row that edges contain -1
28 indices = np.any(edges == 0, axis=1)
29 edges = edges[~indices]
30 weights = weights[~indices]
31 landmarks = landmarks[~indices]
32 rgbs = rgbs[~indices]
33
34 # delete and reindex the landmarks that contains one frame
35 # Note: change the thereshold higher if you do not get good result, e.g. IMC gate
36 _, M, indices_landmarks = delete_thereshold(1, M, edges[:,1]-1)
37 edges[:,1] = indices_landmarks[edges[:,1]-1].copy() + 1
38 # delete the row that edges contain -1
39 indices = np.any(edges == 0, axis=1)
40 edges = edges[~indices]
41 weights = weights[~indices]
42 rgbs = rgbs[~indices]
43 landmarks = landmarks[~indices]
44
45 max_frame, N, indices_frame = delete_thereshold(0, N, edges[:,0]-1)
46 edges[:,0] = indices_frame[edges[:,0]-1].copy() + 1
47
48 N_old = np.where(indices_all > -1)[0].shape[0]
49 indices_all_copy = indices_all.copy()
50 for i in range(N_old):
51 indices_all[np.where(indices_all_copy == i)[0]] = indices_frame[i]
52 # delete the row that edges contain -1
53 indices = np.any(edges == 0, axis=1)
54 edges = edges[~indices]
55 weights = weights[~indices]
56 landmarks = landmarks[~indices]
57 rgbs = rgbs[~indices]
58
59 G = nx.Graph()
60 for u, v in edges:
61 G.add_edge(u, v + N)
62 components = list(nx.connected_components(G))
63 print("Number of connected components: ", len(components))
64 largest_component = max(components, key=len)
65 largest_component_set = set(largest_component)
66 filtered_indices = [
67 i for i, (u, v) in enumerate(edges)
68 if u in largest_component_set and (v + N) in largest_component_set
69 ]
70 filtered_indices = np.array(filtered_indices)
71 if filtered_indices.shape[0] < edges.shape[0]:
72 print("Not connected, Choose Largest Component")

Callers 3

4_test_unidepth.pyFile · 0.90
5_test_ceres.pyFile · 0.90

Calls 2

copyMethod · 0.80
delete_theresholdFunction · 0.70

Tested by

no test coverage detected