Example #1
0
def get_joints_info(num_joints):
    # Body+toe keypoints
    if num_joints == 19:
        joints_left = [5, 6, 7, 8, 13, 14, 15]
        joints_right = [1, 2, 3, 4, 16, 17, 18]

        h36m_skeleton = Skeleton(parents=[
            -1, 0, 1, 2, 3, 0, 5, 6, 7, 0, 9, 10, 11, 10, 13, 14, 10, 16, 17
        ],
                                 joints_left=[5, 6, 7, 8, 13, 14, 15],
                                 joints_right=[1, 2, 3, 4, 16, 17, 18])
    # Body keypoints
    else:
        joints_left = [4, 5, 6, 11, 12, 13]
        joints_right = [1, 2, 3, 14, 15, 16]

        h36m_skeleton = Skeleton(
            parents=[-1, 0, 1, 2, 0, 4, 5, 0, 7, 8, 9, 8, 11, 12, 8, 14, 15],
            joints_left=[4, 5, 6, 11, 12, 13],
            joints_right=[1, 2, 3, 14, 15, 16])

    keypoints_metadata = {
        'keypoints_symmetry': (joints_left, joints_right),
        'layout_name': 'Human3.6M',
        'num_joints': num_joints
    }

    return joints_left, joints_right, h36m_skeleton, keypoints_metadata
    def __init__(self, args):
        print("Application Entry.")
        self.args = args
        assert args.cv_camera_index is not None or args.cv_video_path is not None

        # initialize.
        print("Initialize.")
        self.cap = None
        if args.cv_camera_index is not None:
            self.cap = cv2.VideoCapture(args.cv_camera_index)
        else:
            self.cap = cv2.VideoCapture(args.cv_video_path)

        # setup skeleton
        from common.skeleton import Skeleton
        self.skeleton = Skeleton(
            parents=[-1, 0, 1, 2, 0, 4, 5, 0, 7, 8, 8, 10, 11, 8, 13, 14],
            joints_left=[4, 5, 6, 10, 11, 12],
            joints_right=[1, 2, 3, 13, 14, 15])
        self.skeleton._joints_group = [[2, 3], [5, 6], [1, 4], [0, 7], [8, 9],
                                       [14, 15], [11, 12], [10, 13]]

        # setup drivers
        self.device_driver = DeviceDriver(args)
        self.mmpose_driver = MMPoseDriver(args, self.device_driver,
                                          self.skeleton)
        self.semgcm_driver = SemGCMDriver(args, self.device_driver,
                                          self.skeleton)
Example #3
0
print('=> Rendering...')
prediction = np.load(args.viz_input)
rot = np.array([0.14070565, -0.15007018, -0.7552408, 0.62232804],
               dtype=np.float32)  # Example value taken from h36m
prediction = camera_to_world(prediction, R=rot,
                             t=0)  # Invert camera transformation
prediction[:, :, 2] -= np.min(
    prediction[:, :, 2]
)  # We don't have the trajectory, but at least we can rebase the height

anim_output = {'Inference': prediction}

skeleton = Skeleton(
    parents=[
        -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12, 16, 17, 18,
        19, 20, 19, 22, 12, 24, 25, 26, 27, 28, 27, 30
    ],
    joints_left=[6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23],
    joints_right=[1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31])
skeleton.remove_joints(
    [4, 5, 9, 10, 11, 16, 20, 21, 22, 23, 24, 28, 29, 30, 31])
skeleton._parents[11] = 8
skeleton._parents[14] = 8

render_animation(anim_output,
                 skeleton,
                 24,
                 3000,
                 70.0,
                 args.viz_output,
                 viewport=(1000, 1002))
Example #4
0
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

import numpy as np
import copy
from common.skeleton import Skeleton
from common.mocap_dataset import MocapDataset
from common.camera import normalize_screen_coordinates, image_coordinates
       
humaneva_skeleton = Skeleton(parents=[-1, 0, 1, 2, 3, 1, 5, 6, 0, 8, 9, 0, 11, 12, 1],
       joints_left=[2, 3, 4, 8, 9, 10],
       joints_right=[5, 6, 7, 11, 12, 13])

humaneva_cameras_intrinsic_params = [
    {
        'id': 'C1',
        'res_w': 640,
        'res_h': 480,
        'azimuth': 0, # Only used for visualization
    },
    {
        'id': 'C2',
        'res_w': 640,
        'res_h': 480,
        'azimuth': -90, # Only used for visualization
    },
    {
Example #5
0
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#

import numpy as np
import copy
from common.skeleton import Skeleton
from common.mocap_dataset import MocapDataset
from common.camera import normalize_screen_coordinates, image_coordinates

h36m_skeleton = Skeleton(
    parents=[
        -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12, 16, 17, 18,
        19, 20, 19, 22, 12, 24, 25, 26, 27, 28, 27, 30
    ],
    joints_left=[6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23],
    joints_right=[1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31])

h36m_cameras_intrinsic_params = [
    {
        'id':
        '54138969',
        'center': [512.54150390625, 515.4514770507812],
        'focal_length': [1145.0494384765625, 1143.7811279296875],
        'radial_distortion':
        [-0.20709891617298126, 0.24777518212795258, -0.0030751503072679043],
        'tangential_distortion':
        [-0.0009756988729350269, -0.00142447161488235],
        'res_w':
from __future__ import absolute_import, division

import numpy as np
import copy
from common.skeleton import Skeleton
from common.mocap_dataset import MocapDataset
from common.camera import normalize_screen_coordinates

h36m_skeleton = Skeleton(
    parents=[
        -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13, 14, 12, 16, 17, 18,
        19, 20, 19, 22, 12, 24, 25, 26, 27, 28, 27, 30
    ],
    joints_left=[6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23],
    joints_right=[1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31],
    # joints_group=[(1, 2, 3), (4, 5, 6), (0, 7, 8), (14, 15, 16), (11, 12, 13), (9, 10)])
    joints_group=[[2, 3], [5, 6], [1, 4], [0, 7], [8, 9], [15, 16], [12, 13],
                  [11, 14], [10]],
    N=1)

# Joints in H3.6M -- data has 32 joints, but only 17 that move; these are the indices.
H36M_NAMES = [''] * 32
H36M_NAMES[0] = 'Hip'
H36M_NAMES[1] = 'RHip'
H36M_NAMES[2] = 'RKnee'
H36M_NAMES[3] = 'RFoot'
H36M_NAMES[6] = 'LHip'
H36M_NAMES[7] = 'LKnee'
H36M_NAMES[8] = 'LFoot'
H36M_NAMES[12] = 'Spine'
H36M_NAMES[13] = 'Thorax'
Example #7
0
skeleton_cmu = Skeleton(offsets=[
    [0., 0., 0.],
    [0., 0., 0.],
    [1.36306, -1.79463, 0.83929],
    [2.44811, -6.72613, 0.],
    [2.5622, -7.03959, 0.],
    [0.15764, -0.43311, 2.32255],
    [0., 0., 0.],
    [-1.30552, -1.79463, 0.83929],
    [-2.54253, -6.98555, 0.],
    [-2.56826, -7.05623, 0.],
    [-0.16473, -0.45259, 2.36315],
    [0., 0., 0.],
    [0.02827, 2.03559, -0.19338],
    [0.05672, 2.04885, -0.04275],
    [0., 0., 0.],
    [-0.05417, 1.74624, 0.17202],
    [0.10407, 1.76136, -0.12397],
    [0., 0., 0.],
    [3.36241, 1.20089, -0.31121],
    [4.983, -0., -0.],
    [3.48356, -0., -0.],
    [0., 0., 0.],
    [0.71526, -0., -0.],
    [0., 0., 0.],
    [0., 0., 0.],
    [-3.1366, 1.37405, -0.40465],
    [-5.2419, -0., -0.],
    [-3.44417, -0., -0.],
    [0., 0., 0.],
    [-0.62253, -0., -0.],
    [0., 0., 0.],
],
                        parents=[
                            -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13,
                            14, 15, 13, 17, 18, 19, 20, 21, 20, 13, 24, 25, 26,
                            27, 28, 27
                        ],
                        joints_left=[6, 7, 8, 9, 10, 21, 22, 23, 24, 25],
                        joints_right=[1, 2, 3, 4, 5, 16, 17, 18, 19, 20])
Example #8
0
skeleton_imperial = Skeleton(offsets=[
    [0, 0, 0], [0.091287263088, 0.547940149596, -0.12057665264400001],
    [0, 0.30301749648,
     -1.7184998080799998], [0, 0.28487456662, -1.61524105617],
    [0.437734481618, 3.412177735459999e-12, -0.125472266928],
    [0.224819, 1.7473719546499998e-12, -9.905952296100001e-12],
    [0.091287246328, -0.528250154848, -0.120576355119999],
    [0, -0.30589658032, -1.7348279247199998],
    [0, -0.28551970826, -1.61915893684],
    [0.46028240332799997, -3.583826328e-12, -0.145672347456],
    [0.237732, -1.8561377590799993e-12, -1.047886996199999e-11],
    [-0.0085707703935, -0.0033291245673, 0.444873776633999],
    [0.0060529383405000005, 0.0014894078199000002, 0.44544134246999995],
    [0.009564423742999002, 0.00298004521605, 0.444805990574],
    [-0.036025562196, 0.00261801257508, 0.35821961838000005],
    [-0.05033537756, 0.0022401767544, 0.353248623519999],
    [-0.013775639145499001, 0.00051162794125, 0.363433503294999],
    [-8.7418796185e-19, 0.756491829177, -0.147047146659],
    [2.1336019996000002e-26, 0.6287597852000001, -1.1343121704],
    [2.33509479224e-26, 0.36122902213999997, -0.65167411428],
    [2.63159004766e-26, 0.18061451106999998, -0.32583705714],
    [-0.055182976822999004, 0.17723818283599999, -0.319275285134],
    [-8.741936553799999e-19, -0.733233159039, -0.14252611821299999],
    [-1.8732430327000002e-26, -0.6255842797000001, -1.1285834094],
    [-2.2757703002599992e-26, -0.35511459842, -0.64064340684],
    [-2.69211306906e-26, -0.17755729921, -0.32032170342],
    [-0.055012222539, -0.16729379953200002, -0.301461351522]
],
                             parents=[
                                 -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12,
                                 13, 14, 15, 13, 17, 18, 19, 20, 13, 22, 23,
                                 24, 25
                             ],
                             joints_left=[1, 2, 3, 4, 5, 17, 18, 19, 20, 21],
                             joints_right=[6, 7, 8, 9, 10, 22, 23, 24, 25, 26])
Example #9
0
R_FOOT = 3
R_SHOULDER = 14
R_ELBOW = 15
R_HAND = 16
ROOT = 17

PARENTS = [
    INVALID, PELVIS, R_HIP, R_KNEE, PELVIS, L_HIP, L_KNEE, PELVIS, SPINE,
    CHEST, NECK, CHEST, L_SHOULDER, L_ELBOW, CHEST, R_SHOULDER, R_ELBOW
]

# legs top to bottom (3), arms top to bottom (3)
LEFT = [L_HIP, L_KNEE, L_FOOT, L_SHOULDER, L_ELBOW, L_HAND]
RIGHT = [R_HIP, R_KNEE, R_FOOT, R_SHOULDER, R_ELBOW, R_HAND]

s = Skeleton(PARENTS, LEFT, RIGHT)

# CENTER
s._meta[PELVIS] = {
    "location": "center",
    "joint": "pelvis",
    "joints": (ROOT, PELVIS, SPINE),
    "min": 0,
    "max": 135
}

s._meta[SPINE] = {
    "location": "center",
    "joint": "spine",
    "joints": (PELVIS, SPINE, CHEST),
    "min": 90,
Example #10
0
short_term_weights_path = 'weights_short_term.bin'

skeleton_h36m = Skeleton(offsets=[[0., 0., 0.], [-132.948591, 0., 0.],
                                  [0., -442.894612, 0.], [0., -454.206447, 0.],
                                  [0., 0., 162.767078], [0., 0., 74.999437],
                                  [132.948826, 0., 0.], [0., -442.894413, 0.],
                                  [0., -454.20659, 0.], [0., 0., 162.767426],
                                  [0., 0., 74.999948], [0., 0.1, 0.],
                                  [0., 233.383263, 0.], [0., 257.077681, 0.],
                                  [0., 121.134938, 0.], [0., 115.002227, 0.],
                                  [0., 257.077681, 0.], [0., 151.034226, 0.],
                                  [0., 278.882773, 0.], [0., 251.733451, 0.],
                                  [0., 0., 0.], [0., 0., 99.999627],
                                  [0., 100.000188, 0.], [0., 0., 0.],
                                  [0., 257.077681, 0.], [0., 151.031437, 0.],
                                  [0., 278.892924, 0.], [0., 251.72868, 0.],
                                  [0., 0., 0.], [0., 0., 99.999888],
                                  [0., 137.499922, 0.], [0., 0., 0.]],
                         parents=[
                             -1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 13,
                             14, 12, 16, 17, 18, 19, 20, 19, 22, 12, 24, 25,
                             26, 27, 28, 27, 30
                         ],
                         joints_left=[
                             1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31
                         ],
                         joints_right=[
                             6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23
                         ])

dataset = MocapDataset(dataset_path, skeleton_h36m, fps=50)
Example #11
0
                    self.layers_conv[2 * i + 1](x))))

            x = self.layers_graph_conv[i + 1](x)

        return x


if __name__ == "__main__":
    import torch
    import numpy as np
    import torchsummary
    from common.skeleton import Skeleton
    from common.graph_utils import adj_mx_from_skeleton

    h36m_skeleton = Skeleton(
        parents=[-1, 0, 1, 2, 0, 4, 5, 0, 7, 8, 9, 8, 11, 12, 8, 14, 15],
        joints_left=[6, 7, 8, 9, 10, 16, 17, 18, 19, 20, 21, 22, 23],
        joints_right=[1, 2, 3, 4, 5, 24, 25, 26, 27, 28, 29, 30, 31])

    humaneva_skeleton = Skeleton(
        parents=[-1, 0, 1, 2, 3, 1, 5, 6, 0, 8, 9, 0, 11, 12, 1],
        joints_left=[2, 3, 4, 8, 9, 10],
        joints_right=[5, 6, 7, 11, 12, 13])

    adj = adj_mx_from_skeleton(h36m_skeleton)
    model = SpatioTemporalModel(adj,
                                num_joints_in=17,
                                in_features=2,
                                num_joints_out=17,
                                filter_widths=[3, 3, 3, 3],
                                channels=64)
    model = model.cuda()