← projects

Overseer, a face-tracking robot

Overseer is a robotic art piece inspired by George Orwell’s 1984. It makes surveillance physical: a camera on a motorized arm finds the closest face and turns to follow it. When nobody is in view, it re-centers and waits.

It is built from particleboard and cardboard around two servos, a Raspberry Pi, and its camera.

The finished Overseer: a cardboard camera housing on a particleboard arm with two servos.

How it tracks

Every frame goes through the same loop:

  1. Capture a frame from the camera.
  2. Detect all faces in it.
  3. Pick the closest one.
  4. Turn the arm toward it.

Later additions: a tolerance zone around the target, so small offsets don’t move the arm; bounding boxes around the detected faces; and re-centering after the arm has been idle for a while.

The geometry problem

The image gives the angle between the camera’s view and the face, but that is not the angle the servo has to turn. The camera sits off the servo’s axis, so camera, face, and joint form a triangle with only one known angle and one known side. Without the distance to the face, it can’t be solved.

First sketches of the arm, the servo motion, and the angle calculation.
First sketches of the arm, the servo motion, and the angle calculation.
Two diagrams. Left: camera C on an arm of length r above the servo axis B, a face A at distance d from the camera; the camera sees A at angle alpha, the servo has to turn by phi, and the angle at A is chi. Right: the camera sits on the servo axis, and alpha equals phi.
Left: the camera \(C\) on an arm of length \(r\) around the servo axis \(B\) sees the face \(A\) at \(\alpha\), but the servo has to turn by \(\varphi\). Right: with the lens on the axis, the two angles are equal.

Put the servo axis at \(B\), the camera at \(C\), at distance \(r\) from \(B\) along the arm, and the face at \(A\), at an unknown distance \(d\) from the camera. The camera looks along the arm and sees the face at an angle \(\alpha\) off its optical axis. A face \(x\) pixels off-center in an image \(W\) pixels wide is at

\[ \alpha = \arctan\left(\frac{2x}{W}\tan\frac{\theta}{2}\right), \]

where \(\theta = 62.2^\circ\) is the camera’s horizontal field of view (\(48.8^\circ\) vertically, for the second servo). The servo has to turn by \(\varphi\), the angle at \(B\).

The angle at \(C\) is \(180^\circ - \alpha\), so the angles at \(A\) and \(B\) add up to \(\chi + \varphi = \alpha\). The law of tangents on the sides \(r\) and \(d\) gives

\[ \frac{r-d}{r+d} = \frac{\tan\frac{\chi-\varphi}{2}}{\tan\frac{\chi+\varphi}{2}} = \frac{\tan\frac{\chi-\varphi}{2}}{\tan\frac{\alpha}{2}}, \]

and after substituting \(\chi = \alpha - \varphi\), the boxed formula in the sketch above becomes

\[ \varphi = \frac{\alpha}{2} - \arctan\left(\frac{r-d}{r+d}\tan\frac{\alpha}{2}\right). \]

For a distant face (\(d \gg r\)), \(\varphi \to \alpha\). For a face as far from the camera as the camera is from the axis (\(d = r\)), \(\varphi = \alpha/2\). The camera sees the same \(\alpha\) in both cases, so without \(d\) the servo angle can’t be computed.

We removed \(r\) instead: the servo axis runs through the camera lens, so \(r = 0\) and

\[ \varphi = \frac{\alpha}{2} + \arctan\left(\tan\frac{\alpha}{2}\right) = \alpha \]

for any \(d\). The camera turns in place, and the angle measured in the image is exactly the servo’s rotation. The math became trivial, and the mechanical design considerably harder.

Casing drafts. On the right page, the Zero W box is crossed out in favor of the 3B+.
Casing drafts. On the right page, the Zero W box is crossed out in favor of the 3B+.

Choosing the computer

The plan was a Raspberry Pi Zero W, small enough to fit inside the main enclosure. Face detection used OpenCV 4.3.0, which needs an ARMv7 or newer CPU, and the Zero W has an ARMv6 core. We switched to the Raspberry Pi 3B+ (ARMv8). It needed a second enclosure, so Overseer was no longer a single, self-contained wall-mounted unit.

Final concept with dimensions and the assembly plan. The parts are labelled A to G (bottom right).
Final concept with dimensions and the assembly plan. The parts are labelled A to G (bottom right).
The same parts, marked out and hand-cut from particleboard, then joined with brackets.
The same parts, marked out and hand-cut from particleboard, then joined with brackets.

The frame

The frame is lightweight particleboard, to keep the arm’s inertia low so the servos can move it quickly. It turned out weaker than expected and needed reinforcement in a few places. Loose cables kept catching in the arms and joints, so we zip-tied them along the frame.

Mounting the servos and assembling the arm.
Mounting the servos and assembling the arm.
Cutting plans for the cardboard housings.
Cutting plans for the cardboard housings.

Housings

The servos, the camera, and the electronics sit in cardboard housings, and the main enclosures are thin laminated board.

The assembled arm, and the Pi with its fan in the electronics box.
The assembled arm, and the Pi with its fan in the electronics box.

Tuning

In the last phase we tuned the parameters and lowered the frame rate and image quality to keep processing smooth. A fan keeps the CPU from overheating during long runs.

Overseer from the front, with the camera housing turned toward the viewer.

Parts

  • 2× servo, Waveshare MG996R: 11 kg·cm torque and 0.18 s per 60° at 6 V, 180° range
  • Raspberry Pi 3 Model B+: 1.4 GHz quad-core Cortex-A53 (ARMv8-A), 1 GB RAM
  • Raspberry Pi Camera V2: 8 MP Sony IMX219, 1080p at 30 fps or 720p at 60 fps, 62.2° × 48.8° field of view
  • Fan: 35 × 35 mm, run at 3.3 V instead of 5 V
  • Power supply: 5.1 V, 3 A