Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def paint_detected_face_on_image(frame, location, name=None):
- """
- Paint a rectangle around the face and write the name
- """
- # unpack the coordinates from the location tuple
- top, right, bottom, left = location
- if name is None:
- name = 'Unknown'
- color = (0, 0, 255) # red for unrecognized face
- else:
- color = (0, 128, 0) # dark green for recognized face
- # Draw a box around the face
- cv2.rectangle(frame, (left, top), (right, bottom), color, 2)
- # Draw a label with a name below the face
- cv2.rectangle(frame, (left, bottom - 35), (right, bottom), color, cv2.FILLED)
- 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