Guest User

Untitled

a guest
Dec 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def get_M(i): #матрица преобразования
  2. 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']])))
  3. 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']])))
  4. M = cv2.getPerspectiveTransform(src,dst)
  5. return M
  6.  
  7. def aff_tr(i): #ПРЕОРАЗОВАНИЕ
  8. for slov in list_faces[i].values():
  9. list = np.array([[[slov['x'], slov['y'],1]]])
  10. dot = cv2.transform(list,get_M(i))
  11. x=dot[0][0][0]
  12. y=dot[0][0][1]
  13. slov['x'],slov['y'] = x,y
Add Comment
Please, Sign In to add comment