@blueharford/scrypted-spatial-awareness 0.1.16 → 0.2.1
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 +152 -35
- 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 +1443 -57
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/core/spatial-reasoning.ts +700 -0
- package/src/core/tracking-engine.ts +137 -53
- package/src/main.ts +266 -3
- package/src/models/alert.ts +21 -1
- package/src/models/topology.ts +382 -9
- package/src/ui/editor-html.ts +328 -6
package/README.md
CHANGED
|
@@ -2,39 +2,107 @@
|
|
|
2
2
|
|
|
3
3
|
Cross-camera object tracking for Scrypted NVR with spatial awareness capabilities.
|
|
4
4
|
|
|
5
|
+
## Why This Plugin?
|
|
6
|
+
|
|
7
|
+
**Traditional camera notifications** tell you *what* was detected on *which* camera:
|
|
8
|
+
> "Person detected on Front Door camera"
|
|
9
|
+
|
|
10
|
+
**Spatial Awareness** tells you *where they came from* and *where they're going*:
|
|
11
|
+
> "Man in blue jacket walking from Garage towards Front Door"
|
|
12
|
+
|
|
13
|
+
This plugin **tracks objects across your entire camera system**, understanding that the person who got out of a car in your driveway is the same person now walking to your front door. Instead of getting 5 separate "person detected" alerts from 5 cameras, you get one coherent narrative of movement across your property.
|
|
14
|
+
|
|
15
|
+
### Key Differences from Normal Notifications
|
|
16
|
+
|
|
17
|
+
| Feature | Normal Notifications | Spatial Awareness |
|
|
18
|
+
|---------|---------------------|-------------------|
|
|
19
|
+
| **Scope** | Single camera | Entire property |
|
|
20
|
+
| **Identity** | New detection each camera | Same object tracked across cameras |
|
|
21
|
+
| **Context** | "Person on Camera X" | "Person moving from X towards Y" |
|
|
22
|
+
| **Alert Volume** | Alert per camera per detection | One alert per significant movement |
|
|
23
|
+
| **Intelligence** | Basic detection | Movement patterns, unusual paths, dwell time |
|
|
24
|
+
| **LLM Integration** | None | Rich descriptions like "Woman with dog" |
|
|
25
|
+
|
|
26
|
+
## Use Cases
|
|
27
|
+
|
|
28
|
+
### Home Security
|
|
29
|
+
- **Delivery Tracking**: "Person arrived via Driveway, walked to Front Door, left package, exited via Driveway" (2 minutes on property)
|
|
30
|
+
- **Suspicious Activity**: "Person entered via Back Fence, lingered 5 minutes near Garage, unusual path - did not use normal entry points"
|
|
31
|
+
- **Family Awareness**: Know when family members arrive home and their path through the property
|
|
32
|
+
|
|
33
|
+
### Vehicle Monitoring
|
|
34
|
+
- **Guest Arrivals**: "Black SUV entered via Street, parked in Driveway"
|
|
35
|
+
- **Unusual Vehicles**: "Unknown vehicle circling property - seen on Street Camera, Side Camera, Street Camera again"
|
|
36
|
+
|
|
37
|
+
### Pet & Animal Tracking
|
|
38
|
+
- **Pet Location**: Track your dog's movement through the yard
|
|
39
|
+
- **Wildlife Alerts**: "Deer moving from Back Yard towards Garden"
|
|
40
|
+
|
|
41
|
+
### Property Management
|
|
42
|
+
- **Worker Tracking**: Know when contractors arrive, where they go, when they leave
|
|
43
|
+
- **Occupancy Patterns**: Understand traffic flow through your property
|
|
44
|
+
|
|
5
45
|
## Features
|
|
6
46
|
|
|
7
47
|
- **Cross-Camera Tracking**: Correlate objects (people, vehicles, animals) as they move between cameras
|
|
8
48
|
- **Journey History**: Complete path history for each tracked object across your property
|
|
9
49
|
- **Entry/Exit Detection**: Know when objects enter or leave your property
|
|
50
|
+
- **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)
|
|
10
52
|
- **Visual Floor Plan Editor**: Configure camera topology with an intuitive visual editor
|
|
11
53
|
- **MQTT Integration**: Export tracking data to Home Assistant for automations
|
|
12
54
|
- **REST API**: Query tracked objects and journeys programmatically
|
|
13
|
-
- **Smart
|
|
55
|
+
- **Smart Cooldowns**: Prevent alert spam with per-object cooldowns
|
|
56
|
+
- **Loitering Threshold**: Only alert after objects are visible for a configurable duration
|
|
57
|
+
- **Multiple Notifiers**: Send alerts to multiple notification services simultaneously
|
|
58
|
+
|
|
59
|
+
### Advanced Spatial Awareness
|
|
60
|
+
|
|
61
|
+
- **Landmarks & Static Objects**: Define landmarks like mailbox, shed, driveway, deck to give the system spatial context
|
|
62
|
+
- **Camera Context**: Describe where each camera is mounted and what it can see for richer descriptions
|
|
63
|
+
- **Field of View Configuration**: Define camera FOV (simple angle or polygon) to understand coverage overlap
|
|
64
|
+
- **RAG-Powered Reasoning**: Uses Retrieval-Augmented Generation to understand property layout for intelligent descriptions
|
|
65
|
+
- **AI Landmark Suggestions**: System learns to identify landmarks from camera footage over time
|
|
66
|
+
- **Spatial Relationships**: Auto-inferred relationships between cameras and landmarks based on position
|
|
14
67
|
|
|
15
68
|
## Installation
|
|
16
69
|
|
|
70
|
+
### From NPM (Recommended)
|
|
71
|
+
```bash
|
|
72
|
+
npm install @blueharford/scrypted-spatial-awareness
|
|
73
|
+
```
|
|
74
|
+
|
|
17
75
|
### From Scrypted Plugin Repository
|
|
18
76
|
1. Open Scrypted Management Console
|
|
19
77
|
2. Go to Plugins
|
|
20
|
-
3. Search for "
|
|
78
|
+
3. Search for "@blueharford/scrypted-spatial-awareness"
|
|
21
79
|
4. Click Install
|
|
22
80
|
|
|
23
|
-
### From NPM
|
|
24
|
-
```bash
|
|
25
|
-
npm install @blueharford/scrypted-spatial-awareness
|
|
26
|
-
```
|
|
27
|
-
|
|
28
81
|
## Setup
|
|
29
82
|
|
|
30
|
-
1. **
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
- Upload a floor plan image
|
|
83
|
+
1. **Configure Topology**:
|
|
84
|
+
- Open the plugin settings
|
|
85
|
+
- Click "Open Topology Editor"
|
|
86
|
+
- Upload a floor plan image (or use the drawing tools to create one)
|
|
34
87
|
- Place cameras on the floor plan
|
|
88
|
+
- Mark entry/exit points
|
|
35
89
|
- Draw connections between cameras with expected transit times
|
|
36
|
-
|
|
37
|
-
|
|
90
|
+
|
|
91
|
+
2. **Configure Alerts**:
|
|
92
|
+
- Select one or more notifiers (Pushover, email, Home Assistant, etc.)
|
|
93
|
+
- Adjust loitering threshold (how long before alerting)
|
|
94
|
+
- Adjust per-object cooldown (prevent duplicate alerts)
|
|
95
|
+
- Enable/disable specific alert types
|
|
96
|
+
|
|
97
|
+
3. **Optional - Enable LLM Descriptions**:
|
|
98
|
+
- Install an LLM plugin (OpenAI, Ollama, etc.)
|
|
99
|
+
- Enable "Use LLM for Rich Descriptions" in settings
|
|
100
|
+
- Get alerts like "Woman with stroller" instead of just "Person"
|
|
101
|
+
|
|
102
|
+
4. **Optional - Enable MQTT**:
|
|
103
|
+
- Enable MQTT integration
|
|
104
|
+
- Configure broker URL and credentials
|
|
105
|
+
- Use in Home Assistant automations
|
|
38
106
|
|
|
39
107
|
## How It Works
|
|
40
108
|
|
|
@@ -48,10 +116,56 @@ The plugin listens to object detection events from all configured cameras. When
|
|
|
48
116
|
- **Class (10%)**: Is it the same type of object?
|
|
49
117
|
3. **New Object**: If no correlation is found, a new tracked object is created
|
|
50
118
|
|
|
119
|
+
### Loitering & Cooldown Logic
|
|
120
|
+
|
|
121
|
+
To prevent alert spam and reduce noise:
|
|
122
|
+
|
|
123
|
+
- **Loitering Threshold**: Object must be visible for X seconds before triggering any alerts (default: 3 seconds). This prevents alerts for someone briefly passing through frame.
|
|
124
|
+
- **Per-Object Cooldown**: After alerting for a specific tracked object, won't alert again for that same object for Y seconds (default: 30 seconds). This prevents "Person moving from A to B", "Person moving from B to C", "Person moving from C to D" spam.
|
|
125
|
+
|
|
126
|
+
### LLM Integration
|
|
127
|
+
|
|
128
|
+
When an LLM plugin is installed and enabled, the plugin will:
|
|
129
|
+
1. Capture a snapshot from the camera
|
|
130
|
+
2. Send it to the LLM with context about the movement
|
|
131
|
+
3. Get a rich description like "Man in blue jacket" or "Black pickup truck"
|
|
132
|
+
4. Include this in the notification
|
|
133
|
+
|
|
134
|
+
This transforms generic alerts into contextual, actionable information.
|
|
135
|
+
|
|
136
|
+
## Configuration Options
|
|
137
|
+
|
|
138
|
+
### Tracking Settings
|
|
139
|
+
| Setting | Default | Description |
|
|
140
|
+
|---------|---------|-------------|
|
|
141
|
+
| Correlation Window | 30s | Maximum time to wait for cross-camera correlation |
|
|
142
|
+
| Correlation Threshold | 0.6 | Minimum confidence (0-1) for automatic correlation |
|
|
143
|
+
| Lost Timeout | 300s | Time before marking an object as lost |
|
|
144
|
+
| Visual Matching | ON | Use visual embeddings for correlation |
|
|
145
|
+
| Loitering Threshold | 3s | Object must be visible this long before alerting |
|
|
146
|
+
| Per-Object Cooldown | 30s | Minimum time between alerts for same object |
|
|
147
|
+
| LLM Descriptions | ON | Use LLM plugin for rich descriptions |
|
|
148
|
+
|
|
149
|
+
### Alert Types
|
|
150
|
+
| Alert | Description | Default |
|
|
151
|
+
|-------|-------------|---------|
|
|
152
|
+
| Property Entry | Object entered via an entry point | Enabled |
|
|
153
|
+
| Property Exit | Object exited via an exit point | Enabled |
|
|
154
|
+
| Movement | Object moved between cameras | Enabled |
|
|
155
|
+
| Unusual Path | Object took an unexpected route | Enabled |
|
|
156
|
+
| Dwell Time | Object lingered >5 minutes | Enabled |
|
|
157
|
+
| Restricted Zone | Object entered a restricted zone | Enabled |
|
|
158
|
+
| Lost Tracking | Object disappeared without exiting | Disabled |
|
|
159
|
+
|
|
160
|
+
### Notification Settings
|
|
161
|
+
- **Notifiers**: Select multiple notification services to receive alerts
|
|
162
|
+
- **Thumbnails**: Automatically includes camera snapshot with notifications
|
|
163
|
+
|
|
51
164
|
## API Endpoints
|
|
52
165
|
|
|
53
166
|
The plugin exposes a REST API via Scrypted's HTTP handler:
|
|
54
167
|
|
|
168
|
+
### Core Endpoints
|
|
55
169
|
| Endpoint | Method | Description |
|
|
56
170
|
|----------|--------|-------------|
|
|
57
171
|
| `/api/tracked-objects` | GET | List all tracked objects |
|
|
@@ -59,9 +173,23 @@ The plugin exposes a REST API via Scrypted's HTTP handler:
|
|
|
59
173
|
| `/api/topology` | GET | Get camera topology configuration |
|
|
60
174
|
| `/api/topology` | PUT | Update camera topology |
|
|
61
175
|
| `/api/alerts` | GET | Get recent alerts |
|
|
176
|
+
| `/api/alert-rules` | GET/PUT | Get or update alert rules |
|
|
177
|
+
| `/api/cameras` | GET | List available cameras |
|
|
62
178
|
| `/api/floor-plan` | GET/POST | Get or upload floor plan image |
|
|
63
179
|
| `/ui/editor` | GET | Visual topology editor |
|
|
64
180
|
|
|
181
|
+
### Landmark & Spatial Reasoning Endpoints
|
|
182
|
+
| Endpoint | Method | Description |
|
|
183
|
+
|----------|--------|-------------|
|
|
184
|
+
| `/api/landmarks` | GET | List all configured landmarks |
|
|
185
|
+
| `/api/landmarks` | POST | Add a new landmark |
|
|
186
|
+
| `/api/landmarks/{id}` | GET/PUT/DELETE | Get, update, or delete a landmark |
|
|
187
|
+
| `/api/landmark-suggestions` | GET | Get AI-suggested landmarks |
|
|
188
|
+
| `/api/landmark-suggestions/{id}/accept` | POST | Accept an AI suggestion |
|
|
189
|
+
| `/api/landmark-suggestions/{id}/reject` | POST | Reject an AI suggestion |
|
|
190
|
+
| `/api/landmark-templates` | GET | Get landmark templates for quick setup |
|
|
191
|
+
| `/api/infer-relationships` | GET | Get auto-inferred spatial relationships |
|
|
192
|
+
|
|
65
193
|
## MQTT Topics
|
|
66
194
|
|
|
67
195
|
When MQTT is enabled, the plugin publishes to:
|
|
@@ -95,35 +223,24 @@ The plugin creates these virtual devices in Scrypted:
|
|
|
95
223
|
- **Types**: Entry, Exit, Dwell, Restricted
|
|
96
224
|
- **Use**: Create zone-specific automations and alerts
|
|
97
225
|
|
|
98
|
-
## Alert
|
|
226
|
+
## Example Alert Messages
|
|
99
227
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
| Dwell Time | Object lingered too long in an area |
|
|
106
|
-
| Restricted Zone | Object entered a restricted zone |
|
|
107
|
-
| Lost Tracking | Object disappeared without exiting |
|
|
108
|
-
|
|
109
|
-
## Configuration Options
|
|
110
|
-
|
|
111
|
-
### Tracking Settings
|
|
112
|
-
- **Correlation Window**: Maximum time (seconds) to wait for cross-camera correlation
|
|
113
|
-
- **Correlation Threshold**: Minimum confidence (0-1) for automatic correlation
|
|
114
|
-
- **Lost Timeout**: Time before marking an object as lost
|
|
115
|
-
- **Visual Matching**: Enable/disable visual embedding matching
|
|
228
|
+
With LLM enabled:
|
|
229
|
+
- "Man in blue jacket walking from Garage towards Front Door (5s transit)"
|
|
230
|
+
- "Black SUV driving from Street towards Driveway"
|
|
231
|
+
- "Woman with dog walking from Back Yard towards Side Gate"
|
|
232
|
+
- "Delivery person entered property via Driveway"
|
|
116
233
|
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
- **Base Topic**: Topic prefix for all messages
|
|
234
|
+
Without LLM:
|
|
235
|
+
- "Person moving from Garage towards Front Door (5s transit)"
|
|
236
|
+
- "Car moving from Street towards Driveway"
|
|
237
|
+
- "Dog moving from Back Yard towards Side Gate"
|
|
122
238
|
|
|
123
239
|
## Requirements
|
|
124
240
|
|
|
125
241
|
- Scrypted with NVR plugin
|
|
126
242
|
- Cameras with object detection enabled (via Scrypted NVR, OpenVINO, CoreML, ONNX, or TensorFlow Lite)
|
|
243
|
+
- Optional: LLM plugin for rich descriptions (OpenAI, Ollama, etc.)
|
|
127
244
|
- Optional: MQTT broker for Home Assistant integration
|
|
128
245
|
|
|
129
246
|
## Development
|