Teaching Reachy Mini to follow my face
Face detection, recognition and a head that doesn't fidget: the first brick of turning a Reachy Mini into a desk companion.
I got a Reachy Mini, the little open-source desk robot from Pollen Robotics and Hugging Face. It has a head that moves in every direction, two antennas, a camera, a mic and a speaker. Out of the box it does… not much. So the first thing I wanted was the most basic “this thing is alive” behaviour: look at me when I’m in front of it, and know it’s me.
Code is here: github.com/Epwo/reachy (the face_track/ folder).
The plan
Every frame from the robot’s camera goes through three steps:
- Detect every face in the frame.
- Recognize who each face belongs to (or “unknown”).
- Pick one face to follow, and move the head toward it smoothly.
Steps 1 and 2 are mostly solved problems. Step 3 is where all the fun (and all the tuning) is.
Detection and recognition: InsightFace
I used InsightFace and its buffalo_l model pack. One call gives you bounding boxes and a 512-dimension embedding for each face. The embedding is the important part: two pictures of the same person give vectors pointing in roughly the same direction.
So recognition is just:
- Enrolling someone = saving their normalized embedding to a
.npyfile. Enroll several times (different angles, lighting) and the embeddings are averaged, which makes it more robust. - Recognizing = cosine similarity between the new face and every known face. Best score wins, if it’s above a threshold. Otherwise it’s “unknown”.
python enroll.py Ewann # SPACE to capture, Q when done
python main.py # follow + recognize
No training, no dataset, no GPU. One small trick: InsightFace also loads landmark and age/gender models by default, which I don’t need. Only loading detection and recognition roughly halves the RAM, which matters later when the same Mac mini also runs a language model.
Which face do I look at?
With two people in the frame, a naive “follow the biggest face” makes the head ping-pong between them every time one of them leans forward. Very creepy. So the selection is sticky:
- If I’m already locked on someone and they’re still visible, keep them. Known faces are matched by name; unknown ones by how close their box is to the last one.
- Otherwise, prefer a known face over strangers.
- Otherwise, take the largest face.
Moving the head without it looking like a security camera
My first version sent the head toward the face on every frame. It worked, but it never stopped moving: every tiny jitter in the detection meant a tiny head twitch. Here is what fixed it, one knob at a time.
A dead zone, with hysteresis
The head only starts moving when the face leaves a box in the middle of the frame (the dead zone). It only stops once the face is back inside a smaller box (the recenter zone).
Why two boxes? With a single one, the head stops the exact moment the face crosses the edge, so you end up parked at the border of the frame instead of in the middle. With two, it goes all the way back to center, then rests.
Smoothing, twice
- A light moving average on the detected position, to remove the detection jitter.
- A moving average on the head pose itself, so it glides toward the target instead of snapping.
The pose smoothing is done on the full 3D pose (a 4×4 matrix): the translation is interpolated normally, and the rotation is interpolated then projected back to a valid rotation with an SVD. For small steps it’s basically a slerp, and much cheaper.
A speed cap
Finally, the rotation per frame is capped (in degrees). If you suddenly walk to the other side of the room, the head turns at a calm, steady speed instead of whipping around.
Let the SDK do the geometry
The Reachy SDK has look_at_image(u, v), which turns a pixel into a head pose that looks at that point, from the current head pose. That makes convergence clean: as the head turns, the face moves toward the center of the image, so the target stays roughly anchored on the face in 3D.
A tuning bench
Picking good numbers for all of this by editing code and restarting was painful. So I wrote experiment.py: the same pipeline, but with sliders for every parameter and the zones drawn on top of the video. It works with the Mac webcam, a video file, or the robot camera, with or without the robot connected.
Press S and the settings are saved to tracking_params.json, which the real tracker loads. Here’s where I ended up:
| Setting | Value | What it does |
|---|---|---|
dead_zone |
0.15 | how far off-center (fraction of the frame) before the head moves |
recenter_zone |
0.04 | how centered the face must be before it stops |
tracking_speed |
0.156 | how snappy the head pose smoothing is |
max_step_deg |
3.1 | max rotation per frame |
detection_smoothing |
0.85 | anti-jitter on the detected position |
What I learned
- Detection is the easy part. Making motion feel natural is the real work, and it’s all about hysteresis, smoothing and limits. Very control-theory-ish, without the equations.
- Build the tuning tool early. Sliders plus a live overlay saved me hours compared to change-restart-look.
- Being looked at by a robot that knows your name is surprisingly fun.
This was the first brick. The next one was giving it a voice, and that turned into a much bigger rabbit hole: Billou, a voice assistant that runs entirely on a Mac mini.