Raspberry Pi Face Tracker

Having recently bought a Pimoroni Pan-Tilt HAT – I thought I’d put it to good use as a face tracker! I started off with the code example from the Pimoroni github, but thought I’d tweak it a little so that if it can’t find a face it starts searching.

From the starting position the camera begins capturing frames. OpenCV then processes each frame, looking for faces. If a face is found, a bounding box is drawn and the code then moves the camera to keep the face in the centre of the frame. If a face isn’t seen for a specified time, the camera enters ‘roam’ mode and sweeps across a defined area until a face is again encountered.

I captured the Raspberry Pi display while it was running:

And here’s a video of the actual pan-tilt assembly in action:

todo

The code is available on GitHub as usual. The mad-scientist in me really wants to get a small Nerf gun hooked up to this thing!