Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 4 min read

Putting a vision loop on a $40 TV box: thermal, doze, and what the datasheet omits

We put a camera-based monitor inside a TV box that someone's parents already own. The box plays television, sits in a plastic shell at the back of a cabinet, and is expected to keep watching a room for years without anyo

We put a camera-based monitor inside a TV box that someone's parents already own. The box plays television, sits in a plastic shell at the back of a cabinet, and is expected to keep watching a room for years without anyone touching it.

The interesting engineering is not the model. It is everything the datasheet does not tell you about running a perception loop on hardware you do not control.

The hardware is a TV box, not an edge accelerator

rk3528, four A53 cores, a vendor BSP whose NPU story begins and ends at "there is a driver." We never got a usable delegate out of it that survived a week of uptime, so the loop is CPU-only and designed backwards from that.

Three decisions follow immediately:

  • Downscale before you think about accuracy. Frames arrive at 1080p and get resized to 320Γ—320. At that size a person is 40 pixels tall and a room-scale change is still obvious, but the per-frame cost drops by an order of magnitude.
  • Gate on motion, then classify. A cheap frame-difference pass runs on every sampled frame; the heavier pass only runs when the difference crosses a threshold. In a living room that is maybe 3% of frames. Average load is what matters on a passively cooled box, not peak.
  • Sample at 6–8 fps, not 30. Nothing we care about happens in 33 milliseconds. Sampling slower also means the encoder stays available for whatever the TV is actually playing.

Thermal budget is a duty cycle, not a frame rate

The first version ran inference continuously and the box throttled within twenty minutes. Sustained throughput fell below the burst number we had benchmarked, and the case got hot enough that we would not have shipped it to a stranger's living room.

The fix was to budget a duty cycle β€” a hard ceiling on milliseconds of compute per minute, enforced by the scheduler rather than hoped for β€” and to treat thermal headroom as a resource that inference borrows and must return. Peak FPS is a vanity metric here. The number that predicts whether a device survives a summer is sustained compute per hour.

Android will stop your service, and the vendor will help

A long-running background service on an Android TV build is a negotiation, not a guarantee. Two things broke us repeatedly:

  1. Doze and idle reclaim. A foreground service with a notification is the documented answer, and it works until a vendor "cleaner" utility decides your process is junk and kills it on a schedule. We now run a supervisor that restarts the worker and counts restarts as a health metric. If restarts spike, we report that upward instead of silently recovering forever.
  2. Wall clock is a liar. Cheap boxes have no RTC battery. After a power cut the device wakes up believing it is 1970, then jumps forward when NTP lands. Any event ordering that trusts wall clock produces a timeline that reorders itself after every outage. Events carry a monotonic timestamp for ordering and a reconciled wall time for display, and we never sort by the second one.

The network is the least reliable component, so it must be optional

2.4 GHz in a concrete apartment with a microwave and four neighbours is not a transport you block on. Every event is written to local storage first and flushed opportunistically. If the uplink is down for six hours, inference does not care; the queue drains later and the timeline is still correct because ordering never depended on arrival.

This is also why the whole design keeps working when the internet does not: the perception loop, the storage, and the local dashboard are one unit. The cloud, when it exists, is a convenience for people who are not in the room.

Privacy as an architectural constraint, not a policy

The camera stream never leaves the house. What leaves is a small event summary β€” a timestamp, a category, a confidence, a thumbnail-free status line. This is a stronger promise than an encryption claim because it is structural: there is no code path that uploads frames, so there is no configuration that can turn one on.

It also changes the failure mode. When something is wrong, the system degrades toward saying less, not toward watching more. That is the direction you want a device in a bedroom to fail in.

Updates must be survivable by someone who cannot debug them

The device is in a home where nobody will plug in a keyboard. An update that fails must leave a working device, so: signed payloads, a rollback slot, and a rule that a failed boot after update reverts instead of retrying forever. We also refuse to ship an update that changes the storage format without a migration that can run on 2 GB of RAM.

What we would tell someone starting this today

  • Design for sustained load. Burst benchmarks on passively cooled ARM are fiction.
  • Put monotonic time in your event schema on day one. Retrofitting it is a data migration you cannot do.
  • Write events locally before you try to send them. The network is the flakiest dependency and the easiest to make optional.
  • Count your service restarts and surface them. Silent self-healing hides a device that is slowly dying.
  • Decide what never leaves the device, and enforce it in code structure rather than in a settings page.

The model was the easy part. The hard part was making a $40 television box behave like an appliance that a family can forget about β€” and that is the part we ended up spending the year on.

This is the design we shipped in AnNest: a TV box plus a camera that runs entirely on-device, built for people whose parents live alone in another country. Details at annest.cn. No frames are uploaded, at any tier.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.