No footage saved
JPEG frames are decoded with cv2.imdecode in memory and discarded after inference. Only anonymized track labels and dwell durations hit SQLite.



TRK_014 classified MAN · serving MALE playlist (Male Apex Carbon)
CHILD > WOMAN > MAN > NONE).
A nicotine ad on a store screen is legal for the adult in front of it, and wrong for the child beside them. BATvision is a working full-stack prototype I built in June 2026: YOLOv8n tracks people in real time, a vision LLM classifies each new track once, and a server-side playlist engine keeps every public screen synchronized — switching campaigns by audience or locking down immediately when a minor walks in.
In the United States, nicotine is restricted to adults 21 and over by federal law since December 2019. Print and digital ads carry the mandatory warning block across the top, which is what the Warning Generator solves.
A screen above a retail counter still plays blindly to whoever is standing in line. BATvision closes that loop: it does not replace the warning; it stops adult product media from playing at all whenever a minor is present.
The prototype is a complete multi-screen application. An operator opens the Live HUD on an iPad or desktop browser; public displays run full-bleed on /display synchronized over WebSockets; marketers upload clips and toggle child-safety rules in /library; and /demographics logs detections, dwell time, and local context.
All screenshots below come directly from the compiled BATvision frontend backed by its June 2026 local test database in Winston-Salem, North Carolina.
TRK_015 resolves as CHILD, the Playlist Engine bypasses the 15 s ad lock and flips every screen to LOCKDOWN.
/ws/display (re-seeks if drift exceeds 1.5 s), plus procedural lockdown and ambient screens.
kids_playlist vs lockdown switch.Running a vision LLM on every video frame would stall playback and burn tokens. Instead, YOLOv8-nano runs locally on every frame inside an asyncio.Lock worker thread so WebSocket display sync never drops, while the vision LLM is called strictly once per new track_id.
Browser HUD or headless camera_agent.py streams 640 × 480 JPEG frames. A second client supersedes the first cleanly (WS_SUPERSEDED 4001).
model.track(persist=True) assigns persistent track IDs to people and secondary objects; unseen tracks flush after 3.5 s via track_reaper().
First crop (padded 15% for head-and-shoulders context) is sent once to gemini-2.5-flash or claude-haiku-4-5 and cached in vision.track_history.
Evaluates the last 1.5 s of presence (CHILD > WOMAN > MAN > NONE), honors a 15 s ad lock, and pushes state over /ws/display.
# backend/playlist.py — authoritative server-side PlaylistEngine
PRESENCE_WINDOW = 1.5 # seconds of recent presence considered "in front of screen"
DEMO_TO_PLAYLIST = {"MAN": "MALE", "WOMAN": "FEMALE", "CHILD": "KIDS", "NONE": "AMBIENT"}
# Priority: CHILD (safety -> lockdown or kids_playlist) > WOMAN > MAN > NONE
if "CHILD" in recent:
target = "LOCKDOWN" if child_policy == "lockdown" else "KIDS"
# child-triggered switches and manual overrides bypass the 15 s ad lock
Every resolved track and clip playback is written to a local SQLite WAL database (batvision.db) enriched by context.py with live Open-Meteo weather and local events. A dedicated docker-compose.pi.yml stack packages the backend, nginx frontend, and headless OpenCV /dev/video0 camera agent for a Raspberry Pi 4/5 kiosk.
A camera beside a retail screen requires strict boundaries. BATvision was built as an internal working prototype to prove that AI compliance can operate without storing personal video or identity records.
JPEG frames are decoded with cv2.imdecode in memory and discarded after inference. Only anonymized track labels and dwell durations hit SQLite.
Demographic transitions respect a configurable ad-lock interval (default 15 s) so clips finish cleanly, but a CHILD detection bypasses the lock immediately.
tests/test_engine.py verifies priority resolution, ad-lock hold vs child bypass, lockdown suspension, least-recently-played rotation, and impression counting.
All architecture specs and constants verified directly against the BATvision V1 source repository (June 2026). This is a functional R&D prototype, not a deployed store network.
Todd Ivon
BAT · Reynolds American · 2026 · working prototype