import matplotlib.pyplot as plt
import numpy as np

# NOTE if there are joints here that are not included in joints_to_use the system will crash
cmap = plt.get_cmap('rainbow')  # type: ignore
colors = [cmap(i) for i in np.linspace(0, 1, 30)]
colors = [(c[2] * 255, c[1] * 255, c[0] * 255) for c in colors]

intial_estimate_joints = {
    'Nose': {"X": -0.011931225908468976,
             "Y": -1.3500069344693573,
             "Z": 1.5195400594516275, 'color': colors[0]},
    'Neck': {"X": -0.002828986166210869,
             "Y": -1.4792963007352076,
             "Z": 1.3334492680845924, 'color': colors[1]},
    'RShoulder': {"X": 0.17858398728958041,
                  "Y": -1.4408879673547788,
                  "Z": 1.3353490283055618, 'color': colors[2]},
    'RElbow': {"X": 0.19021404713190418,
               "Y": -1.4454096099237208,
               "Z": 1.0389961892176993, 'color': colors[3]},
    'RWrist': {"X": 0.2507815939363723,
               "Y": -1.3068317796196849,
               "Z": 0.8313105174336778, 'color': colors[4]},
    'LShoulder': {"X": -0.18289791976878025,
                  "Y": -1.468522830676231,
                  "Z": 1.3459798176540658, 'color': colors[5]},
    'LElbow': {"X": -0.21719431784632545,
               "Y": -1.5217849169297066,
               "Z": 1.070100201494739, 'color': colors[6]},
    'LWrist': {"X": -0.22777161018459746,
               "Y": -1.5244029522185218,
               "Z": 0.8254671428039356, 'color': colors[7]},
    'MidHip': {"X": -0.003934954285780833,
               "Y": -1.437178711864687,
               "Z": 0.8892167244249765, 'color': colors[8]},
    'RHip': {"X": 0.09104363491038035,
             "Y": -1.4262779927492784,
             "Z": 0.8859766670087011, 'color': colors[9]},
    'RKnee': {"X": 0.05415743682731961,
              "Y": -1.525489891197472,
              "Z": 0.47353747835441656, 'color': colors[10]},
    'RAnkle': {"X": 0.030397093303463258,
               "Y": -1.805423571078289,
               "Z": 0.1698958177894045, 'color': colors[11]},
    'LHip': {"X": -0.09807438064978387,
             "Y": -1.4214586673271723,
             "Z": 0.8967604550380698, 'color': colors[12]},
    'LKnee': {"X": -0.07666407420406857,
              "Y": -1.2000064875861698,
              "Z": 0.5698771428492223, 'color': colors[13]},
    'LAnkle': {"X": -0.06468238665227964,
               "Y": -1.2294031399642658,
               "Z": 0.08785246198816044, 'color': colors[14]},
    'LBigToe': {"X": 0.008346489652686643,
                "Y": -1.0660328370254306,
                "Z": 0.07004412043132632, 'color': colors[19]},
    'LSmallToe': {"X": -0.07054794175771945,
                  "Y": -1.076827290535403,
                  "Z": 0.06698293745655524, 'color': colors[20]},
    'LHeel': {"X": -0.048298218877391746,
              "Y": -1.2541632534990816,
              "Z": 0.04523104199959744, 'color': colors[21]},
    'RBigToe': {"X": 0.018572095057777478,
                "Y": -1.7607791752365995,
                "Z": 0.038461284710888326, 'color': colors[22]},
    'RSmallToe': {"X": 0.03921310062184305,
                  "Y": -1.7735459079592482,
                  "Z": 0.03687936259145665, 'color': colors[23]},
    'RHeel': {"X": 0.02067012467204425,
              "Y": -1.9336844780565792,
              "Z": 0.11919814156783963, 'color': colors[24]}}

joint_idxs = {
    'Nose': {'idx': 0, 'color': colors[0]},
    'Neck': {'idx': 1, 'color': colors[1]},
    'RShoulder': {'idx': 2, 'color': colors[2]},
    'RElbow': {'idx': 3, 'color': colors[3]},
    'RWrist': {'idx': 4, 'color': colors[4]},
    'LShoulder': {'idx': 5, 'color': colors[5]},
    'LElbow': {'idx': 6, 'color': colors[6]},
    'LWrist': {'idx': 7, 'color': colors[7]},
    'MidHip': {'idx': 8, 'color': colors[8]},
    'RHip': {'idx': 9, 'color': colors[9]},
    'RKnee': {'idx': 10, 'color': colors[10]},
    'RAnkle': {'idx': 11, 'color': colors[11]},
    'LHip': {'idx': 12, 'color': colors[12]},
    'LKnee': {'idx': 13, 'color': colors[13]},
    'LAnkle': {'idx': 14, 'color': colors[14]},
    'REye': {'idx': 15, 'color': colors[15]},
    'LEye': {'idx': 16, 'color': colors[16]},
    'REar': {'idx': 17, 'color': colors[17]},
    'LEar': {'idx': 18, 'color': colors[18]},
    'LBigToe': {'idx': 19, 'color': colors[19]},
    'LSmallToe': {'idx': 20, 'color': colors[20]},
    'LHeel': {'idx': 21, 'color': colors[21]},
    'RBigToe': {'idx': 22, 'color': colors[22]},
    'RSmallToe': {'idx': 23, 'color': colors[23]},
    'RHeel': {'idx': 24, 'color': colors[24]}}

joint_idxs_op_mpi = {
    'Nose': {'idx': 0, 'color': colors[0]},
    'Neck': {'idx': 1, 'color': colors[1]},
    'RShoulder': {'idx': 2, 'color': colors[2]},
    'RElbow': {'idx': 3, 'color': colors[3]},
    'RWrist': {'idx': 4, 'color': colors[4]},
    'LShoulder': {'idx': 5, 'color': colors[5]},
    'LElbow': {'idx': 6, 'color': colors[6]},
    'LWrist': {'idx': 7, 'color': colors[7]},
    'MidHip': {'idx': 14, 'color': colors[8]},
    'RHip': {'idx': 8, 'color': colors[9]},
    'RKnee': {'idx': 9, 'color': colors[10]},
    'RAnkle': {'idx': 10, 'color': colors[11]},
    'LHip': {'idx': 11, 'color': colors[12]},
    'LKnee': {'idx': 12, 'color': colors[13]},
    'LAnkle': {'idx': 13, 'color': colors[14]},
    # 'REye': {'idx': 15, 'color': colors[15]},
    # 'LEye': {'idx': 16, 'color': colors[16]},
    # 'REar': {'idx': 17, 'color': colors[17]},
    # 'LEar': {'idx': 18, 'color': colors[18]},
    # 'LBigToe': {'idx': 19, 'color': colors[19]},
    # 'LSmallToe': {'idx': 20, 'color': colors[20]},
    # 'LHeel': {'idx': 21, 'color': colors[21]},
    # 'RBigToe': {'idx': 22, 'color': colors[22]},
    # 'RSmallToe': {'idx': 23, 'color': colors[23]},
    # 'RHeel': {'idx': 24, 'color': colors[24]}
    }


# MAPPING["RANKLE"] = 0
# MAPPING["RKNEE"] = 1
# MAPPING["RHIP"] = 2
# MAPPING["LHIP"] = 3
# MAPPING["LKNEE"] = 4
# MAPPING["LANKLE"] = 5
# MAPPING["MIDHIP"] = 6 # called pelvis in MPII
# MAPPING["MIDSHOULDER"] = 7 # called thorax in MPII
# MAPPING["NECK"] = 8
# MAPPING["TOP"] = 9
# MAPPING["RWRIST"] = 10
# MAPPING["RELBOW"] = 11
# MAPPING["RSHOULDER"] = 12
# MAPPING["LSHOULDER"] = 13
# MAPPING["LELBOW"] = 14
# MAPPING["LWRIST"] = 15

joints_mediapipe = {
    'Nose': {'idx': 0, 'color': colors[0]},
    # 'Neck': {'idx': 1, 'color': colors[1]},
    'RShoulder': {'idx': 12, 'color': colors[2]},
    'RElbow': {'idx': 14, 'color': colors[3]},
    'RWrist': {'idx': 16, 'color': colors[4]},
    'LShoulder': {'idx': 11, 'color': colors[5]},
    'LElbow': {'idx': 13, 'color': colors[6]},
    'LWrist': {'idx': 15, 'color': colors[7]},
    # 'MidHip': {'idx': 8, 'color': colors[8]},
    'RHip': {'idx': 24, 'color': colors[9]},
    'RKnee': {'idx': 26, 'color': colors[10]},
    'RAnkle': {'idx': 28, 'color': colors[11]},
    'LHip': {'idx': 23, 'color': colors[12]},
    'LKnee': {'idx': 25, 'color': colors[13]},
    'LAnkle': {'idx': 27, 'color': colors[14]},
    # 'REye': {'idx': 5, 'color': colors[15]},
    # 'LEye': {'idx': 2, 'color': colors[16]},
    # 'REar': {'idx': 8, 'color': colors[17]},
    # 'LEar': {'idx': 7, 'color': colors[18]},
    'LBigToe': {'idx': 31, 'color': colors[19]},
    # 'LSmallToe': {'idx': 20, 'color': colors[20]},
    'LHeel': {'idx': 29, 'color': colors[21]},
    'RBigToe': {'idx': 32, 'color': colors[22]},
    # 'RSmallToe': {'idx': 23, 'color': colors[23]},
    'RHeel': {'idx': 30, 'color': colors[24]}}

joints_human36m = {'Hip': {'idx': 0, 'color': colors[0]},
                   'RHip': {'idx': 1, 'color': colors[0]},
                   'RKnee': {'idx': 2, 'color': colors[0]},
                   'RFoot': {'idx': 3, 'color': colors[0]},
                   'RFootTip': {'idx': 4, 'color': colors[0]},
                   'LHip': {'idx': 6, 'color': colors[0]},
                   'LKnee': {'idx': 7, 'color': colors[0]},
                   'LFoot': {'idx': 8, 'color': colors[0]},
                   'LFootTip': {'idx': 9, 'color': colors[0]},
                   'MidHip': {'idx': 11, 'color': colors[0]},
                   'Spine': {'idx': 12, 'color': colors[0]},
                   'Thorax': {'idx': 13, 'color': colors[0]},
                   'Nose': {'idx': 14, 'color': colors[0]},
                   'Head': {'idx': 15, 'color': colors[0]},
                   'LShoulder': {'idx': 17, 'color': colors[0]},
                   'LElbow': {'idx': 18, 'color': colors[0]},
                   'LWrist': {'idx': 19, 'color': colors[0]},
                   'RShoulder': {'idx': 25, 'color': colors[0]},
                   'RElbow': {'idx': 26, 'color': colors[0]},
                   'RWrist': {'idx': 27, 'color': colors[0]}
                   }

# joints_mpi_inf_3dhp = {'Pelvis': {'idx': 4, 'color': colors[4]},
#                        'RHip': {'idx': 23, 'color': colors[23]},
#                        'RKnee': {'idx': 24, 'color': colors[24]},
#                        'RAnkle': {'idx': 25, 'color': colors[25]},
#                        'RFoot': {'idx': 26, 'color': colors[26]},
#                        # 'RFootTip': {'idx': 27, 'color': colors[0]},
#                        'LHip': {'idx': 18, 'color': colors[18]},
#                        'LKnee': {'idx': 19, 'color': colors[19]},
#                        'LAnkle': {'idx': 20, 'color': colors[20]},
#                        'LFoot': {'idx': 21, 'color': colors[21]},
#                        # 'LFootTip': {'idx': 22, 'color': colors[0]},
#                        # 'Spine': {'idx': 3, 'color': colors[0]},
#                        'Spine2': {'idx': 2, 'color': colors[2]},
#                        'Spine3': {'idx': 0, 'color': colors[0]},
#                        'Spine4': {'idx': 1, 'color': colors[1]},
#                        # 'Thorax': {'idx': 13, 'color': colors[0]},
#                        'Neck': {'idx': 5, 'color': colors[5]},
#                        'Head': {'idx': 6, 'color': colors[6]},
#                        'HeadTop': {'idx': 7, 'color': colors[7]},
#                        # 'LClavicle': {'idx': 8, 'color': colors[0]},
#                        'LShoulder': {'idx': 9, 'color': colors[9]},
#                        'LElbow': {'idx': 10, 'color': colors[10]},
#                        'LWrist': {'idx': 11, 'color': colors[11]},
#                        'LHand': {'idx': 12, 'color': colors[12]},
#                        # 'RClavicle': {'idx': 13, 'color': colors[0]},
#                        'RShoulder': {'idx': 14, 'color': colors[14]},
#                        'RElbow': {'idx': 15, 'color': colors[15]},
#                        'RWrist': {'idx': 16, 'color': colors[16]},
#                        'RHand': {'idx': 17, 'color': colors[17]}
#                        }


joints_mpi_inf_3dhp = {'Pelvis': {'idx': 4, 'color': colors[4]},
                       'RHip': {'idx': 23, 'color': colors[23]},
                       'RKnee': {'idx': 24, 'color': colors[24]},
                       'RAnkle': {'idx': 25, 'color': colors[25]},
                       'RFoot': {'idx': 26, 'color': colors[26]},
                       # 'RFootTip': {'idx': 27, 'color': colors[0]},
                       'LHip': {'idx': 18, 'color': colors[18]},
                       'LKnee': {'idx': 19, 'color': colors[19]},
                       'LAnkle': {'idx': 20, 'color': colors[20]},
                       'LFoot': {'idx': 21, 'color': colors[21]},
                       # 'LFootTip': {'idx': 22, 'color': colors[0]},
                       # 'Spine': {'idx': 3, 'color': colors[0]},
                       'Spine2': {'idx': 2, 'color': colors[2]},
                       'Spine3': {'idx': 0, 'color': colors[0]},
                       'Spine4': {'idx': 1, 'color': colors[1]},
                       # 'Thorax': {'idx': 13, 'color': colors[0]},
                       'Neck': {'idx': 5, 'color': colors[5]},
                       'Head': {'idx': 6, 'color': colors[6]},
                       'HeadTop': {'idx': 7, 'color': colors[7]},
                       # 'LClavicle': {'idx': 8, 'color': colors[0]},
                       'LShoulder': {'idx': 9, 'color': colors[1]},
                       'LElbow': {'idx': 10, 'color': colors[10]},
                       'LWrist': {'idx': 11, 'color': colors[15]},
                       'LHand': {'idx': 12, 'color': colors[20]},
                       # 'RClavicle': {'idx': 13, 'color': colors[0]},
                       'RShoulder': {'idx': 14, 'color': colors[14]},
                       'RElbow': {'idx': 15, 'color': colors[15]},
                       'RWrist': {'idx': 16, 'color': colors[16]},
                       'RHand': {'idx': 17, 'color': colors[17]}
                       }

links_openpose = {
    'right_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
    'right_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
    'right_blade:': {'parent': 'Neck', 'child': 'RShoulder'},
    'left_arm': {'parent': 'LShoulder', 'child': 'LElbow'},
    'left_forearm': {'parent': 'LElbow', 'child': 'LWrist'},
    'left_blade:': {'parent': 'Neck', 'child': 'LShoulder'},
    'neck': {'parent': 'Neck', 'child': 'Nose'},
    # 'right_face_in': {'parent': 'Nose', 'child': 'REye'},
    # 'right_face_ou:': {'parent': 'REye', 'child': 'REar'},
    # 'left_face_in': {'parent': 'Nose', 'child': 'LEye'},
    # 'left_face_out': {'parent': 'LEye', 'child': 'LEar'},
    'body:': {'parent': 'Neck', 'child': 'MidHip'},
    'right_hip': {'parent': 'MidHip', 'child': 'RHip'},
    'right_tigh': {'parent': 'RHip', 'child': 'RKnee'},
    'right_leg:': {'parent': 'RKnee', 'child': 'RAnkle'},
    'left_hip': {'parent': 'MidHip', 'child': 'LHip'},
    'left_tigh': {'parent': 'LHip', 'child': 'LKnee'},
    'left_leg:': {'parent': 'LKnee', 'child': 'LAnkle'},
    'right_heel': {'parent': 'RAnkle', 'child': 'RHeel'},
    'right_foot': {'parent': 'RAnkle', 'child': 'RBigToe'},
    'right_foot_fingers:': {'parent': 'RBigToe', 'child': 'RSmallToe'},
    'left_heel': {'parent': 'LAnkle', 'child': 'LHeel'},
    'left_foot': {'parent': 'LAnkle', 'child': 'LBigToe'},
    'left_foot_fingers:': {'parent': 'LBigToe', 'child': 'LSmallToe'},
}
links_op_mpi = {
    'right_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
    'right_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
    'right_blade:': {'parent': 'Neck', 'child': 'RShoulder'},
    'left_arm': {'parent': 'LShoulder', 'child': 'LElbow'},
    'left_forearm': {'parent': 'LElbow', 'child': 'LWrist'},
    'left_blade:': {'parent': 'Neck', 'child': 'LShoulder'},
    'neck': {'parent': 'Neck', 'child': 'Nose'},
    # 'right_face_in': {'parent': 'Nose', 'child': 'REye'},
    # 'right_face_ou:': {'parent': 'REye', 'child': 'REar'},
    # 'left_face_in': {'parent': 'Nose', 'child': 'LEye'},
    # 'left_face_out': {'parent': 'LEye', 'child': 'LEar'},
    'body:': {'parent': 'Neck', 'child': 'MidHip'},
    'right_hip': {'parent': 'MidHip', 'child': 'RHip'},
    'right_tigh': {'parent': 'RHip', 'child': 'RKnee'},
    'right_leg:': {'parent': 'RKnee', 'child': 'RAnkle'},
    'left_hip': {'parent': 'MidHip', 'child': 'LHip'},
    'left_tigh': {'parent': 'LHip', 'child': 'LKnee'},
    'left_leg:': {'parent': 'LKnee', 'child': 'LAnkle'},
    # 'right_heel': {'parent': 'RAnkle', 'child': 'RHeel'},
    # 'right_foot': {'parent': 'RAnkle', 'child': 'RBigToe'},
    # 'right_foot_fingers:': {'parent': 'RBigToe', 'child': 'RSmallToe'},
    # 'left_heel': {'parent': 'LAnkle', 'child': 'LHeel'},
    # 'left_foot': {'parent': 'LAnkle', 'child': 'LBigToe'},
    # 'left_foot_fingers:': {'parent': 'LBigToe', 'child': 'LSmallToe'},
}

links_mediapipe = {
    'right_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
    'right_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
    # 'right_blade:': {'parent': 'Neck', 'child': 'RShoulder'},
    'left_arm': {'parent': 'LShoulder', 'child': 'LElbow'},
    'left_forearm': {'parent': 'LElbow', 'child': 'LWrist'},
    # 'left_blade:': {'parent': 'Neck', 'child': 'LShoulder'},
    'nose': {'parent': 'Nose', 'child': 'Nose'},
    # 'right_face_in': {'parent': 'Nose', 'child': 'REye'},
    # 'right_face_ou:': {'parent': 'REye', 'child': 'REar'},
    # 'left_face_in': {'parent': 'Nose', 'child': 'LEye'},
    # 'left_face_out': {'parent': 'LEye', 'child': 'LEar'},
    'body_up:': {'parent': 'RShoulder', 'child': 'LShoulder'},
    'body_down:': {'parent': 'RHip', 'child': 'LHip'},
    'body_right:': {'parent': 'RShoulder', 'child': 'RHip'},
    'body_left:': {'parent': 'LHip', 'child': 'LShoulder'},
    # 'right_hip': {'parent': 'MidHip', 'child': 'RHip'},
    'right_tigh': {'parent': 'RHip', 'child': 'RKnee'},
    'right_leg:': {'parent': 'RKnee', 'child': 'RAnkle'},
    # 'left_hip': {'parent': 'MidHip', 'child': 'LHip'},
    'left_tigh': {'parent': 'LHip', 'child': 'LKnee'},
    'left_leg:': {'parent': 'LKnee', 'child': 'LAnkle'},
    'right_heel': {'parent': 'RAnkle', 'child': 'RHeel'},
    'right_foot': {'parent': 'RAnkle', 'child': 'RBigToe'},
    'right_foot_fingers:': {'parent': 'RBigToe', 'child': 'RAnkle'},
    'left_heel': {'parent': 'LAnkle', 'child': 'LHeel'},
    'left_foot': {'parent': 'LAnkle', 'child': 'LBigToe'},
    'left_foot_fingers:': {'parent': 'LBigToe', 'child': 'LAnkle'},
}

links_ground_truth = {
    'right_arm': {'parent': 'RightShoulder', 'child': 'RightArm'},
    'right_forearm': {'parent': 'RightArm', 'child': 'RightForeArm'},
    'right_wrist': {'parent': 'RightForeArm', 'child': 'RightHand'},
    'right_blade:': {'parent': 'Neck', 'child': 'RightShoulder'},
    'right_hand': {'parent': 'RightHand', 'child': 'RightFingerBase'},
    'right_thumb': {'parent': 'RightFingerBase', 'child': 'RThumb'},
    'right_idx_finger': {'parent': 'RightFingerBase', 'child': 'RightHandIndex1'},
    'left_arm': {'parent': 'LeftShoulder', 'child': 'LeftArm'},
    'left_forearm': {'parent': 'LeftArm', 'child': 'LeftForeArm'},
    'left_wrist': {'parent': 'LeftForeArm', 'child': 'LeftHand'},
    'left_blade:': {'parent': 'Neck', 'child': 'LeftShoulder'},
    'left_hand': {'parent': 'LeftHand', 'child': 'LeftFingerBase'},
    'left_thumb': {'parent': 'LeftFingerBase', 'child': 'LThumb'},
    'left_idx_finger': {'parent': 'LeftFingerBase', 'child': 'LeftHandIndex1'},
    'neck': {'parent': 'Neck', 'child': 'Neck1'},
    'head': {'parent': 'Neck1', 'child': 'Head'},
    'body1': {'parent': 'Neck', 'child': 'Spine1'},
    'body2': {'parent': 'Spine1', 'child': 'Spine'},
    'body3': {'parent': 'Spine', 'child': 'LowerBack'},
    'hip:': {'parent': 'LowerBack', 'child': 'Hips'},
    'right_hip': {'parent': 'Hips', 'child': 'RHipJoint'},
    'right_tigh': {'parent': 'RHipJoint', 'child': 'RightUpLeg'},
    'right_leg:': {'parent': 'RightUpLeg', 'child': 'RightLeg'},
    'right_heel': {'parent': 'RightLeg', 'child': 'RightFoot'},
    'right_foot': {'parent': 'RightFoot', 'child': 'RightToeBase'},
    'left_hip': {'parent': 'Hips', 'child': 'LHipJoint'},
    'left_tigh': {'parent': 'LHipJoint', 'child': 'LeftUpLeg'},
    'left_leg:': {'parent': 'LeftUpLeg', 'child': 'LeftLeg'},
    'left_heel': {'parent': 'LeftLeg', 'child': 'LeftFoot'},
    'left_foot': {'parent': 'LeftFoot', 'child': 'LeftToeBase'},
}

links_human36m = {
    'right_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
    'right_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
    'right_blade:': {'parent': 'Thorax', 'child': 'RShoulder'},
    'left_arm': {'parent': 'LShoulder', 'child': 'LElbow'},
    'left_forearm': {'parent': 'LElbow', 'child': 'LWrist'},
    'left_blade:': {'parent': 'Thorax', 'child': 'LShoulder'},
    'neck': {'parent': 'Thorax', 'child': 'Nose'},
    'body_up:': {'parent': 'Thorax', 'child': 'Spine'},
    'body_down:': {'parent': 'Spine', 'child': 'MidHip'},
    'right_hip': {'parent': 'MidHip', 'child': 'RHip'},
    'right_tigh': {'parent': 'RHip', 'child': 'RKnee'},
    'right_leg:': {'parent': 'RKnee', 'child': 'RFoot'},
    'left_hip': {'parent': 'MidHip', 'child': 'LHip'},
    'left_tigh': {'parent': 'LHip', 'child': 'LKnee'},
    'left_leg:': {'parent': 'LKnee', 'child': 'LFoot'},
    'right_foot': {'parent': 'RFoot', 'child': 'RFootTip'},
    'left_foot': {'parent': 'LFoot', 'child': 'LFootTip'},
}
links_mpi_inf_3dhp = {
    'head': {'parent': 'HeadTop', 'child': 'Head'},
    'neck': {'parent': 'Head', 'child': 'Neck'},
    'body4': {'parent': 'Neck', 'child': 'Spine4'},
    'body3': {'parent': 'Spine4', 'child': 'Spine3'},
    'body2': {'parent': 'Spine3', 'child': 'Spine2'},
    'body': {'parent': 'Spine2', 'child': 'Pelvis'},

    'r_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
    'r_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
    'r_hand': {'parent': 'RWrist', 'child': 'RHand'},
    'r_blade': {'parent': 'Spine4', 'child': 'RShoulder'},

    'l_arm': {'parent': 'LShoulder', 'child': 'LElbow'},
    'l_forearm': {'parent': 'LElbow', 'child': 'LWrist'},
    'l_hand': {'parent': 'LWrist', 'child': 'LHand'},
    'l_blade': {'parent': 'Spine4', 'child': 'LShoulder'},

    'r_hip': {'parent': 'Pelvis', 'child': 'RHip'},
    'r_tigh': {'parent': 'RHip', 'child': 'RKnee'},
    'r_leg': {'parent': 'RKnee', 'child': 'RAnkle'},
    # 'r_heel': {'parent': 'RAnkle', 'child': 'RHeel'},
    'r_foot': {'parent': 'RAnkle', 'child': 'RFoot'},
    # 'r_foot_fingers:': {'parent': 'RBigToe', 'child': 'RSmallToe'},

    'l_hip': {'parent': 'Pelvis', 'child': 'LHip'},
    'l_tigh': {'parent': 'LHip', 'child': 'LKnee'},
    'l_leg': {'parent': 'LKnee', 'child': 'LAnkle'},
    # 'l_heel': {'parent': 'LAnkle', 'child': 'LHeel'},
    'l_foot': {'parent': 'LAnkle', 'child': 'LFoot'},
    # 'l_foot_fingers:': {'parent': 'LBigToe', 'child': 'LSmallToe'},
}

# links_mpi_inf_3dhp = {
#     # 'head': {'parent': 'HeadTop', 'child': 'Head'},
#     # 'neck': {'parent': 'Head', 'child': 'Neck'},
#     # 'body4:': {'parent': 'Neck', 'child': 'Spine4'},
#     # 'body3:': {'parent': 'Spine4', 'child': 'Spine3'},
#     # 'body2:': {'parent': 'Spine3', 'child': 'Spine2'},
#     # 'body:': {'parent': 'Spine2', 'child': 'Pelvis'},
#
#     # 'right_arm': {'parent': 'RShoulder', 'child': 'RElbow'},
#     # 'right_forearm': {'parent': 'RElbow', 'child': 'RWrist'},
#     # 'right_hand': {'parent': 'RWrist', 'child': 'RHand'},
#     # 'right_blade:': {'parent': 'Spine4', 'child': 'RShoulder'},
#
#     'left_arm': {'parent': 'LShoulder', 'child': 'LElbow', 'standard_measurement': 300},
#     'left_forearm': {'parent': 'LElbow', 'child': 'LWrist', 'standard_measurement': 260},
#     'left_hand': {'parent': 'LWrist', 'child': 'LHand', 'standard_measurement': 90},
#     # 'left_blade:': {'parent': 'Spine4', 'child': 'LShoulder'},
#
#     # 'right_hip': {'parent': 'Pelvis', 'child': 'RHip'},
#     # 'right_tigh': {'parent': 'RHip', 'child': 'RKnee'},
#     # 'right_leg:': {'parent': 'RKnee', 'child': 'RAnkle'},
#     # 'right_heel': {'parent': 'RAnkle', 'child': 'RHeel'},
#     # 'right_foot': {'parent': 'RAnkle', 'child': 'RFoot'},
#     # 'right_foot_fingers:': {'parent': 'RBigToe', 'child': 'RSmallToe'},
#
#     # 'left_hip': {'parent': 'Pelvis', 'child': 'LHip'},
#     # 'left_tigh': {'parent': 'LHip', 'child': 'LKnee'},
#     # 'left_leg:': {'parent': 'LKnee', 'child': 'LAnkle'},
#     # 'left_heel': {'parent': 'LAnkle', 'child': 'LHeel'},
#     # 'left_foot': {'parent': 'LAnkle', 'child': 'LFoot'},
#     # 'left_foot_fingers:': {'parent': 'LBigToe', 'child': 'LSmallToe'},
# }

joint_correspondence = {
    'right_wrist': {'ground_truth': 'RightHand', 'body25': 'RWrist'},
    'right_elbow': {'ground_truth': 'RightForeArm', 'body25': 'RElbow'},
    'right_shoulder': {'ground_truth': 'RightArm', 'body25': 'RShoulder'},
    'left_wrist': {'ground_truth': 'LeftHand', 'body25': 'LWrist'},
    'left_elbow': {'ground_truth': 'LeftForeArm', 'body25': 'LElbow'},
    'left_shoulder': {'ground_truth': 'LeftArm', 'body25': 'LShoulder'},

    'right_hip': {'ground_truth': 'RightUpLeg', 'body25': 'RHip'},
    'right_knee': {'ground_truth': 'RightLeg', 'body25': 'RKnee'},
    'right_ankle': {'ground_truth': 'RightFoot', 'body25': 'RAnkle'},
    'right_toe': {'ground_truth': 'RightToeBase', 'body25': 'RBigToe'},

    'left_hip': {'ground_truth': 'LeftUpLeg', 'body25': 'LHip'},
    'left_knee': {'ground_truth': 'LeftLeg', 'body25': 'LKnee'},
    'left_ankle': {'ground_truth': 'LeftFoot', 'body25': 'LAnkle'},
    'left_toe': {'ground_truth': 'LeftToeBase', 'body25': 'LBigToe'},

    # 'head': {'ground_truth': 'Head', 'body25': 'Nose'},
    # 'neck': {'ground_truth': 'Neck', 'body25': 'Neck'},
}

joint_correspondence_human36m = {
    'right_wrist': {'ground_truth': 'RWrist', 'body25': 'RWrist'},
    'right_elbow': {'ground_truth': 'RElbow', 'body25': 'RElbow'},
    'right_shoulder': {'ground_truth': 'RShoulder', 'body25': 'RShoulder'},
    'left_wrist': {'ground_truth': 'LWrist', 'body25': 'LWrist'},
    'left_elbow': {'ground_truth': 'LElbow', 'body25': 'LElbow'},
    'left_shoulder': {'ground_truth': 'LShoulder', 'body25': 'LShoulder'},

    'right_hip': {'ground_truth': 'RHip', 'body25': 'RHip'},
    'right_knee': {'ground_truth': 'RKnee', 'body25': 'RKnee'},
    'right_ankle': {'ground_truth': 'RFoot', 'body25': 'RAnkle'},
    'right_toe': {'ground_truth': 'RFootTip', 'body25': 'RBigToe'},

    'left_hip': {'ground_truth': 'LHip', 'body25': 'LHip'},
    'left_knee': {'ground_truth': 'LKnee', 'body25': 'LKnee'},
    'left_ankle': {'ground_truth': 'LFoot', 'body25': 'LAnkle'},
    'left_toe': {'ground_truth': 'LFootTip', 'body25': 'LBigToe'},

    'mid_hip': {'ground_truth': 'MidHip', 'body25': 'MidHip'},
    'thorax': {'ground_truth': 'Thorax', 'body25': 'Neck'},

    # 'head': {'ground_truth': 'Head', 'body25': 'Nose'},
    # 'neck': {'ground_truth': 'Neck', 'body25': 'Neck'},
}

joint_correspondence_human36m_mediapipe = {
    'right_wrist': {'ground_truth': 'RWrist', 'body25': 'RWrist'},
    'right_elbow': {'ground_truth': 'RElbow', 'body25': 'RElbow'},
    'right_shoulder': {'ground_truth': 'RShoulder', 'body25': 'RShoulder'},
    'left_wrist': {'ground_truth': 'LWrist', 'body25': 'LWrist'},
    'left_elbow': {'ground_truth': 'LElbow', 'body25': 'LElbow'},
    'left_shoulder': {'ground_truth': 'LShoulder', 'body25': 'LShoulder'},

    'right_hip': {'ground_truth': 'RHip', 'body25': 'RHip'},
    'right_knee': {'ground_truth': 'RKnee', 'body25': 'RKnee'},
    'right_ankle': {'ground_truth': 'RFoot', 'body25': 'RAnkle'},
    'right_toe': {'ground_truth': 'RFootTip', 'body25': 'RBigToe'},

    'left_hip': {'ground_truth': 'LHip', 'body25': 'LHip'},
    'left_knee': {'ground_truth': 'LKnee', 'body25': 'LKnee'},
    'left_ankle': {'ground_truth': 'LFoot', 'body25': 'LAnkle'},
    'left_toe': {'ground_truth': 'LFootTip', 'body25': 'LBigToe'},

    # 'mid_hip': {'ground_truth': 'MidHip', 'body25': 'MidHip'},
    # 'thorax': {'ground_truth': 'Thorax', 'body25': 'Neck'},

    'nose': {'ground_truth': 'Nose', 'body25': 'Nose'},
    # 'neck': {'ground_truth': 'Neck', 'body25': 'Neck'},
}


joint_correspondence_mpi_mediapipe = {
    'right_wrist': {'ground_truth': 'RWrist', 'body25': 'RWrist'},
    'right_elbow': {'ground_truth': 'RElbow', 'body25': 'RElbow'},
    'right_shoulder': {'ground_truth': 'RShoulder', 'body25': 'RShoulder'},
    'left_wrist': {'ground_truth': 'LWrist', 'body25': 'LWrist'},
    'left_elbow': {'ground_truth': 'LElbow', 'body25': 'LElbow'},
    'left_shoulder': {'ground_truth': 'LShoulder', 'body25': 'LShoulder'},

    'right_hip': {'ground_truth': 'RHip', 'body25': 'RHip'},
    'right_knee': {'ground_truth': 'RKnee', 'body25': 'RKnee'},
    'right_ankle': {'ground_truth': 'RFoot', 'body25': 'RAnkle'},
    # 'right_toe': {'ground_truth': 'RFootTip', 'body25': 'RBigToe'},

    'left_hip': {'ground_truth': 'LHip', 'body25': 'LHip'},
    'left_knee': {'ground_truth': 'LKnee', 'body25': 'LKnee'},
    'left_ankle': {'ground_truth': 'LFoot', 'body25': 'LAnkle'},
    # 'left_toe': {'ground_truth': 'LFootTip', 'body25': 'LBigToe'},

    # 'mid_hip': {'ground_truth': 'MidHip', 'body25': 'MidHip'},
    # 'thorax': {'ground_truth': 'Thorax', 'body25': 'Neck'},

    # 'nose': {'ground_truth': 'Head', 'body25': 'Nose'},
    # 'neck': {'ground_truth': 'Neck', 'body25': 'Neck'},
}


links_evaluation = {'right_arm': {'parent': 'right_shoulder', 'child': 'right_elbow'},
                    'right_forearm': {'parent': 'right_elbow', 'child': 'right_wrist'},

                    'left_arm': {'parent': 'left_shoulder', 'child': 'left_elbow'},
                    'left_forearm': {'parent': 'left_elbow', 'child': 'left_wrist'},

                    'right_tigh': {'parent': 'right_hip', 'child': 'right_knee'},
                    'right_leg:': {'parent': 'right_knee', 'child': 'right_ankle'},

                    'left_tigh': {'parent': 'left_hip', 'child': 'left_knee'},
                    'left_leg:': {'parent': 'left_knee', 'child': 'left_ankle'},

                    'right_foot': {'parent': 'right_ankle', 'child': 'right_toe'},
                    'left_foot': {'parent': 'left_ankle', 'child': 'left_toe'},

                    'middle_arms': {'parent': 'right_shoulder', 'child': 'left_shoulder'},
                    'middle_legs': {'parent': 'right_hip', 'child': 'left_hip'},
                    'arms_2_legs_right': {'parent': 'right_shoulder', 'child': 'right_hip'},
                    'arms_2_legs_left': {'parent': 'left_shoulder', 'child': 'left_hip'},

                    }

links_evaluation_human36m = {'right_arm': {'parent': 'right_shoulder', 'child': 'right_elbow'},
                             'right_forearm': {'parent': 'right_elbow', 'child': 'right_wrist'},

                             'left_arm': {'parent': 'left_shoulder', 'child': 'left_elbow'},
                             'left_forearm': {'parent': 'left_elbow', 'child': 'left_wrist'},

                             'right_tigh': {'parent': 'right_hip', 'child': 'right_knee'},
                             'right_leg:': {'parent': 'right_knee', 'child': 'right_ankle'},

                             'left_tigh': {'parent': 'left_hip', 'child': 'left_knee'},
                             'left_leg:': {'parent': 'left_knee', 'child': 'left_ankle'},

                             'right_foot': {'parent': 'right_ankle', 'child': 'right_toe'},
                             'left_foot': {'parent': 'left_ankle', 'child': 'left_toe'},

                             'right_blade': {'parent': 'thorax', 'child': 'right_shoulder'},
                             'left_blade': {'parent': 'thorax', 'child': 'left_shoulder'},

                             'left_hip': {'parent': 'mid_hip', 'child': 'left_hip'},
                             'right_hip': {'parent': 'mid_hip', 'child': 'right_hip'},

                             'spine': {'parent': 'thorax', 'child': 'mid_hip'}

                             # 'middle_arms': {'parent': 'right_shoulder', 'child': 'left_shoulder'},
                             # 'middle_legs': {'parent': 'right_hip', 'child': 'left_hip'},
                             # 'arms_2_legs_right': {'parent': 'right_shoulder', 'child': 'right_hip'},
                             # 'arms_2_legs_left': {'parent': 'left_shoulder', 'child': 'left_hip'},

                             }

links_evaluation_human36m_mediapipe = {'right_arm': {'parent': 'right_shoulder', 'child': 'right_elbow'},
                                       'right_forearm': {'parent': 'right_elbow', 'child': 'right_wrist'},

                                       'left_arm': {'parent': 'left_shoulder', 'child': 'left_elbow'},
                                       'left_forearm': {'parent': 'left_elbow', 'child': 'left_wrist'},

                                       'right_tigh': {'parent': 'right_hip', 'child': 'right_knee'},
                                       'right_leg:': {'parent': 'right_knee', 'child': 'right_ankle'},

                                       'left_tigh': {'parent': 'left_hip', 'child': 'left_knee'},
                                       'left_leg:': {'parent': 'left_knee', 'child': 'left_ankle'},

                                       'right_foot': {'parent': 'right_ankle', 'child': 'right_toe'},
                                       'left_foot': {'parent': 'left_ankle', 'child': 'left_toe'},

                                       # 'right_blade': {'parent': 'thorax', 'child': 'right_shoulder'},
                                       # 'left_blade': {'parent': 'thorax', 'child': 'left_shoulder'},

                                       # 'left_hip': {'parent': 'mid_hip', 'child': 'left_hip'},
                                       # 'right_hip': {'parent': 'mid_hip', 'child': 'right_hip'},

                                       # 'spine': {'parent': 'thorax', 'child': 'mid_hip'}

                                       'middle_arms': {'parent': 'right_shoulder', 'child': 'left_shoulder'},
                                       'middle_legs': {'parent': 'right_hip', 'child': 'left_hip'},
                                       'arms_2_legs_right': {'parent': 'right_shoulder', 'child': 'right_hip'},
                                       'arms_2_legs_left': {'parent': 'left_shoulder', 'child': 'left_hip'},

                                       }
