+ 2

Help with Identifying single face in photo!

Please see sample code! (HELP WITH THIS CODE) I want to be able to see if a selected face is in a group photo, find that face, then draw a bow around that one found face. import PIL.Image import PIL.ImageDraw import face_recognition import numpy as np # Load the image of the face you want to detect in the photo load into numpy array peyton_manning = face_recognition.load_image_file("peyton.jpg") # Load the group photo denver_group_Photo = face_recognition.load_image_file('Denteam.jpg') # Location info for Peytons Face peyton_locations = face_recognition.face_locations(peyton_manning) # Find all the faces in the group image faces_in_Denver_group_photo = face_recognition.face_locations(denver_group_Photo) number_of_faces = len(faces_in_Denver_group_photo) print("I found {} face(s) in this photograph.".format(number_of_faces)) # Load the image into a Python Image Library object so that we can draw on top of it and display it pil_image = PIL.Image.fromarray(denver_group_Photo) # Encode Peyton face for comparison peyton_encoded = face_recognition.face_encodings(peyton_manning) # Encode entire image used to search for special case (this returns a array containing 128bit info for every face found) group_encoded = face_recognition.face_encodings(denver_group_Photo) for single_encode in group_encoded: results = face_recognition.compare_faces(peyton_encoded, single_encode) if results[0]: print("Peyton Manning's FACE is in this photo") for face_location in faces_in_Denver_group_photo: # Print the location of each face in this image. Each face is a list of co-ordinates in # (top, right, bottom, left) order. top, right, bottom, left = face_location # Let's draw a box around each face that the program has found! draw = PIL.ImageDraw.Draw(pil_image) draw.rectangle([left, top, right, bottom], outline="red",

12th Dec 2018, 5:50 AM
Wi$e Xhi8F
Wi$e Xhi8F - avatar
1 Antwort
+ 4
Don't know about that but you could use a haar Cascade to build your custom face recogniser. Tutorial link: https://youtu.be/ydSXgBZ1ybk
12th Dec 2018, 10:29 AM
Aditya
Aditya - avatar