import sys import networkx as nx import numpy as np from graph import tools sys.path.extend(["../"]) # Joint index: # {0, "Nose"} # {1, "Neck"}, # {2, "RShoulder"}, # {3, "RElbow"}, # {4, "RWrist"}, # {5, "LShoulder"}, # {6, "LElbow"}, # {7, "LWrist"}, # {8, "RHip"}, # {9, "RKnee"}, # {10, "RAnkle"}, # {11, "LHip"}, # {12, "LKnee"}, # {13, "LAnkle"}, # {14, "REye"}, # {15, "LEye"}, # {16, "REar"}, # {17, "LEar"}, # Edge format: (origin, neighbor) num_node = 18 self_link = [(i, i) for i in range(num_node)] inward = [ (4, 3), (3, 2), (7, 6), (6, 5), (13, 12), (12, 11), (10, 9), (9, 8), (11, 5), (8, 2), (5, 1), (2, 1), (0, 1), (15, 0), (14, 0), (17, 15), (16, 14), ] outward = [(j, i) for (i, j) in inward] neighbor = inward + outward class Graph: def __init__(self, labeling_mode="spatial"): self.A = self.get_adjacency_matrix(labeling_mode) self.num_node = num_node self.self_link = self_link self.inward = inward self.outward = outward self.neighbor = neighbor def get_adjacency_matrix(self, labeling_mode=None): if labeling_mode is None: return self.A if labeling_mode == "spatial": A = tools.get_spatial_graph(num_node, self_link, inward, outward) else: raise ValueError() return A if __name__ == "__main__": A = Graph("spatial").get_adjacency_matrix() print("")