Jan-18-2017, 10:04 AM
Hi all,
My requirement is i need to detect multiple faces in a single image. The following code is able to read only single face. Pls suggest how can i read multiple faces in a image ?
vijay
My requirement is i need to detect multiple faces in a single image. The following code is able to read only single face. Pls suggest how can i read multiple faces in a image ?
import caffe, dlib, io from __future__ import print_function import os import matplotlib.pyplot as plt detector = dlib.get_frontal_face_detector() img21 = 'group.jpg' im_name = img21 img = io.imread(os.path.join('./',im_name)) faces=[] faces= detector(img) total= len(faces) print('total faces here :',total) cropped_face = input_image_cropped[faces[0].top():faces[0].bottom(), faces[0].left():faces[0].right(), :] input_image_cropped = caffe.io.load_image(os.path.join('./', im_name)) cropped_face = input_image_cropped[faces[0].top():faces[0].bottom(), faces[0].left():faces[0].right(), :] h = faces[0].bottom() - faces[0].top() w = faces[0].right() - faces[0].left() age_prediction_cropped = age_net.predict([cropped_face]) print('\n\t predicted age (Dlib-cropped image):', age_prediction_cropped[0].argmax()) plt.show()Thanks
vijay