@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/dist/plugin.zip
CHANGED
|
Binary file
|
package/out/main.nodejs.js
CHANGED
|
@@ -35106,26 +35106,34 @@ const { systemManager, mediaManager } = sdk_1.default;
|
|
|
35106
35106
|
*/
|
|
35107
35107
|
async function mediaObjectToBase64(mediaObject) {
|
|
35108
35108
|
try {
|
|
35109
|
+
console.log(`[Image] Converting MediaObject, mimeType=${mediaObject?.mimeType}`);
|
|
35109
35110
|
// Convert MediaObject to Buffer using mediaManager
|
|
35110
35111
|
const buffer = await mediaManager.convertMediaObjectToBuffer(mediaObject, sdk_1.ScryptedMimeTypes.Image);
|
|
35111
|
-
if (!buffer
|
|
35112
|
-
console.warn('
|
|
35112
|
+
if (!buffer) {
|
|
35113
|
+
console.warn('[Image] convertMediaObjectToBuffer returned null/undefined');
|
|
35113
35114
|
return null;
|
|
35114
35115
|
}
|
|
35115
|
-
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
if (!base64 || base64.length < 100) {
|
|
35119
|
-
console.warn(`Invalid base64: length=${base64?.length || 0}`);
|
|
35116
|
+
console.log(`[Image] Buffer received: ${buffer.length} bytes`);
|
|
35117
|
+
if (buffer.length === 0) {
|
|
35118
|
+
console.warn('[Image] Buffer is empty (0 bytes)');
|
|
35120
35119
|
return null;
|
|
35121
35120
|
}
|
|
35121
|
+
// Check if buffer is too small to be a valid image (< 1KB is suspicious)
|
|
35122
|
+
if (buffer.length < 1000) {
|
|
35123
|
+
// Log what the buffer contains - might be an error message
|
|
35124
|
+
const bufferContent = buffer.toString('utf8').substring(0, 100);
|
|
35125
|
+
console.warn(`[Image] Buffer too small (${buffer.length} bytes), content: ${bufferContent}`);
|
|
35126
|
+
return null;
|
|
35127
|
+
}
|
|
35128
|
+
// Convert buffer to base64 (raw, no data URL prefix)
|
|
35129
|
+
const base64 = buffer.toString('base64');
|
|
35122
35130
|
// Determine MIME type - default to JPEG for camera images
|
|
35123
35131
|
const mediaType = mediaObject.mimeType?.split(';')[0] || 'image/jpeg';
|
|
35124
35132
|
console.log(`[Image] Converted to base64: ${base64.length} chars, type=${mediaType}`);
|
|
35125
35133
|
return { base64, mediaType };
|
|
35126
35134
|
}
|
|
35127
35135
|
catch (e) {
|
|
35128
|
-
console.warn('Failed to convert MediaObject to base64:', e);
|
|
35136
|
+
console.warn('[Image] Failed to convert MediaObject to base64:', e);
|
|
35129
35137
|
return null;
|
|
35130
35138
|
}
|
|
35131
35139
|
}
|
|
@@ -36189,10 +36197,21 @@ class TopologyDiscoveryEngine {
|
|
|
36189
36197
|
try {
|
|
36190
36198
|
const camera = systemManager.getDeviceById(cameraId);
|
|
36191
36199
|
if (!camera?.interfaces?.includes(sdk_1.ScryptedInterface.Camera)) {
|
|
36200
|
+
this.console.warn(`[Discovery] Camera ${cameraId} doesn't have Camera interface`);
|
|
36192
36201
|
return null;
|
|
36193
36202
|
}
|
|
36203
|
+
this.console.log(`[Discovery] Taking snapshot from camera: ${camera.name || cameraId}`);
|
|
36194
36204
|
const mediaObject = await camera.takePicture();
|
|
36195
|
-
|
|
36205
|
+
if (!mediaObject) {
|
|
36206
|
+
this.console.warn(`[Discovery] takePicture() returned null for ${camera.name}`);
|
|
36207
|
+
return null;
|
|
36208
|
+
}
|
|
36209
|
+
this.console.log(`[Discovery] MediaObject received: mimeType=${mediaObject.mimeType}`);
|
|
36210
|
+
const imageData = await (0, spatial_reasoning_1.mediaObjectToBase64)(mediaObject);
|
|
36211
|
+
if (!imageData) {
|
|
36212
|
+
this.console.warn(`[Discovery] Failed to convert MediaObject to base64 for ${camera.name}`);
|
|
36213
|
+
}
|
|
36214
|
+
return imageData;
|
|
36196
36215
|
}
|
|
36197
36216
|
catch (e) {
|
|
36198
36217
|
this.console.warn(`[Discovery] Failed to get snapshot from camera ${cameraId}:`, e);
|