@blueharford/scrypted-spatial-awareness 0.4.3 → 0.4.4

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/plugin.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueharford/scrypted-spatial-awareness",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Cross-camera object tracking for Scrypted NVR with spatial awareness",
5
5
  "author": "Joshua Seidel <blueharford>",
6
6
  "license": "Apache-2.0",
package/src/main.ts CHANGED
@@ -37,7 +37,7 @@ import { EDITOR_HTML } from './ui/editor-html';
37
37
  import { TRAINING_HTML } from './ui/training-html';
38
38
  import { TrainingConfig, TrainingLandmark } from './models/training';
39
39
 
40
- const { deviceManager, systemManager } = sdk;
40
+ const { deviceManager, systemManager, mediaManager } = sdk;
41
41
 
42
42
  const TRACKING_ZONE_PREFIX = 'tracking-zone:';
43
43
  const GLOBAL_TRACKER_ID = 'global-tracker';
@@ -1046,24 +1046,26 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
1046
1046
  }
1047
1047
  }
1048
1048
 
1049
- private getFloorPlanPath(): string {
1050
- // Use plugin's data directory for persistent storage
1051
- const pluginVolume = process.env.SCRYPTED_PLUGIN_VOLUME || '/server/volume/plugins/@blueharford/scrypted-spatial-awareness';
1052
- const dataDir = path.join(pluginVolume, 'data');
1049
+ private async getFloorPlanPath(): Promise<string> {
1050
+ // Use mediaManager.getFilesPath() for proper persistent storage
1051
+ const filesPath = await mediaManager.getFilesPath();
1052
+ this.console.log('Files path from mediaManager:', filesPath);
1053
1053
  // Ensure directory exists
1054
- if (!fs.existsSync(dataDir)) {
1055
- fs.mkdirSync(dataDir, { recursive: true });
1054
+ if (!fs.existsSync(filesPath)) {
1055
+ fs.mkdirSync(filesPath, { recursive: true });
1056
1056
  }
1057
- return path.join(dataDir, 'floorplan.png');
1057
+ return path.join(filesPath, 'floorplan.png');
1058
1058
  }
1059
1059
 
1060
- private handleFloorPlanRequest(request: HttpRequest, response: HttpResponse): void {
1060
+ private async handleFloorPlanRequest(request: HttpRequest, response: HttpResponse): Promise<void> {
1061
1061
  if (request.method === 'GET') {
1062
1062
  try {
1063
- const floorPlanPath = this.getFloorPlanPath();
1063
+ const floorPlanPath = await this.getFloorPlanPath();
1064
+ this.console.log('Loading floor plan from:', floorPlanPath, 'exists:', fs.existsSync(floorPlanPath));
1064
1065
  if (fs.existsSync(floorPlanPath)) {
1065
1066
  const imageBuffer = fs.readFileSync(floorPlanPath);
1066
1067
  const imageData = 'data:image/png;base64,' + imageBuffer.toString('base64');
1068
+ this.console.log('Floor plan loaded, size:', imageBuffer.length);
1067
1069
  response.send(JSON.stringify({ imageData }), {
1068
1070
  headers: { 'Content-Type': 'application/json' },
1069
1071
  });
@@ -1087,7 +1089,7 @@ export class SpatialAwarenessPlugin extends ScryptedDeviceBase
1087
1089
  const base64Data = imageData.replace(/^data:image\/\w+;base64,/, '');
1088
1090
  const imageBuffer = Buffer.from(base64Data, 'base64');
1089
1091
 
1090
- const floorPlanPath = this.getFloorPlanPath();
1092
+ const floorPlanPath = await this.getFloorPlanPath();
1091
1093
  fs.writeFileSync(floorPlanPath, imageBuffer);
1092
1094
 
1093
1095
  this.console.log('Floor plan saved to:', floorPlanPath, 'size:', imageBuffer.length);