text stringlengths 0 93.6k |
|---|
trans_scene2cano_list = saved_data['trans_scene2cano_list'] |
n_seq = len(rec_ric_data_noisy_list) |
clip_len_rec = rec_ric_data_noisy_list.shape[1] |
print('n_seq:', n_seq) |
print('clip_len_rec:', clip_len_rec) |
joints_gt_scene_coord_list = joints_gt_scene_coord_list[:, 0:clip_len_rec] if args.dataset == 'egobody' else None |
################ get contact lbls |
contact_lbl_rec_list = motion_repr_rec_list[:, :, -4:] # np, [n_seq, clip_len, 4] |
contact_lbl_rec_list[contact_lbl_rec_list > 0.5] = 1.0 |
contact_lbl_rec_list[contact_lbl_rec_list <= 0.5] = 0.0 |
################### transform back to scene coord |
for seq_idx in range(n_seq): |
cur_joints_scene_coord = points_coord_trans(rec_ric_data_noisy_list[seq_idx].reshape(-1, 3), np.linalg.inv(trans_scene2cano_list[seq_idx])) |
rec_ric_data_noisy_list[seq_idx] = cur_joints_scene_coord.reshape(clip_len_rec, 22, 3) |
cur_joints_scene_coord = points_coord_trans(rec_ric_data_rec_list_from_smpl[seq_idx].reshape(-1, 3), np.linalg.inv(trans_scene2cano_list[seq_idx])) |
rec_ric_data_rec_list_from_smpl[seq_idx] = cur_joints_scene_coord.reshape(clip_len_rec, 22, 3) |
############################### skating ratio |
thresh_height = 0.10 |
thresh_vel = 0.10 |
fps = 30 |
foot_joint_index_list = [7, 10, 8, 11] # contact lbl dim order: 7, 10, 8, 11, left ankle, toe, right angle, toe |
joints_foot_rec = rec_ric_data_rec_list_from_smpl[:, :, foot_joint_index_list, :] # [n_seq, clip_len, 2, 3] |
if args.dataset == 'prox': |
# prox scene coord up axis is z |
ground_height = prox_floor_height[scene_name] |
joints_feet_horizon_vel_rec = np.linalg.norm(joints_foot_rec[:, 1:, :, [0, 1]] - joints_foot_rec[:, :-1, :, [0, 1]], axis=-1) * fps # [n_seq, clip_len, 2] |
joints_feet_height_rec = joints_foot_rec[:, 0:-1, :, 2] # [n_seq, clip_len, 2] |
elif args.dataset == 'egobody': |
# egobody scene coord up axis is y |
ground_height = egobody_floor_height[scene_name] |
joints_feet_horizon_vel_rec = np.linalg.norm(joints_foot_rec[:, 1:, :, [0, 2]] - joints_foot_rec[:, :-1, :, [0, 2]], axis=-1) * fps |
joints_feet_height_rec = joints_foot_rec[:, 0:-1, :, 1] |
joints_feet_height_rec = joints_feet_height_rec - ground_height |
skating_rec_left = (joints_feet_horizon_vel_rec[:, :, 0] > thresh_vel) * (joints_feet_horizon_vel_rec[:, :, 1] > thresh_vel) * \ |
(joints_feet_height_rec[:, :, 0] < (thresh_height + 0.05)) * (joints_feet_height_rec[:, :, 1] < thresh_height) |
skating_rec_right = (joints_feet_horizon_vel_rec[:, :, 2] > thresh_vel) * (joints_feet_horizon_vel_rec[:, :, 3] > thresh_vel) * \ |
(joints_feet_height_rec[:, :, 2] < (thresh_height + 0.05)) * (joints_feet_height_rec[:, :, 3] < thresh_height) |
skating_rec = skating_rec_left * skating_rec_right # [n_clip, 142] |
if recording_name not in skating_list.keys(): |
skating_list[recording_name] = [] |
skating_list[recording_name].append(skating_rec) |
else: |
skating_list[recording_name].append(skating_rec) |
########################### acceleration metrics |
acc_rec = (rec_ric_data_rec_list_from_smpl[:, 2:] - 2 * rec_ric_data_rec_list_from_smpl[:, 1:-1] + rec_ric_data_rec_list_from_smpl[:, :-2]) * (fps ** 2) # [n_clip, 141, 22, 3] |
if args.dataset == 'egobody': |
acc_gt = (joints_gt_scene_coord_list[:, 2:] - 2 * joints_gt_scene_coord_list[:, 1:-1] + joints_gt_scene_coord_list[:, :-2]) * (fps ** 2) |
acc_error = np.linalg.norm(acc_rec - acc_gt, axis=-1).mean(axis=-1) |
acc_rec = np.linalg.norm(acc_rec, axis=-1).mean(axis=-1) # [n_clip, 141] |
if recording_name not in acc_error_list.keys(): |
acc_list[recording_name] = [] |
acc_list[recording_name].append(acc_rec) |
if args.dataset == 'egobody': |
acc_error_list[recording_name] = [] |
acc_error_list[recording_name].append(acc_error) |
else: |
acc_list[recording_name].append(acc_rec) |
acc_error_list[recording_name].append(acc_error) if args.dataset == 'egobody' else None |
########################### mpjpe metrics |
if args.dataset == 'egobody': |
if recording_name not in joint_mask_list.keys(): |
joint_mask_list[recording_name] = [] |
joint_mask_list[recording_name].append(mask_joint_vis_list) |
else: |
joint_mask_list[recording_name].append(mask_joint_vis_list) |
joints_mpjpe_global = np.linalg.norm(joints_gt_scene_coord_list - rec_ric_data_rec_list_from_smpl, axis=-1) # [n_seq, clip_len, 22] |
joints_mpjpe_local = np.linalg.norm((joints_gt_scene_coord_list - joints_gt_scene_coord_list[:, 0:clip_len_rec, [0]]) - |
(rec_ric_data_rec_list_from_smpl - rec_ric_data_rec_list_from_smpl[:, :, [0]]), axis=-1) |
joints_mpjpe_local_vis = joints_mpjpe_local * mask_joint_vis_list |
joints_mpjpe_local_invis = joints_mpjpe_local * (1 - mask_joint_vis_list) |
if recording_name not in gmpjpe_list.keys(): |
gmpjpe_list[recording_name] = [] |
gmpjpe_list[recording_name].append(joints_mpjpe_global) |
mpjpe_list[recording_name] = [] |
mpjpe_list_vis[recording_name] = [] |
mpjpe_list_occ[recording_name] = [] |
mpjpe_list[recording_name].append(joints_mpjpe_local) |
mpjpe_list_vis[recording_name].append(joints_mpjpe_local_vis) |
mpjpe_list_occ[recording_name].append(joints_mpjpe_local_invis) |
else: |
gmpjpe_list[recording_name].append(joints_mpjpe_global) |
mpjpe_list[recording_name].append(joints_mpjpe_local) |
mpjpe_list_vis[recording_name].append(joints_mpjpe_local_vis) |
mpjpe_list_occ[recording_name].append(joints_mpjpe_local_invis) |
########################### ground penetration metrics |
if args.dataset == 'egobody': |
pene_dist = rec_ric_data_rec_list_from_smpl[:, :, [10, 11], 1] - ground_height # [n_clip, 143, 2] |
elif args.dataset == 'prox': |
pene_dist = rec_ric_data_rec_list_from_smpl[:, :, [10, 11], 2] - ground_height |
pene_freq = pene_dist < -0.05 # [clip_len] |
pene_freq = pene_freq.mean(axis=-1) # [n_clip, 143] |
pene_dist[pene_dist >= 0] = 0 |
pene_dist = pene_dist.mean(axis=-1) # [n_clip, 143] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.