Face detection and tracking can be done using the OpenCV Haar Cascade object detection algorithms. What is Haar Cascade? A Haar filter is a type of wavelet filter which resembles a truncated sine wave. The cascade is formed by lining up Haar filters in layers to optimize the detection of particular objects.
At the 2017 Maker Faire in San Mateo, California, the Pi Eye participated in a demonstration of Haar-Cascade face detection where the face was a Beagle named “Penny”. The “Find Penny” project (organized by a fifth-grader named Vian) used 43 images of the beagle and 111 images without the beagle in 28 layers of Haar-Cascade training that took nearly 24 hours to complete.
The Pi Eye was programmed to scan the horizon for Penny and track her picture once the face was detected. When the face was close enough to the Eye, multi-colored LED lights from the Sense-Hat shield board signaled successful recognition of the dog.
The standard OpenCV distribution comes with a human-face detection program as a sample program and it works well and is an excellent way to begin understanding one method of visual object detection.