def getSequence(self): """ Gets the sequence """ nodes = self.nodes[0] edges = self.edges[0] numNodes = len(nodes.keys()) #해당 sequence에 나타나는 총 노드의 개수 # print("********************* numNodes {}***********".format(numNodes)) list_of_nodes = {} # print("seq: ", self.seq_length)#### seq_length = obs_length + pred_length retNodes = np.zeros((self.seq_length, numNodes, 2)) retEdges = np.zeros((self.seq_length, numNodes * numNodes, 2)) # Diagonal contains temporal edges retNodePresent = [[] for _ in range(self.seq_length) ] #c// Only, save the node ID and type retEdgePresent = [[] for _ in range(self.seq_length)] #c # retNodes_type = [[] for c in range(self.seq_length)] # retEdges_type = [[] for c in range(self.seq_length)] for i, ped in enumerate(nodes.keys()): list_of_nodes[ped] = i pos_list = nodes[ ped].node_pos_list #해당 노드의 sequence; { frame: (x,y), ... } for framenum in range(self.seq_length): if framenum in pos_list: retNodePresent[framenum].append((i, nodes[ped].getType())) retNodes[framenum, i, :] = list(pos_list[framenum]) # retNodes_type[framenum].append(nodes[ped].getType()) for ped, ped_other in edges.keys(): i, j = list_of_nodes[ped], list_of_nodes[ped_other] edge = edges[(ped, ped_other)] if ped == ped_other: # Temporal edge for framenum in range(self.seq_length): if framenum in edge.edge_pos_list: retEdgePresent[framenum].append((i, j, edge.getType())) retEdges[framenum, i * (numNodes) + j, :] = getVector( edge.edge_pos_list[framenum] ) # Gets the vector pointing from second element to first element else: # Spatial edge for framenum in range(self.seq_length): if framenum in edge.edge_pos_list: retEdgePresent[framenum].append((i, j, edge.getType())) retEdgePresent[framenum].append((j, i, edge.getType())) # the position returned is a tuple of tuples retEdges[framenum, i * numNodes + j, :] = getVector( edge.edge_pos_list[framenum]) retEdges[framenum, j * numNodes + i, :] = -np.copy( retEdges[framenum, i * (numNodes) + j, :]) # 어차피 마이너스 vector가 되므로. return retNodes, retEdges, retNodePresent, retEdgePresent
def getSequence(self): ''' Gets the sequence ''' nodes = self.nodes[0] edges = self.edges[0] numNodes = len(nodes.keys()) list_of_nodes = {} retNodes = np.zeros((self.seq_length, numNodes, 2)) retEdges = np.zeros((self.seq_length, numNodes * numNodes, 2)) # Diagonal contains temporal edges retNodePresent = [[] for c in range(self.seq_length)] retEdgePresent = [[] for c in range(self.seq_length)] #index and pedID for i, ped in enumerate(nodes.keys()): list_of_nodes[ped] = i #{pedID0:0,pedID1:1,...,} pos_list = nodes[ped].node_pos_list #{pedID:pos,...,} for framenum in range(self.seq_length): if framenum in pos_list: #append present Ped index in specific frame retNodePresent[framenum].append(i) retNodes[framenum, i, :] = list(pos_list[framenum]) for ped, ped_other in edges.keys(): # ped index i, j = list_of_nodes[ped], list_of_nodes[ped_other] edge = edges[(ped, ped_other)] if ped == ped_other: # Temporal edge for framenum in range(self.seq_length): #got data if framenum in edge.edge_pos_list: retEdgePresent[framenum].append((i, j)) retEdges[framenum, i * (numNodes) + j, :] = getVector( edge.edge_pos_list[framenum]) else: # Spatial edge for framenum in range(self.seq_length): if framenum in edge.edge_pos_list: retEdgePresent[framenum].append((i, j)) retEdgePresent[framenum].append((j, i)) # the position returned is a tuple of tuples retEdges[framenum, i * numNodes + j, :] = getVector( edge.edge_pos_list[framenum]) retEdges[framenum, j * numNodes + i, :] = -np.copy(retEdges[framenum, i * (numNodes) + j, :]) return retNodes, retEdges, retNodePresent, retEdgePresent
def getSequence(self): ''' Gets the sequence ''' nodes = self.nodes[0] edges = self.edges[0] numNodes = len(nodes.keys()) list_of_nodes = {} retNodes = np.zeros((self.seq_length, numNodes, 2)) retEdges = np.zeros((self.seq_length, numNodes * numNodes, 2)) # Diagonal contains temporal edges retNodePresent = [[] for c in range(self.seq_length)] retEdgePresent = [[] for c in range(self.seq_length)] # retObsNodes = np.zeros((self.seq_length,numNodes, 2)) # retObsEdges = np.zeros((self.seq_length,numNodes*numNodes, 2)) # retObsNodePresent = [[] for c in range(self.seq_length)] # retObsEdgePresent = [[] for c in range(self.seq_length)] for i, ped in enumerate(nodes.keys()): list_of_nodes[ped] = i pos_list = nodes[ped].node_pos_list for framenum in range(self.seq_length): if nodes[ped].node_type == 'H': if framenum in pos_list: retNodePresent[framenum].append(i) retNodes[framenum, i, :] = list(pos_list[framenum]) # elif nodes[ped].node_type == 'O': # if framenum in nodes[ped].obs_node_pos_list: # retObsNodePresent[framenum].append(i) # retObsNodes[framenum, i, :] = list(nodes[ped].obs_node_pos_list[framenum]) for ped, ped_other in edges.keys(): i, j = list_of_nodes[ped], list_of_nodes[ped_other] edge = edges[(ped, ped_other)] if ped == ped_other: # Temporal edge for framenum in range(self.seq_length): if framenum in edge.edge_pos_list: retEdgePresent[framenum].append((i, j)) retEdges[framenum, i * (numNodes) + j, :] = helper.getVector( edge.edge_pos_list[framenum]) else: # Spatial edge # Spatial edges are bi-directional and the opposite direction has negated values of positions for framenum in range(self.seq_length): if framenum in edge.edge_pos_list: # if edges.get((ped,ped_other)).edge_type == 'H-H/S': retEdgePresent[framenum].append((i, j)) retEdgePresent[framenum].append((j, i)) # the position returned is a tuple of tuples retEdges[framenum, i * numNodes + j, :] = helper.getVector( edge.edge_pos_list[framenum]) retEdges[framenum, j * numNodes + i, :] = -np.copy(retEdges[framenum, i * (numNodes) + j, :]) # elif framenum in edge.ped_obs_edge: # # if edges.get((ped,ped_other)).edge_type == 'H-O/S': # retObsEdgePresent[framenum].append((i,j)) # # retObsEdgePresent[framenum].append((j,i)) # retObsEdges[framenum, i*numNodes + j, :] = helper.getVector(edge.ped_obs_edge[framenum]) # retObsEdges[framenum, j*numNodes + i, :] = -np.copy(retObsEdges[framenum, i*(numNodes) + j, :]) return retNodes, retEdges, retNodePresent, retEdgePresent #, retObsNodes, retObsEdges ,retObsNodePresent , retObsEdgePresent