Beispiel #1
0
    def get_affective_features(data):
        # 0: root,              1: left_hip,        2: left_knee,   3: left_heel,           4: left_toe,
        # 5: right_hip,         6: right_knee,      7: right_heel,  8: right_toe,
        # 9: lower_back,        10: spine,          11: neck,       12: head,
        # 13: left_shoulder,    14: left_elbow,     15: left_hand,  16: left_hand_index,
        # 17: right_shoulder,   18: right_elbow,    19: right_hand, 20: right_hand_index

        affs_dim = 18

        _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10,\
        _11, _12, _13, _14, _15, _16, _17, _18, _19, _20 = MocapDataset.get_joints(data)

        affective_features = np.zeros(data.shape[:-2] + (affs_dim,))
        fidx = 0
        affective_features[..., fidx] = common.angle_between_points(_17, _9, _13)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_19, _9, _15)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_16, _11) / common.dist_between(_16, _0)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_20, _11) / common.dist_between(_20, _0)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_16, _20) / common.dist_between(_11, _0)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_17, _9, _13) / common.area_of_triangle(_17, _0, _13)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_19, _9, _15) / common.area_of_triangle(_19, _0, _15)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_13, _14, _15)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_17, _18, _19)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_12, _11, _13)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_12, _11, _17)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_12, _0, _2)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_12, _0, _6)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_4, _8) / common.dist_between(_11, _0)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_8, _0, _4)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_1, _2, _3)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_5, _6, _7)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_20, _11, _16) / common.area_of_triangle(_8, _0, _4)
        fidx += 1

        return np.nan_to_num(affective_features)
Beispiel #2
0
    def get_mpi_affective_features(data):
        # 0: root,          1: chest,           2: chest2,          3: chest3,
        # 4: chest4,        5: neck,            6: head,
        # 7: left_collar,   8: left_shoulder,   9: left_elbow,      10: left_wrist,
        # 11: right_collar, 12: right_shoulder, 13: right_elbow,    14: right_wrist,
        # 15: left_hip,     16: left_knee,      17: left_heel,      18: left_toe,
        # 19: right_hip,    20: right_knee,     21: right_heel,     22: right_toe

        affs_dim = 15

        if type(data).__module__ != np.__name__:
            data_np = data.detach().cpu().numpy()
        else:
            data_np = data
        _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12,\
        _13, _14, _15, _16, _17, _18, _19, _20, _21, _22 = MocapDataset.get_mpi_joints(data_np)

        affective_features = np.zeros(data_np.shape[:-2] + (affs_dim,))
        fidx = 0
        affective_features[..., fidx] = common.angle_between_points(_0, _2, _6) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_9, _4, _6) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_13, _4, _6) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_0, _10, _4) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_0, _14, _4) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_8, _9, _10) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_12, _13, _14) / np.pi
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_10, _0) / common.dist_between(_10, _4)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_10, _0) / common.dist_between(_10, _6)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_14, _0) / common.dist_between(_14, _4)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_14, _0) / common.dist_between(_14, _6)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(_10, _14) / common.dist_between(_0, _6)
        fidx += 1
        affective_features[..., fidx] = common.area_of_triangle(_10, _0, _14) / common.area_of_triangle(_10, _4, _14)
        fidx += 1
        affective_features[..., fidx] = common.area_of_triangle(_6, _10, _0) / common.area_of_triangle(_6, _14, _0)
        fidx += 1
        affective_features[..., fidx] = common.area_of_triangle(_4, _10, _0) / common.area_of_triangle(_4, _14, _0)
        fidx += 1

        affective_features = np.nan_to_num(affective_features)
        if type(data).__module__ != np.__name__:
            affective_features = torch.from_numpy(affective_features).cuda()
        return affective_features
    def get_affective_features(data):
        # 0: hips,
        # 1: left_hip_joint,        2: left_up_leg,         3: left_leg,        4: left_foot,   5: left_toe_base,
        # 6: right_hip_joint,       7: right_up_leg,        8: right_leg,       9: right_foot,  10: right_toe_base,
        # 11: lower_back,           12: spine,              13: spine1,
        # 14: neck,                 15: neck1,              16: head,
        # 17: left_shoulder,        18: left_arm,           19: left_forearm,   20: left_hand,
        # 21: left_finger_base,     22: left_hand_index1,   23: left_thumb,
        # 24: right_shoulder,       25: right_arm,          26: right_forearm,  27: right_hand,
        # 28: right_finger_base,    29: right_hand_index1,  30: right_thumb,

        affs_dim = 18

        _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\
        _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30 = MocapDataset.get_joints(data)

        affective_features = np.zeros(data.shape[:-2] + (affs_dim, ))
        fidx = 0
        affective_features[...,
                           fidx] = common.angle_between_points(_25, _12, _18)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_27, _12, _20)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(
            _22, _15) / common.dist_between(_22, _0)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(
            _29, _15) / common.dist_between(_29, _0)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(
            _22, _29) / common.dist_between(_15, _0)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_25, _12, _18) / common.area_of_triangle(_25, _0, _18)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_27, _12, _20) / common.area_of_triangle(_27, _0, _20)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_18, _19, _20)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_25, _26, _27)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_16, _15, _18)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_16, _15, _25)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_16, _0, _3)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_16, _0, _8)
        fidx += 1
        affective_features[..., fidx] = common.dist_between(
            _5, _10) / common.dist_between(_15, _0)
        fidx += 1
        affective_features[...,
                           fidx] = common.angle_between_points(_10, _0, _5)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_2, _3, _4)
        fidx += 1
        affective_features[..., fidx] = common.angle_between_points(_7, _8, _9)
        fidx += 1
        affective_features[..., fidx] = \
            common.area_of_triangle(_29, _15, _22) / common.area_of_triangle(_10, _0, _5)
        fidx += 1

        return np.nan_to_num(affective_features)