Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. faces = faceCascade.detectMultiScale(
  2. gray,
  3. scaleFactor=1.1,
  4. minNeighbors=5,
  5. minSize=(30, 30),
  6. flags = cv2.cv.CV_HAAR_SCALE_IMAGE
  7. )
  8.  
  9. for (x, y, w, h) in faces:
  10. mid_x = x + int(w/2)
  11. mid_y = y + int(h/2)
  12.  
  13. height, width = img.shape
  14. x_dot = ...
  15. y_dot = ...
  16.  
  17. dx_dot = int(width/2) - x_dot
  18. dy_dot = int(height/2) - y_dot
  19.  
  20. M = np.float32([[1,0,dx_dot],[0,1,dy_dot]])
  21. dst = cv2.warpAffine(img,M,(cols,rows))
  22.  
  23. p_1 = [eyes_x, eye_y]
  24. p_2 = [int(width/2),int(height/2)] # default: center of the image
  25. p_3 = [mouth_x, mouth_y]
  26.  
  27. target_p_1 = [eyes_x, int(eye_y * 0.45)]
  28. target_p_2 = [int(width/2),int(height/2)] # don't want to change
  29. target_p_3 = [mouth_x, int(mouth_y * 0.75)]
  30.  
  31. pts1 = np.float32([p_1,p_2,p_3])
  32. pts2 = np.float32([target_p_1,target_p_2,target_p_3])
  33.  
  34. M = cv2.getAffineTransform(pts1,pts2)
  35.  
  36. output = cv2.warpAffine(image,M,(height,width))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement