Python Forum
detect Multiple faces using dlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
detect Multiple faces using dlib
#1
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 ?

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
Reply
#2
Hello!

See OpenCVhttps://realpython.com/blog/python/face-...th-python/
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pip install dlib packge issue MahendraYadav 1 6,749 Aug-31-2021, 07:06 PM
Last Post: snippsat
  Loop face landmarking in all folder using dlib lokoprof 5 2,866 Apr-17-2020, 10:08 AM
Last Post: deanhystad
  pycharm cannt find dlib which is installed kevinlee325 2 4,252 Oct-15-2019, 04:56 AM
Last Post: kevinlee325
  AWS rekognition - index faces coffe2go00 3 3,760 Jun-02-2018, 01:01 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020