@@ -119,7 +119,6 @@ def _calculate_mouth_landmarks(self):
119
119
mouth_open = self ._remap_blendshape (FaceBlendShape .MouthOpen , mouth_open_dist / mouth_width ) #mouth aspect ratio
120
120
self ._face_data .set_blendshape (FaceBlendShape .MouthOpen , mouth_open )
121
121
122
-
123
122
#Simle
124
123
mouth_smile_left ,mouth_smile_right = self .detect_smile (upper_lip ,mouth_corner_left ,mouth_corner_right )
125
124
@@ -133,24 +132,17 @@ def _calculate_mouth_landmarks(self):
133
132
134
133
135
134
uppest_lip = self ._get_landmark (0 )
136
-
137
- #Jaw left right
138
- self .detect_Jaw_direction (nose_tip ,lowest_chin )
139
-
140
- #
141
135
lowest_lip = self ._get_landmark (self .blend_shape_config .CanonicalPoints .lowest_lip )
142
136
under_lip = self ._get_landmark (self .blend_shape_config .CanonicalPoints .under_lip )
143
137
144
- outer_lip_dist = self .dist (lower_lip , lowest_lip )
145
- upper_lip_dist = self .dist (upper_lip , upper_outer_lip )
146
- self ._face_data .set_blendshape (
147
- FaceBlendShape .MouthRollLower , 1 - self ._remap_blendshape (FaceBlendShape .MouthRollLower , outer_lip_dist ))
148
- self ._face_data .set_blendshape (
149
- FaceBlendShape .MouthRollUpper , 1 - self ._remap_blendshape (FaceBlendShape .MouthRollUpper , upper_lip_dist ))
138
+ #Jaw left right
139
+ self .detect_Jaw_direction (nose_tip ,lowest_chin )
150
140
141
+ #mouth roll
142
+ self .detect_Mouth_Roll (lower_lip ,upper_lip ,upper_outer_lip ,lowest_lip )
151
143
152
144
#mouth pucker
153
- self .detect_mouth_pucker (mouth_width )
145
+ self .detect_mouth_pucker (mouth_width , mouth_open_dist )
154
146
155
147
#Mouth shrug
156
148
self .detect_mouth_shrug (nose_tip ,uppest_lip ,lowest_lip )
@@ -180,6 +172,7 @@ def detect_smile(self,upper_lip,mouth_corner_left,mouth_corner_right):
180
172
mouth_smile_right = 1 - \
181
173
self ._remap_blendshape (FaceBlendShape .MouthSmileRight , smile_right )
182
174
175
+ print (mouth_smile_right )
183
176
self ._face_data .set_blendshape (
184
177
FaceBlendShape .MouthSmileLeft , mouth_smile_left )
185
178
self ._face_data .set_blendshape (
@@ -233,6 +226,8 @@ def detect_mouth_Stretch(self,mouth_center,mouth_corner_left,mouth_corner_right,
233
226
FaceBlendShape .MouthLeft , mouth_left )
234
227
self ._face_data .set_blendshape (
235
228
FaceBlendShape .MouthRight , mouth_right )
229
+
230
+
236
231
# self._live_link_face.set_blendshape(ARKitFace.MouthRight, 1 - remap(mouth_left_right, -1.5, 0.0))
237
232
#-------------------------------------------------------
238
233
@@ -254,6 +249,19 @@ def detect_mouth_Stretch(self,mouth_center,mouth_corner_left,mouth_corner_right,
254
249
mouth_right_stretch_final = self ._remap (mouth_right_stretch , stretch_normal_right , stretch_max_right )
255
250
self ._face_data .set_blendshape (FaceBlendShape .MouthStretchRight , mouth_right_stretch_final )
256
251
252
+
253
+ # when your mouth roll and shrink this will be near to 1
254
+ def detect_Mouth_Roll (self ,lower_lip ,upper_lip ,upper_outer_lip ,lowest_lip ):
255
+
256
+
257
+ outer_lip_dist = self .dist (lower_lip , lowest_lip )
258
+ upper_lip_dist = self .dist (upper_lip , upper_outer_lip )
259
+ self ._face_data .set_blendshape (
260
+ FaceBlendShape .MouthRollLower , 1 - self ._remap_blendshape (FaceBlendShape .MouthRollLower , outer_lip_dist ))
261
+ self ._face_data .set_blendshape (
262
+ FaceBlendShape .MouthRollUpper , 1 - self ._remap_blendshape (FaceBlendShape .MouthRollUpper , upper_lip_dist ))
263
+
264
+
257
265
def detect_Jaw_direction (self ,nose_tip ,lowest_chin ):
258
266
#Jaw left right
259
267
# jaw only interesting on x yxis
@@ -268,6 +276,7 @@ def detect_Jaw_direction(self,nose_tip,lowest_chin):
268
276
self ._face_data .set_blendshape (FaceBlendShape .JawRight , jaw_right )
269
277
#-------------------------------
270
278
279
+ # will appear in the time of mouth press(when you hide your lips by pulling it inside your mouth!)
271
280
def detect_mouth_press (self ):
272
281
left_upper_press = self .dist (
273
282
self ._get_landmark (self .blend_shape_config .CanonicalPoints .left_upper_press [0 ]),
@@ -292,13 +301,15 @@ def detect_mouth_press(self):
292
301
mouth_press_left_final = 1 - self ._remap_blendshape (FaceBlendShape .MouthPressLeft , mouth_press_left )
293
302
mouth_press_right_final = 1 - self ._remap_blendshape (FaceBlendShape .MouthPressRight , mouth_press_right )
294
303
304
+ # print(mouth_press_left_final)
295
305
self ._face_data .set_blendshape (
296
306
FaceBlendShape .MouthPressLeft , mouth_press_left_final )
297
307
self ._face_data .set_blendshape (
298
308
FaceBlendShape .MouthPressRight ,
299
309
mouth_press_right_final
300
310
)
301
311
312
+ #will appear when your whole mouth goes to corner left down or right direction
302
313
def detect_mouth_lower_direction (self ,mouth_open_dist ):
303
314
lower_down_left = self .dist (self ._get_landmark (
304
315
424 ), self ._get_landmark (319 )) + mouth_open_dist * 0.5
@@ -307,9 +318,9 @@ def detect_mouth_lower_direction(self,mouth_open_dist):
307
318
308
319
lower_down_left_final = 1 - self ._remap_blendshape (FaceBlendShape .MouthLowerDownLeft , lower_down_left )
309
320
lower_down_right_final = 1 - self ._remap_blendshape (FaceBlendShape .MouthLowerDownRight ,lower_down_right )
310
-
321
+ # print(lower_down_right_final)
311
322
self ._face_data .set_blendshape (FaceBlendShape .MouthLowerDownLeft , lower_down_left_final )
312
- self ._face_data .set_blendshape (FaceBlendShape .MouthLowerDownRight , lower_down_right_final )
323
+ self ._face_data .set_blendshape (FaceBlendShape .MouthLowerDownRight , lower_down_right_final )
313
324
314
325
def detect_mouth_shrug (self ,nose_tip ,uppest_lip ,lowest_lip ):
315
326
#mouth shrug up will be near 1 if upper mouth is near nose!
@@ -327,11 +338,16 @@ def detect_mouth_shrug(self,nose_tip,uppest_lip,lowest_lip):
327
338
328
339
#------------------------------------------------------------------
329
340
330
- def detect_mouth_pucker (self ,mouth_width ):
341
+ def detect_mouth_pucker (self ,mouth_width , mouth_open_dist ):
331
342
mouth_pucker = self ._remap_blendshape (
332
- FaceBlendShape .MouthPucker , mouth_width )
343
+ FaceBlendShape .MouthPucker , mouth_open_dist / mouth_width )
344
+ # self._face_data.set_blendshape(
345
+ # FaceBlendShape.MouthPucker, 1 - mouth_pucker)
333
346
self ._face_data .set_blendshape (
334
- FaceBlendShape .MouthPucker , 1 - mouth_pucker )
347
+ FaceBlendShape .MouthPucker , mouth_pucker )
348
+
349
+ # print(mouth_pucker)
350
+
335
351
# mouth funnel only can be seen if mouth pucker is really small
336
352
if self ._face_data .get_blendshape (FaceBlendShape .MouthPucker ) < 0.5 :
337
353
self ._face_data .set_blendshape (
@@ -368,14 +384,16 @@ def get_eye_open_ration(points):
368
384
self ._get_landmark (self .blend_shape_config .CanonicalPoints .squint_left [1 ])
369
385
)
370
386
self ._face_data .set_blendshape (
371
- FaceBlendShape .EyeSquintLeft , 1 - self ._remap_blendshape (FaceBlendShape .EyeSquintLeft , squint_left ))
387
+ FaceBlendShape .EyeSquintLeft , self ._remap_blendshape (FaceBlendShape .EyeSquintLeft , squint_left ))
372
388
373
389
squint_right = self .dist (
374
390
self ._get_landmark (self .blend_shape_config .CanonicalPoints .squint_right [0 ]),
375
391
self ._get_landmark (self .blend_shape_config .CanonicalPoints .squint_right [1 ])
376
392
)
377
393
self ._face_data .set_blendshape (
378
- FaceBlendShape .EyeSquintRight , 1 - self ._remap_blendshape (FaceBlendShape .EyeSquintRight , squint_right ))
394
+ FaceBlendShape .EyeSquintRight , self ._remap_blendshape (FaceBlendShape .EyeSquintRight , squint_right ))
395
+
396
+ # print(self._remap_blendshape(FaceBlendShape.EyeSquintRight, squint_right))
379
397
380
398
#Brow
381
399
self .detect_brow_actions ()
@@ -403,6 +421,7 @@ def detect_blinks(self,get_eye_open_ration):
403
421
FaceBlendShape .EyeWideLeft , eye_open_ratio_left ))
404
422
self ._face_data .set_blendshape (FaceBlendShape .EyeWideRight , self ._remap_blendshape (
405
423
FaceBlendShape .EyeWideRight , eye_open_ratio_right ))
424
+
406
425
# ----------------------------------------
407
426
408
427
def detect_brow_actions (self ):
@@ -447,8 +466,9 @@ def detect_brow_actions(self):
447
466
self ._face_data .set_blendshape (FaceBlendShape .BrowInnerUp , brow_inner_up )
448
467
# print(brow_inner_up)
449
468
469
+
450
470
def detect_cheek (self ):
451
- # Cheek is turned over left or right
471
+ # Cheek is turned over left or right (will be higher when goes right up or left up) (will be 1 when nose also turn over)
452
472
453
473
cheek_squint_left = self .dist (
454
474
self ._get_landmark (self .blend_shape_config .CanonicalPoints .cheek_squint_left [0 ]),
@@ -466,6 +486,8 @@ def detect_cheek(self):
466
486
cheek_squint_right_final = 1 - self ._remap_blendshape (FaceBlendShape .CheekSquintRight , cheek_squint_right )
467
487
self ._face_data .set_blendshape (FaceBlendShape .CheekSquintRight , cheek_squint_right_final )
468
488
489
+ # print(cheek_squint_right_final)
490
+
469
491
# ----------------------------------------------
470
492
471
493
# just use the same values for cheeksquint for nose sneer, mediapipe deosn't seem to have a separate value for nose sneer
0 commit comments