fix(cv): add per-direction crossing cooldown to suppress track-churn double-counts

When a blob briefly drops below CV_MIN_BLOB_PX, its track is killed and respawns,
causing the same person to generate multiple counts per visit (~50/min observed
in field). Add a per-direction cooldown (default 5 frames ≈ 0.8s @ 5 fps) that
drops subsequent entries (or exits) within the window of the last counted one.
Entry and exit cooldowns are tracked independently.

Fixed at compile time for now; exposing as a server-push tunable is deferred
until the server-push-config branch lands. See docs/server-prompt-crossing-
cooldown.md for the server-side coordination notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 06:33:11 -07:00
parent 9d5b588231
commit 62931e26ff
6 changed files with 150 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ pio run -t upload --upload-port /dev/ttyUSB0
| Module | Behavior |
|--------|----------|
| CV pipeline | 5 fps, 96×96 grayscale, blob tracking, line-crossing count |
| CV pipeline | 5 fps, 96×96 grayscale, blob tracking, line-crossing count with per-direction cooldown |
| BLE scanner | Continuous passive scan; deinits during hourly upload to free heap |
| Reporter | Hourly HMAC-signed POST; 60s boot report for fast connectivity check |
| Provisioning | Captive portal AP on first boot for WiFi setup |
@@ -32,6 +32,17 @@ pio run -t upload --upload-port /dev/ttyUSB0
- **First report**: 60 seconds after NTP sync (connectivity check)
- **Subsequent reports**: every 3600 seconds
### Crossing cooldown
To suppress double-counts from track churn (a blob briefly dropping below the
minimum-blob-pixel threshold, causing the tracker to kill and respawn a track
that then re-crosses the line), each direction enforces a cooldown window
between counted crossings. Default: `CV_CROSSING_COOLDOWN_FRAMES = 5`, which
suppresses any second crossing in the same direction whose frame gap is `< 5`
— ≈0.8s at 5 fps. Entries and exits maintain separate cooldowns, so a real entry
immediately followed by a real exit still counts both. See
`firmware/lib/cv/cv.h`.
## Operator Setup
### 1. Flash firmware