File size: 6,362 Bytes
5ac1897
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# "Skeletons" here means virtual "bones" between joints. It is used to draw the skeleton on the image.

class Skeleton():
    bones = []
    bone_colors = []
    chains = []
    parent = []


class Skeleton_SMPL24(Skeleton):
    # The joints definition are copied from
    # [ROMP](https://github.com/Arthur151/ROMP/blob/4eebd3647f57d291d26423e51f0d514ff7197cb3/romp/lib/constants.py#L58).
    chains = [
            [0, 1, 4, 7, 10],         # left leg
            [0, 2, 5, 8, 11],         # right leg
            [0, 3, 6, 9, 12, 15],     # spine & head
            [12, 13, 16, 18, 20, 22], # left arm
            [12, 14, 17, 19, 21, 23], # right arm
        ]
    bones = [
            [ 0,  1], [ 1,  4], [ 4,  7], [ 7, 10],           # left leg
            [ 0,  2], [ 2,  5], [ 5,  8], [ 8, 11],           # right leg
            [ 0,  3], [ 3,  6], [ 6,  9], [ 9, 12], [12, 15], # spine & head
            [12, 13], [13, 16], [16, 18], [18, 20], [20, 22], # left arm
            [12, 14], [14, 17], [17, 19], [19, 21], [21, 23], # right arm
        ]
    bone_colors = [
            [127,   0,   0], [148,  21,  21], [169,  41,  41], [191,  63,  63],                  # red
            [  0, 127,   0], [ 21, 148,  21], [ 41, 169,  41], [ 63, 191,  63],                  # green
            [  0,   0, 127], [ 15,  15, 143], [ 31,  31, 159], [ 47,  47, 175], [ 63,  63, 191], # blue
            [  0, 127, 127], [ 15, 143, 143], [ 31, 159, 159], [ 47, 175, 175], [ 63, 191, 191], # cyan
            [127,   0, 127], [143,  15, 143], [159,  31, 159], [175,  47, 175], [191,  63, 191], # magenta
        ]
    parent = [-1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 12, 12, 13, 14, 16, 17, 18, 19, 20, 21]


class Skeleton_SMPL22(Skeleton):
    chains = [
            [0, 1, 4, 7, 10],     # left leg
            [0, 2, 5, 8, 11],     # right leg
            [0, 3, 6, 9, 12, 15], # spine & head
            [12, 13, 16, 18, 20], # left arm
            [12, 14, 17, 19, 21], # right arm
        ]
    bones = [
            [ 0,  1], [ 1,  4], [ 4,  7], [ 7, 10],           # left leg
            [ 0,  2], [ 2,  5], [ 5,  8], [ 8, 11],           # right leg
            [ 0,  3], [ 3,  6], [ 6,  9], [ 9, 12], [12, 15], # spine & head
            [12, 13], [13, 16], [16, 18], [18, 20],           # left arm
            [12, 14], [14, 17], [17, 19], [19, 21],           # right arm
        ]
    bone_colors = [
            [127,   0,   0], [148,  21,  21], [169,  41,  41], [191,  63,  63],                  # red
            [  0, 127,   0], [ 21, 148,  21], [ 41, 169,  41], [ 63, 191,  63],                  # green
            [  0,   0, 127], [ 15,  15, 143], [ 31,  31, 159], [ 47,  47, 175], [ 63,  63, 191], # blue
            [  0, 127, 127], [ 15, 143, 143], [ 31, 159, 159], [ 47, 175, 175],                  # cyan
            [127,   0, 127], [143,  15, 143], [159,  31, 159], [175,  47, 175],                  # magenta
        ]
    parent = [-1, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 12, 12, 13, 14, 16, 17, 18, 19]


class Skeleton_SKEL24(Skeleton):
    chains = [
            [ 0,  6,  7,  8,  9, 10], # left leg
            [ 0,  1,  2,  3,  4,  5], # right leg
            [ 0, 11, 12, 13],         # spine & head
            [12, 19, 20, 21, 22, 23], # left arm
            [12, 14, 15, 16, 17, 18], # right arm
        ]
    bones = [
            [ 0,  6], [ 6,  7], [ 7,  8], [ 8,  9], [ 9, 10], # left leg
            [ 0,  1], [ 1,  2], [ 2,  3], [ 3,  4], [ 4,  5], # right leg
            [ 0, 11], [11, 12], [12, 13],                     # spine & head
            [12, 19], [19, 20], [20, 21], [21, 22], [22, 23], # left arm
            [12, 14], [14, 15], [15, 16], [16, 17], [17, 18], # right arm
        ]
    bone_colors = [
            [127,   0,   0], [148,  21,  21], [169,  41,  41], [191,  63,  63], [191,  63,  63], # red
            [  0, 127,   0], [ 21, 148,  21], [ 41, 169,  41], [ 63, 191,  63], [ 63, 191,  63], # green
            [  0,   0, 127], [ 31,  31, 159], [ 63,  63, 191],                                   # blue
            [  0, 127, 127], [ 15, 143, 143], [ 31, 159, 159], [ 47, 175, 175], [ 63, 191, 191], # cyan
            [127,   0, 127], [143,  15, 143], [159,  31, 159], [175,  47, 175], [191,  63, 191], # magenta
        ]
    parent = [-1, 0, 1, 2, 3, 4, 0, 6, 7, 8, 9, 0, 11, 12, 12, 19, 20, 21, 22, 12, 14, 15, 16, 17]


class Skeleton_OpenPose25(Skeleton):
    ''' https://www.researchgate.net/figure/Twenty-five-keypoints-of-the-OpenPose-software-model_fig1_374116819 '''
    chain = [
            [ 8, 12, 13, 14, 19, 20],  # left leg
            [14, 21],                  # left heel
            [ 8,  9, 10, 11, 22, 23],  # right leg
            [11, 24],                  # right heel
            [ 8,  1,  0],              # spine & head
            [ 0, 16, 18],              # left face
            [ 0, 15, 17],              # right face
            [ 1,  5,  6,  7],          # left arm
            [ 1,  2,  3,  4],          # right arm
        ]
    bones = [
            [ 8, 12], [12, 13], [13, 14],  # left leg
            [14, 19], [19, 20], [14, 21],  # left foot
            [ 8,  9], [ 9, 10], [10, 11],  # right leg
            [11, 22], [22, 23], [11, 24],  # right foot
            [ 8,  1], [ 1,  0],            # spine & head
            [ 0, 16], [16, 18],            # left face
            [ 0, 15], [15, 17],            # right face
            [ 1,  5], [ 5,  6], [ 6,  7],  # left arm
            [ 1,  2], [ 2,  3], [ 3,  4],  # right arm
        ]
    bone_colors = [
            [ 95,   0, 255], [ 79,   0, 255], [ 83,   0, 255],  # dark blue
            [ 31,   0, 255], [ 15,   0, 255], [  0,   0, 255],  # dark blue
            [127, 205, 255], [127, 205, 255], [ 95, 205, 255],  # light blue
            [ 63, 205, 255], [ 31, 205, 255], [  0, 205, 255],  # light blue
            [255,   0,   0], [255,   0,   0],                   # red
            [191,  63,  63], [191,  63, 191],                   # magenta
            [255,   0, 127], [255,   0, 255],                   # purple
            [127, 255,   0], [ 63, 255,   0], [  0, 255,   0],  # green
            [255, 127,   0], [255, 191,   0], [255, 255,   0],  # yellow

        ]
    parent = [1, 8, 1, 2, 3, 1, 5, 6, -1, 8, 9, 10, 8, 12, 13, 0, 0, 15, 16, 14, 19, 14, 11, 22, 11]