@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/out/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -1866,7 +1866,13 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
|
|
|
1866
1866
|
const dirRad = (direction - 90) * Math.PI / 180;
|
|
1867
1867
|
const halfFov = (fovAngle / 2) * Math.PI / 180;
|
|
1868
1868
|
|
|
1869
|
-
// Use
|
|
1869
|
+
// Use landmark TYPE to determine distance - some things are inherently far away
|
|
1870
|
+
// regardless of where they appear in the camera frame
|
|
1871
|
+
const landmarkType = suggestion.landmark.type;
|
|
1872
|
+
const farTypes = ['neighbor', 'boundary', 'street']; // Always place at edge of FOV
|
|
1873
|
+
const isFarType = farTypes.includes(landmarkType || '');
|
|
1874
|
+
|
|
1875
|
+
// Use bounding box if available for horizontal positioning
|
|
1870
1876
|
// boundingBox format: [x, y, width, height] normalized 0-1
|
|
1871
1877
|
const bbox = (suggestion.landmark as any).boundingBox as [number, number, number, number] | undefined;
|
|
1872
1878
|
|
|
@@ -1874,33 +1880,46 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
|
|
|
1874
1880
|
let distanceMultiplier: number;
|
|
1875
1881
|
|
|
1876
1882
|
if (bbox && bbox.length >= 2) {
|
|
1877
|
-
// Use bounding box
|
|
1883
|
+
// Use bounding box X for horizontal position in FOV
|
|
1878
1884
|
const bboxCenterX = bbox[0] + (bbox[2] || 0) / 2; // 0 = left edge, 1 = right edge
|
|
1879
|
-
const bboxCenterY = bbox[1] + (bbox[3] || 0) / 2; // 0 = top (far), 1 = bottom (close)
|
|
1880
1885
|
|
|
1881
1886
|
// Map X position to angle within FOV
|
|
1882
|
-
// bboxCenterX 0 → left side of FOV (-halfFov)
|
|
1883
|
-
// bboxCenterX 0.5 → center of FOV (0)
|
|
1884
|
-
// bboxCenterX 1 → right side of FOV (+halfFov)
|
|
1885
1887
|
angleOffset = (bboxCenterX - 0.5) * 2 * halfFov;
|
|
1886
1888
|
|
|
1887
|
-
//
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1889
|
+
// For distance: use TYPE first, then bbox Y as hint
|
|
1890
|
+
if (isFarType) {
|
|
1891
|
+
// Neighbors, boundaries, streets are BEYOND the camera's normal range
|
|
1892
|
+
// Place at 150-200% of range to indicate they're distant background features
|
|
1893
|
+
distanceMultiplier = 1.5 + Math.random() * 0.5; // 150-200% of range
|
|
1894
|
+
this.console.log(`[Discovery] Far-type landmark "${landmarkType}" placed BEYOND FOV (${(distanceMultiplier * 100).toFixed(0)}% of range)`);
|
|
1895
|
+
} else {
|
|
1896
|
+
// For other types, use bbox Y as a hint (but cap minimum distance)
|
|
1897
|
+
const bboxCenterY = bbox[1] + (bbox[3] || 0) / 2;
|
|
1898
|
+
// Map Y to distance: 0 (top) = far, 1 (bottom) = closer (but not too close)
|
|
1899
|
+
distanceMultiplier = Math.max(0.4, 0.9 - (bboxCenterY * 0.5));
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
this.console.log(`[Discovery] Using bounding box [${bbox.join(',')}] for horizontal position`);
|
|
1893
1903
|
} else {
|
|
1894
|
-
//
|
|
1904
|
+
// No bounding box - use type and spread pattern
|
|
1895
1905
|
const cameraDeviceId = camera.deviceId;
|
|
1896
1906
|
const existingFromCamera = (topology.landmarks || []).filter(l =>
|
|
1897
1907
|
l.visibleFromCameras?.includes(cameraDeviceId) ||
|
|
1898
1908
|
l.visibleFromCameras?.includes(camera.name)
|
|
1899
1909
|
).length;
|
|
1900
1910
|
|
|
1911
|
+
// Spread horizontally across FOV
|
|
1901
1912
|
angleOffset = (existingFromCamera % 3 - 1) * halfFov * 0.6;
|
|
1902
|
-
|
|
1903
|
-
|
|
1913
|
+
|
|
1914
|
+
// Distance based on type
|
|
1915
|
+
if (isFarType) {
|
|
1916
|
+
// Neighbors, boundaries, streets are BEYOND the camera's normal range
|
|
1917
|
+
distanceMultiplier = 1.5 + Math.random() * 0.5; // 150-200% of range
|
|
1918
|
+
this.console.log(`[Discovery] Far-type landmark "${landmarkType}" (no bbox) placed BEYOND FOV`);
|
|
1919
|
+
} else {
|
|
1920
|
+
distanceMultiplier = 0.5 + (existingFromCamera % 2) * 0.3;
|
|
1921
|
+
this.console.log(`[Discovery] No bounding box, using fallback spread (existing: ${existingFromCamera})`);
|
|
1922
|
+
}
|
|
1904
1923
|
}
|
|
1905
1924
|
|
|
1906
1925
|
const finalAngle = dirRad + angleOffset;
|