def get_face_encodings(path_to_image): #Equalise image using Histogram equalization in cv2 path_to_image = IE.avg_brightness(path_to_image) # Load image using scipy image = scipy.misc.imread(path_to_image) # Detect faces using the face detector detected_faces_using_SVM = face_detector(image, 1) #detected_faces_using_CNN = cnn_face_detector(image, 1) #gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) #detected_faces_using_Haar = haar_detector.detectMultiScale(gray, 1.8, 2) # Get pose/landmarks of those faces # Will be used as an input to the function that computes face encodings # This allows the neural network to be able to produce similar numbers for faces of the same people, regardless of camera angle and/or face positioning in the image shapes_faces = [ shape_predictor(image, face) for face in detected_faces_using_SVM ] #shapes_faces = [shape_predictor(image, dlib.rectangle(face.rect.left(),face.rect.top(),face.rect.right(),face.rect.bottom())) for face in detected_faces_using_CNN] #shapes_faces = [shape_predictor(image,dlib.rectangle(x,y,x+w,y+h)) for (x,y,w,h) in detected_faces_using_Haar] # For every face detected, compute the face encodings face_encoding = [ np.array( face_recognition_model.compute_face_descriptor( image, face_pose, 1)) for face_pose in shapes_faces ] return face_encoding
def get_face_encodings(path_to_image): #Equalise image using Histogram equalization in cv2 path_to_image = IE.avg_brightness(path_to_image) # Load image using scipy image = scipy.misc.imread(path_to_image) return haar_detector(image) return svm_detector(image) return cnn_detector(image)