@blueharford/scrypted-spatial-awareness 0.6.5 → 0.6.6
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/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 +33 -14
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/main.ts +34 -15
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/out/main.nodejs.js
CHANGED
|
@@ -40311,34 +40311,53 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
|
|
|
40311
40311
|
// Convert direction to radians (0 = up/north, 90 = right/east)
|
|
40312
40312
|
const dirRad = (direction - 90) * Math.PI / 180;
|
|
40313
40313
|
const halfFov = (fovAngle / 2) * Math.PI / 180;
|
|
40314
|
-
// Use
|
|
40314
|
+
// Use landmark TYPE to determine distance - some things are inherently far away
|
|
40315
|
+
// regardless of where they appear in the camera frame
|
|
40316
|
+
const landmarkType = suggestion.landmark.type;
|
|
40317
|
+
const farTypes = ['neighbor', 'boundary', 'street']; // Always place at edge of FOV
|
|
40318
|
+
const isFarType = farTypes.includes(landmarkType || '');
|
|
40319
|
+
// Use bounding box if available for horizontal positioning
|
|
40315
40320
|
// boundingBox format: [x, y, width, height] normalized 0-1
|
|
40316
40321
|
const bbox = suggestion.landmark.boundingBox;
|
|
40317
40322
|
let angleOffset;
|
|
40318
40323
|
let distanceMultiplier;
|
|
40319
40324
|
if (bbox && bbox.length >= 2) {
|
|
40320
|
-
// Use bounding box
|
|
40325
|
+
// Use bounding box X for horizontal position in FOV
|
|
40321
40326
|
const bboxCenterX = bbox[0] + (bbox[2] || 0) / 2; // 0 = left edge, 1 = right edge
|
|
40322
|
-
const bboxCenterY = bbox[1] + (bbox[3] || 0) / 2; // 0 = top (far), 1 = bottom (close)
|
|
40323
40327
|
// Map X position to angle within FOV
|
|
40324
|
-
// bboxCenterX 0 → left side of FOV (-halfFov)
|
|
40325
|
-
// bboxCenterX 0.5 → center of FOV (0)
|
|
40326
|
-
// bboxCenterX 1 → right side of FOV (+halfFov)
|
|
40327
40328
|
angleOffset = (bboxCenterX - 0.5) * 2 * halfFov;
|
|
40328
|
-
//
|
|
40329
|
-
|
|
40330
|
-
|
|
40331
|
-
|
|
40332
|
-
|
|
40329
|
+
// For distance: use TYPE first, then bbox Y as hint
|
|
40330
|
+
if (isFarType) {
|
|
40331
|
+
// Neighbors, boundaries, streets are BEYOND the camera's normal range
|
|
40332
|
+
// Place at 150-200% of range to indicate they're distant background features
|
|
40333
|
+
distanceMultiplier = 1.5 + Math.random() * 0.5; // 150-200% of range
|
|
40334
|
+
this.console.log(`[Discovery] Far-type landmark "${landmarkType}" placed BEYOND FOV (${(distanceMultiplier * 100).toFixed(0)}% of range)`);
|
|
40335
|
+
}
|
|
40336
|
+
else {
|
|
40337
|
+
// For other types, use bbox Y as a hint (but cap minimum distance)
|
|
40338
|
+
const bboxCenterY = bbox[1] + (bbox[3] || 0) / 2;
|
|
40339
|
+
// Map Y to distance: 0 (top) = far, 1 (bottom) = closer (but not too close)
|
|
40340
|
+
distanceMultiplier = Math.max(0.4, 0.9 - (bboxCenterY * 0.5));
|
|
40341
|
+
}
|
|
40342
|
+
this.console.log(`[Discovery] Using bounding box [${bbox.join(',')}] for horizontal position`);
|
|
40333
40343
|
}
|
|
40334
40344
|
else {
|
|
40335
|
-
//
|
|
40345
|
+
// No bounding box - use type and spread pattern
|
|
40336
40346
|
const cameraDeviceId = camera.deviceId;
|
|
40337
40347
|
const existingFromCamera = (topology.landmarks || []).filter(l => l.visibleFromCameras?.includes(cameraDeviceId) ||
|
|
40338
40348
|
l.visibleFromCameras?.includes(camera.name)).length;
|
|
40349
|
+
// Spread horizontally across FOV
|
|
40339
40350
|
angleOffset = (existingFromCamera % 3 - 1) * halfFov * 0.6;
|
|
40340
|
-
|
|
40341
|
-
|
|
40351
|
+
// Distance based on type
|
|
40352
|
+
if (isFarType) {
|
|
40353
|
+
// Neighbors, boundaries, streets are BEYOND the camera's normal range
|
|
40354
|
+
distanceMultiplier = 1.5 + Math.random() * 0.5; // 150-200% of range
|
|
40355
|
+
this.console.log(`[Discovery] Far-type landmark "${landmarkType}" (no bbox) placed BEYOND FOV`);
|
|
40356
|
+
}
|
|
40357
|
+
else {
|
|
40358
|
+
distanceMultiplier = 0.5 + (existingFromCamera % 2) * 0.3;
|
|
40359
|
+
this.console.log(`[Discovery] No bounding box, using fallback spread (existing: ${existingFromCamera})`);
|
|
40360
|
+
}
|
|
40342
40361
|
}
|
|
40343
40362
|
const finalAngle = dirRad + angleOffset;
|
|
40344
40363
|
const distance = range * distanceMultiplier;
|