@blueharford/scrypted-spatial-awareness 0.5.5 → 0.5.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 +28 -9
- 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 +19 -8
- package/src/core/topology-discovery.ts +17 -1
package/out/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -84,23 +84,34 @@ export interface ImageData {
|
|
|
84
84
|
*/
|
|
85
85
|
export async function mediaObjectToBase64(mediaObject: MediaObject): Promise<ImageData | null> {
|
|
86
86
|
try {
|
|
87
|
+
console.log(`[Image] Converting MediaObject, mimeType=${mediaObject?.mimeType}`);
|
|
88
|
+
|
|
87
89
|
// Convert MediaObject to Buffer using mediaManager
|
|
88
90
|
const buffer = await mediaManager.convertMediaObjectToBuffer(mediaObject, ScryptedMimeTypes.Image);
|
|
89
91
|
|
|
90
|
-
if (!buffer
|
|
91
|
-
console.warn('
|
|
92
|
+
if (!buffer) {
|
|
93
|
+
console.warn('[Image] convertMediaObjectToBuffer returned null/undefined');
|
|
92
94
|
return null;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
const base64 = buffer.toString('base64');
|
|
97
|
+
console.log(`[Image] Buffer received: ${buffer.length} bytes`);
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.warn(`Invalid base64: length=${base64?.length || 0}`);
|
|
99
|
+
if (buffer.length === 0) {
|
|
100
|
+
console.warn('[Image] Buffer is empty (0 bytes)');
|
|
101
101
|
return null;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// Check if buffer is too small to be a valid image (< 1KB is suspicious)
|
|
105
|
+
if (buffer.length < 1000) {
|
|
106
|
+
// Log what the buffer contains - might be an error message
|
|
107
|
+
const bufferContent = buffer.toString('utf8').substring(0, 100);
|
|
108
|
+
console.warn(`[Image] Buffer too small (${buffer.length} bytes), content: ${bufferContent}`);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Convert buffer to base64 (raw, no data URL prefix)
|
|
113
|
+
const base64 = buffer.toString('base64');
|
|
114
|
+
|
|
104
115
|
// Determine MIME type - default to JPEG for camera images
|
|
105
116
|
const mediaType = mediaObject.mimeType?.split(';')[0] || 'image/jpeg';
|
|
106
117
|
|
|
@@ -108,7 +119,7 @@ export async function mediaObjectToBase64(mediaObject: MediaObject): Promise<Ima
|
|
|
108
119
|
|
|
109
120
|
return { base64, mediaType };
|
|
110
121
|
} catch (e) {
|
|
111
|
-
console.warn('Failed to convert MediaObject to base64:', e);
|
|
122
|
+
console.warn('[Image] Failed to convert MediaObject to base64:', e);
|
|
112
123
|
return null;
|
|
113
124
|
}
|
|
114
125
|
}
|
|
@@ -213,11 +213,27 @@ export class TopologyDiscoveryEngine {
|
|
|
213
213
|
try {
|
|
214
214
|
const camera = systemManager.getDeviceById<Camera>(cameraId);
|
|
215
215
|
if (!camera?.interfaces?.includes(ScryptedInterface.Camera)) {
|
|
216
|
+
this.console.warn(`[Discovery] Camera ${cameraId} doesn't have Camera interface`);
|
|
216
217
|
return null;
|
|
217
218
|
}
|
|
218
219
|
|
|
220
|
+
this.console.log(`[Discovery] Taking snapshot from camera: ${camera.name || cameraId}`);
|
|
219
221
|
const mediaObject = await camera.takePicture();
|
|
220
|
-
|
|
222
|
+
|
|
223
|
+
if (!mediaObject) {
|
|
224
|
+
this.console.warn(`[Discovery] takePicture() returned null for ${camera.name}`);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
this.console.log(`[Discovery] MediaObject received: mimeType=${mediaObject.mimeType}`);
|
|
229
|
+
|
|
230
|
+
const imageData = await mediaObjectToBase64(mediaObject);
|
|
231
|
+
|
|
232
|
+
if (!imageData) {
|
|
233
|
+
this.console.warn(`[Discovery] Failed to convert MediaObject to base64 for ${camera.name}`);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return imageData;
|
|
221
237
|
} catch (e) {
|
|
222
238
|
this.console.warn(`[Discovery] Failed to get snapshot from camera ${cameraId}:`, e);
|
|
223
239
|
return null;
|