This chapter does not appear in the book.
This chapter describes two ways of detecting facial features such as the eyes, eyebrows, nose, mouth, and chin. The first employs Haar cascade classifiers, in much the same way as I coded face detection and eye tracking in earlier chapters. Three examples of what's possible are shown below.
I'm using the pre-calculated Haar classifiers from the OpenCV download to find the frontal face, left eye, right eye, nose and mouth. I utilize the bounded box details returned by those classifiers to draw colored rectangles on top of the input image.
One drawback is the lack of detail returned by a classifier. For example, it would be useful to have more information about the outline shapes of the nose and mouth. Also, the classifiers aren't that accurate (i.e. overly large rectangles, and the occasionally missed feature, such as James Gosling's left eye). However, I'll explain how detection rates can be improved by using region-of-interest (ROI) cropping on the image.
A fun alternative is the FaceSDK API from Luxand, which offers a range of capabilities including face detection and recognition, and eye tracking. My interest is in its support for facial features, which are quite a bit superior to what I can code up with Haar cascades. As an example, the screenshot at the top of the page shows an application using the FaceSDK.
Webcam snaps are being processed, which explains the image quality difference from the images shown above. FaceSDK represents an analyzed face by 66 coordinates for the eyes, eyebrows, lips, nose, cheek lines, and chin. I've used those points to draw yellow lines and blue and green dots on top of the webcam picture.
The major drawback of FaceSDK is that it isn't free, although you can obtain a trial version that remains fully functional for 6 weeks. Another current weakness is that there isn't a port for Android. I've used the facial coordinates in two simple examples, shown below.
The happy/sad detector on the left of Figure 3 utilizes a less-than-sophisticated mouse/nose width ratio calculation to determine if the user is smiling or not, and writes the word "HAPPY" or "SAD" onto the user's brow. The mustache augmenter draws a mustache pinned midway between the user's upper lip and nose.