DEV Community

Divyakush Punjabi
Divyakush Punjabi

Posted on

I built a camera that decides where to look

The first version of my auto-tracking camera shook like it was nervous. It knew exactly where the person was — and that precision was the problem. It kept chasing a target that was already "close enough," vibrating itself into uselessness.

Fixing that taught me more about control than any tutorial, and it's the heart of Netra — a camera that decides where to look on its own.

The trap of "keep it centered"

The naive rule is obvious: if the person isn't dead-center, move toward them. But "dead-center" is never exactly true — there's always a pixel or two of error — so the servos chase sub-pixel noise forever and the whole rig jitters. A tracking system that reacts to every tiny error is a system that never settles.

The fix isn't more precision. It's less reaction, applied intelligently.

Two ideas from control theory

Proportional control. The servo speed scales with how far the target is from center. Someone at the edge of the frame gets a fast correction; someone almost centered gets a gentle nudge. This alone is the difference between a camera that snaps and overshoots and one that glides.

A dead zone. A 12% tolerance band around the center where the servos do nothing. Inside that band, "close enough" is treated as "centered," which kills the jitter completely.

Those two rules — scale the response, ignore tiny errors — did more for tracking quality than any amount of model tuning. YOLOv8 finds the person; the control loop decides how to move; the servos (MG90S, 0°–180° pan, 30°–150° tilt) follow smoothly. It runs closed-loop over MQTT, and the dashboard exposes manual, auto-tracking, and waypoint-patrol modes.

The bigger lesson

This generalizes far past cameras. Any system that reacts to every fluctuation — a thermostat, a rate limiter, an autoscaler, a UI — will oscillate and exhaust itself. The wisdom is knowing what errors to ignore. Sometimes the smartest thing your code can do is nothing, on purpose.

That single insight turned a twitchy demo into something that tracks a walking person calmly across a room. The full control-loop breakdown and the edge-to-cloud architecture are on the project page.

👉 How it works: www.divyakush.com/projects/netra


Divyakush Punjabi — Full-Stack & AI Systems Engineer

🌐 https://www.divyakush.com · 💼 LinkedIn · 💻 GitHub

Top comments (0)