Gesture/DTW Recognition Enginev2.0.0
👋
Signal · Developer

Gesture

Core gesture recognition engine using Dynamic Time Warping. Provides template management, matching, and confidence scoring against ESP32-S3 CSI motion frames.

versionv2.0.0
size16 KB
difficultyEasy
hardwareESP32-S3
inputCSI motion
eventsgesture_match
Easy Developer Signal
Templates
6
5 enabled
Matches / hr
142
rolling 60 min
Avg confidence
0.87
threshold 0.65
DTW cost (avg)
0.41
lower is closer
Description
What this cog does

The Gesture cog runs a Dynamic Time Warping (DTW) matcher over a sliding window of CSI amplitude frames from the ESP32-S3. Each enabled template is scored independently; the best score under the threshold emits a gesture_match event with the matched template_id and a normalised confidence in [0, 1].

Templates are loaded at boot from flash and may be added, retrained, or disabled at runtime. The matcher is gated by a configurable activation window and Sakoe-Chiba band to keep latency under one frame at 50 Hz.

Events emitted
Subscribe via the cog bus
1 topic
gesture_match event
confidence f32 ∈ [0,1]
template_id str, e.g. "wave_left"
Hardware
ESP32-S3 CSI motion 50 Hz
DTW match trail
Last 60 seconds of best-template confidence (live)
Confidence Threshold DTW cost
Gesture templates
Stored in flash · loaded at boot
Per-template DTW similarity
Distance to live signal · lower = closer match
Match distribution
Share of matches per template (session)
Live recognition
Synthetic CSI feed · click Start to begin emitting gesture_match events
CSI subcarrier A CSI subcarrier B Motion envelope
Confidence (live)
Best-template score, last 60 s
Confidence Threshold
gesture_match feed
0 events
Confidence vs duration
0 events · hover a dot for details
Match rate
Bucketed live · 0 matches
matches / bucket rolling mean
Activity heatmap
Match count · day-of-week × hour-of-day (last 7 days)
low
high max matches
Source
cognitum-one/cogs/src/cogs/gesture
gesture/
├── manifest.toml          # name, version, deps, events
├── cog.py                 # entrypoint + event loop
├── dtw.py                 # Sakoe-Chiba banded DTW
├── templates.py           # load / save / enable / score
├── templates/
│   ├── wave_left.bin
│   ├── wave_right.bin
│   ├── circle_cw.bin
│   ├── circle_ccw.bin
│   ├── push.bin
│   └── tap.bin
└── tests/
    ├── test_dtw.py
    └── test_templates.py
manifest.toml
Cog metadata
[cog]
name        = "gesture"
version     = "2.0.0"
description = "Core DTW gesture recognition engine with template management"
author      = "developer"
size_kb     = 16
difficulty  = "easy"
category    = "signal"

[hardware]
target = "esp32-s3"

[inputs]
csi_motion = { rate_hz = 50, channels = 2 }

[[events]]
name   = "gesture_match"
fields = ["confidence", "template_id"]

[config]
threshold       = 0.65
window_ms       = 1200
smoothing       = 0.35
band_width      = 8
max_templates   = 12
Runtime configuration
Applied to the matcher on save · persisted to flash
Match threshold Min confidence to emit gesture_match · 0.50–0.95
0.65
DTW window (ms) Sliding window over CSI frames · 400–2400
1200
Smoothing α EMA factor on motion envelope · 0.10–0.80
0.35
Sakoe-Chiba band Warping band width in frames · 2–16
8
Auto-suppress repeats Reject same template within N ms
350 ms
Emit on confidence change Re-fire if best template confidence shifts > 0.1
Train mode Capture new templates over the cog bus