-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathmeasurement_definitions.py
288 lines (244 loc) · 12.3 KB
/
measurement_definitions.py
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
from landmark_definitions import *
from joint_definitions import *
STANDARD_LABELS = {
'A': 'head circumference',
'B': 'neck circumference',
'C': 'shoulder to crotch height',
'D': 'chest circumference',
'E': 'waist circumference',
'F': 'hip circumference',
'G': 'wrist right circumference',
'H': 'bicep right circumference',
'I': 'forearm right circumference',
'J': 'arm right length',
'K': 'inside leg height',
'L': 'thigh left circumference',
'M': 'calf left circumference',
'N': 'ankle left circumference',
'O': 'shoulder breadth',
'P': 'height'
}
class MeasurementType():
CIRCUMFERENCE = "circumference"
LENGTH = "length"
MEASUREMENT_TYPES = {
"height": MeasurementType.LENGTH,
"head circumference": MeasurementType.CIRCUMFERENCE,
"neck circumference": MeasurementType.CIRCUMFERENCE,
"shoulder to crotch height": MeasurementType.LENGTH,
"chest circumference": MeasurementType.CIRCUMFERENCE,
"waist circumference": MeasurementType.CIRCUMFERENCE,
"hip circumference": MeasurementType.CIRCUMFERENCE,
"wrist right circumference": MeasurementType.CIRCUMFERENCE,
"bicep right circumference": MeasurementType.CIRCUMFERENCE,
"forearm right circumference": MeasurementType.CIRCUMFERENCE,
"arm right length": MeasurementType.LENGTH,
"inside leg height": MeasurementType.LENGTH,
"thigh left circumference": MeasurementType.CIRCUMFERENCE,
"calf left circumference": MeasurementType.CIRCUMFERENCE,
"ankle left circumference": MeasurementType.CIRCUMFERENCE,
"shoulder breadth": MeasurementType.LENGTH,
"arm length (shoulder to elbow)": MeasurementType.LENGTH,
"arm length (spine to wrist)": MeasurementType.LENGTH,
"crotch height": MeasurementType.LENGTH,
"Hip circumference max height": MeasurementType.LENGTH,
}
class SMPLMeasurementDefinitions():
'''
Definition of SMPL measurements.
To add a new measurement:
1. add it to the measurement_types dict and set the type:
LENGTH or CIRCUMFERENCE
2. depending on the type, define the measurement in LENGTHS or
CIRCUMFERENCES dict
- LENGTHS are defined using 2 landmarks - the measurement is
found with distance between landmarks
- CIRCUMFERENCES are defined with landmarks and joints - the
measurement is found by cutting the SMPL model with the
plane defined by a point (landmark point) and normal (
vector connecting the two joints)
3. If the body part is a CIRCUMFERENCE, a possible issue that arises is
that the plane cutting results in multiple body part slices. To alleviate
that, define the body part where the measurement should be located in
CIRCUMFERENCE_TO_BODYPARTS dict. This way, only slice in that body part is
used for finding the measurement. The body parts are defined by the SMPL
face segmentation.
'''
LENGTHS = {"height":
(SMPL_LANDMARK_INDICES["HEAD_TOP"],
SMPL_LANDMARK_INDICES["HEELS"]
),
"shoulder to crotch height":
(SMPL_LANDMARK_INDICES["SHOULDER_TOP"],
SMPL_LANDMARK_INDICES["INSEAM_POINT"]
),
"arm left length":
(SMPL_LANDMARK_INDICES["LEFT_SHOULDER"],
SMPL_LANDMARK_INDICES["LEFT_WRIST"]
),
"arm right length":
(SMPL_LANDMARK_INDICES["RIGHT_SHOULDER"],
SMPL_LANDMARK_INDICES["RIGHT_WRIST"]
),
"inside leg height":
(SMPL_LANDMARK_INDICES["LOW_LEFT_HIP"],
SMPL_LANDMARK_INDICES["LEFT_ANKLE"]
),
"shoulder breadth":
(SMPL_LANDMARK_INDICES["LEFT_SHOULDER"],
SMPL_LANDMARK_INDICES["RIGHT_SHOULDER"]
),
"arm length (shoulder to elbow)":
(
# SMPL_LANDMARK_INDICES["LEFT_SHOULDER"],
# SMPL_LANDMARK_INDICES["LEFT_ELBOW"]
SMPL_LANDMARK_INDICES["Rt. Acromion"],
SMPL_LANDMARK_INDICES["Rt. Humeral Lateral Epicn"]
),
"crotch height":
(SMPL_LANDMARK_INDICES["CROTCH"],
SMPL_LANDMARK_INDICES["HEELS"]
),
"Hip circumference max height":
(SMPL_LANDMARK_INDICES["PUBIC_BONE"],
SMPL_LANDMARK_INDICES["HEELS"]
),
# FIXME: implement geodesic distance for this measurement
"arm length (spine to wrist)":
(
# SMPL_LANDMARK_INDICES["SHOULDER_TOP"],
# SMPL_LANDMARK_INDICES["LEFT_WRIST"]
SMPL_LANDMARK_INDICES["Cervicale"],
SMPL_LANDMARK_INDICES["Rt. Acromion"],
SMPL_LANDMARK_INDICES["Rt. Humeral Lateral Epicn"],
SMPL_LANDMARK_INDICES["Rt. Ulnar Styloid"]
),
}
# defined with landmarks and joints
# landmarks are defined with indices of the smpl model points
# normals are defined with joint names of the smpl model
CIRCUMFERENCES = {
"head circumference":{"LANDMARKS":["HEAD_LEFT_TEMPLE"],
"JOINTS":["pelvis","spine3"]},
"neck circumference":{"LANDMARKS":["NECK_ADAM_APPLE"],
"JOINTS":["spine2","head"]},
"chest circumference":{"LANDMARKS":["LEFT_NIPPLE","RIGHT_NIPPLE"],
"JOINTS":["pelvis","spine3"]},
"waist circumference":{"LANDMARKS":["BELLY_BUTTON","BACK_BELLY_BUTTON"],
"JOINTS":["pelvis","spine3"]},
"hip circumference":{"LANDMARKS":["PUBIC_BONE"],
"JOINTS":["pelvis","spine3"]},
"wrist right circumference":{"LANDMARKS":["RIGHT_WRIST"],
"JOINTS":["right_wrist","right_hand"]},
"bicep right circumference":{"LANDMARKS":["RIGHT_BICEP"],
"JOINTS":["right_shoulder","right_elbow"]},
"forearm right circumference":{"LANDMARKS":["RIGHT_FOREARM"],
"JOINTS":["right_elbow","right_wrist"]},
"thigh left circumference":{"LANDMARKS":["LEFT_THIGH"],
"JOINTS":["pelvis","spine3"]},
"calf left circumference":{"LANDMARKS":["LEFT_CALF"],
"JOINTS":["pelvis","spine3"]},
"ankle left circumference":{"LANDMARKS":["LEFT_ANKLE"],
"JOINTS":["pelvis","spine3"]},
}
possible_measurements = list(LENGTHS.keys()) + list(CIRCUMFERENCES.keys())
CIRCUMFERENCE_TO_BODYPARTS = {
"head circumference": "head",
"neck circumference":"neck",
"chest circumference":["spine1","spine2"],
"waist circumference":["hips","spine"],
"hip circumference":"hips",
"wrist right circumference":["rightHand","rightForeArm"],
"bicep right circumference":"rightArm",
"forearm right circumference":"rightForeArm",
"thigh left circumference": "leftUpLeg",
"calf left circumference": "leftLeg",
"ankle left circumference": "leftLeg",
}
class SMPLXMeasurementDefinitions():
'''
Definition of SMPLX measurements.
To add a new measurement:
1. add it to the measurement_types dict and set the type:
LENGTH or CIRCUMFERENCE
2. depending on the type, define the measurement in LENGTHS or
CIRCUMFERENCES dict
- LENGTHS are defined using 2 landmarks - the measurement is
found with distance between landmarks
- CIRCUMFERENCES are defined with landmarks and joints - the
measurement is found by cutting the SMPLX model with the
plane defined by a point (landmark point) and normal (
vector connecting the two joints)
3. If the body part is a CIRCUMFERENCE, a possible issue that arises is
that the plane cutting results in multiple body part slices. To alleviate
that, define the body part where the measurement should be located in
CIRCUMFERENCE_TO_BODYPARTS dict. This way, only slice in that body part is
used for finding the measurement. The body parts are defined by the SMPL
face segmentation.
'''
LENGTHS = {"height":
(SMPLX_LANDMARK_INDICES["HEAD_TOP"],
SMPLX_LANDMARK_INDICES["HEELS"]
),
"shoulder to crotch height":
(SMPLX_LANDMARK_INDICES["SHOULDER_TOP"],
SMPLX_LANDMARK_INDICES["INSEAM_POINT"]
),
"arm left length":
(SMPLX_LANDMARK_INDICES["LEFT_SHOULDER"],
SMPLX_LANDMARK_INDICES["LEFT_WRIST"]
),
"arm right length":
(SMPLX_LANDMARK_INDICES["RIGHT_SHOULDER"],
SMPLX_LANDMARK_INDICES["RIGHT_WRIST"]
),
"inside leg height":
(SMPLX_LANDMARK_INDICES["LOW_LEFT_HIP"],
SMPLX_LANDMARK_INDICES["LEFT_ANKLE"]
),
"shoulder breadth":
(SMPLX_LANDMARK_INDICES["LEFT_SHOULDER"],
SMPLX_LANDMARK_INDICES["RIGHT_SHOULDER"]
),
}
# defined with landmarks and joints
# landmarks are defined with indices of the smpl model points
# normals are defined with joint names of the smpl model
CIRCUMFERENCES = {
"head circumference":{"LANDMARKS":["HEAD_LEFT_TEMPLE"],
"JOINTS":["pelvis","spine3"]},
"neck circumference":{"LANDMARKS":["NECK_ADAM_APPLE"],
"JOINTS":["spine1","spine3"]},
"chest circumference":{"LANDMARKS":["LEFT_NIPPLE","RIGHT_NIPPLE"],
"JOINTS":["pelvis","spine3"]},
"waist circumference":{"LANDMARKS":["BELLY_BUTTON","BACK_BELLY_BUTTON"],
"JOINTS":["pelvis","spine3"]},
"hip circumference":{"LANDMARKS":["PUBIC_BONE"],
"JOINTS":["pelvis","spine3"]},
"wrist right circumference":{"LANDMARKS":["RIGHT_WRIST"],
"JOINTS":["right_wrist","right_elbow"]}, # different from SMPL
"bicep right circumference":{"LANDMARKS":["RIGHT_BICEP"],
"JOINTS":["right_shoulder","right_elbow"]},
"forearm right circumference":{"LANDMARKS":["RIGHT_FOREARM"],
"JOINTS":["right_elbow","right_wrist"]},
"thigh left circumference":{"LANDMARKS":["LEFT_THIGH"],
"JOINTS":["pelvis","spine3"]},
"calf left circumference":{"LANDMARKS":["LEFT_CALF"],
"JOINTS":["pelvis","spine3"]},
"ankle left circumference":{"LANDMARKS":["LEFT_ANKLE"],
"JOINTS":["pelvis","spine3"]},
}
possible_measurements = list(LENGTHS.keys()) + list(CIRCUMFERENCES.keys())
CIRCUMFERENCE_TO_BODYPARTS = {
"head circumference": "head",
"neck circumference":"neck",
"chest circumference":["spine1","spine2"],
"waist circumference":["hips","spine"],
"hip circumference":"hips",
"wrist right circumference":["rightHand","rightForeArm"],
"bicep right circumference":"rightArm",
"forearm right circumference":"rightForeArm",
"thigh left circumference": "leftUpLeg",
"calf left circumference": "leftLeg",
"ankle left circumference": "leftLeg",
}