Full implementation of Project AETHER — Contrastive CSI Embedding Model. ## Phases Delivered 1. ProjectionHead (64→128→128) + L2 normalization 2. CsiAugmenter (5 physically-motivated augmentations) 3. InfoNCE contrastive loss + SimCLR pretraining 4. FingerprintIndex (4 index types: env, activity, temporal, person) 5. RVF SEG_EMBED (0x0C) + CLI integration 6. Cross-modal alignment (PoseEncoder + InfoNCE) 7. Deep RuVector: MicroLoRA, EWC++, drift detection, hard-negative mining, SEG_LORA ## Stats - 276 tests passing (191 lib + 51 bin + 16 rvf + 18 vitals) - 3,342 additions across 8 files - Zero unsafe/unwrap/panic/todo stubs - ~55KB INT8 model for ESP32 edge deployment Also fixes deprecated GitHub Actions (v3→v4) and adds feat/* branch CI triggers. Closes #50
129 lines
4.4 KiB
Markdown
129 lines
4.4 KiB
Markdown
# wifi-densepose-wasm
|
|
|
|
[](https://crates.io/crates/wifi-densepose-wasm)
|
|
[](https://docs.rs/wifi-densepose-wasm)
|
|
[](LICENSE)
|
|
|
|
WebAssembly bindings for running WiFi-DensePose directly in the browser.
|
|
|
|
## Overview
|
|
|
|
`wifi-densepose-wasm` compiles the WiFi-DensePose stack to `wasm32-unknown-unknown` and exposes a
|
|
JavaScript API via [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/). The primary export is
|
|
`MatDashboard` -- a fully client-side disaster response dashboard that manages scan zones, tracks
|
|
survivors, generates triage alerts, and renders to an HTML Canvas element.
|
|
|
|
The crate also provides utility functions (`init`, `getVersion`, `isMatEnabled`, `getTimestamp`) and
|
|
a logging bridge that routes Rust `log` output to the browser console.
|
|
|
|
## Features
|
|
|
|
- **MatDashboard** -- Create disaster events, add rectangular and circular scan zones, subscribe to
|
|
survivor-detected and alert-generated callbacks, and render zone/survivor overlays on Canvas.
|
|
- **Real-time callbacks** -- Register JavaScript closures for `onSurvivorDetected` and
|
|
`onAlertGenerated` events, called from the Rust event loop.
|
|
- **Canvas rendering** -- Draw zone boundaries, survivor markers (colour-coded by triage status),
|
|
and alert indicators directly to a `CanvasRenderingContext2d`.
|
|
- **WebSocket integration** -- Connect to a sensing server for live CSI data via `web-sys` WebSocket
|
|
bindings.
|
|
- **Panic hook** -- `console_error_panic_hook` provides human-readable stack traces in the browser
|
|
console on panic.
|
|
- **Optimised WASM** -- Release profile uses `-O4` wasm-opt with mutable globals for minimal binary
|
|
size.
|
|
|
|
### Feature flags
|
|
|
|
| Flag | Default | Description |
|
|
|----------------------------|---------|-------------|
|
|
| `console_error_panic_hook` | yes | Better panic messages in the browser console |
|
|
| `mat` | no | Enable MAT disaster detection dashboard |
|
|
|
|
## Quick Start
|
|
|
|
### Build
|
|
|
|
```bash
|
|
# Build with wasm-pack (recommended)
|
|
wasm-pack build --target web --features mat
|
|
|
|
# Or with cargo directly
|
|
cargo build --target wasm32-unknown-unknown --features mat
|
|
```
|
|
|
|
### JavaScript Usage
|
|
|
|
```javascript
|
|
import init, {
|
|
MatDashboard,
|
|
initLogging,
|
|
getVersion,
|
|
isMatEnabled,
|
|
} from './wifi_densepose_wasm.js';
|
|
|
|
async function main() {
|
|
await init();
|
|
initLogging('info');
|
|
|
|
console.log('Version:', getVersion());
|
|
console.log('MAT enabled:', isMatEnabled());
|
|
|
|
const dashboard = new MatDashboard();
|
|
|
|
// Create a disaster event
|
|
const eventId = dashboard.createEvent(
|
|
'earthquake', 37.7749, -122.4194, 'Bay Area Earthquake'
|
|
);
|
|
|
|
// Add scan zones
|
|
dashboard.addRectangleZone('Building A', 50, 50, 200, 150);
|
|
dashboard.addCircleZone('Search Area B', 400, 200, 80);
|
|
|
|
// Subscribe to real-time events
|
|
dashboard.onSurvivorDetected((survivor) => {
|
|
console.log('Survivor:', survivor);
|
|
});
|
|
|
|
dashboard.onAlertGenerated((alert) => {
|
|
console.log('Alert:', alert);
|
|
});
|
|
|
|
// Render to canvas
|
|
const canvas = document.getElementById('map');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
function render() {
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
dashboard.renderZones(ctx);
|
|
dashboard.renderSurvivors(ctx);
|
|
requestAnimationFrame(render);
|
|
}
|
|
render();
|
|
}
|
|
|
|
main();
|
|
```
|
|
|
|
## Exported API
|
|
|
|
| Export | Kind | Description |
|
|
|--------|------|-------------|
|
|
| `init()` | Function | Initialise the WASM module (called automatically via `wasm_bindgen(start)`) |
|
|
| `initLogging(level)` | Function | Set log level: `trace`, `debug`, `info`, `warn`, `error` |
|
|
| `getVersion()` | Function | Return the crate version string |
|
|
| `isMatEnabled()` | Function | Check whether the MAT feature is compiled in |
|
|
| `getTimestamp()` | Function | High-resolution timestamp via `Performance.now()` |
|
|
| `MatDashboard` | Class | Disaster response dashboard (zones, survivors, alerts, rendering) |
|
|
|
|
## Related Crates
|
|
|
|
| Crate | Role |
|
|
|-------|------|
|
|
| [`wifi-densepose-mat`](../wifi-densepose-mat) | MAT engine (linked when `mat` feature enabled) |
|
|
| [`wifi-densepose-core`](../wifi-densepose-core) | Shared types and traits |
|
|
| [`wifi-densepose-cli`](../wifi-densepose-cli) | Terminal-based MAT interface |
|
|
| [`wifi-densepose-sensing-server`](../wifi-densepose-sensing-server) | Backend sensing server for WebSocket data |
|
|
|
|
## License
|
|
|
|
MIT OR Apache-2.0
|