MCPcopy Create free account
hub / github.com/MediaBrain-SJTU/MemoNet / visualize_data

Method visualize_data

ETH/data/map.py:194–223  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

192
193
194 def visualize_data(self, data):
195 pre_motion = np.stack(data['pre_motion_3D']) * data['traj_scale']
196 fut_motion = np.stack(data['fut_motion_3D']) * data['traj_scale']
197 heading = data['heading']
198 img = np.transpose(self.data, (1, 2, 0))
199 for i in range(pre_motion.shape[0]):
200 cur_pos = pre_motion[i, -1]
201 # draw agent
202 cur_pos = np.round(self.to_map_points(cur_pos)).astype(int)
203 img = cv2.circle(img, (cur_pos[1], cur_pos[0]), 3, (0, 255, 0), -1)
204 prev_pos = cur_pos
205 # draw fut traj
206 for t in range(fut_motion.shape[0]):
207 pos = fut_motion[i, t]
208 pos = np.round(self.to_map_points(pos)).astype(int)
209 img = cv2.line(img, (prev_pos[1], prev_pos[0]), (pos[1], pos[0]), (0, 255, 0), 2)
210
211 # draw heading
212 theta = heading[i]
213 v= np.array([5.0, 0.0])
214 v_new = v.copy()
215 v_new[0] = v[0] * np.cos(theta) - v[1] * np.sin(theta)
216 v_new[1] = v[0] * np.sin(theta) + v[1] * np.cos(theta)
217 vend = pre_motion[i, -1] + v_new
218 vend = np.round(self.to_map_points(vend)).astype(int)
219 img = cv2.line(img, (cur_pos[1], cur_pos[0]), (vend[1], vend[0]), (0, 255, 255), 2)
220
221 fname = f'out/agent_maps/{data["seq"]}_{data["frame"]}_vis.png'
222 os.makedirs(os.path.dirname(fname), exist_ok=True)
223 cv2.imwrite(fname, img)
224

Callers

nothing calls this directly

Calls 1

to_map_pointsMethod · 0.95

Tested by

no test coverage detected