(Track_Traj, Obj_info, Track_Visibility, height, width, video_np, dot_radius, max_step_num, region_box=None, name="")
| 125 | |
| 126 | |
| 127 | def visualize_motion(Track_Traj, Obj_info, Track_Visibility, height, width, video_np, dot_radius, max_step_num, region_box=None, name=""): |
| 128 | |
| 129 | |
| 130 | # Convert Track_Traj to the data form of (temporal, object, points, xy) |
| 131 | train_frame_num = 49 |
| 132 | if max_step_num > 1: |
| 133 | iter_gap = 1 |
| 134 | else: |
| 135 | iter_gap = 1 |
| 136 | |
| 137 | |
| 138 | |
| 139 | # Draw the Region Box Area |
| 140 | if region_box is not None: |
| 141 | _, (top_left_x, top_left_y), (bottom_right_x, bottom_right_y) = region_box |
| 142 | new_video_np = [] |
| 143 | for frame_idx, frame in enumerate(video_np): |
| 144 | new_video_np.append(cv2.rectangle(frame.copy(), (top_left_x, top_left_y), (bottom_right_x, bottom_right_y), (255, 0, 0), 5)) |
| 145 | video_np = np.array(new_video_np) |
| 146 | |
| 147 | |
| 148 | # Read the basic info |
| 149 | text_name, original_start_frame_idx, fps_scale = Obj_info # This is expected to be all the same in the video |
| 150 | downsample_panoptic_frame_idx = int(fps_scale * original_start_frame_idx) |
| 151 | |
| 152 | # Prepare the tracjectory |
| 153 | pred_tracks = Track_Traj |
| 154 | visibility_tracks = Track_Visibility |
| 155 | |
| 156 | # Fetch the ideal range needed and Convert to the full_pred_tracks data structure |
| 157 | selected_frames = video_np[downsample_panoptic_frame_idx : downsample_panoptic_frame_idx + iter_gap * train_frame_num : iter_gap] |
| 158 | pred_tracks = pred_tracks[downsample_panoptic_frame_idx : downsample_panoptic_frame_idx + iter_gap * train_frame_num : iter_gap] |
| 159 | visibility_tracks = visibility_tracks[downsample_panoptic_frame_idx : downsample_panoptic_frame_idx + iter_gap * train_frame_num : iter_gap] |
| 160 | if len(pred_tracks) != train_frame_num: |
| 161 | raise Exception("The len of pre_track does not match") |
| 162 | |
| 163 | # Change the dim form to be usable in the following traj cases |
| 164 | full_pred_tracks = [[] for _ in range(train_frame_num)] # The dim should be: (temporal, object, points, xy) The fps should be fixed to 12 fps, which is the same as training decode fps |
| 165 | full_visibility_tracks = [[] for _ in range(train_frame_num)] |
| 166 | for temporal_idx, pred_track in enumerate(pred_tracks): |
| 167 | full_pred_tracks[temporal_idx].append(pred_track) # pred_tracks will be 49 frames, and each one represent all tracking points for single objects; only one object here |
| 168 | full_visibility_tracks[temporal_idx].append(visibility_tracks[temporal_idx]) |
| 169 | |
| 170 | |
| 171 | # Call the Drawing function |
| 172 | prepare_traj_visual(full_pred_tracks, full_visibility_tracks, height, width, selected_frames, dot_radius, width, height, name = name) |
| 173 | |
| 174 | |
| 175 |
nothing calls this directly
no test coverage detected