jetson/ · the edge box
zvision — the camera rig
A ring of cameras becomes one full-circle contact list. There is no camera config file: cameras are declared entirely on the command line, because their mounting bearings are a field calibration, not a code constant.
Modules
| Module | Role |
|---|---|
app.py | CLI runner; the broadcast + tracker loop |
rig.py | Camera mounts, --camera spec parsing, full-circle merge and overlap dedup, coverage-gap reporting |
capture.py | UvcCamera and ThermalCamera (cv2); reopens a camera that wedges in select() at cold boot |
detector.py | Detector protocol, FakeDetector, MotionDetector |
geometry.py | Pixel → bearing through a lens model, bbox → size, constant-bearing collision rule |
normalize.py | The array-free arithmetic — contrast stretch window, track-id assignment, re-baseline guard, camera-stall guard. Exists so the suite runs without numpy |
threat.py / threat_protocol.py | The DriverThreat record and the ZTHREAT wire format |
broadcaster.py | UDP sender — multicast and subnet broadcast |
fleet_bus.py | Group / port constants, mirrored from Kotlin |
tracker.py | DMX target selection, pan/tilt mapping, slew, idle sound show |
dmx.py | DMX transport — FakeDmxSink and OlaDmxSink |
dmxpark.py | Standalone universe-zeroing fail-safe, with its own entry point |
audio_bus.py | $ZAUD listener for the idle sound-reactive show |
recorder.py | Frame + weak-label dump for model training |
tracklog.py | NMEA breadcrumb CSV recorder, own service |
trackserve.py | Read-only HTTP server for those CSVs |
The pipeline
_mounts_from_args ─► build_rig ─► MultiDetector
│ per camera: detect() → to_global()
▼
merge_contacts (cross-camera overlap dedup)
│
┌────────────────┴────────────────┐
▼ ▼
format_frame ─► ThreatBroadcaster Tracker.update ─► DmxSink
(ZTHREAT, 10 Hz default) (pan/tilt/dimmer)
Declaring cameras
python3 -m zvision -v \
--camera thermal:/dev/v4l/by-path/thermal:az=0:fov=160:lens=fisheye:name=thermal \
--camera rgb:/dev/v4l/by-path/stbd-aft:az=120:fov=90:fovref=h:lens=pinhole:name=stbd-aft \
--camera rgb:/dev/v4l/by-path/port-aft:az=-120:fov=90:fovref=h:lens=pinhole:name=port-aft
az is the camera's bearing off the nose (+right), so az=180 faces
astern. On the box these live in ZVISION_ARGS in
/etc/default/zvision.
Verbose start-up prints each camera's covered arc and the blind sectors:
thermal: thermal /dev/v4l/by-path/thermal az=+0° fov=160°d equidistant -> covers -64°..+64°
stbd-aft: rgb /dev/v4l/by-path/stbd-aft az=+120° fov=90°h rectilinear -> covers +75°..+165°
port-aft: rgb /dev/v4l/by-path/port-aft az=-120° fov=90°h rectilinear -> covers -165°..-75°
blind: -74°..-64°, +65°..+75°, +166°..+195°
By-path names are shortened here; use the real /dev/v4l/by-path/ entries, which survive reboots. --fov-ref defaults to d, and the RGB lenses, quoted as widths, say fovref=h. The Lepton Ultra Wide's quoted
160° is the diagonal — argued from physics in HARDWARE.md
and since confirmed by measurement (a true 40.4° target reported at 42.5°; the horizontal
reading predicts 32.3°). Both sides of the vehicle now compute
±64° by default, and the tablet's
SurroundRing.COVERED_ARCS carries the matching arc.
Full detail →
install.sh writes ZVISION_ARGS=--source fake --hz 10. The service
deliberately fails to start if that file is missing, rather than broadcasting synthetic contacts
unattended.
Fusion
to_global rotates each camera's local bearing by its mount azimuth and namespaces
track ids as camera_index × 1000 + local_id (id 0 never
latches the tracker light).
merge_contacts ranks by collision, then size and drops any contact
within the dedup angle (--merge-deg, default 8°) of an
already-kept contact from a different camera — never within one camera, which
would erase two people standing together.
Lens models
These matter because bearings drive both the HUD and where a real spotlight points.
| Model | Projection | Use for |
|---|---|---|
rectilinear | r = tan θ | An ordinary lens, e.g. the RGB modules (pinhole in a spec) |
equidistant | r = θ | A fisheye — the default for the Lepton Ultra Wide (fisheye in a spec) |
equisolid | — | Other fisheye designs |
linear | — | Legacy |
Field tuning
The detection numbers cannot be got right on a bench — they depend on how high the camera
ends up mounted, how far away people actually walk, and how much contrast a body has against hot
ground at 2am. So they are all reachable from the command line: a flag sets a rig-wide default, and
the matching --camera spec key overrides one camera.
| Flag | Spec key | What it does | Reach for it when |
|---|---|---|---|
--min-area | minarea | Min blob area, fraction of frame | Dust / shimmer / shade-cloth make phantom contacts (raise) · people missed at range (lower) |
--match-dist | match | Track association distance | Ids churn as people walk (raise) · two passers swap ids (lower) |
--far-h / --near-h | farh / nearh | bbox height → the 0..1 range proxy | Expect to change these first — pure guesswork until real bodies stand at real distances |
--collision-az-rate | azrate | deg/s still counted as constant bearing | ! BRAKE ! too twitchy (lower) · missing real intercepts (raise) |
--collision-min-size | minsize | How near before collision can trip | Alarms firing on distant contacts (raise) |
--merge-deg | — | Cross-camera duplicate collapse | One person shows twice in an overlap (raise) · two close people merge (lower) |
| — | az | That camera's mount bearing | Measure against the vehicle nose — an error here rotates that camera's whole contact set and swings the tracker light onto the wrong person |
--fov-ref | fovref | Is the quoted FOV width or diagonal | Edge bearings consistently off |
--check before you commit a config
python3 -m zvision --check --min-area 0.008 \
--camera thermal:/dev/v4l/by-path/thermal:az=0:fov=160:lens=fisheye:name=thermal
Validates the whole configuration, prints the resolved rig and its blind arcs, and exits without opening a camera or touching the network.
--check before writing /etc/default/zvision
The unit is Restart=always, so an unvalidated typo becomes a crash loop —
miserable to unpick from a laptop in the dust.
Recording training data
python3 -m zvision --record /data/drive-01 --record-hz 1 \
--camera thermal:/dev/v4l/by-path/thermal:az=0:fov=160:fovref=d:lens=fisheye:name=thermal
Writes frames per camera plus an index.jsonl carrying the pixel boxes
the motion detector found — weak labels, so an annotator corrects rather than draws.
- 1 Hz default — consecutive 10 Hz frames are near-duplicates that waste disk and annotator attention.
- Small frames go to lossless PNG and large ones to JPEG. The split is by pixel count, not by camera kind, so the 160×120 thermal lands on PNG. (The threshold was originally 128×128, chosen for a sensor believed to be 120×120, which silently JPEG'd the thermal — and JPEG artefacts on a low-contrast 160×120 frame destroy real signal.)
- 20 GB cap by default, shared across all cameras, so a long night cannot fill the boot disk.
- Failures are reported once and never interrupt detection.
Footage can only be captured while the rig is on the vehicle; GPU time can be rented any evening — which is why the recorder exists before any model work. The training plan →
USB device identity
Today every camera is pinned by port
(/dev/v4l/by-path/…usb-0:2.3:1.0…). Measured 2026-08-09, what
identity is actually available:
| Device | Serial | Addressable by identity? |
|---|---|---|
| PureThermal | 000b0026-5103-3133-3332-3733… | Yes — a real per-unit UID |
| FTDI / DMX | BG03OCDS | Yes, and already is — olad patches it as 13-BG03OCDS-O-1, so the dongle survives a re-plug into any port |
| Arducam RGB | SN0001 | No — a firmware constant, identical on every unit of this model |
The az= binding. A camera spec ties a device to a bearing on the vehicle,
and the port is what makes that true. If identical cameras can move ports, a camera's entire
contact set silently rotates onto the wrong bearing — wrong threat bearings on the driver's
HUD, tracker light on the wrong person — and it fails silently: everything
opens, frames flow, nothing errors. For the ring, the port is not a limitation to route around; it
is the only identity the hardware offers.
Open follow-ups: move thermal and DMX to by-id (free robustness, no downside); name
the ports via udev (/dev/zodiac-cam-front etc.) so a mis-plug shows up as a
missing device rather than a working camera pointing the wrong way; add a startup identity
check that asserts every spec resolves to a distinct device. And label the cables — the
realistic failure is someone unplugging everything to fix something else. No code replaces that.
Converted fromjetson/README.md · ARCHITECTURE.md §6.1, §6.2 · jetson/DEPLOY.md §5, §8 · jetson/TRAINING.md §B2 · tasks/open.md