swarm / companies/sparrow/seed/overlay.py

raw file 969 bytes
#!/usr/bin/env python3
"""Overlay HUD (seed v1 — functional and ugly on purpose).

draw_overlay(frame, snap, info) -> frame with:
  - tracked points drawn as small dots with short motion tails
  - plain annotation (upgrade me: age colors, labels, tails from real map data)

June Park owns the aesthetics; Dmitri/Priya own what feeds it.
"""
import numpy as np
import cv2

TAIL = 5


def draw_overlay(frame, snap, info=None):
    pts = snap.get("image_pts") or []
    for i, p in enumerate(pts):
        x, y = p[0], p[1]
        cv_tail = 3
        if len(p) > 2 and p[2]:
            dx = float(np.clip(p[2] * 0.08, -9, 9))
            cv2.line(frame, (int(x - dx), int(y)), (int(x), int(y)), (140, 220, 140), 1)
        color = (120, 255, 120) if i % 3 else (255, 220, 90)
        cv2.circle(frame, (int(x), int(y)), 2, color, -1)
    if not pts:
        cv2.putText(frame, "no features", (12, 24), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (80, 80, 255), 1)
    return frame