|
| 1 | +--- |
| 2 | +name: depth-estimation |
| 3 | +description: "Real-time depth map privacy transforms using Depth Anything v2 (CoreML + PyTorch)" |
| 4 | +version: 1.2.0 |
| 5 | +category: privacy |
| 6 | + |
| 7 | +parameters: |
| 8 | + - name: model |
| 9 | + label: "Depth Model" |
| 10 | + type: select |
| 11 | + options: ["depth-anything-v2-small", "depth-anything-v2-base", "depth-anything-v2-large"] |
| 12 | + default: "depth-anything-v2-small" |
| 13 | + group: Model |
| 14 | + |
| 15 | + - name: variant |
| 16 | + label: "CoreML Variant (macOS)" |
| 17 | + type: select |
| 18 | + options: ["DepthAnythingV2SmallF16", "DepthAnythingV2SmallF16INT8", "DepthAnythingV2SmallF32"] |
| 19 | + default: "DepthAnythingV2SmallF16" |
| 20 | + group: Model |
| 21 | + |
| 22 | + - name: blend_mode |
| 23 | + label: "Display Mode" |
| 24 | + type: select |
| 25 | + options: ["depth_only", "overlay", "side_by_side"] |
| 26 | + default: "depth_only" |
| 27 | + group: Display |
| 28 | + |
| 29 | + - name: opacity |
| 30 | + label: "Overlay Opacity" |
| 31 | + type: number |
| 32 | + min: 0.0 |
| 33 | + max: 1.0 |
| 34 | + default: 0.5 |
| 35 | + group: Display |
| 36 | + |
| 37 | + - name: colormap |
| 38 | + label: "Depth Colormap" |
| 39 | + type: select |
| 40 | + options: ["inferno", "viridis", "plasma", "magma", "jet", "turbo", "hot", "cool"] |
| 41 | + default: "viridis" |
| 42 | + group: Display |
| 43 | + |
| 44 | + - name: device |
| 45 | + label: "Device" |
| 46 | + type: select |
| 47 | + options: ["auto", "cpu", "cuda", "mps"] |
| 48 | + default: "auto" |
| 49 | + group: Performance |
| 50 | + |
| 51 | +capabilities: |
| 52 | + live_transform: |
| 53 | + script: scripts/transform.py |
| 54 | + description: "Real-time depth estimation overlay on live feed" |
| 55 | +--- |
| 56 | + |
| 57 | +# Depth Estimation (Privacy) |
| 58 | + |
| 59 | +Real-time monocular depth estimation using Depth Anything v2. Transforms camera feeds with colorized depth maps — near objects appear warm, far objects appear cool. |
| 60 | + |
| 61 | +When used for **privacy mode**, the `depth_only` blend mode fully anonymizes the scene while preserving spatial layout and activity, enabling security monitoring without revealing identities. |
| 62 | + |
| 63 | +## Hardware Backends |
| 64 | + |
| 65 | +| Platform | Backend | Runtime | Model | |
| 66 | +|----------|---------|---------|-------| |
| 67 | +| **macOS** | CoreML | Apple Neural Engine | `apple/coreml-depth-anything-v2-small` (.mlpackage) | |
| 68 | +| Linux/Windows | PyTorch | CUDA / CPU | `depth-anything/Depth-Anything-V2-Small` (.pth) | |
| 69 | + |
| 70 | +On macOS, CoreML runs on the Neural Engine, leaving the GPU free for other tasks. The model is auto-downloaded from HuggingFace and stored at `~/.aegis-ai/models/feature-extraction/`. |
| 71 | + |
| 72 | +## What You Get |
| 73 | + |
| 74 | +- **Privacy anonymization** — depth-only mode hides all visual identity |
| 75 | +- **Depth overlays** on live camera feeds |
| 76 | +- **3D scene understanding** — spatial layout of the scene |
| 77 | +- **CoreML acceleration** — Neural Engine on Apple Silicon (3-5x faster than MPS) |
| 78 | + |
| 79 | +## Interface: TransformSkillBase |
| 80 | + |
| 81 | +This skill implements the `TransformSkillBase` interface. Any new privacy skill can be created by subclassing `TransformSkillBase` and implementing two methods: |
| 82 | + |
| 83 | +```python |
| 84 | +from transform_base import TransformSkillBase |
| 85 | + |
| 86 | +class MyPrivacySkill(TransformSkillBase): |
| 87 | + def load_model(self, config): |
| 88 | + # Load your model, return {"model": "...", "device": "..."} |
| 89 | + ... |
| 90 | + |
| 91 | + def transform_frame(self, image, metadata): |
| 92 | + # Transform BGR image, return BGR image |
| 93 | + ... |
| 94 | +``` |
| 95 | + |
| 96 | +## Protocol |
| 97 | + |
| 98 | +### Aegis → Skill (stdin) |
| 99 | +```jsonl |
| 100 | +{"event": "frame", "frame_id": "cam1_1710001", "camera_id": "front_door", "frame_path": "/tmp/frame.jpg", "timestamp": "..."} |
| 101 | +{"command": "config-update", "config": {"opacity": 0.8, "blend_mode": "overlay"}} |
| 102 | +{"command": "stop"} |
| 103 | +``` |
| 104 | + |
| 105 | +### Skill → Aegis (stdout) |
| 106 | +```jsonl |
| 107 | +{"event": "ready", "model": "coreml-DepthAnythingV2SmallF16", "device": "neural_engine", "backend": "coreml"} |
| 108 | +{"event": "transform", "frame_id": "cam1_1710001", "camera_id": "front_door", "transform_data": "<base64 JPEG>"} |
| 109 | +{"event": "perf_stats", "total_frames": 50, "timings_ms": {"transform": {"avg": 12.5, ...}}} |
| 110 | +``` |
| 111 | + |
| 112 | +## Setup |
| 113 | + |
| 114 | +```bash |
| 115 | +python3 -m venv .venv && source .venv/bin/activate |
| 116 | +pip install -r requirements.txt |
| 117 | +``` |
0 commit comments