Sunday 23 November 2014

Making Faces and Faking Faces

I have been playing with the Haar-cascade-based face detector demo that comes with OpenCV. Among other things the demo can, in real time, detect faces in video frames from a camera. It draws circles around whatever it finds.

It occurred to me to confirm that the demo will detect multiple faces simultaneously. As I only have one face of my own, this doubled as an experiment to see how much of a realistic face I had to draw before the detector would recognise it as a face.

Loosely speaking, a Haar cascade models the thing to be detected as an arrangement of contrasting light and dark rectangular regions. Unsurprisingly, then, it didn't pick up a very stylised face with just a line for a mouth, dots for eyes and no nose. But once I'd darkened the mouth line enough, and put in some eyebrows and some nostrils, the face detector started to spot the fake face quite reliably.

The demo also does a second detection step within any region found by the first step. This can be used to find the eyes within the face, for example. The eye detector proved somewhat harder to fool. Even with heavy ellipses for the eyes, and well defined irises and pupils, it wasn't convinced. Only once I started to sketch the shadow either side of the nose did it become likely that the eye detector would detect eyes in my fake face.

Face detector draws circles around the regions it detects as containing faces and eyes
The face I drew is nonetheless far from realistic. Any face detector that finds nearly all things that are faces will also find some things that are not faces. In machines, this explains why Google Street View blurs out KFC's Colonel Sanders. In humans, we call it pareidolia.

No comments:

Post a Comment