Several personal projects I’ve had in the past relied on some basic face feature detection either for face isolation, face state detection, or some kinds of perspective estimation. I found that there are plenty of resources for learning how to perform face detection in Python, but most of them suffer from a handful of the following issues:
Isn’t easy to use right out of the box.
Doesn’t provide face feature detection, just simple face detection.
Relies on older and no-longer maintained methods from
cv2for face detection.
Is pretty greedy in terms of memory usage and scattered method calls.
Doesn’t provide a selection of helpers to make face detection easier and quicker.
Requires that you write a whole bunch of boilerplate to get anything clean looking.
Or just my own personal disagreements with some of the code structure.
This project is my own attempt to provide decent face feature detection when you don’t
want to think too hard about it.
We try to get as close as possible to a single
pip install and still provide
effective detection and recognition in Python.
However, we do have several system dependencies that are necessary, see
System Requirements for more details.
Below is a simple example of full face feature detection and rendering out to a standard OpenCV window using some of the features available in Facelift. To get started using this package, please see the Getting Started guide.
1 2 3 4 5 6 7 8 9 10 11 12
from facelift import FullFaceDetector, iter_stream_frames from facelift.render import draw_line from facelift.window import opencv_window detector = FullFaceDetector() with opencv_window() as window: for frame in iter_stream_frames(): for face in detector.iter_faces(frame): for feature, points in face.landmarks.items(): frame = draw_line(frame, points) window.render(frame)