Guest User

Untitled

a guest
Jul 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def paint_detected_face_on_image(frame, location, name=None):
  2. """
  3. Paint a rectangle around the face and write the name
  4. """
  5. # unpack the coordinates from the location tuple
  6. top, right, bottom, left = location
  7.  
  8. if name is None:
  9. name = 'Unknown'
  10. color = (0, 0, 255) # red for unrecognized face
  11. else:
  12. color = (0, 128, 0) # dark green for recognized face
  13.  
  14. # Draw a box around the face
  15. cv2.rectangle(frame, (left, top), (right, bottom), color, 2)
  16.  
  17. # Draw a label with a name below the face
  18. cv2.rectangle(frame, (left, bottom - 35), (right, bottom), color, cv2.FILLED)
  19. cv2.putText(frame, name, (left + 6, bottom - 6), cv2.FONT_HERSHEY_DUPLEX, 1.0, (255, 255, 255), 1)
Add Comment
Please, Sign In to add comment