All projects
Computer Vision Face-Tracking Turret
A webcam on a servo that finds your face and follows it.

Summary
- What it is
- A single-axis face-tracking camera turret
- Team
- Solo (personal project)
- Dates
- Aug 2026
- Tools
- Python, OpenCV (Haar cascades), Arduino Mega, servo, serial communication
- Results
- Stable tracking after Kp tuning (0.05 → 0.035 degrees of pan per pixel of error) and a 15 px deadzone
- Servo signal
- Mega pin 6
- Serial
- 9600 baud
- Power
- USB from the laptop; servo on the Mega's 5V pin
What I built
- A single-axis face-tracking camera turret: Python + OpenCV (Haar cascades) detects a face on a USB webcam and streams pan angles over serial to an Arduino Mega driving the servo.
- I eliminated oscillation by tuning a proportional controller (Kp stepped down from 0.05 to 0.035 degrees of pan per pixel of error, applied each frame) and adding a 15-pixel deadzone around the frame centre.
- I debugged the full stack: inverted control direction from servo mounting, an OpenCV 5 API break (pinned to 4.x), and Windows camera-backend errors.


How it works
- A USB webcam feeds the laptop. Python + OpenCV finds the face with Haar cascades, which is classical computer vision.
- Proportional control: each frame, the pan angle changes by Kp degrees per pixel of error, with a 15-pixel deadzone around the frame centre.
- The laptop streams pan angles over serial at 9600 baud to an Arduino Mega. The servo signal is on Mega pin 6. Everything is powered over USB from the laptop, with the servo on the Mega's 5V pin.
Results
- 0.05 → 0.035
- Kp, degrees of pan per pixel of error
- 15 px
- Deadzone around the frame centre
Stable tracking after Kp tuning and the deadzone.
What went wrong
01
Oscillation
At Kp 0.05 the turret oscillated. Stepping Kp down to 0.035 and adding the 15-pixel deadzone eliminated it.
02
Inverted control direction
The control direction was inverted because of how the servo was mounted.
03
OpenCV 5 API break
An API break in OpenCV 5. I pinned OpenCV to 4.x.
04
Windows camera backend
Windows camera-backend errors.
Next steps
Finish the 3D-printed webcam bracket (the webcam is currently taped to the servo horn), then reshoot the demo.
Placeholder
Video not filmed yet: a 10–15 s side-by-side clip of the turret tracking and the laptop screen with the OpenCV bounding box.