4

I am using Dlib's frontal face detector to detect faces in an images; however, it cannot detect faces smaller than 80 by 80 pixels.

Dlib's example in face_detection_ex.cpp upsamples the input image using pyramid_up() to increase the face sizes. However, it makes the algorithm much slower because it will have to search in a larger image.

I wonder if anyone knows a solution for this problem.

mhaghighat
  • 1,073
  • 16
  • 27

1 Answers1

5

Dlib's face detector is trained to process 80x80 faces. If you want to detect smaller faces, you have two ways:

  1. increase resolution to make faces bigger. you can use pyramid_up or any other way lice cv::resize. And you can increase resultion not 2x, but may be 1.5x will be enough - it's on you
  2. train new face detector that will work on small faces - dlib has samples for training process

And the next your question is performance of face detector. Yes, it depends on resolution and if you want to detect 20x20 faces on 13 MP image - it will be slow. To make it work fast you have this options:

  1. reduce amount of pixels that should be processed by detector - use the right scale and region of interest
  2. use greyscale images
  3. reduce the amount of scale changes at scanning process
  4. use the recommendations from FAQ . I can only add that MinGW/GCC code works about 20% faster than MSVC and Android/ARM code is not using SIMD instructions
  5. for videos: apply motion detection and detect only changed areas (crop them manually and detect in cropped area) and also run frames in separate threads to consume all CPU cores
Evgeniy
  • 2,208
  • 12
  • 22
  • I tried to train the face detector without upsampling the images so that I can detect smaller faces. I tried it on the example file "*fhog_object_detector_ex.cpp*". I commented out the two lines of upsampling (`upsample_image_dataset`), and decreased the detection window size to 40x40. However, it is not able to detect most of the faces in the test images. Could you please tell me where my mistake is? – mhaghighat Sep 28 '16 at 18:32