DeepFaceLive/xlib/face/FLandmarks2D.py
2022-05-13 12:26:20 +04:00

1355 lines
51 KiB
Python

from typing import Tuple
import cv2
import numpy as np
from .. import math as lib_math
from ..math import Affine2DMat, Affine2DUniMat
from .ELandmarks2D import ELandmarks2D
from .FRect import FRect
from .IState import IState
class FLandmarks2D(IState):
def __init__(self):
"""
Describes 2D face landmarks in uniform float coordinates
"""
self._type : ELandmarks2D = None
self._ulmrks : np.ndarray = None
def restore_state(self, state : dict):
self._type = IState._restore_enum(ELandmarks2D, state.get('_type', None))
self._ulmrks = IState._restore_np_array(state.get('_ulmrks', None))
def dump_state(self) -> dict:
return {'_type' : IState._dump_enum(self._type),
'_ulmrks' : IState._dump_np_array(self._ulmrks),
}
@staticmethod
def create( type : ELandmarks2D, ulmrks : np.ndarray):
"""
ulmrks np.ndarray (*,2|3)
"""
if not isinstance(type, ELandmarks2D):
raise ValueError('type must be ELandmarks2D')
ulmrks = np.float32(ulmrks)
if len(ulmrks.shape) != 2:
raise ValueError('ulmrks shape must have rank 2')
if ulmrks.shape[1] != 2:
raise ValueError('ulmrks dim must be == 2')
ulmrks_count = ulmrks.shape[0]
if type == ELandmarks2D.L5:
if ulmrks_count != 5:
raise ValueError('ulmrks_count must be == 5')
elif type == ELandmarks2D.L68:
if ulmrks_count != 68:
raise ValueError('ulmrks_count must be == 68')
elif type == ELandmarks2D.L106:
if ulmrks_count != 106:
raise ValueError('ulmrks_count must be == 106')
elif type == ELandmarks2D.L468:
if ulmrks_count != 468:
raise ValueError('ulmrks_count must be == 468')
face_ulmrks = FLandmarks2D()
face_ulmrks._type = type
face_ulmrks._ulmrks = ulmrks
return face_ulmrks
def get_type(self) -> ELandmarks2D: return self._type
def get_count(self) -> int: return self._ulmrks.shape[0]
def as_numpy(self, w_h = None):
"""
get landmarks as np.ndarray
w_h(None) provide (w,h) to scale uniform landmarks to exact size
"""
ulmrks = self._ulmrks.copy()
if w_h is not None:
ulmrks *= w_h
return ulmrks
def transform(self, mat, invert=False) -> 'FLandmarks2D':
"""
Tranforms FLandmarks2D using affine mat and returns new FLandmarks2D()
mat : np.ndarray
"""
if not isinstance(mat, np.ndarray):
raise ValueError('mat must be an instance of np.ndarray')
if invert:
mat = cv2.invertAffineTransform (mat)
ulmrks = self._ulmrks.copy()
ulmrks = np.expand_dims(ulmrks, axis=1)
ulmrks = cv2.transform(ulmrks, mat, ulmrks.shape).squeeze()
return FLandmarks2D.create(type=self._type, ulmrks=ulmrks)
def get_FRect(self, coverage=1.6) -> FRect:
"""
create FRect from landmarks with given coverage
"""
_, uni_mat = self.calc_cut( (1,1), coverage, 1, exclude_moving_parts=False)
xlt, xlb, xrb, xrt = uni_mat.invert().transform_points([[0,0], [0,1], [1,1], [1,0]])
l = min(xlt[0], xlb[0])
t = min(xlt[1], xrt[1])
r = max(xrt[0], xrb[0])
b = max(xlb[1], xrb[1])
return FRect.from_ltrb( (l,t,r,b) )
def calc_cut(self, h_w, coverage : float, output_size : int,
exclude_moving_parts : bool = False,
head_yaw : float = None,
x_offset : float = 0, y_offset : float = 0,
freeze_z_rotation = False):
"""
Calculates affine mat for face cut.
returns
mat, matrix to transform img space to face_image space
uni_mat matrix to transform uniform img space to uniform face_image space
"""
h,w = h_w
type = self._type
lmrks = (self._ulmrks * (w,h)).astype(np.float32)
# estimate landmarks transform from global space to local aligned space with bounds [0..1]
if type == ELandmarks2D.L106:
type = ELandmarks2D.L68
lmrks = lmrks[ lmrks_106_to_68_mean_pairs ]
lmrks = lmrks.reshape( (68,2,2)).mean(1)
if type == ELandmarks2D.L68:
mat = Affine2DMat.umeyama( np.concatenate ([ lmrks[17:36], lmrks[36:37], lmrks[39:40], lmrks[42:43], lmrks[45:46], lmrks[48:49], lmrks[54:55] ]), uni_landmarks_68)
elif type == ELandmarks2D.L468:
src_lmrks = lmrks
dst_lmrks = uni_landmarks_468
if exclude_moving_parts:
src_lmrks = np.delete(src_lmrks, landmarks_468_moving_parts_indexes, 0)
dst_lmrks = np.delete(dst_lmrks, landmarks_468_moving_parts_indexes, 0)
mat = Affine2DMat.umeyama(src_lmrks, dst_lmrks)
else:
raise NotImplementedError()
# get corner points in global space
g_p = mat.invert().transform_points ( [(0,0),(1,0),(1,1),(0,1),(0.5,0.5) ] )
g_c = g_p[4]
# calc diagonal vectors between corners in global space
tb_diag_vec = lib_math.segment_to_vector(g_p[0], g_p[2]).astype(np.float32)
bt_diag_vec = lib_math.segment_to_vector(g_p[3], g_p[1]).astype(np.float32)
mod = lib_math.segment_length(g_p[0],g_p[4])*coverage
if head_yaw is not None:
# Damp near zero
x_offset += -(head_yaw * np.abs(np.tanh(head_yaw*2)) ) * 0.5
# adjust vertical offset to cover more forehead
h_vec = (g_p[1]-g_p[0]).astype(np.float32)
v_vec = (g_p[3]-g_p[0]).astype(np.float32)
g_c += h_vec*x_offset + v_vec*y_offset
if not freeze_z_rotation:
l_t = np.array([g_c - tb_diag_vec*mod,
g_c + bt_diag_vec*mod,
g_c + tb_diag_vec*mod], np.float32 )
else:
# remove_align - face will be centered in the frame but not aligned
l_t = np.array([g_c - tb_diag_vec*mod,
g_c + bt_diag_vec*mod,
g_c + tb_diag_vec*mod,
g_c - bt_diag_vec*mod], np.float32 )
# get area of face square in global space
area = 0.5*np.abs(np.dot(l_t[:,0],np.roll(l_t[:,1],1))-np.dot(l_t[:,1],np.roll(l_t[:,0],1)))
# calc side of square
side = np.float32(np.sqrt(area) / 2)
# calc 3 points with unrotated square
l_t = np.array([g_c + [-side,-side],
g_c + [ side,-side],
g_c + [ side, side]], np.float32 )
# calc affine transform from 3 global space points to 3 local space points size of 'output_size'
mat = Affine2DMat.from_3_pairs ( l_t, np.float32(( (0,0),(output_size,0),(output_size,output_size) )))
uni_mat = Affine2DUniMat.from_3_pairs ( (l_t / (w,h) ).astype(np.float32), np.float32(( (0,0),(1,0),(1,1) )) )
return mat, uni_mat
def cut(self, img : np.ndarray,
coverage : float,
output_size : int,
exclude_moving_parts : bool = False,
head_yaw : float = None,
x_offset : float = 0,
y_offset : float = 0,
freeze_z_rotation : bool = False) -> Tuple[np.ndarray, Affine2DUniMat]:
"""
Cut the face to square of output_size from img using landmarks with given parameters
arguments
img np.ndarray
coverage float
output_size int
exclude_moving_parts(False) exclude moving parts of the face, such as eyebrows and jaw
head_yaw(None) float fit the head in center using provided yaw radian value.
x_offset
y_offset float uniform x/y offset
returns face_image,
uni_mat uniform affine matrix to transform uniform img space to uniform face_image space
"""
h,w = img.shape[0:2]
mat, uni_mat = self.calc_cut( (h,w), coverage, output_size, exclude_moving_parts, head_yaw=head_yaw, x_offset=x_offset, y_offset=y_offset, freeze_z_rotation=freeze_z_rotation)
face_image = cv2.warpAffine(img, mat, (output_size, output_size), cv2.INTER_CUBIC )
return face_image, uni_mat
def draw(self, img : np.ndarray, color, radius=1):
"""
draw landmarks on the img scaled by img.wh
color tuple of values should be the same as img color channels
"""
h,w = img.shape[0:2]
pts = self.as_numpy(w_h=(w,h)).astype(np.int32)
for x, y in pts:
cv2.circle(img, (x, y), radius, color, lineType=cv2.LINE_AA)
def get_convexhull_mask(self, h_w, color=(1,), dtype=np.float32) -> np.ndarray:
"""
"""
h, w = h_w
ch = len(color)
lmrks = (self._ulmrks * h_w).astype(np.int32)
mask = np.zeros( (h,w,ch), dtype=dtype)
cv2.fillConvexPoly( mask, cv2.convexHull(lmrks), color)
return mask
lmrks_106_to_68_mean_pairs = [1,9, 10,11, 12,13, 14,15, 16,2, 3,4, 5,6, 7,8, 0,0, 24,23, 22,21, 20,19, 18,32, 31,30, 29,28, 27,26,25,17,
43,43, 48,44, 49,45, 51,47, 50,46,
102,97, 103,98, 104,99, 105,100, 101,101,
72,72, 73,73, 74,74, 86,86, 77,78, 78,79, 80,80, 85,84, 84,83,
35,35, 41,40, 40,42, 39,39, 37,33, 33,36,
89,89, 95,94, 94,96, 93,93, 91,87, 87,90,
52,52, 64,64, 63,63, 71,71, 67,67, 68,68, 61,61, 58,58, 59,59, 53,53, 56,56, 55,55, 65,65, 66,66, 62,62, 70,70, 69,69, 57,57, 60,60, 54,54]
uni_landmarks_68 = np.float32([
[ 0.000213256, 0.106454 ], #17
[ 0.0752622, 0.038915 ], #18
[ 0.18113, 0.0187482 ], #19
[ 0.29077, 0.0344891 ], #20
[ 0.393397, 0.0773906 ], #21
[ 0.586856, 0.0773906 ], #22
[ 0.689483, 0.0344891 ], #23
[ 0.799124, 0.0187482 ], #24
[ 0.904991, 0.038915 ], #25
[ 0.98004, 0.106454 ], #26
[ 0.490127, 0.203352 ], #27
[ 0.490127, 0.307009 ], #28
[ 0.490127, 0.409805 ], #29
[ 0.490127, 0.515625 ], #30
[ 0.36688, 0.587326 ], #31
[ 0.426036, 0.609345 ], #32
[ 0.490127, 0.628106 ], #33
[ 0.554217, 0.609345 ], #34
[ 0.613373, 0.587326 ], #35
[ 0.121737, 0.216423 ], #36
#[ 0.187122, 0.178758 ], #37
#[ 0.265825, 0.179852 ], #38
[ 0.334606, 0.231733 ], #39
#[ 0.260918, 0.245099 ], #40
#[ 0.182743, 0.244077 ], #41
[ 0.645647, 0.231733 ], #42
#[ 0.714428, 0.179852 ], #43
#[ 0.793132, 0.178758 ], #44
[ 0.858516, 0.216423 ], #45
#[ 0.79751, 0.244077 ], #46
#[ 0.719335, 0.245099 ], #47
[ 0.254149, 0.780233 ], #48
[ 0.726104, 0.780233 ], #54
])
uni_landmarks_468 = np.float32([
[0.499976992607117, 0.652534008026123],
[0.500025987625122, 0.547487020492554],
[0.499974012374878, 0.602371990680695],
[0.482113003730774, 0.471979022026062],
[0.500150978565216, 0.527155995368958],
[0.499909996986389, 0.498252987861633],
[0.499523013830185, 0.40106201171875],
[0.289712011814117, 0.380764007568359],
[0.499954998493195, 0.312398016452789],
[0.499987006187439, 0.269918978214264],
[0.500023007392883, 0.107050001621246],
[0.500023007392883, 0.666234016418457],
[0.5000159740448, 0.679224014282227],
[0.500023007392883, 0.692348003387451],
[0.499976992607117, 0.695277988910675],
[0.499976992607117, 0.70593398809433],
[0.499976992607117, 0.719385027885437],
[0.499976992607117, 0.737019002437592],
[0.499967992305756, 0.781370997428894],
[0.499816000461578, 0.562981009483337],
[0.473773002624512, 0.573909997940063],
[0.104906998574734, 0.254140973091125],
[0.365929991006851, 0.409575998783112],
[0.338757991790771, 0.41302502155304],
[0.311120003461838, 0.409460008144379],
[0.274657994508743, 0.389131009578705],
[0.393361985683441, 0.403706014156342],
[0.345234006643295, 0.344011008739471],
[0.370094001293182, 0.346076011657715],
[0.319321990013123, 0.347265005111694],
[0.297903001308441, 0.353591024875641],
[0.24779200553894, 0.410809993743896],
[0.396889001131058, 0.842755019664764],
[0.280097991228104, 0.375599980354309],
[0.106310002505779, 0.399955987930298],
[0.2099249958992, 0.391353011131287],
[0.355807989835739, 0.534406006336212],
[0.471751004457474, 0.65040397644043],
[0.474155008792877, 0.680191993713379],
[0.439785003662109, 0.657229006290436],
[0.414617002010345, 0.66654098033905],
[0.450374007225037, 0.680860996246338],
[0.428770989179611, 0.682690978050232],
[0.374971002340317, 0.727805018424988],
[0.486716985702515, 0.547628998756409],
[0.485300987958908, 0.527395009994507],
[0.257764995098114, 0.314490020275116],
[0.401223003864288, 0.455172002315521],
[0.429818987846375, 0.548614978790283],
[0.421351999044418, 0.533740997314453],
[0.276895999908447, 0.532056987285614],
[0.483370006084442, 0.499586999416351],
[0.33721199631691, 0.282882988452911],
[0.296391993761063, 0.293242990970612],
[0.169294998049736, 0.193813979625702],
[0.447580009698868, 0.302609980106354],
[0.392390012741089, 0.353887975215912],
[0.354490011930466, 0.696784019470215],
[0.067304998636246, 0.730105042457581],
[0.442739009857178, 0.572826027870178],
[0.457098007202148, 0.584792017936707],
[0.381974011659622, 0.694710969924927],
[0.392388999462128, 0.694203019142151],
[0.277076005935669, 0.271932005882263],
[0.422551989555359, 0.563233017921448],
[0.385919004678726, 0.281364023685455],
[0.383103013038635, 0.255840003490448],
[0.331431001424789, 0.119714021682739],
[0.229923993349075, 0.232002973556519],
[0.364500999450684, 0.189113974571228],
[0.229622006416321, 0.299540996551514],
[0.173287004232407, 0.278747975826263],
[0.472878992557526, 0.666198015213013],
[0.446828007698059, 0.668527007102966],
[0.422762006521225, 0.673889994621277],
[0.445307999849319, 0.580065965652466],
[0.388103008270264, 0.693961024284363],
[0.403039008378983, 0.706539988517761],
[0.403629004955292, 0.693953037261963],
[0.460041999816895, 0.557139039039612],
[0.431158006191254, 0.692366003990173],
[0.452181994915009, 0.692366003990173],
[0.475387006998062, 0.692366003990173],
[0.465828001499176, 0.779190003871918],
[0.472328990697861, 0.736225962638855],
[0.473087012767792, 0.717857003211975],
[0.473122000694275, 0.704625964164734],
[0.473033010959625, 0.695277988910675],
[0.427942007780075, 0.695277988910675],
[0.426479011774063, 0.703539967536926],
[0.423162013292313, 0.711845993995667],
[0.4183090031147, 0.720062971115112],
[0.390094995498657, 0.639572978019714],
[0.013953999616206, 0.560034036636353],
[0.499913990497589, 0.58014702796936],
[0.413199990987778, 0.69539999961853],
[0.409626007080078, 0.701822996139526],
[0.468080013990402, 0.601534962654114],
[0.422728985548019, 0.585985004901886],
[0.463079988956451, 0.593783974647522],
[0.37211999297142, 0.47341400384903],
[0.334562003612518, 0.496073007583618],
[0.411671012639999, 0.546965003013611],
[0.242175996303558, 0.14767599105835],
[0.290776997804642, 0.201445996761322],
[0.327338010072708, 0.256527006626129],
[0.399509996175766, 0.748921036720276],
[0.441727995872498, 0.261676013469696],
[0.429764986038208, 0.187834024429321],
[0.412198007106781, 0.108901023864746],
[0.288955003023148, 0.398952007293701],
[0.218936994671822, 0.435410976409912],
[0.41278201341629, 0.398970007896423],
[0.257135003805161, 0.355440020561218],
[0.427684992551804, 0.437960982322693],
[0.448339998722076, 0.536936044692993],
[0.178560003638268, 0.45755398273468],
[0.247308000922203, 0.457193970680237],
[0.286267012357712, 0.467674970626831],
[0.332827985286713, 0.460712015628815],
[0.368755996227264, 0.447206974029541],
[0.398963987827301, 0.432654976844788],
[0.476410001516342, 0.405806005001068],
[0.189241006970406, 0.523923993110657],
[0.228962004184723, 0.348950982093811],
[0.490725994110107, 0.562400996685028],
[0.404670000076294, 0.485132992267609],
[0.019469000399113, 0.401564002037048],
[0.426243007183075, 0.420431017875671],
[0.396993011236191, 0.548797011375427],
[0.266469985246658, 0.376977026462555],
[0.439121007919312, 0.51895797252655],
[0.032313998788595, 0.644356966018677],
[0.419054001569748, 0.387154996395111],
[0.462783008813858, 0.505746960639954],
[0.238978996872902, 0.779744982719421],
[0.198220998048782, 0.831938028335571],
[0.107550002634525, 0.540755033493042],
[0.183610007166862, 0.740257024765015],
[0.134409993886948, 0.333683013916016],
[0.385764002799988, 0.883153975009918],
[0.490967005491257, 0.579378008842468],
[0.382384985685349, 0.508572995662689],
[0.174399003386497, 0.397670984268188],
[0.318785011768341, 0.39623498916626],
[0.343364000320435, 0.400596976280212],
[0.396100014448166, 0.710216999053955],
[0.187885001301765, 0.588537991046906],
[0.430987000465393, 0.944064974784851],
[0.318993002176285, 0.898285031318665],
[0.266247987747192, 0.869701027870178],
[0.500023007392883, 0.190576016902924],
[0.499976992607117, 0.954452991485596],
[0.366169989109039, 0.398822009563446],
[0.393207013607025, 0.39553701877594],
[0.410373002290726, 0.391080021858215],
[0.194993004202843, 0.342101991176605],
[0.388664990663528, 0.362284004688263],
[0.365961998701096, 0.355970978736877],
[0.343364000320435, 0.355356991291046],
[0.318785011768341, 0.35834002494812],
[0.301414996385574, 0.363156020641327],
[0.058132998645306, 0.319076001644135],
[0.301414996385574, 0.387449026107788],
[0.499987989664078, 0.618434011936188],
[0.415838003158569, 0.624195992946625],
[0.445681989192963, 0.566076993942261],
[0.465844005346298, 0.620640993118286],
[0.49992299079895, 0.351523995399475],
[0.288718998432159, 0.819945991039276],
[0.335278987884521, 0.852819979190826],
[0.440512001514435, 0.902418971061707],
[0.128294005990028, 0.791940987110138],
[0.408771991729736, 0.373893976211548],
[0.455606997013092, 0.451801002025604],
[0.499877005815506, 0.908990025520325],
[0.375436991453171, 0.924192011356354],
[0.11421000212431, 0.615022003650665],
[0.448662012815475, 0.695277988910675],
[0.4480200111866, 0.704632043838501],
[0.447111994028091, 0.715808033943176],
[0.444831997156143, 0.730794012546539],
[0.430011987686157, 0.766808986663818],
[0.406787008047104, 0.685672998428345],
[0.400738000869751, 0.681069016456604],
[0.392399996519089, 0.677703022956848],
[0.367855995893478, 0.663918972015381],
[0.247923001646996, 0.601333022117615],
[0.452769994735718, 0.420849978923798],
[0.43639200925827, 0.359887003898621],
[0.416164010763168, 0.368713974952698],
[0.413385987281799, 0.692366003990173],
[0.228018000721931, 0.683571994304657],
[0.468268007040024, 0.352671027183533],
[0.411361992359161, 0.804327011108398],
[0.499989002943039, 0.469825029373169],
[0.479153990745544, 0.442654013633728],
[0.499974012374878, 0.439637005329132],
[0.432112008333206, 0.493588984012604],
[0.499886006116867, 0.866917014122009],
[0.49991300702095, 0.821729004383087],
[0.456548988819122, 0.819200992584229],
[0.344549000263214, 0.745438992977142],
[0.37890899181366, 0.574010014533997],
[0.374292999505997, 0.780184984207153],
[0.319687992334366, 0.570737957954407],
[0.357154995203018, 0.604269981384277],
[0.295284003019333, 0.621580958366394],
[0.447750002145767, 0.862477004528046],
[0.410986006259918, 0.508723020553589],
[0.31395098567009, 0.775308012962341],
[0.354128003120422, 0.812552988529205],
[0.324548006057739, 0.703992962837219],
[0.189096003770828, 0.646299958229065],
[0.279776990413666, 0.71465802192688],
[0.1338230073452, 0.682700991630554],
[0.336768001317978, 0.644733011722565],
[0.429883986711502, 0.466521978378296],
[0.455527991056442, 0.548622965812683],
[0.437114000320435, 0.558896005153656],
[0.467287987470627, 0.529924988746643],
[0.414712011814117, 0.335219979286194],
[0.37704598903656, 0.322777986526489],
[0.344107985496521, 0.320150971412659],
[0.312875986099243, 0.32233202457428],
[0.283526003360748, 0.333190023899078],
[0.241245999932289, 0.382785975933075],
[0.102986000478268, 0.468762993812561],
[0.267612010240555, 0.424560010433197],
[0.297879010438919, 0.433175981044769],
[0.333433985710144, 0.433878004550934],
[0.366427004337311, 0.426115989685059],
[0.396012008190155, 0.416696012020111],
[0.420121014118195, 0.41022801399231],
[0.007561000064015, 0.480777025222778],
[0.432949006557465, 0.569517970085144],
[0.458638995885849, 0.479089021682739],
[0.473466008901596, 0.545744001865387],
[0.476087987422943, 0.563830018043518],
[0.468472003936768, 0.555056989192963],
[0.433990985155106, 0.582361996173859],
[0.483518004417419, 0.562983989715576],
[0.482482999563217, 0.57784903049469],
[0.42645001411438, 0.389798998832703],
[0.438998997211456, 0.39649498462677],
[0.450067013502121, 0.400434017181396],
[0.289712011814117, 0.368252992630005],
[0.276670008897781, 0.363372981548309],
[0.517862021923065, 0.471948027610779],
[0.710287988185883, 0.380764007568359],
[0.526226997375488, 0.573909997940063],
[0.895093023777008, 0.254140973091125],
[0.634069979190826, 0.409575998783112],
[0.661242008209229, 0.41302502155304],
[0.688880026340485, 0.409460008144379],
[0.725341975688934, 0.389131009578705],
[0.606630027294159, 0.40370500087738],
[0.654766023159027, 0.344011008739471],
[0.629905998706818, 0.346076011657715],
[0.680678009986877, 0.347265005111694],
[0.702096998691559, 0.353591024875641],
[0.75221198797226, 0.410804986953735],
[0.602918028831482, 0.842862963676453],
[0.719901978969574, 0.375599980354309],
[0.893692970275879, 0.399959981441498],
[0.790081977844238, 0.391354024410248],
[0.643998026847839, 0.534487962722778],
[0.528249025344849, 0.65040397644043],
[0.525849997997284, 0.680191040039062],
[0.560214996337891, 0.657229006290436],
[0.585384011268616, 0.66654098033905],
[0.549625992774963, 0.680860996246338],
[0.57122802734375, 0.682691991329193],
[0.624852001667023, 0.72809898853302],
[0.513050019741058, 0.547281980514526],
[0.51509702205658, 0.527251958847046],
[0.742246985435486, 0.314507007598877],
[0.598631024360657, 0.454979002475739],
[0.570338010787964, 0.548575043678284],
[0.578631997108459, 0.533622980117798],
[0.723087012767792, 0.532054007053375],
[0.516445994377136, 0.499638974666595],
[0.662801027297974, 0.282917976379395],
[0.70362401008606, 0.293271005153656],
[0.830704987049103, 0.193813979625702],
[0.552385985851288, 0.302568018436432],
[0.607609987258911, 0.353887975215912],
[0.645429015159607, 0.696707010269165],
[0.932694971561432, 0.730105042457581],
[0.557260990142822, 0.572826027870178],
[0.542901992797852, 0.584792017936707],
[0.6180260181427, 0.694710969924927],
[0.607590973377228, 0.694203019142151],
[0.722943007946014, 0.271963000297546],
[0.577413976192474, 0.563166975975037],
[0.614082992076874, 0.281386971473694],
[0.616907000541687, 0.255886018276215],
[0.668509006500244, 0.119913995265961],
[0.770092010498047, 0.232020974159241],
[0.635536015033722, 0.189248979091644],
[0.77039098739624, 0.299556016921997],
[0.826722025871277, 0.278755009174347],
[0.527121007442474, 0.666198015213013],
[0.553171992301941, 0.668527007102966],
[0.577238023281097, 0.673889994621277],
[0.554691970348358, 0.580065965652466],
[0.611896991729736, 0.693961024284363],
[0.59696102142334, 0.706539988517761],
[0.596370995044708, 0.693953037261963],
[0.539958000183105, 0.557139039039612],
[0.568841993808746, 0.692366003990173],
[0.547818005084991, 0.692366003990173],
[0.52461302280426, 0.692366003990173],
[0.534089982509613, 0.779141008853912],
[0.527670979499817, 0.736225962638855],
[0.526912987232208, 0.717857003211975],
[0.526877999305725, 0.704625964164734],
[0.526966989040375, 0.695277988910675],
[0.572058022022247, 0.695277988910675],
[0.573521018028259, 0.703539967536926],
[0.57683801651001, 0.711845993995667],
[0.581691026687622, 0.720062971115112],
[0.609944999217987, 0.639909982681274],
[0.986046016216278, 0.560034036636353],
[0.5867999792099, 0.69539999961853],
[0.590372025966644, 0.701822996139526],
[0.531915009021759, 0.601536989212036],
[0.577268004417419, 0.585934996604919],
[0.536915004253387, 0.593786001205444],
[0.627542972564697, 0.473352015018463],
[0.665585994720459, 0.495950996875763],
[0.588353991508484, 0.546862006187439],
[0.757824003696442, 0.14767599105835],
[0.709249973297119, 0.201507985591888],
[0.672684013843536, 0.256581008434296],
[0.600408971309662, 0.74900496006012],
[0.55826598405838, 0.261672019958496],
[0.570303976535797, 0.187870979309082],
[0.588165998458862, 0.109044015407562],
[0.711045026779175, 0.398952007293701],
[0.781069993972778, 0.435405015945435],
[0.587247014045715, 0.398931980133057],
[0.742869973182678, 0.355445981025696],
[0.572156012058258, 0.437651991844177],
[0.55186802148819, 0.536570012569427],
[0.821442008018494, 0.457556009292603],
[0.752701997756958, 0.457181990146637],
[0.71375697851181, 0.467626988887787],
[0.66711300611496, 0.460672974586487],
[0.631101012229919, 0.447153985500336],
[0.6008620262146, 0.432473003864288],
[0.523481011390686, 0.405627012252808],
[0.810747981071472, 0.523926019668579],
[0.771045982837677, 0.348959028720856],
[0.509127020835876, 0.562718033790588],
[0.595292985439301, 0.485023975372314],
[0.980530977249146, 0.401564002037048],
[0.573499977588654, 0.420000016689301],
[0.602994978427887, 0.548687994480133],
[0.733529984951019, 0.376977026462555],
[0.560611009597778, 0.519016981124878],
[0.967685997486115, 0.644356966018677],
[0.580985009670258, 0.387160003185272],
[0.537728011608124, 0.505385041236877],
[0.760966002941132, 0.779752969741821],
[0.801778972148895, 0.831938028335571],
[0.892440974712372, 0.54076099395752],
[0.816350996494293, 0.740260004997253],
[0.865594983100891, 0.333687007427216],
[0.614073991775513, 0.883246004581451],
[0.508952975273132, 0.579437971115112],
[0.617941975593567, 0.508316040039062],
[0.825608015060425, 0.397674977779388],
[0.681214988231659, 0.39623498916626],
[0.656635999679565, 0.400596976280212],
[0.603900015354156, 0.710216999053955],
[0.81208598613739, 0.588539004325867],
[0.56801301240921, 0.944564998149872],
[0.681007981300354, 0.898285031318665],
[0.733752012252808, 0.869701027870178],
[0.633830010890961, 0.398822009563446],
[0.606792986392975, 0.39553701877594],
[0.589659988880157, 0.391062021255493],
[0.805015981197357, 0.342108011245728],
[0.611334979534149, 0.362284004688263],
[0.634037971496582, 0.355970978736877],
[0.656635999679565, 0.355356991291046],
[0.681214988231659, 0.35834002494812],
[0.698584973812103, 0.363156020641327],
[0.941866993904114, 0.319076001644135],
[0.698584973812103, 0.387449026107788],
[0.584177017211914, 0.624107003211975],
[0.554318010807037, 0.566076993942261],
[0.534153997898102, 0.62064003944397],
[0.711217999458313, 0.819975018501282],
[0.664629995822906, 0.852871000766754],
[0.559099972248077, 0.902631998062134],
[0.871706008911133, 0.791940987110138],
[0.591234028339386, 0.373893976211548],
[0.544341027736664, 0.451583981513977],
[0.624562978744507, 0.924192011356354],
[0.88577002286911, 0.615028977394104],
[0.551338016986847, 0.695277988910675],
[0.551980018615723, 0.704632043838501],
[0.552887976169586, 0.715808033943176],
[0.555167973041534, 0.730794012546539],
[0.569944024085999, 0.767035007476807],
[0.593203008174896, 0.685675978660583],
[0.599261999130249, 0.681069016456604],
[0.607599973678589, 0.677703022956848],
[0.631937980651855, 0.663500010967255],
[0.752032995223999, 0.601315021514893],
[0.547226011753082, 0.420395016670227],
[0.563543975353241, 0.359827995300293],
[0.583841025829315, 0.368713974952698],
[0.586614012718201, 0.692366003990173],
[0.771915018558502, 0.683578014373779],
[0.531597018241882, 0.352482974529266],
[0.588370978832245, 0.804440975189209],
[0.52079701423645, 0.442565023899078],
[0.567984998226166, 0.493479013442993],
[0.543282985687256, 0.819254994392395],
[0.655317008495331, 0.745514988899231],
[0.621008992195129, 0.574018001556396],
[0.625559985637665, 0.78031200170517],
[0.680198013782501, 0.570719003677368],
[0.64276397228241, 0.604337990283966],
[0.704662978649139, 0.621529996395111],
[0.552012026309967, 0.862591981887817],
[0.589071989059448, 0.508637011051178],
[0.685944974422455, 0.775357007980347],
[0.645735025405884, 0.812640011310577],
[0.675342977046967, 0.703978002071381],
[0.810858011245728, 0.646304965019226],
[0.72012197971344, 0.714666962623596],
[0.866151988506317, 0.682704985141754],
[0.663187026977539, 0.644596993923187],
[0.570082008838654, 0.466325998306274],
[0.544561982154846, 0.548375964164734],
[0.562758982181549, 0.558784961700439],
[0.531987011432648, 0.530140042304993],
[0.585271000862122, 0.335177004337311],
[0.622952997684479, 0.32277899980545],
[0.655896008014679, 0.320163011550903],
[0.687132000923157, 0.322345972061157],
[0.716481983661652, 0.333200991153717],
[0.758756995201111, 0.382786989212036],
[0.897013008594513, 0.468769013881683],
[0.732392013072968, 0.424547016620636],
[0.70211398601532, 0.433162987232208],
[0.66652500629425, 0.433866024017334],
[0.633504986763, 0.426087975502014],
[0.603875994682312, 0.416586995124817],
[0.579657971858978, 0.409945011138916],
[0.992439985275269, 0.480777025222778],
[0.567192018032074, 0.569419980049133],
[0.54136598110199, 0.478899002075195],
[0.526564002037048, 0.546118021011353],
[0.523913025856018, 0.563830018043518],
[0.531529009342194, 0.555056989192963],
[0.566035985946655, 0.582329034805298],
[0.51631098985672, 0.563053965568542],
[0.5174720287323, 0.577877044677734],
[0.573594987392426, 0.389806985855103],
[0.560697972774506, 0.395331978797913],
[0.549755990505219, 0.399751007556915],
[0.710287988185883, 0.368252992630005],
[0.723330020904541, 0.363372981548309]
])
landmarks_468_moving_parts_indexes = [0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 46, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 95, 96, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 117, 118, 124, 130, 132, 133, 135, 136, 138, 139, 140, 143, 144, 145, 146, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 168, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 189, 190, 191, 192, 193, 194, 199, 200, 201, 202, 204, 208, 210, 211, 212, 213, 214, 215, 221, 222, 223, 224, 225, 226, 228, 229, 230, 231, 232, 233, 243, 244, 245, 246, 247, 249, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 267, 268, 269, 270, 271, 272, 273, 276, 282, 283, 284, 285, 286, 287, 288, 291, 292, 293, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 306, 307, 308, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 324, 325, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 346, 347, 353, 359, 361, 362, 364, 365, 367, 368, 369, 372, 373, 374, 375, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 394, 395, 396, 397, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 413, 414, 415, 416, 417, 418, 421, 422, 424, 428, 430, 431, 432, 433, 434, 435, 441, 442, 443, 444, 445, 446, 448, 449, 450, 451, 452, 453, 463, 464, 465, 466, 467]
uni_landmarks_468 = np.array(
[[ 0.49066195, 0.7133885 ],
[ 0.49042386, 0.52723485],
[ 0.49050152, 0.6244965 ],
[ 0.45844677, 0.39348277],
[ 0.4905825 , 0.49120593],
[ 0.49006602, 0.43998772],
[ 0.48907965, 0.26775706],
[ 0.11721139, 0.23243594],
[ 0.48957095, 0.11063451],
[ 0.48949632, 0.03535742],
[ 0.48905632, -0.25326234],
[ 0.4907858 , 0.73766613],
[ 0.49081355, 0.7606857 ],
[ 0.4908666 , 0.7839426 ],
[ 0.49079415, 0.78913504],
[ 0.4908271 , 0.80801845],
[ 0.49086872, 0.831855 ],
[ 0.49092326, 0.8631041 ],
[ 0.49104446, 0.94170016],
[ 0.49009967, 0.5546924 ],
[ 0.44398275, 0.5741402 ],
[-0.2106727 , 0.00861922],
[ 0.2523662 , 0.2832579 ],
[ 0.2042254 , 0.28945392],
[ 0.1552372 , 0.28322184],
[ 0.09056008, 0.24730967],
[ 0.30096018, 0.27277085],
[ 0.21548809, 0.16713436],
[ 0.2595488 , 0.17071684],
[ 0.16957955, 0.17298089],
[ 0.13164258, 0.18425746],
[ 0.043018 , 0.28581 ],
[ 0.30856833, 1.0507976 ],
[ 0.10015843, 0.22331452],
[-0.20773543, 0.26701325],
[-0.02414621, 0.25144747],
[ 0.23481508, 0.5045001 ],
[ 0.44063616, 0.7097012 ],
[ 0.4449884 , 0.762481 ],
[ 0.3840104 , 0.7218947 ],
[ 0.33943903, 0.73847425],
[ 0.40284824, 0.76374006],
[ 0.36457124, 0.76704985],
[ 0.26937196, 0.84716266],
[ 0.46683946, 0.5275276 ],
[ 0.4642676 , 0.49167544],
[ 0.06039319, 0.11509081],
[ 0.31504983, 0.36394927],
[ 0.3660137 , 0.52945083],
[ 0.3509634 , 0.50311893],
[ 0.09496811, 0.5005815 ],
[ 0.46075967, 0.4424029 ],
[ 0.20108324, 0.05883435],
[ 0.12877828, 0.07731954],
[-0.09675749, -0.09848522],
[ 0.39672711, 0.09345116],
[ 0.29908365, 0.18449144],
[ 0.23298171, 0.7922538 ],
[-0.27583498, 0.85219014],
[ 0.38898414, 0.5723152 ],
[ 0.41446668, 0.59347576],
[ 0.28167963, 0.7884952 ],
[ 0.30013445, 0.7875627 ],
[ 0.09448256, 0.03961415],
[ 0.3531811 , 0.5553779 ],
[ 0.2873921 , 0.05599196],
[ 0.28232294, 0.01076962],
[ 0.1903341 , -0.23029903],
[ 0.0108011 , -0.03099815],
[ 0.24915197, -0.10741784],
[ 0.01047484, 0.08868673],
[-0.08942058, 0.05201372],
[ 0.44268388, 0.7376863 ],
[ 0.39652622, 0.741894 ],
[ 0.35389552, 0.7514722 ],
[ 0.393559 , 0.5851372 ],
[ 0.2925385 , 0.7871472 ],
[ 0.31904542, 0.80939215],
[ 0.32005206, 0.787085 ],
[ 0.4195982 , 0.5444628 ],
[ 0.3688312 , 0.78418756],
[ 0.40608776, 0.7841225 ],
[ 0.4472093 , 0.78405076],
[ 0.43053833, 0.9379409 ],
[ 0.44192585, 0.8617842 ],
[ 0.44321233, 0.82923037],
[ 0.4432334 , 0.80578357],
[ 0.44304678, 0.78921837],
[ 0.36314115, 0.7893578 ],
[ 0.36057413, 0.8040033 ],
[ 0.35472178, 0.8187327 ],
[ 0.34614718, 0.83330894],
[ 0.2959003 , 0.69076014],
[-0.37090415, 0.5509728 ],
[ 0.4903264 , 0.5851119 ],
[ 0.3370172 , 0.78961957],
[ 0.33070365, 0.8010128 ],
[ 0.43397966, 0.6231119 ],
[ 0.35356513, 0.59569615],
[ 0.42509514, 0.6093918 ],
[ 0.2635329 , 0.39636588],
[ 0.19704658, 0.43663597],
[ 0.33384863, 0.52658314],
[ 0.03225203, -0.18047164],
[ 0.11854403, -0.08533629],
[ 0.18350407, 0.01215954],
[ 0.31292278, 0.8845064 ],
[ 0.3862302 , 0.02093028],
[ 0.36480215, -0.1098879 ],
[ 0.33342764, -0.2497105 ],
[ 0.11592615, 0.2646692 ],
[-0.00803981, 0.3294946 ],
[ 0.33535972, 0.26431814],
[ 0.05940344, 0.18766014],
[ 0.36188984, 0.33336782],
[ 0.39879864, 0.50869733],
[-0.07952328, 0.36885905],
[ 0.04230375, 0.36800843],
[ 0.11137532, 0.3864613 ],
[ 0.19386435, 0.37397826],
[ 0.25749052, 0.34993485],
[ 0.310977 , 0.3240539 ],
[ 0.44813582, 0.2762354 ],
[-0.06039021, 0.4864401 ],
[ 0.00945808, 0.17624807],
[ 0.4739895 , 0.55369264],
[ 0.32125092, 0.4170324 ],
[-0.36162117, 0.27013144],
[ 0.3592803 , 0.3023075 ],
[ 0.30784345, 0.529875 ],
[ 0.07601253, 0.22579695],
[ 0.3824061 , 0.47686696],
[-0.33810768, 0.70034444],
[ 0.34643772, 0.24336138],
[ 0.42429656, 0.45338264],
[ 0.02854156, 0.939626 ],
[-0.04352415, 1.0322431 ],
[-0.20510256, 0.51651907],
[-0.06969981, 0.8698207 ],
[-0.1581445 , 0.14948419],
[ 0.2889787 , 1.1224228 ],
[ 0.47446907, 0.58377683],
[ 0.2818322 , 0.4586393 ],
[-0.08708218, 0.2627534 ],
[ 0.16877942, 0.25976214],
[ 0.21234928, 0.267416 ],
[ 0.30676025, 0.81592965],
[-0.06259334, 0.6009466 ],
[ 0.36930662, 1.2302231 ],
[ 0.17070079, 1.149443 ],
[ 0.07714309, 1.0989524 ],
[ 0.48931465, -0.1052461 ],
[ 0.49159575, 1.2484183 ],
[ 0.2527582 , 0.26420003],
[ 0.30066028, 0.25829503],
[ 0.3310663 , 0.25034374],
[-0.05075949, 0.16421606],
[ 0.29250854, 0.19938153],
[ 0.2522571 , 0.18826446],
[ 0.21220936, 0.18724632],
[ 0.16866222, 0.19260857],
[ 0.13789575, 0.2011967 ],
[-0.29335994, 0.12383505],
[ 0.1379709 , 0.24424627],
[ 0.49057597, 0.65296 ],
[ 0.34147182, 0.663431 ],
[ 0.3941785 , 0.5603462 ],
[ 0.43007633, 0.6569765 ],
[ 0.48963526, 0.17996965],
[ 0.11681002, 1.0107123 ],
[ 0.19942053, 1.068824 ],
[ 0.38605705, 1.1563928 ],
[-0.16756529, 0.9615808 ],
[ 0.32817602, 0.21989337],
[ 0.41141313, 0.3578073 ],
[ 0.49127796, 1.1678538 ],
[ 0.27080515, 1.195178 ],
[-0.19307071, 0.6481067 ],
[ 0.399859 , 0.7892937 ],
[ 0.39875022, 0.80587196],
[ 0.39717573, 0.8256797 ],
[ 0.3931817 , 0.85224336],
[ 0.3670306 , 0.9161113 ],
[ 0.3256227 , 0.7724022 ],
[ 0.31488904, 0.76426226],
[ 0.3001029 , 0.7583232 ],
[ 0.2565659 , 0.73397243],
[ 0.0438394 , 0.6234349 ],
[ 0.40628996, 0.30296788],
[ 0.37707803, 0.19498621],
[ 0.34125936, 0.21069102],
[ 0.33733743, 0.7842425 ],
[ 0.00882016, 0.769232 ],
[ 0.4335431 , 0.1821002 ],
[ 0.33409703, 0.9826546 ],
[ 0.49011812, 0.3896104 ],
[ 0.45311242, 0.34152514],
[ 0.4899982 , 0.33611432],
[ 0.369907 , 0.43193236],
[ 0.49116373, 1.0932964 ],
[ 0.49107185, 1.0132186 ],
[ 0.41421878, 1.008873 ],
[ 0.21551576, 0.8785059 ],
[ 0.27587482, 0.57461077],
[ 0.2683325 , 0.9399872 ],
[ 0.17091931, 0.56899554],
[ 0.23741819, 0.6283017 ],
[ 0.12783033, 0.65916985],
[ 0.39875996, 1.0855893 ],
[ 0.33251646, 0.45881665],
[ 0.16138549, 0.93153137],
[ 0.23269826, 0.99740875],
[ 0.17994387, 0.8051213 ],
[-0.06026869, 0.7033027 ],
[ 0.10063827, 0.8241594 ],
[-0.15810522, 0.7679798 ],
[ 0.2014156 , 0.7000692 ],
[ 0.365875 , 0.3839739 ],
[ 0.4115726 , 0.5293855 ],
[ 0.378973 , 0.5476473 ],
[ 0.43235463, 0.49621448],
[ 0.3385827 , 0.15134089],
[ 0.27179635, 0.12940899],
[ 0.21341887, 0.12485553],
[ 0.15807948, 0.12881717],
[ 0.10610204, 0.14814937],
[ 0.03133116, 0.236169 ],
[-0.21341309, 0.38895622],
[ 0.07818349, 0.3101151 ],
[ 0.1318462 , 0.32528982],
[ 0.19485526, 0.32642388],
[ 0.25329807, 0.31256682],
[ 0.30569646, 0.29578218],
[ 0.34839994, 0.2842457 ],
[-0.3824783 , 0.41054142],
[ 0.37162504, 0.5664833 ],
[ 0.41687053, 0.40615496],
[ 0.4433516 , 0.5242282 ],
[ 0.44805393, 0.5562703 ],
[ 0.43453053, 0.5407472 ],
[ 0.37351128, 0.58924097],
[ 0.46121803, 0.55474806],
[ 0.45942986, 0.5810936 ],
[ 0.35955238, 0.24802393],
[ 0.38181108, 0.25985107],
[ 0.40143687, 0.26679716],
[ 0.11717269, 0.2102652 ],
[ 0.0940459 , 0.2016577 ],
[ 0.5217974 , 0.39331725],
[ 0.8625129 , 0.23113514],
[ 0.5369363 , 0.57397795],
[ 1.1896138 , 0.00617525],
[ 0.7275363 , 0.28242856],
[ 0.7756985 , 0.2884565 ],
[ 0.82466465, 0.28205347],
[ 0.88921595, 0.24591576],
[ 0.6788919 , 0.27210945],
[ 0.7640089 , 0.166177 ],
[ 0.7199609 , 0.16991326],
[ 0.8099376 , 0.17186326],
[ 0.8479136 , 0.18300733],
[ 0.9368992 , 0.28424102],
[ 0.67367214, 1.0503516 ],
[ 0.8795338 , 0.22195426],
[ 1.1875838 , 0.26458502],
[ 1.0039485 , 0.24965489],
[ 0.74551606, 0.50375396],
[ 0.54075617, 0.7095265 ],
[ 0.5365969 , 0.76231945],
[ 0.59742403, 0.7215222 ],
[ 0.6420548 , 0.7379461 ],
[ 0.5787324 , 0.7634331 ],
[ 0.617019 , 0.766611 ],
[ 0.71218634, 0.8469107 ],
[ 0.513503 , 0.52683127],
[ 0.5170686 , 0.49132976],
[ 0.91894245, 0.11362247],
[ 0.66487545, 0.36299667],
[ 0.61502695, 0.52894545],
[ 0.6296784 , 0.50242335],
[ 0.88566196, 0.49919614],
[ 0.5193738 , 0.4423927 ],
[ 0.7780587 , 0.05788935],
[ 0.8504331 , 0.07610969],
[ 1.0753254 , -0.1005309 ],
[ 0.5824533 , 0.09305263],
[ 0.6804744 , 0.18382579],
[ 0.7485537 , 0.79121745],
[ 1.2577202 , 0.8495136 ],
[ 0.59192824, 0.57196105],
[ 0.5665197 , 0.59321034],
[ 0.6999867 , 0.7877651 ],
[ 0.6814933 , 0.7868972 ],
[ 0.8846023 , 0.03829005],
[ 0.62761134, 0.5547819 ],
[ 0.6917209 , 0.05532694],
[ 0.6966465 , 0.01012804],
[ 0.7876697 , -0.2309872 ],
[ 0.9680314 , -0.03263693],
[ 0.7294528 , -0.1080169 ],
[ 0.96877015, 0.08704082],
[ 1.0685298 , 0.05000517],
[ 0.538806 , 0.7375185 ],
[ 0.5849781 , 0.7415651 ],
[ 0.62764204, 0.7509944 ],
[ 0.58739805, 0.5847989 ],
[ 0.68912315, 0.78645504],
[ 0.6626941 , 0.8087924 ],
[ 0.6616096 , 0.7864889 ],
[ 0.5612171 , 0.5442156 ],
[ 0.61282057, 0.7837617 ],
[ 0.575564 , 0.7838267 ],
[ 0.5344426 , 0.7838985 ],
[ 0.551505 , 0.93764293],
[ 0.5399973 , 0.8616131 ],
[ 0.53859717, 0.8290639 ],
[ 0.5384943 , 0.8056173 ],
[ 0.53862303, 0.78905153],
[ 0.6185288 , 0.78891206],
[ 0.62114686, 0.8035485 ],
[ 0.62705064, 0.81825733],
[ 0.635676 , 0.8328036 ],
[ 0.6854969 , 0.69067734],
[ 1.3517375 , 0.54796624],
[ 0.64465326, 0.78908265],
[ 0.6510032 , 0.8004538 ],
[ 0.5471015 , 0.62291807],
[ 0.62742317, 0.59512955],
[ 0.55593795, 0.6091671 ],
[ 0.7161671 , 0.39546603],
[ 0.7836529 , 0.435396 ],
[ 0.64694774, 0.5258542 ],
[ 0.94603044, -0.1820665 ],
[ 0.86011904, -0.08652072],
[ 0.79549086, 0.01118712],
[ 0.66893554, 0.8840338 ],
[ 0.59274685, 0.02056277],
[ 0.613851 , -0.11025709],
[ 0.64526045, -0.25000137],
[ 0.8639107 , 0.26336375],
[ 0.9881146 , 0.3277454 ],
[ 0.6445285 , 0.26371115],
[ 0.92017305, 0.18616839],
[ 0.61790556, 0.3323734 ],
[ 0.58225924, 0.5077285 ],
[ 1.0597262 , 0.36687428],
[ 0.93791103, 0.36642405],
[ 0.86892897, 0.38505408],
[ 0.78624976, 0.37287512],
[ 0.7223912 , 0.34902957],
[ 0.6687594 , 0.32310694],
[ 0.5315497 , 0.2757726 ],
[ 1.0409807 , 0.48452145],
[ 0.9700836 , 0.17458573],
[ 0.5065989 , 0.55419755],
[ 0.6590531 , 0.41624966],
[ 1.3414742 , 0.26715896],
[ 0.62023264, 0.30108824],
[ 0.67289865, 0.5290446 ],
[ 0.9036883 , 0.22435239],
[ 0.59769833, 0.47659585],
[ 1.3194624 , 0.6974514 ],
[ 0.63339525, 0.24286939],
[ 0.5571053 , 0.45250946],
[ 0.9535533 , 0.9380257 ],
[ 1.0260391 , 1.0303764 ],
[ 1.1858007 , 0.51410204],
[ 1.0515786 , 0.867869 ],
[ 1.1375865 , 0.14722979],
[ 0.6935665 , 1.1218798 ],
[ 0.5063422 , 0.58382744],
[ 0.69926125, 0.45745537],
[ 1.0669235 , 0.26074636],
[ 0.8110406 , 0.25864118],
[ 0.7674977 , 0.26644707],
[ 0.67500204, 0.81528693],
[ 1.0435516 , 0.5990178 ],
[ 0.6121316 , 1.2306852 ],
[ 0.81222653, 1.1483234 ],
[ 0.9056057 , 1.0975065 ],
[ 0.7270778 , 0.26337218],
[ 0.6791554 , 0.25763443],
[ 0.6487802 , 0.24975733],
[ 1.0302606 , 0.16233999],
[ 0.68710136, 0.19869283],
[ 0.72731376, 0.18743533],
[ 0.7673578 , 0.1862774 ],
[ 0.81092334, 0.1914876 ],
[ 0.84171957, 0.1999683 ],
[ 1.2727026 , 0.12110176],
[ 0.8417947 , 0.24301787],
[ 0.63978463, 0.6627527 ],
[ 0.5866921 , 0.5600102 ],
[ 0.5511283 , 0.6567636 ],
[ 0.8655194 , 1.009457 ],
[ 0.78306264, 1.0678959 ],
[ 0.59620714, 1.1564037 ],
[ 1.149833 , 0.9592815 ],
[ 0.65151644, 0.21932903],
[ 0.56865776, 0.3571483 ],
[ 0.71228063, 1.1944076 ],
[ 1.1742088 , 0.6457327 ],
[ 0.5818109 , 0.78897613],
[ 0.5829775 , 0.80555046],
[ 0.5846211 , 0.82535255],
[ 0.5887078 , 0.8519021 ],
[ 0.6150045 , 0.916079 ],
[ 0.65597004, 0.771831 ],
[ 0.66669285, 0.7636482 ],
[ 0.6814582 , 0.7576576 ],
[ 0.7245435 , 0.73241323],
[ 0.9371713 , 0.62184393],
[ 0.5736738 , 0.30186948],
[ 0.60240346, 0.19448838],
[ 0.6383993 , 0.21017241],
[ 0.64431435, 0.7837067 ],
[ 0.9726586 , 0.7675604 ],
[ 0.54576766, 0.18157108],
[ 0.6477745 , 0.98230904],
[ 0.5269076 , 0.34123868],
[ 0.61068684, 0.43131724],
[ 0.56792 , 1.0087004 ],
[ 0.7662271 , 0.8776794 ],
[ 0.7048996 , 0.57387614],
[ 0.7136024 , 0.9394351 ],
[ 0.8097781 , 0.56784695],
[ 0.7435453 , 0.62753886],
[ 0.85328954, 0.6578133 ],
[ 0.5835228 , 1.0854707 ],
[ 0.64810187, 0.45811343],
[ 0.82059515, 0.9304676 ],
[ 0.7494546 , 0.9966611 ],
[ 0.8015866 , 0.80400985],
[ 1.0415541 , 0.70138854],
[ 0.8809724 , 0.8228132 ],
[ 1.1396528 , 0.7657218 ],
[ 0.7798614 , 0.69881856],
[ 0.6143189 , 0.383193 ],
[ 0.56934875, 0.52867246],
[ 0.60162777, 0.54706186],
[ 0.5470082 , 0.4963955 ],
[ 0.6408297 , 0.15073723],
[ 0.7075675 , 0.12865019],
[ 0.76593757, 0.12391254],
[ 0.8212976 , 0.12768434],
[ 0.87334216, 0.14682971],
[ 0.948411 , 0.23457018],
[ 1.1936799 , 0.38651106],
[ 0.90181875, 0.30865455],
[ 0.84818983, 0.3240165 ],
[ 0.7851249 , 0.32537246],
[ 0.72658616, 0.3116911 ],
[ 0.6740513 , 0.2949461 ],
[ 0.63111407, 0.28325075],
[ 1.362823 , 0.4074953 ],
[ 0.60951644, 0.5658945 ],
[ 0.5634702 , 0.4055624 ],
[ 0.5374476 , 0.5247268 ],
[ 0.53280455, 0.5561224 ],
[ 0.5462737 , 0.5405522 ],
[ 0.6075077 , 0.58877414],
[ 0.51933056, 0.55477065],
[ 0.52143395, 0.58103496],
[ 0.62030756, 0.24758299],
[ 0.59746987, 0.2574137 ],
[ 0.5780933 , 0.2652785 ],
[ 0.8624742 , 0.2089644 ],
[ 0.8855709 , 0.20027623]], dtype=np.float32)
# import numpy as np
# import cv2
# pts = uni_landmarks_468
# res = 900
# pts -= pts.min(axis=0)
# pts /= pts.max(axis=0)
# pts *= [res, res]
# pts = pts.astype(np.int)
# img = np.zeros( (res,res,3), np.uint8 )
# wnd_name = 'asd'
# selected = [False]*len(pts)
# sel = [0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 46, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 95, 96, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 117, 118, 124, 130, 132, 133, 135, 136, 138, 139, 140, 143, 144, 145, 146, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 168, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 189, 190, 191, 192, 193, 194, 199, 200, 201, 202, 204, 208, 210, 211, 212, 213, 214, 215, 221, 222, 223, 224, 225, 226, 228, 229, 230, 231, 232, 233, 243, 244, 245, 246, 247, 249, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 267, 268, 269, 270, 271, 272, 273, 276, 282, 283, 284, 285, 286, 287, 288, 291, 292, 293, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 306, 307, 308, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 324, 325, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 346, 347, 353, 359, 361, 362, 364, 365, 367, 368, 369, 372, 373, 374, 375, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 394, 395, 396, 397, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 413, 414, 415, 416, 417, 418, 421, 422, 424, 428, 430, 431, 432, 433, 434, 435, 441, 442, 443, 444, 445, 446, 448, 449, 450, 451, 452, 453, 463, 464, 465, 466, 467]
# print(len(sel))
# for i in sel:
# selected[i] = True
# select_holding = False
# unselect_holding = False
# def onMouse(event, x, y, flags, _):
# global select_holding
# global unselect_holding
# if event == cv2.EVENT_LBUTTONDOWN:
# select_holding = True
# elif event == cv2.EVENT_LBUTTONUP:
# select_holding = False
# elif event == cv2.EVENT_RBUTTONDOWN:
# unselect_holding = True
# elif event == cv2.EVENT_RBUTTONUP:
# unselect_holding = False
# elif event == cv2.EVENT_MBUTTONDOWN:
# print([ i for i, x in enumerate(selected) if x == True ])
# pt_idx = np.argsort( np.linalg.norm(pts - [x,y], axis=1) )[0]
# if select_holding:
# selected[pt_idx] = True
# if unselect_holding:
# selected[pt_idx] = False
# cv2.namedWindow(wnd_name)
# cv2.setMouseCallback(wnd_name, onMouse)
# while True:
# for pt_idx, (x,y) in enumerate(pts):
# if selected[pt_idx]:
# color = (255,0,0)
# else:
# color = (255,255,255)
# cv2.circle(img, (x,y), 1, color, 1 )
# cv2.imshow(wnd_name,img)
# cv2.waitKey(5)
# import multiprocessing
# import threading
# import time
# def proc1(ev = multiprocessing.Event()):
# while True:
# ev.wait(timeout=0.001)
# # def proc2(obj : ClassWithEvent):
# # print('before wait')
# # obj.ev.wait(timeout=0.005)
# # print('after wait')
# if __name__ == '__main__':
# multiprocessing.set_start_method('spawn', force=True)
# ev = multiprocessing.Event()
# ev.set()
# p = multiprocessing.Process(target=proc1, args=(ev,), daemon=True)
# threading.Thread(target=lambda: p.start(), daemon=True).start()
# time.sleep(1.0)
# p.terminate()
# p.join()
# del p
# # p = multiprocessing.Process(target=proc2, args=(obj,), daemon=True)
# # threading.Thread(target=lambda: p.start(), daemon=True).start()
# # time.sleep(1.0)
# import code
# code.interact(local=dict(globals(), **locals()))