The one-line mental model
AI aerial cinematography is a tracking and planning problem in creative clothing: lock onto a subject robustly, decide where in the frame it should sit and how the camera should move around it, then execute the move with smoothing that hides the automation.
You will be able to:
- Track subjects through occlusion and scale changes with a stable track ID
- Express framing rules β rule of thirds, lead room, horizon β as code
- Generate orbit, reveal, and dolly shot paths from a subject state
- Smooth camera motion with splines and jerk-limited profiles
Prerequisites
- !Object detection and tracking
- !Camera gimbal basics
- !BΓ©zier or spline interpolation
What You'll Learn
- 1Explain why naive center-framing looks amateur
- 2Implement a framing controller that steers gimbal and position
- 3Generate cinematic shot templates parametrically
Why center-framing looks like surveillance footage
Point a tracker at a person and hold them in the dead center of every frame and you have made a bodycam, not a film. Professional cinematography follows compositional conventions that evolved over a century of filmmaking, and the good news is that most of them translate directly into tracking error targets rather than vibes. The rule of thirds places the subject on a horizontal or vertical third line rather than the center. Lead room, or nose room, puts empty space in front of a moving subject so the viewer subconsciously expects continued motion. Horizon placement communicates scale: a low horizon emphasizes sky and makes a subject look small and heroic; a high horizon emphasizes ground texture and context. Headroom β the gap between the top of the subject's head and the frame edge β stays roughly constant across a shot so the audience stops noticing the camera.
Each of these becomes a numeric target in a framing controller. Instead of driving tracking error to zero, you drive it to a desired offset: the subject's centroid belongs at 33 percent of frame width for a profile shot, with lead room extending to 55 percent when lateral velocity is significant. The controller then converts that framing error into two outputs β a yaw or position correction to re-center laterally, and a gimbal pitch correction to fix vertical placement. The separation matters: moving the aircraft changes parallax and background, while moving only the gimbal keeps the background stable. Professional operators bias toward gimbal-first corrections for fine framing and reserve aircraft motion for larger composition changes.
| Compositional rule | Target in code | Typical use |
|---|---|---|
| Rule of thirds | Subject centroid at 0.33 or 0.66 of frame | Interviews, portraits, static subjects |
| Lead room | Empty space = 0.55 of frame along velocity | Running, cycling, vehicles |
| Headroom | Gap above head 0.08 to 0.12 of frame height | People, animals |
| Horizon line | Horizon at 0.33 or 0.66 of frame | Landscapes, establishing shots |
| Center weight | Centroid at 0.5 | Symmetry shots, reveals, landings |
A framing controller you can tune
The controller below takes a detection in normalized frame coordinates plus a velocity estimate, computes the error against the active compositional rule, and emits gimbal and yaw commands with separate gains. Separating the two gains is what lets you create the gentle floating feel of a professional shot instead of a twitchy gimbal hunting for the target.
from dataclasses import dataclass, field
from enum import Enum
class Framing(Enum):
CENTER = (0.50, 0.50)
LEFT_THIRD = (0.33, 0.50)
RIGHT_THIRD = (0.67, 0.50)
LEAD_ROOM = None # computed from velocity
@dataclass
class FramingController:
yaw_gain: float = 0.8
pitch_gain: float = 0.6
lead_fraction: float = 0.55
deadband: float = 0.02
state: dict = field(default_factory=dict)
def target_for(self, framing: Framing, vel_x: float):
if framing is Framing.LEAD_ROOM:
if abs(vel_x) < 0.01:
return (0.50, 0.50)
x = 1.0 - self.lead_fraction if vel_x > 0 else self.lead_fraction
return (x, 0.50)
return framing.value
def step(self, detection_xy, framing: Framing, vel_x: float,
vel_y: float = 0.0):
"""Returns (yaw_cmd, pitch_cmd) in deg/s-ish units."""
tx, ty = self.target_for(framing, vel_x)
ex = detection_xy[0] - tx
ey = detection_xy[1] - ty
if abs(ex) < self.deadband:
ex = 0.0
if abs(ey) < self.deadband:
ey = 0.0
yaw = self.yaw_gain * ex * 10.0
pitch = self.pitch_gain * ey * 8.0
self.state.update({"error": (ex, ey), "target": (tx, ty)})
return yaw, -pitch # camera pitch axis often inverted
ctl = FramingController()
frames = [
((0.50, 0.48), Framing.LEFT_THIRD, 0.0),
((0.40, 0.49), Framing.LEFT_THIRD, 0.0),
((0.62, 0.50), Framing.LEAD_ROOM, 0.30),
((0.48, 0.52), Framing.LEAD_ROOM, -0.25),
]
for det, framing, vx in frames:
yaw, pitch = ctl.step(det, framing, vel_x=vx)
print(f"det {det} framing {framing.name:12s} -> yaw {yaw:+.2f} "
f"pitch {pitch:+.2f} error {ctl.state['error']}")
Tune the deadband first. A controller with no deadband jitters on detector noise at every frame; a deadband around two percent of frame width β roughly the detector's own localization noise β produces still, confident framing. Only then adjust gains, and prefer lower yaw gain with slightly higher pitch gain: lateral overshoot is far more visible to audiences than vertical overshoot because the background sweeps horizontally.
Shot templates as parametric paths
Production aerial work runs on a vocabulary of repeatable shots β orbit, rise-and-reveal, dolly-in, tracking parallel, pull-back β each defined by a small parameter set. Encoding them as functions of subject state turns a director's request into a trajectory the planner can deconflict and the controller can fly smoothly.
from dataclasses import dataclass
import numpy as np
@dataclass
class ShotParams:
subject: np.ndarray # x, y, z
radius: float = 12.0 # m for orbits
altitude_delta: float = 0.0 # m relative to subject
speed_mps: float = 3.0
duration_s: float = 12.0
start_angle_deg: float = 0.0
arc_deg: float = 90.0
def orbit_path(p: ShotParams, samples=60):
"""Waypoints around a subject at constant radius and altitude offset."""
pts = []
for i in range(samples):
frac = i / (samples - 1)
theta = np.radians(p.start_angle_deg + p.arc_deg * frac)
x = p.subject[0] + p.radius * np.cos(theta)
y = p.subject[1] + p.radius * np.sin(theta)
z = p.subject[2] + p.altitude_delta
pts.append((x, y, z, theta))
return pts
def rise_reveal_path(p: ShotParams, samples=40):
"""Descend behind an occluder then rise to reveal the subject."""
pts = []
start_z = p.subject[2] - max(8.0, abs(p.altitude_delta) + 6.0)
for i in range(samples):
frac = i / (samples - 1)
z = start_z + (p.subject[2] + p.altitude_delta - start_z) * frac
# Drift slightly forward as we rise
y = p.subject[1] - p.radius + p.radius * 0.6 * frac
pts.append((p.subject[0], y, z, np.pi)) # facing subject
return pts
def jerk_limited_speed(target_speed, current_speed, dt=0.1, accel=1.5):
"""Rate-limit speed changes so camera motion reads as intentional."""
max_dv = accel * dt
dv = np.clip(target_speed - current_speed, -max_dv, max_dv)
return current_speed + dv
orbit = orbit_path(ShotParams(subject=np.array([10.0, 5.0, 3.0]),
radius=14.0, arc_deg=180.0,
start_angle_deg=-90.0))
reveal = rise_reveal_path(ShotParams(subject=np.array([0.0, 20.0, 4.0]),
radius=10.0, altitude_delta=2.0))
print(f"orbit: {len(orbit)} waypoints, "
f"start {tuple(round(v, 1) for v in orbit[0][:3])}, "
f"end {tuple(round(v, 1) for v in orbit[-1][:3])}")
print(f"reveal: {len(reveal)} waypoints, "
f"z {reveal[0][2]:.1f} -> {reveal[-1][2]:.1f}")
speed = 0.0
for _ in range(10):
speed = jerk_limited_speed(target_speed=4.0, current_speed=speed)
print(f"speed ramp over 1 s: {speed:.2f} m/s (target 4.0)")
The yaw column in the orbit output is the look-at angle the gimbal should hold β pointing inward at the subject throughout. Generating yaw targets from the same parameterization that generates positions prevents the classic amateur error of a perfect orbit filmed with the camera staring at the horizon.
Tracking through occlusion and scale change
The best framing controller is useless if the track ID flips mid-shot. Aerial subjects pass behind trees, dip into shadows, and shrink to twenty pixels as the aircraft climbs for a wider composition. Robust tracking stacks detector re-identification on top of the short-term tracker: when the tracker loses the target, a search region around the last known position is re-detected, and appearance embeddings re-associate the new detection with the previous identity. For known subjects β a specific vehicle, a branded athlete β pre-registered appearance embeddings make re-identification far more reliable than generic features.
from dataclasses import dataclass, field
import numpy as np
@dataclass
class Track:
tid: int
bbox: tuple
appearance: np.ndarray
missed: int = 0
class TrackerWithReID:
"""Byte-track-like association with appearance fallback."""
def __init__(self, iou_gate=0.2, appearance_gate=0.6):
self.iou_gate = iou_gate
self.appearance_gate = appearance_gate
self.tracks: list[Track] = []
self.next_id = 1
def update(self, detections):
"""detections: list of (bbox, appearance_vector)."""
assigned = set()
for tr in self.tracks:
best, best_iou = None, self.iou_gate
for i, (bbox, _) in enumerate(detections):
if i in assigned:
continue
iou = _iou(tr.bbox, bbox)
if iou > best_iou:
best, best_iou = i, iou
if best is not None:
bbox, app = detections[best]
tr.bbox, tr.appearance, tr.missed = bbox, app, 0
assigned.add(best)
else:
tr.missed += 1
for i, (bbox, app) in enumerate(detections):
if i in assigned:
continue
matched = False
for tr in self.tracks:
if tr.missed == 0:
continue
sim = float(np.dot(tr.appearance, app)
/ (np.linalg.norm(tr.appearance)
* np.linalg.norm(app) + 1e-8))
if sim >= self.appearance_gate:
tr.bbox, tr.appearance, tr.missed = bbox, app, 0
matched = True
break
if not matched:
self.tracks.append(Track(self.next_id, bbox, app))
self.next_id += 1
self.tracks = [t for t in self.tracks if t.missed <= 10]
def _iou(a, b):
x1, y1 = max(a[0], b[0]), max(a[1], b[1])
x2, y2 = min(a[2], b[2]), min(a[3], b[3])
inter = max(0, x2 - x1) * max(0, y2 - y1)
aa = (a[2]-a[0]) * (a[3]-a[1]); ab = (b[2]-b[0]) * (b[3]-b[1])
return inter / (aa + ab - inter + 1e-8)
rng = np.random.default_rng(8)
tracker = TrackerWithReID()
subj_app = rng.normal(size=8); subj_app /= np.linalg.norm(subj_app)
for step in range(6):
dets = []
if step not in (2, 3): # two-frame occlusion
x0 = 40 + step * 10
dets.append(((x0, 40, x0 + 20, 70), subj_app + rng.normal(0, 0.05, 8)))
if step == 4: # distractor appears
other = rng.normal(size=8); other /= np.linalg.norm(other)
dets.append(((200, 40, 220, 70), other))
tracker.update(dets)
ids = [t.tid for t in tracker.tracks if t.missed == 0]
print(f"step {step}: active track ids {ids}")
Putting automation in the operator's hands
The final layer is a supervisory interface. The operator picks the subject, the framing rule, and the shot template; the system executes with framing control and track recovery; the operator retains an override that immediately recenters or freezes the move. This division is what makes AI cinematography trustworthy on a set with a schedule: creative decisions stay with the person whose name is on the cut, and the automation handles the continuous servo work that no human flies perfectly for twelve straight seconds. Log every framing correction and track dropout β they are the raw material for tuning gains and re-identification thresholds between shoot days.
Common Mistakes
Driving tracking error to zero β dead-center framing always
Fix: Drive error to the offset the active compositional rule demands; center only for symmetry shots.
Equal yaw and pitch gains with no deadband
Fix: Set a deadband at detector noise scale and bias yaw gains lower; lateral overshoot is most visible on screen.
Hand-flying the camera move instead of generating a parametric path
Fix: Generate orbit and reveal paths from shot parameters; consistency across takes is what editors need.
Abandoning the track on a two-frame occlusion
Fix: Keep tracks alive briefly and re-associate on appearance similarity before minting a new ID.
Best Practices
- Pre-register appearance embeddings for known subjects before the shoot
- Shoot the same template twice with the editor's likely cut points in mind β coverage beats one perfect long take
- Log framing errors and correction magnitudes per shot for post-day tuning
- Keep a physical remote override wired and tested; automation on a set answers to the person paying for the light
Key Takeaways
- Cinematic framing is expressible as numeric targets: thirds, lead room, headroom, horizon
- Separate yaw and pitch gains with a tuned deadband to avoid gimbal jitter and visible overshoot
- Shot templates turn creative requests into repeatable, deconflicted parametric paths
- Track recovery through appearance re-identification is what keeps a twelve-second move usable in the cut
- The operator keeps override authority; the automation does the continuous servo work nobody holds perfectly by hand