import matplotlib.pyplot as plt
from  mpl_toolkits.mplot3d import Axes3D
import numpy as np

# h36m骨架连接顺序，每个骨架三个维度，分别为：起始关节，终止关节，左右关节标识(1 left 0 right)
human36m_connectivity_dict = [[0,1,0],[1, 2, 0], [2, 6, 0], [5, 4, 1], [4, 3, 1], [3, 6, 1], [6, 7, 0],
                              [7, 8, 0], [8, 9, 0],
                              [8, 12, 0], [11, 12, 0], [10, 11, 0], [8, 13, 1], [13, 14, 1], [14, 15, 1]]


def draw3Dpose(d_pose, ax, lcolor="#3498db", rcolor="#e74c3c", add_labels=False):  # blue, orange
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
        # print(x)
        # print(y)
        # print(z)
        # print(i)
        # break

    RADIUS = 0.6  # space around the subject
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])

    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")


if __name__ == '__main__':
    specific_3d_skeleton = np.array([[-60.70762, 403.8008, 109.0549],#0右脚腕
                                     [-21.792213, 350.7608, 542.72705],#1右膝
                                     [19.21995, 377.59323, 992.2105],#2右臀
                                     [306.85883, 326.98297, 967.81555],#3左臀
                                     [280.36816, 338.44727, 516.5916],#4左膝
                                     [255.34781, 397.92474, 82.73034],#root节点5左脚腕
                                     [163.04, 332.288, 980.013],#6臀部中点(骨盆)
                                     [178.85904, 234.66092, 1240.1534],#7腰部(脊柱)
                                     [164.37048, 211.85312, 1487.3542],#8颈部(胸部)
                                     [164.81487, 211.43636, 1683.0452],#9头部
                                     [-104.66232, 412.21793, 511.5632],#10右手腕
                                     [4.860744, 460.55948, 1061.1226],#11右手肘
                                     [34.860744, 360.55948, 1461.1226],#12右肩
                                     [353.3462, 285.74405, 1454.4487],#13左肩
                                     [440.2841, 285.90445, 1022.6831],#14左手肘
                                     [408.4938, 280.56336, 562.1969],#15左手腕
                                     [164.2095, 206.31268, 1568.9426]])#16鼻子
    # data=np.array([
    #     [269.09,300.92,1020],#18.右踝-0
    #     [269.09,300.92,903],#17.右膝-1
    #     [245.916,203.577,1044],#16.右臀-2
    #     [200.722,201.658,1110],#12.左臀-3
    #     [199.913,282.803,1116],#13.左膝-4
    #     [199.913,282.803,900],#14.左踝-5
    #     [223.207,202.611,1077],#0.臀部中点-6
    #     [224.747,114.517,1112],#1.臀部上部中点-7
    #     [226.18,37.1176,1228],#2.脖子-8
    #     [227.589,1.96397,1154],#3.头-9
    #     [279.357,189.911,1006],#10.右腕-10
    #     [288.588,129.108,1163],#9.右肘-11
    #     [200.722,201.658,1110],#12.左臀-3
    #     [199.913,282.803,1116],#13.左膝-4
    #     [167.957,142.195,1266],#5.左肘-14
    #     [159.034,198.601,1183],#6.左腕-15
    #     [269.09,300.92,913]])
    data=np.array([
        [ 0.478819,-0.7916512,3.275743],
        [ 0.4507392,-0.4806581,3.162828],
        [ 0.4160445,-0.1715734,3.173684],
        [ 0.2813471,-0.1679728,3.221935],#12
        [ 0.3034572,-0.4572012,3.329852],#13
        [ 0.3647171,-0.7599866,3.410001],#14
        [ 0.3525464,-0.1716039,3.231897],#0
        [ 0.3616037,0.102996,3.164535],#1
        [ 0.3683444,0.3741698,3.088903],#2
        [ 0.3475621,0.5187062,3.051989],#3
        [ 0.3062175,0.02678134,2.88056],
        [ 0.5200339,0.06213368,2.98291],
        [ 0.487476,0.2670175,3.015251],
        [ 0.2096776,0.3053874,3.16089],
        [ 0.1648699,0.1060671,3.155235],#5
        [ 0.2736065,0.09086692,2.901276]#6
    ])#NTU-RGBD的标准骨骼数据 
    # data=np.array([[ 0.3525464,-0.1716039,3.231897],#0
    #     [ 0.3616037,0.102996,3.164535],#1
    #     [ 0.3683444,0.3741698,3.088903],#2
    #     [ 0.3475621,0.5187062,3.051989],#3
    #     [ 0.2096776,0.3053874,3.16089],#4
    #     [ 0.1648699,0.1060671,3.155235],#5
    #     [ 0.2736065,0.09086692,2.901276],#6
    #     [ 0.2961145,0.03280195,2.841183],#7
    #     [ 0.487476,0.2670175,3.015251],#8
    #     [ 0.5200339,0.06213368,2.98291],#9
    #     [ 0.3062175,0.02678134,2.88056],#10
    #     [ 0.2372144,0.03553688,2.833289],#11
    #     [ 0.2813471,-0.1679728,3.221935],#12
    #     [ 0.3034572,-0.4572012,3.329852],#13
    #     [ 0.3647171,-0.7599866,3.410001],#14
    #     [ 0.3303504,-0.8361098,3.411484],#15
    #     [ 0.4160445,-0.1715734,3.173684],#16
    #     [ 0.4507392,-0.4806581,3.162828],#17
    #     [ 0.478819,-0.7916512,3.275743],#18
    #     [ 0.4258861,-0.8481283,3.164284],#19
    #     [ 0.3669905,0.3070622,3.109868],#20
    #     [ 0.2723106,0.03126522,2.804767],#21
    #     [ 0.2636626,0.0477571,2.7945],#22
    #     [ 0.1978352,0.03234557,2.834733],#23
    #     [ 0.1932472,0.00465894,2.851]])#24
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    draw3Dpose(data, ax)
    plt.show()


379f45f698694aa78eae650e89c09f3ec4eeab94
<mask token>


def draw3Dpose(d_pose, ax, lcolor='#3498db', rcolor='#e74c3c', add_labels=False
    ):
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in
            range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
    RADIUS = 0.6
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')


<mask token>

<mask token>


def draw3Dpose(d_pose, ax, lcolor='#3498db', rcolor='#e74c3c', add_labels=False
    ):
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in
            range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
    RADIUS = 0.6
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')


if __name__ == '__main__':
    specific_3d_skeleton = np.array([[-60.70762, 403.8008, 109.0549], [-
        21.792213, 350.7608, 542.72705], [19.21995, 377.59323, 992.2105], [
        306.85883, 326.98297, 967.81555], [280.36816, 338.44727, 516.5916],
        [255.34781, 397.92474, 82.73034], [163.04, 332.288, 980.013], [
        178.85904, 234.66092, 1240.1534], [164.37048, 211.85312, 1487.3542],
        [164.81487, 211.43636, 1683.0452], [-104.66232, 412.21793, 511.5632
        ], [4.860744, 460.55948, 1061.1226], [34.860744, 360.55948, 
        1461.1226], [353.3462, 285.74405, 1454.4487], [440.2841, 285.90445,
        1022.6831], [408.4938, 280.56336, 562.1969], [164.2095, 206.31268, 
        1568.9426]])
    data = np.array([[0.478819, -0.7916512, 3.275743], [0.4507392, -
        0.4806581, 3.162828], [0.4160445, -0.1715734, 3.173684], [0.2813471,
        -0.1679728, 3.221935], [0.3034572, -0.4572012, 3.329852], [
        0.3647171, -0.7599866, 3.410001], [0.3525464, -0.1716039, 3.231897],
        [0.3616037, 0.102996, 3.164535], [0.3683444, 0.3741698, 3.088903],
        [0.3475621, 0.5187062, 3.051989], [0.3062175, 0.02678134, 2.88056],
        [0.5200339, 0.06213368, 2.98291], [0.487476, 0.2670175, 3.015251],
        [0.2096776, 0.3053874, 3.16089], [0.1648699, 0.1060671, 3.155235],
        [0.2736065, 0.09086692, 2.901276]])
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    draw3Dpose(data, ax)
    plt.show()

<mask token>
human36m_connectivity_dict = [[0, 1, 0], [1, 2, 0], [2, 6, 0], [5, 4, 1], [
    4, 3, 1], [3, 6, 1], [6, 7, 0], [7, 8, 0], [8, 9, 0], [8, 12, 0], [11, 
    12, 0], [10, 11, 0], [8, 13, 1], [13, 14, 1], [14, 15, 1]]


def draw3Dpose(d_pose, ax, lcolor='#3498db', rcolor='#e74c3c', add_labels=False
    ):
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in
            range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
    RADIUS = 0.6
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')


if __name__ == '__main__':
    specific_3d_skeleton = np.array([[-60.70762, 403.8008, 109.0549], [-
        21.792213, 350.7608, 542.72705], [19.21995, 377.59323, 992.2105], [
        306.85883, 326.98297, 967.81555], [280.36816, 338.44727, 516.5916],
        [255.34781, 397.92474, 82.73034], [163.04, 332.288, 980.013], [
        178.85904, 234.66092, 1240.1534], [164.37048, 211.85312, 1487.3542],
        [164.81487, 211.43636, 1683.0452], [-104.66232, 412.21793, 511.5632
        ], [4.860744, 460.55948, 1061.1226], [34.860744, 360.55948, 
        1461.1226], [353.3462, 285.74405, 1454.4487], [440.2841, 285.90445,
        1022.6831], [408.4938, 280.56336, 562.1969], [164.2095, 206.31268, 
        1568.9426]])
    data = np.array([[0.478819, -0.7916512, 3.275743], [0.4507392, -
        0.4806581, 3.162828], [0.4160445, -0.1715734, 3.173684], [0.2813471,
        -0.1679728, 3.221935], [0.3034572, -0.4572012, 3.329852], [
        0.3647171, -0.7599866, 3.410001], [0.3525464, -0.1716039, 3.231897],
        [0.3616037, 0.102996, 3.164535], [0.3683444, 0.3741698, 3.088903],
        [0.3475621, 0.5187062, 3.051989], [0.3062175, 0.02678134, 2.88056],
        [0.5200339, 0.06213368, 2.98291], [0.487476, 0.2670175, 3.015251],
        [0.2096776, 0.3053874, 3.16089], [0.1648699, 0.1060671, 3.155235],
        [0.2736065, 0.09086692, 2.901276]])
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    draw3Dpose(data, ax)
    plt.show()

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
human36m_connectivity_dict = [[0, 1, 0], [1, 2, 0], [2, 6, 0], [5, 4, 1], [
    4, 3, 1], [3, 6, 1], [6, 7, 0], [7, 8, 0], [8, 9, 0], [8, 12, 0], [11, 
    12, 0], [10, 11, 0], [8, 13, 1], [13, 14, 1], [14, 15, 1]]


def draw3Dpose(d_pose, ax, lcolor='#3498db', rcolor='#e74c3c', add_labels=False
    ):
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in
            range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
    RADIUS = 0.6
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')


if __name__ == '__main__':
    specific_3d_skeleton = np.array([[-60.70762, 403.8008, 109.0549], [-
        21.792213, 350.7608, 542.72705], [19.21995, 377.59323, 992.2105], [
        306.85883, 326.98297, 967.81555], [280.36816, 338.44727, 516.5916],
        [255.34781, 397.92474, 82.73034], [163.04, 332.288, 980.013], [
        178.85904, 234.66092, 1240.1534], [164.37048, 211.85312, 1487.3542],
        [164.81487, 211.43636, 1683.0452], [-104.66232, 412.21793, 511.5632
        ], [4.860744, 460.55948, 1061.1226], [34.860744, 360.55948, 
        1461.1226], [353.3462, 285.74405, 1454.4487], [440.2841, 285.90445,
        1022.6831], [408.4938, 280.56336, 562.1969], [164.2095, 206.31268, 
        1568.9426]])
    data = np.array([[0.478819, -0.7916512, 3.275743], [0.4507392, -
        0.4806581, 3.162828], [0.4160445, -0.1715734, 3.173684], [0.2813471,
        -0.1679728, 3.221935], [0.3034572, -0.4572012, 3.329852], [
        0.3647171, -0.7599866, 3.410001], [0.3525464, -0.1716039, 3.231897],
        [0.3616037, 0.102996, 3.164535], [0.3683444, 0.3741698, 3.088903],
        [0.3475621, 0.5187062, 3.051989], [0.3062175, 0.02678134, 2.88056],
        [0.5200339, 0.06213368, 2.98291], [0.487476, 0.2670175, 3.015251],
        [0.2096776, 0.3053874, 3.16089], [0.1648699, 0.1060671, 3.155235],
        [0.2736065, 0.09086692, 2.901276]])
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    draw3Dpose(data, ax)
    plt.show()

import matplotlib.pyplot as plt
from  mpl_toolkits.mplot3d import Axes3D
import numpy as np

# h36m骨架连接顺序，每个骨架三个维度，分别为：起始关节，终止关节，左右关节标识(1 left 0 right)
human36m_connectivity_dict = [[0,1,0],[1, 2, 0], [2, 6, 0], [5, 4, 1], [4, 3, 1], [3, 6, 1], [6, 7, 0],
                              [7, 8, 0], [8, 9, 0],
                              [8, 12, 0], [11, 12, 0], [10, 11, 0], [8, 13, 1], [13, 14, 1], [14, 15, 1]]


def draw3Dpose(d_pose, ax, lcolor="#3498db", rcolor="#e74c3c", add_labels=False):  # blue, orange
    for i in human36m_connectivity_dict:
        x, y, z = [np.array([d_pose[i[0], j], d_pose[i[1], j]]) for j in range(3)]
        ax.plot(x, y, z, lw=2, c=lcolor if i[2] else rcolor)
        # print(x)
        # print(y)
        # print(z)
        # print(i)
        # break

    RADIUS = 0.6  # space around the subject
    xroot, yroot, zroot = d_pose[5, 0], d_pose[5, 1], d_pose[5, 2]
    ax.set_xlim3d([-RADIUS + xroot, RADIUS + xroot])
    ax.set_zlim3d([0, 2 * RADIUS + zroot])
    ax.set_ylim3d([-RADIUS + yroot, RADIUS + yroot])

    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")


if __name__ == '__main__':
    specific_3d_skeleton = np.array([[-60.70762, 403.8008, 109.0549],#0右脚腕
                                     [-21.792213, 350.7608, 542.72705],#1右膝
                                     [19.21995, 377.59323, 992.2105],#2右臀
                                     [306.85883, 326.98297, 967.81555],#3左臀
                                     [280.36816, 338.44727, 516.5916],#4左膝
                                     [255.34781, 397.92474, 82.73034],#root节点5左脚腕
                                     [163.04, 332.288, 980.013],#6臀部中点(骨盆)
                                     [178.85904, 234.66092, 1240.1534],#7腰部(脊柱)
                                     [164.37048, 211.85312, 1487.3542],#8颈部(胸部)
                                     [164.81487, 211.43636, 1683.0452],#9头部
                                     [-104.66232, 412.21793, 511.5632],#10右手腕
                                     [4.860744, 460.55948, 1061.1226],#11右手肘
                                     [34.860744, 360.55948, 1461.1226],#12右肩
                                     [353.3462, 285.74405, 1454.4487],#13左肩
                                     [440.2841, 285.90445, 1022.6831],#14左手肘
                                     [408.4938, 280.56336, 562.1969],#15左手腕
                                     [164.2095, 206.31268, 1568.9426]])#16鼻子
    # data=np.array([
    #     [269.09,300.92,1020],#18.右踝-0
    #     [269.09,300.92,903],#17.右膝-1
    #     [245.916,203.577,1044],#16.右臀-2
    #     [200.722,201.658,1110],#12.左臀-3
    #     [199.913,282.803,1116],#13.左膝-4
    #     [199.913,282.803,900],#14.左踝-5
    #     [223.207,202.611,1077],#0.臀部中点-6
    #     [224.747,114.517,1112],#1.臀部上部中点-7
    #     [226.18,37.1176,1228],#2.脖子-8
    #     [227.589,1.96397,1154],#3.头-9
    #     [279.357,189.911,1006],#10.右腕-10
    #     [288.588,129.108,1163],#9.右肘-11
    #     [200.722,201.658,1110],#12.左臀-3
    #     [199.913,282.803,1116],#13.左膝-4
    #     [167.957,142.195,1266],#5.左肘-14
    #     [159.034,198.601,1183],#6.左腕-15
    #     [269.09,300.92,913]])
    data=np.array([
        [ 0.478819,-0.7916512,3.275743],
        [ 0.4507392,-0.4806581,3.162828],
        [ 0.4160445,-0.1715734,3.173684],
        [ 0.2813471,-0.1679728,3.221935],#12
        [ 0.3034572,-0.4572012,3.329852],#13
        [ 0.3647171,-0.7599866,3.410001],#14
        [ 0.3525464,-0.1716039,3.231897],#0
        [ 0.3616037,0.102996,3.164535],#1
        [ 0.3683444,0.3741698,3.088903],#2
        [ 0.3475621,0.5187062,3.051989],#3
        [ 0.3062175,0.02678134,2.88056],
        [ 0.5200339,0.06213368,2.98291],
        [ 0.487476,0.2670175,3.015251],
        [ 0.2096776,0.3053874,3.16089],
        [ 0.1648699,0.1060671,3.155235],#5
        [ 0.2736065,0.09086692,2.901276]#6
    ])#NTU-RGBD的标准骨骼数据 
    # data=np.array([[ 0.3525464,-0.1716039,3.231897],#0
    #     [ 0.3616037,0.102996,3.164535],#1
    #     [ 0.3683444,0.3741698,3.088903],#2
    #     [ 0.3475621,0.5187062,3.051989],#3
    #     [ 0.2096776,0.3053874,3.16089],#4
    #     [ 0.1648699,0.1060671,3.155235],#5
    #     [ 0.2736065,0.09086692,2.901276],#6
    #     [ 0.2961145,0.03280195,2.841183],#7
    #     [ 0.487476,0.2670175,3.015251],#8
    #     [ 0.5200339,0.06213368,2.98291],#9
    #     [ 0.3062175,0.02678134,2.88056],#10
    #     [ 0.2372144,0.03553688,2.833289],#11
    #     [ 0.2813471,-0.1679728,3.221935],#12
    #     [ 0.3034572,-0.4572012,3.329852],#13
    #     [ 0.3647171,-0.7599866,3.410001],#14
    #     [ 0.3303504,-0.8361098,3.411484],#15
    #     [ 0.4160445,-0.1715734,3.173684],#16
    #     [ 0.4507392,-0.4806581,3.162828],#17
    #     [ 0.478819,-0.7916512,3.275743],#18
    #     [ 0.4258861,-0.8481283,3.164284],#19
    #     [ 0.3669905,0.3070622,3.109868],#20
    #     [ 0.2723106,0.03126522,2.804767],#21
    #     [ 0.2636626,0.0477571,2.7945],#22
    #     [ 0.1978352,0.03234557,2.834733],#23
    #     [ 0.1932472,0.00465894,2.851]])#24
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    draw3Dpose(data, ax)
    plt.show()

