Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_M(i): #матрица преобразования
- src = np.float32(np.array(([list_faces[i]['mouthLeft']['x'],list_faces[i]['mouthLeft']['y']], [list_faces[i]['mouthRight']['x'],list_faces[i]['mouthRight']['y']], [list_faces[i]['noseLeftAlarOutTip']['x'],list_faces[i]['noseLeftAlarOutTip']['y']],[list_faces[i]['noseRightAlarOutTip']['x'],list_faces[i]['noseRightAlarOutTip']['y']])))
- dst = np.float32(np.array(([list_faces[3]['mouthLeft']['x'],list_faces[3]['mouthLeft']['y']], [list_faces[3]['mouthRight']['x'],list_faces[3]['mouthRight']['y']], [list_faces[3]['noseLeftAlarOutTip']['x'],list_faces[3]['noseLeftAlarOutTip']['y']],[list_faces[3]['noseRightAlarOutTip']['x'],list_faces[3]['noseRightAlarOutTip']['y']])))
- M = cv2.getPerspectiveTransform(src,dst)
- return M
- def aff_tr(i): #ПРЕОРАЗОВАНИЕ
- for slov in list_faces[i].values():
- list = np.array([[[slov['x'], slov['y'],1]]])
- dot = cv2.transform(list,get_M(i))
- x=dot[0][0][0]
- y=dot[0][0][1]
- slov['x'],slov['y'] = x,y
Add Comment
Please, Sign In to add comment