Skip to content

Commit

Permalink
Tweak demo to show multiple faces in one window instead of separate w…
Browse files Browse the repository at this point in the history
…indows
  • Loading branch information
ageitgey committed Aug 21, 2018
1 parent 634db2e commit 99bd91c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/find_facial_features_in_picture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
import face_recognition

# Load the jpg file into a numpy array
image = face_recognition.load_image_file("biden.jpg")
image = face_recognition.load_image_file("two_people.jpg")

# Find all facial features in all the faces in the image
face_landmarks_list = face_recognition.face_landmarks(image)

print("I found {} face(s) in this photograph.".format(len(face_landmarks_list)))

# Create a PIL imagedraw object so we can draw on the picture
pil_image = Image.fromarray(image)
d = ImageDraw.Draw(pil_image)

for face_landmarks in face_landmarks_list:

# Print the location of each facial feature in this image
for facial_feature in face_landmarks.keys():
print("The {} in this face has the following points: {}".format(facial_feature, face_landmarks[facial_feature]))

# Let's trace out each facial feature in the image with a line!
pil_image = Image.fromarray(image)
d = ImageDraw.Draw(pil_image)

for facial_feature in face_landmarks.keys():
d.line(face_landmarks[facial_feature], width=5)

pil_image.show()
# Show the picture
pil_image.show()

0 comments on commit 99bd91c

Please sign in to comment.