1
+ import math
1
2
import pickle
2
3
import re
3
4
from collections import defaultdict
8
9
import numpy as np
9
10
import cv2
10
11
12
+ activity2id = {
13
+ "BG" : 0 , # background
14
+ "activity_walking" : 1 ,
15
+ "activity_standing" : 2 ,
16
+ "activity_carrying" : 3 ,
17
+ "activity_gesturing" : 4 ,
18
+ "Closing" : 5 ,
19
+ "Opening" : 6 ,
20
+ "Interacts" : 7 ,
21
+ "Exiting" : 8 ,
22
+ "Entering" : 9 ,
23
+ "Talking" : 10 ,
24
+ "Transport_HeavyCarry" : 11 ,
25
+ "Unloading" : 12 ,
26
+ "Pull" : 13 ,
27
+ "Loading" : 14 ,
28
+ "Open_Trunk" : 15 ,
29
+ "Closing_Trunk" : 16 ,
30
+ "Riding" : 17 ,
31
+ "specialized_texting_phone" : 18 ,
32
+ "Person_Person_Interaction" : 19 ,
33
+ "specialized_talking_phone" : 20 ,
34
+ "activity_running" : 21 ,
35
+ "PickUp" : 22 ,
36
+ "specialized_using_tool" : 23 ,
37
+ "SetDown" : 24 ,
38
+ "activity_crouching" : 25 ,
39
+ "activity_sitting" : 26 ,
40
+ "Object_Transfer" : 27 ,
41
+ "Push" : 28 ,
42
+ "PickUp_Person_Vehicle" : 29 ,
43
+ }
44
+
11
45
12
46
def get_person_box_at_frame (tracking_results , target_frame_idx ):
13
47
"""Get all the box from the tracking result at frameIdx."""
@@ -86,12 +120,11 @@ def visualise(args):
86
120
with open (args .pred_path , "rb" ) as f :
87
121
pred_data = pickle .load (f )
88
122
pred_data = {
89
- k : v for k , v in pred_data .items () if k in ['obs_list' , 'pred_gt_list' , 'pred_list' ]
123
+ k : v for k , v in pred_data .items () if k in ['seq_ids' , ' obs_list' , 'pred_gt_list' , 'pred_list' , 'pred_act ' ]
90
124
}
91
125
92
126
video_dict = get_video_dict (pred_data )
93
-
94
- del pred_data ['act_pred_list' ]
127
+ id2activity = {v :k for k ,v in activity2id .items ()}
95
128
for video_name in video_dict :
96
129
video_file = os .path .join (args .video_base , video_name + '.mp4' )
97
130
@@ -117,7 +150,7 @@ def visualise(args):
117
150
#
118
151
#
119
152
# print(seq_id, video_meta)
120
- cur_frame = - 1
153
+ cur_frame = - 8 * args . drop_frame
121
154
next_signal = False
122
155
while cur_frame < video_meta ["frame_count" ]:
123
156
cur_frame += 1
@@ -131,15 +164,21 @@ def visualise(args):
131
164
132
165
for idx in filter_pred (video_pred_data , video_name + f'_{ cur_frame } _+' ):
133
166
seq_id = video_pred_data ['seq_ids' ][idx ]
134
- obs_traj = video_pred_data ['obs_traj_list' ][idx ]
135
- pred_traj = video_pred_data ['pred_traj_list' ][idx ]
136
- gt_traj = video_pred_data ['gt_traj_list' ][idx ]
137
-
167
+ obs_traj = video_pred_data ['obs_list' ][idx ]
168
+ pred_traj = video_pred_data ['pred_list' ][idx ]
169
+ gt_traj = video_pred_data ['pred_gt_list' ][idx ]
170
+ # pred_act =sigmoid(np.array( video_pred_data['pred_act'][idx] * 20 ))
171
+ pred_act = video_pred_data ['pred_act' ][idx ]
138
172
frame = cv2 .resize (frame , (1920 , 1080 ))
139
173
frame = plot_traj (frame , obs_traj , (255 , 0 , 0 ))
140
174
frame = plot_traj (frame , pred_traj , (0 , 255 , 0 ))
141
175
frame = plot_traj (frame , gt_traj , (0 , 0 , 255 ))
176
+ act_ids = np .nonzero ( pred_act > 0.7 )[0 ]
177
+ print (act_ids )
178
+ msg = ',' .join ([id2activity [id ] for id in act_ids ])
142
179
180
+ frame = cv2 .putText (frame ,msg , (int (obs_traj [- 1 ,0 ]), int (obs_traj [- 1 ,1 ])),cv2 .FONT_HERSHEY_SIMPLEX ,
181
+ 1 , (255 , 0 , 0 ), 1 , cv2 .LINE_AA )
143
182
# center = obs_traj[-1].astype("int")
144
183
# frame = frame[center[1] - 200: center[1] + 200, center[0] - 200: center[0] + 200]
145
184
frame = cv2 .putText (frame , video_name + ' ' + 'frame ' + str (cur_frame ), (30 ,30 ), cv2 .FONT_HERSHEY_SIMPLEX ,
0 commit comments