AI Pan Tilt Camera Tracker banner

AI Pan Tilt Camera Tracker

1 devlog
15m 27s

This project is an automated, real-time camera tracking system that uses classic Computer Vision techniques to follow specific objects, such as balls, based on their color profiles and geometric contours. Built for the Raspberry Pi, it continuousl…

This project is an automated, real-time camera tracking system that uses classic Computer Vision techniques to follow specific objects, such as balls, based on their color profiles and geometric contours. Built for the Raspberry Pi, it continuously analyzes a live video feed using OpenCV and applies a Proportional (P) control algorithm to calculate the target’s distance from the center of the frame. This data is instantly sent to an I2C motor driver (PCA9685) that dynamically adjusts a two-axis pan-tilt servo mechanism, keeping the object perfectly centered in the shot. The system also features a lightweight, zero-lag Flask web server that streams the annotated video feed and telemetry directly to any browser, resulting in a highly customizable, closed-loop control project that is very easy to implement by following the provided steps.

This project uses AI

Used Gemini for fixing bugs

Demo Repository

Loading README...

alberto.castells.garc

Shipped this project!

I built a pan-tilt camera tracker using a Raspberry Pi and Python. It uses computer vision to detect an object (like a ball) and moves two servos to keep it centered in the frame. It also streams the live video directly to my phone.

Definitely fixing the video lag over Wi-Fi. I had to rewrite the camera code to read raw JPEG bytes and clear the buffer so the stream wouldn’t freeze. Tuning the motor logic so the camera wouldn’t shake violently was also tricky!

Getting all the multithreading to work perfectly. Running the camera, the vision processing, the web server, and the physical motors all at the same time without crashing the Pi was hard. Seeing it physically chase a ball for the first time was amazing!

alberto.castells.garc

I finally got the project working, everything worked perfectly, I’m very happy, after connecting the camera and servos to the Raspberry Pi 5 8GB

Attachment
0