You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
666 B
20 lines
666 B
![]()
3 years ago
|
|
||
|
from PIL import Image
|
||
|
import face_recognition
|
||
|
|
||
|
image = face_recognition.load_image_file("testimage.png")
|
||
|
face_locations = face_recognition.face_locations(image)
|
||
|
|
||
|
|
||
|
print("I found {} face(s) in this photograph.".format(len(face_locations)))
|
||
|
|
||
|
for face_location in face_locations:
|
||
|
|
||
|
# Print the location of each face in this image
|
||
|
top, right, bottom, left = face_location
|
||
|
print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
|
||
|
|
||
|
# You can access the actual face itself like this:
|
||
|
face_image = image[top:bottom, left:right]
|
||
|
pil_image = Image.fromarray(face_image)
|
||
|
pil_image.show()
|