FT Face Tracker
OpenCV · LBPH · Arduino Servo

Face Tracker

A Python-powered face recognition and tracking project that trains a custom LBPH model, detects the recognized face through the webcam, and steers an Arduino servo through a configurable COM port — all from one unified GUI.

One-click project ZIP

Download everything from this website

Click once to download the latest public project files from GitHub as a ZIP. After extraction, the project can run locally from the included Python scripts and Arduino sketch.

ZIP

Whole public repo

Downloads the source code, website, GUI launcher, tracker scripts, and Arduino sketch.

SAFE

Private data stays local

Your face dataset, trained model, and demo recordings are generated on your computer.

Project Snapshot

The project is organized around face capture, model training, live tracking, and optional Arduino control.

Training Images Local

Capture your own samples into the private dataset folder.

Recognition Model LBPH

Custom model saved as face_model.xml.

Servo Range 45-135

Horizontal tracking angle mapped from face position.

Controller GUI

Modern Tkinter parent launcher with themes and COM settings.

Setup Guide

Follow these steps after downloading the ZIP so Python, OpenCV, LBPH, and Arduino all line up cleanly.

01

Download and open the project

Extract the ZIP, open the extracted folder in VS Code or a terminal, and keep the folder structure unchanged so the GUI can find the trainer, tracker, dataset, and Arduino sketch.

cd Servo-Facial-Tracking-main
02

Create a Python environment

Use a virtual environment so OpenCV and PySerial install only for this project.

py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
03

Prepare the Arduino servo

Open facearduino/facearduino.ino in Arduino IDE, attach the servo signal wire to pin 9, connect power and ground, upload the sketch, then copy the port name shown by the IDE.

Signal D9 Baud 9600 Example COM10
04

Launch, train, and track

Start the dashboard, capture face samples with the trainer, let it write custom face/face_model.xml, then run the LBPH tracker with Arduino access on or off.

python face_tracker_gui.py

Required software

  • Python 3Runs the GUI, trainer, OpenCV tracker, and serial bridge.
  • Arduino IDEUploads the servo sketch when hardware tracking is enabled.
  • WebcamCaptures training samples and live tracking frames.

Training controls

  • SpaceCaptures a detected face sample during training.
  • QFinishes training and lets the model save locally.
  • Run LBPH TrackerStarts recognition after the model exists.

Generated locally

  • dataset/Your captured face images.
  • custom face/face_model.xmlThe trained LBPH recognition model.
  • Keep privateDo not publish personal face data unless you mean to.

Workflow

Each part has a clear job, so the project can be tested in pieces or run as one system.

Capture

Run the trainer, press Space when your face is detected, and save normalized face crops into the dataset.

Train

The trainer reads the dataset, labels the images as your face, and writes the LBPH model file.

Track

The LBPH tracker recognizes the face, smooths the target position, and calculates a servo angle.

Control

The GUI launches scripts, switches themes, manages Arduino access, and passes the selected COM port.

Architecture

Camera frames move through detection and recognition before turning into motion commands.

01

Webcam Input

OpenCV captures frames and converts them to grayscale for face detection.

02

Haar Cascade

The tracker locates face rectangles and keeps recent positions for stable movement.

03

LBPH Recognition

The model checks whether the detected face matches the trained label.

04

Servo Output

When Arduino access is enabled, Python sends angle values over serial.

Launch Command

python face_tracker_gui.py

Arduino Settings Passed By GUI

FACE_TRACKER_USE_ARDUINO=1
FACE_TRACKER_COM_PORT=COM10

These values are applied when a tracker is started from the GUI, so the scripts can run with or without Arduino access.

Privacy-Safe Publishing

This page shows the system without embedding your face dataset, demo video, or biometric model.

No Face Media

The public overview uses generated interface graphics instead of webcam video or dataset images.

Keep Local

Dataset images, demo recordings, and trained recognition models should stay out of hosted folders.

File Map

Open the main pieces directly from this page.

Runtime Controls

Useful keys and GUI settings while testing.

Tracker Keys

Q quits, C centers, R moves to minimum angle, I inverts, and P pauses output.

Manual Motion

A and D nudge the servo angle with momentum while face tracking briefly waits.

Arduino Access

The GUI can turn Arduino serial access on or off and pass a COM port such as COM10.

Circuit Schematics

Wiring the servo and Arduino to work with the Python tracker over serial.

ARDUINO UNO GND 5V D9 (PWM) USB SERVO GND +5V SIG PC / Python pyserial → COM port Signal (D9) +5V GND
Arduino Pin Servo Wire Colour Notes
D9 (PWM) Signal Yellow / White PWM angle from Python
5V Power Red Servo power rail
GND Ground Brown / Black Common ground
Servo range mapped to 45°–135° by the tracker. Upload facearduino.ino first.

Serial Protocol

Python sends a plain integer (e.g. 90\n) over the selected COM port at 9600 baud. Arduino reads it with Serial.parseInt() and writes it directly to the servo.

Power Note

For multiple servos or high-torque motors use an external 5 V supply sharing a common ground with the Arduino — do not draw more than ~500 mA from the onboard 5 V pin.

Demo Video

Watch the tracker recognise a face and steer the servo in real time.

Recorded locally — face data stays on your machine. Download video