@blueharford/scrypted-spatial-awareness 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -10
- package/dist/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.map +1 -1
- package/dist/plugin.zip +0 -0
- package/out/main.nodejs.js +2585 -60
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/core/tracking-engine.ts +963 -10
- package/src/main.ts +492 -19
- package/src/models/training.ts +300 -0
- package/src/ui/editor-html.ts +256 -0
- package/src/ui/training-html.ts +1007 -0
package/README.md
CHANGED
|
@@ -44,20 +44,28 @@ This plugin **tracks objects across your entire camera system**, understanding t
|
|
|
44
44
|
|
|
45
45
|
## Features
|
|
46
46
|
|
|
47
|
+
### Core Tracking
|
|
47
48
|
- **Cross-Camera Tracking**: Correlate objects (people, vehicles, animals) as they move between cameras
|
|
48
49
|
- **Journey History**: Complete path history for each tracked object across your property
|
|
49
50
|
- **Entry/Exit Detection**: Know when objects enter or leave your property
|
|
50
51
|
- **Movement Alerts**: Get notified when objects move between camera zones
|
|
51
|
-
- **LLM-Enhanced Descriptions**: Rich, contextual alerts like "Man in red shirt walking from garage towards front door" (requires LLM plugin)
|
|
52
|
-
- **Visual Floor Plan Editor**: Configure camera topology with an intuitive visual editor
|
|
53
|
-
- **MQTT Integration**: Export tracking data to Home Assistant for automations
|
|
54
|
-
- **REST API**: Query tracked objects and journeys programmatically
|
|
55
52
|
- **Smart Cooldowns**: Prevent alert spam with per-object cooldowns
|
|
56
53
|
- **Loitering Threshold**: Only alert after objects are visible for a configurable duration
|
|
57
54
|
- **Multiple Notifiers**: Send alerts to multiple notification services simultaneously
|
|
58
55
|
|
|
59
|
-
###
|
|
56
|
+
### LLM-Enhanced Descriptions
|
|
57
|
+
- **Rich Contextual Alerts**: Get alerts like "Man in red shirt walking from garage towards front door" (requires LLM plugin)
|
|
58
|
+
- **Configurable Rate Limiting**: Prevent LLM API overload with configurable debounce intervals
|
|
59
|
+
- **Automatic Fallback**: Falls back to basic notifications when LLM is slow or unavailable
|
|
60
|
+
- **Configurable Timeouts**: Set maximum wait time for LLM responses
|
|
61
|
+
|
|
62
|
+
### Visual Floor Plan Editor
|
|
63
|
+
- **Drag-and-Drop**: Place cameras, landmarks, and connections visually
|
|
64
|
+
- **Live Tracking Overlay**: See tracked objects move across your floor plan in real-time
|
|
65
|
+
- **Journey Visualization**: Click any tracked object to see their complete path drawn on the floor plan
|
|
66
|
+
- **Drawing Tools**: Add walls, rooms, and labels without needing an image
|
|
60
67
|
|
|
68
|
+
### Spatial Intelligence
|
|
61
69
|
- **Landmarks & Static Objects**: Define landmarks like mailbox, shed, driveway, deck to give the system spatial context
|
|
62
70
|
- **Camera Context**: Describe where each camera is mounted and what it can see for richer descriptions
|
|
63
71
|
- **Field of View Configuration**: Define camera FOV (simple angle or polygon) to understand coverage overlap
|
|
@@ -65,6 +73,25 @@ This plugin **tracks objects across your entire camera system**, understanding t
|
|
|
65
73
|
- **AI Landmark Suggestions**: System learns to identify landmarks from camera footage over time
|
|
66
74
|
- **Spatial Relationships**: Auto-inferred relationships between cameras and landmarks based on position
|
|
67
75
|
|
|
76
|
+
### Automatic Learning
|
|
77
|
+
- **Transit Time Learning**: Automatically adjusts connection transit times based on observed movement patterns
|
|
78
|
+
- **Connection Suggestions**: System suggests new camera connections based on observed object movements
|
|
79
|
+
- **Confidence Scoring**: Suggestions include confidence scores based on consistency of observations
|
|
80
|
+
- **One-Click Approval**: Accept or reject suggestions directly from the topology editor
|
|
81
|
+
|
|
82
|
+
### Training Mode (NEW in v0.4.0)
|
|
83
|
+
- **Guided Walkthrough**: Walk your property and let the system learn your camera layout
|
|
84
|
+
- **Mobile-Optimized UI**: Designed for phone use while walking around
|
|
85
|
+
- **Auto Camera Detection**: System detects you automatically as you walk
|
|
86
|
+
- **Transit Time Recording**: Learns actual transit times between cameras
|
|
87
|
+
- **Overlap Detection**: Identifies where camera coverage overlaps
|
|
88
|
+
- **Landmark Marking**: Mark landmarks (mailbox, gate, etc.) as you encounter them
|
|
89
|
+
- **One-Click Setup**: Apply training results to generate your complete topology
|
|
90
|
+
|
|
91
|
+
### Integrations
|
|
92
|
+
- **MQTT Integration**: Export tracking data to Home Assistant for automations
|
|
93
|
+
- **REST API**: Query tracked objects and journeys programmatically
|
|
94
|
+
|
|
68
95
|
## Installation
|
|
69
96
|
|
|
70
97
|
### From NPM (Recommended)
|
|
@@ -78,7 +105,68 @@ npm install @blueharford/scrypted-spatial-awareness
|
|
|
78
105
|
3. Search for "@blueharford/scrypted-spatial-awareness"
|
|
79
106
|
4. Click Install
|
|
80
107
|
|
|
81
|
-
##
|
|
108
|
+
## Getting Started: Training Mode (NEW in v0.4.0)
|
|
109
|
+
|
|
110
|
+
The fastest way to set up Spatial Awareness is using **Training Mode** - a guided walkthrough where you physically walk around your property while the system learns your camera layout.
|
|
111
|
+
|
|
112
|
+
### Why Training Mode?
|
|
113
|
+
|
|
114
|
+
Instead of manually drawing connections and guessing transit times, simply:
|
|
115
|
+
1. Start training on your phone
|
|
116
|
+
2. Walk between cameras
|
|
117
|
+
3. The system automatically learns:
|
|
118
|
+
- Which cameras can see you
|
|
119
|
+
- How long it takes to walk between cameras
|
|
120
|
+
- Where cameras overlap
|
|
121
|
+
- Your property's layout
|
|
122
|
+
|
|
123
|
+
### Quick Start
|
|
124
|
+
|
|
125
|
+
1. **Open Training Mode**
|
|
126
|
+
- Navigate to: `/endpoint/@blueharford/scrypted-spatial-awareness/ui/training`
|
|
127
|
+
- Or scan the QR code in the plugin settings (mobile-optimized)
|
|
128
|
+
|
|
129
|
+
2. **Start Training**
|
|
130
|
+
- Tap "Start Training"
|
|
131
|
+
- The system begins listening for person detections
|
|
132
|
+
|
|
133
|
+
3. **Walk Your Property**
|
|
134
|
+
- Walk to each camera on your property
|
|
135
|
+
- The system detects you automatically and records:
|
|
136
|
+
- Camera positions
|
|
137
|
+
- Transit times between cameras
|
|
138
|
+
- Camera overlaps (when both cameras see you)
|
|
139
|
+
|
|
140
|
+
4. **Mark Landmarks** (Optional)
|
|
141
|
+
- Tap the "Mark" tab to add landmarks as you encounter them
|
|
142
|
+
- Select type (mailbox, gate, shed, etc.) and name
|
|
143
|
+
- Landmarks are associated with the current camera
|
|
144
|
+
|
|
145
|
+
5. **End Training**
|
|
146
|
+
- When finished, tap "End Training"
|
|
147
|
+
- Review the statistics: cameras visited, transits recorded, landmarks marked
|
|
148
|
+
|
|
149
|
+
6. **Apply Results**
|
|
150
|
+
- Tap "Apply Results" to generate your topology
|
|
151
|
+
- The system creates camera connections with learned transit times
|
|
152
|
+
- Open the Topology Editor to fine-tune if needed
|
|
153
|
+
|
|
154
|
+
### Training Tips
|
|
155
|
+
|
|
156
|
+
- **Walk naturally** - Don't rush between cameras, walk at your normal pace
|
|
157
|
+
- **Hit every camera** - Try to be detected by each camera at least once
|
|
158
|
+
- **Create multiple transits** - Walk back and forth between cameras to improve accuracy
|
|
159
|
+
- **Mark key landmarks** - Mailbox, gates, driveway end, etc. help with contextual alerts
|
|
160
|
+
- **Re-train anytime** - Run training again to improve accuracy or add new cameras
|
|
161
|
+
|
|
162
|
+
### Mobile Access
|
|
163
|
+
|
|
164
|
+
Training Mode is designed to be used on your phone while walking. Access via:
|
|
165
|
+
```
|
|
166
|
+
https://[your-scrypted-server]/endpoint/@blueharford/scrypted-spatial-awareness/ui/training
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Setup (Manual)
|
|
82
170
|
|
|
83
171
|
1. **Configure Topology**:
|
|
84
172
|
- Open the plugin settings
|
|
@@ -97,6 +185,7 @@ npm install @blueharford/scrypted-spatial-awareness
|
|
|
97
185
|
3. **Optional - Enable LLM Descriptions**:
|
|
98
186
|
- Install an LLM plugin (OpenAI, Ollama, etc.)
|
|
99
187
|
- Enable "Use LLM for Rich Descriptions" in settings
|
|
188
|
+
- Configure rate limiting and fallback options
|
|
100
189
|
- Get alerts like "Woman with stroller" instead of just "Person"
|
|
101
190
|
|
|
102
191
|
4. **Optional - Enable MQTT**:
|
|
@@ -104,6 +193,11 @@ npm install @blueharford/scrypted-spatial-awareness
|
|
|
104
193
|
- Configure broker URL and credentials
|
|
105
194
|
- Use in Home Assistant automations
|
|
106
195
|
|
|
196
|
+
5. **Optional - Enable Learning Features**:
|
|
197
|
+
- Enable "Learn Transit Times" to auto-adjust connection timing
|
|
198
|
+
- Enable "Suggest Camera Connections" to discover new paths
|
|
199
|
+
- Enable "Learn Landmarks from AI" for automatic landmark discovery
|
|
200
|
+
|
|
107
201
|
## How It Works
|
|
108
202
|
|
|
109
203
|
The plugin listens to object detection events from all configured cameras. When an object (person, car, animal, package) is detected:
|
|
@@ -126,10 +220,12 @@ To prevent alert spam and reduce noise:
|
|
|
126
220
|
### LLM Integration
|
|
127
221
|
|
|
128
222
|
When an LLM plugin is installed and enabled, the plugin will:
|
|
129
|
-
1.
|
|
130
|
-
2.
|
|
131
|
-
3.
|
|
132
|
-
4.
|
|
223
|
+
1. Check rate limiting (configurable, default: 10 second minimum between calls)
|
|
224
|
+
2. Capture a snapshot from the camera
|
|
225
|
+
3. Send it to the LLM with context about the movement
|
|
226
|
+
4. Apply timeout (configurable, default: 3 seconds) with automatic fallback
|
|
227
|
+
5. Get a rich description like "Man in blue jacket" or "Black pickup truck"
|
|
228
|
+
6. Include this in the notification
|
|
133
229
|
|
|
134
230
|
This transforms generic alerts into contextual, actionable information.
|
|
135
231
|
|
|
@@ -144,7 +240,18 @@ This transforms generic alerts into contextual, actionable information.
|
|
|
144
240
|
| Visual Matching | ON | Use visual embeddings for correlation |
|
|
145
241
|
| Loitering Threshold | 3s | Object must be visible this long before alerting |
|
|
146
242
|
| Per-Object Cooldown | 30s | Minimum time between alerts for same object |
|
|
243
|
+
|
|
244
|
+
### AI & Spatial Reasoning Settings (NEW in v0.3.0)
|
|
245
|
+
| Setting | Default | Description |
|
|
246
|
+
|---------|---------|-------------|
|
|
147
247
|
| LLM Descriptions | ON | Use LLM plugin for rich descriptions |
|
|
248
|
+
| LLM Rate Limit | 10s | Minimum time between LLM API calls |
|
|
249
|
+
| Fallback to Basic | ON | Use basic notifications when LLM unavailable |
|
|
250
|
+
| LLM Timeout | 3s | Maximum time to wait for LLM response |
|
|
251
|
+
| Learn Transit Times | ON | Auto-adjust transit times from observations |
|
|
252
|
+
| Suggest Connections | ON | Suggest new camera connections |
|
|
253
|
+
| Learn Landmarks | ON | Allow AI to suggest landmarks |
|
|
254
|
+
| Landmark Confidence | 0.7 | Minimum confidence for landmark suggestions |
|
|
148
255
|
|
|
149
256
|
### Alert Types
|
|
150
257
|
| Alert | Description | Default |
|
|
@@ -170,6 +277,7 @@ The plugin exposes a REST API via Scrypted's HTTP handler:
|
|
|
170
277
|
|----------|--------|-------------|
|
|
171
278
|
| `/api/tracked-objects` | GET | List all tracked objects |
|
|
172
279
|
| `/api/journey/{id}` | GET | Get journey for specific object |
|
|
280
|
+
| `/api/journey-path/{id}` | GET | Get journey path with positions for visualization |
|
|
173
281
|
| `/api/topology` | GET | Get camera topology configuration |
|
|
174
282
|
| `/api/topology` | PUT | Update camera topology |
|
|
175
283
|
| `/api/alerts` | GET | Get recent alerts |
|
|
@@ -178,6 +286,11 @@ The plugin exposes a REST API via Scrypted's HTTP handler:
|
|
|
178
286
|
| `/api/floor-plan` | GET/POST | Get or upload floor plan image |
|
|
179
287
|
| `/ui/editor` | GET | Visual topology editor |
|
|
180
288
|
|
|
289
|
+
### Live Tracking Endpoints (NEW in v0.3.0)
|
|
290
|
+
| Endpoint | Method | Description |
|
|
291
|
+
|----------|--------|-------------|
|
|
292
|
+
| `/api/live-tracking` | GET | Get current state of all tracked objects |
|
|
293
|
+
|
|
181
294
|
### Landmark & Spatial Reasoning Endpoints
|
|
182
295
|
| Endpoint | Method | Description |
|
|
183
296
|
|----------|--------|-------------|
|
|
@@ -190,6 +303,25 @@ The plugin exposes a REST API via Scrypted's HTTP handler:
|
|
|
190
303
|
| `/api/landmark-templates` | GET | Get landmark templates for quick setup |
|
|
191
304
|
| `/api/infer-relationships` | GET | Get auto-inferred spatial relationships |
|
|
192
305
|
|
|
306
|
+
### Connection Suggestion Endpoints
|
|
307
|
+
| Endpoint | Method | Description |
|
|
308
|
+
|----------|--------|-------------|
|
|
309
|
+
| `/api/connection-suggestions` | GET | Get suggested camera connections |
|
|
310
|
+
| `/api/connection-suggestions/{id}/accept` | POST | Accept a connection suggestion |
|
|
311
|
+
| `/api/connection-suggestions/{id}/reject` | POST | Reject a connection suggestion |
|
|
312
|
+
|
|
313
|
+
### Training Mode Endpoints (NEW in v0.4.0)
|
|
314
|
+
| Endpoint | Method | Description |
|
|
315
|
+
|----------|--------|-------------|
|
|
316
|
+
| `/api/training/start` | POST | Start a new training session |
|
|
317
|
+
| `/api/training/pause` | POST | Pause the current training session |
|
|
318
|
+
| `/api/training/resume` | POST | Resume a paused training session |
|
|
319
|
+
| `/api/training/end` | POST | End the training session and get results |
|
|
320
|
+
| `/api/training/status` | GET | Get current training status and stats |
|
|
321
|
+
| `/api/training/landmark` | POST | Mark a landmark during training |
|
|
322
|
+
| `/api/training/apply` | POST | Apply training results to topology |
|
|
323
|
+
| `/ui/training` | GET | Mobile-optimized training UI |
|
|
324
|
+
|
|
193
325
|
## MQTT Topics
|
|
194
326
|
|
|
195
327
|
When MQTT is enabled, the plugin publishes to:
|
|
@@ -236,6 +368,39 @@ Without LLM:
|
|
|
236
368
|
- "Car moving from Street towards Driveway"
|
|
237
369
|
- "Dog moving from Back Yard towards Side Gate"
|
|
238
370
|
|
|
371
|
+
## Changelog
|
|
372
|
+
|
|
373
|
+
### v0.4.0
|
|
374
|
+
- **Training Mode**: Guided walkthrough to train the system by walking your property
|
|
375
|
+
- **Mobile-Optimized Training UI**: Phone-friendly interface for training while walking
|
|
376
|
+
- **Auto Camera Detection**: System automatically detects you as you walk between cameras
|
|
377
|
+
- **Transit Time Learning**: Records actual transit times during training
|
|
378
|
+
- **Camera Overlap Detection**: Identifies where multiple cameras see the same area
|
|
379
|
+
- **Landmark Marking**: Mark landmarks (mailbox, gate, etc.) during training sessions
|
|
380
|
+
- **One-Click Topology Generation**: Apply training results to create complete topology
|
|
381
|
+
|
|
382
|
+
### v0.3.0
|
|
383
|
+
- **Live Tracking Overlay**: View tracked objects in real-time on the floor plan
|
|
384
|
+
- **Journey Visualization**: Click any tracked object to see their complete path
|
|
385
|
+
- **Transit Time Learning**: Automatically adjusts connection times based on observations
|
|
386
|
+
- **Connection Suggestions**: System suggests new camera connections
|
|
387
|
+
- **LLM Rate Limiting**: Configurable debounce intervals to prevent API overload
|
|
388
|
+
- **LLM Fallback**: Automatic fallback to basic notifications when LLM is slow
|
|
389
|
+
- **LLM Timeout**: Configurable timeout with automatic fallback
|
|
390
|
+
|
|
391
|
+
### v0.2.0
|
|
392
|
+
- **Landmark System**: Add landmarks for spatial context
|
|
393
|
+
- **RAG Reasoning**: Context-aware movement descriptions
|
|
394
|
+
- **AI Learning**: Automatic landmark suggestions
|
|
395
|
+
- **Camera Context**: Rich camera descriptions for better alerts
|
|
396
|
+
|
|
397
|
+
### v0.1.0
|
|
398
|
+
- Initial release with cross-camera tracking
|
|
399
|
+
- Entry/exit detection
|
|
400
|
+
- Movement alerts
|
|
401
|
+
- MQTT integration
|
|
402
|
+
- Visual topology editor
|
|
403
|
+
|
|
239
404
|
## Requirements
|
|
240
405
|
|
|
241
406
|
- Scrypted with NVR plugin
|