Pick a target
Stay on the current track ID while it's visible. Otherwise choose by class priority (people first), then by size. An operator can override from the dashboard by clicking any box.
COOP is an AI tracking camera on a Raspberry Pi 5 that spots people and cars, predicts where they're heading, and turns on stepper motors to keep them in frame, streamed live to your browser.
01 · Pipeline
Every frame runs the same loop. Vision stays on the Pi; precise step timing lives on a microcontroller.
OV5647 through Picamera2, 640×480 BGR frames.
Pi 5YOLO11n at 320 px finds people and vehicles; ByteTrack keeps a stable ID on each.
Pi 5 · CPUPixels become world angles; a constant-velocity filter estimates speed and aims 150 ms ahead.
Pi 5Target positions over USB serial (T pan tilt); AccelStepper ramps each move.
NEMA 17 motors on TMC2209 drivers turn the camera onto the target.
12 VStay on the current track ID while it's visible. Otherwise choose by class priority (people first), then by size. An operator can override from the dashboard by clicking any box.
When the camera turns, the whole scene slides across the frame. Tracking the world angle (gimbal angle + in-frame offset) means the camera's own motion never looks like target motion.
A Flask server streams the annotated MJPEG feed and a JSON status API to a dashboard any phone can open, with Auto / Manual / Stop control and an event log.
02 · The math
Two small pieces of math do most of the work.
A pinhole model turns the target's pixel column x in a frame of width w into an angle off the optical axis, then adds the gimbal's own angle. Tilt is the same with y, h and the vertical FOV.
With FOVh = 63°, the frame edge maps to exactly ±31.5°. Using atan (not a linear scale) keeps off-center targets accurate.
State is angle and angular velocity on both axes. Each frame predicts forward by the frame time Δt, then corrects with the new measurement.
H picks out the two angles we measure; q = 200 (deg/s²)² lets the target change speed, R = 0.5 deg² models detection jitter, and tlead = 0.15 s.
03 · Hardware
The Pi 5 handles vision. An Arduino Uno generates the step pulses, because Linux can't time them reliably.
┌─► buck 12V→5.1V ─USB-C─► Pi 5 ─USB─► Uno ─STEP/DIR─► TMC2209 ×2 ─► NEMA 17 ×2
12 V supply ────┤ │ ▲
└───────────────────────────┼──────────── VM (motor power) ──┘
└─ camera ribbon (22-pin)
04 · Team
Everything runs on a laptop with a webcam and simulated motors, so software and hardware never blocked each other.
Software
Vision, tracking, prediction, the control API and the dashboard.
Design & hardware
Enclosure, mount, steppers and wiring.