MCPcopy Create free account
hub / github.com/UVA-Computer-Vision-Lab/FrameINO / visualize_track

Function visualize_track

evaluation/evaluate_INO_Traj.py:29–64  ·  view source on GitHub ↗
(frames, pred_tracks, instance_idx, dot_radius_resize = 6)

Source from the content-addressed store, hash-verified

27
28
29def visualize_track(frames, pred_tracks, instance_idx, dot_radius_resize = 6):
30
31 # Define the color code
32 all_color_codes = [(255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 255, 255),
33 (255, 0, 255), (0, 0, 255), (128, 128, 128), (64, 224, 208),
34 (233, 150, 122)]
35 for _ in range(100): # Should not be over 100 colors
36 all_color_codes.append((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
37
38
39 # Prediction Tracks
40 drawn_frames = []
41 for frame_idx in range(len(pred_tracks)):
42 frame = frames[frame_idx].copy()
43 original_height, original_width, _ = frame.shape
44
45 for points_idx in range(len(pred_tracks[0])):
46 coord = (pred_tracks[frame_idx, points_idx, 0], pred_tracks[frame_idx, points_idx, 1])
47
48 if coord[0] != 0 and coord[1] != 0:
49
50 # Prepare
51 color_code = all_color_codes[points_idx % len(all_color_codes)]
52 horizontal, vertical = coord
53
54 # Draw square around the target position
55 vertical_start = min(original_height, max(0, vertical - dot_radius_resize))
56 vertical_end = min(original_height, max(0, vertical + dot_radius_resize)) # Diameter, used to be 10, but want smaller if there are too many points now
57 horizontal_start = min(original_width, max(0, horizontal - dot_radius_resize))
58 horizontal_end = min(original_width, max(0, horizontal + dot_radius_resize))
59
60 frame[vertical_start:vertical_end, horizontal_start:horizontal_end, :] = color_code
61
62 drawn_frames.append(frame)
63
64 imageio.mimsave("merge_visual" + str(instance_idx) + ".mp4", drawn_frames, fps=12)
65
66
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected