dlib frontal face detector code example

Example: dlib frontal face detector too slow

You can take several actions to make Dlib run faster/

Dlib is capable of detecting faces in very small areas (80x80 pixels). 
You are probably sending raw WebCam frames at approximately 1280x720 resolution, 
which is not necessary. 
I recommend from my experience 
to reduce the frames about a quarter of the original resolution. #
Yes, 320x180 is fine for Dlib. In consequence you will get 4x speed.

As mentioned in the comments, 
by turning on the compilation optimizations while building Dlib, 
you will get significantly improvement in speed.

Dlib works faster with grayscale images. 
You do not need the color on the webcam frame. 
You can use OpenCV to convert into grayscale the previously reduced in size 
frame.

Dlib takes its time finding faces but is extremely fast finding landmarks 
on faces. Only if your Webcam provides a high framerate (24-30fps), you
could skip some frames because faces normally doesn't move so much.

Tags:

Misc Example