@blueharford/scrypted-spatial-awareness 0.6.6 → 0.6.7

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
@@ -40054,7 +40054,7 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
40054
40054
  });
40055
40055
  }
40056
40056
  }
40057
- handleTrainingEndRequest(response) {
40057
+ async handleTrainingEndRequest(response) {
40058
40058
  if (!this.trackingEngine) {
40059
40059
  response.send(JSON.stringify({ error: 'Tracking engine not running' }), {
40060
40060
  code: 500,
@@ -40064,6 +40064,39 @@ class SpatialAwarenessPlugin extends sdk_1.ScryptedDeviceBase {
40064
40064
  }
40065
40065
  const session = this.trackingEngine.endTrainingSession();
40066
40066
  if (session) {
40067
+ // Get unique visited cameras
40068
+ const visitedCameraIds = [...new Set(session.visits.map(v => v.cameraId))];
40069
+ // Auto-run discovery on visited cameras to detect landmarks and zones
40070
+ if (this.discoveryEngine && visitedCameraIds.length > 0) {
40071
+ this.console.log(`[Training] Running discovery analysis on ${visitedCameraIds.length} visited cameras...`);
40072
+ let landmarksFound = 0;
40073
+ let zonesFound = 0;
40074
+ for (const cameraId of visitedCameraIds) {
40075
+ try {
40076
+ const analysis = await this.discoveryEngine.analyzeScene(cameraId);
40077
+ if (analysis.isValid) {
40078
+ landmarksFound += analysis.landmarks.length;
40079
+ zonesFound += analysis.zones.length;
40080
+ this.console.log(`[Training] ${cameraId}: Found ${analysis.landmarks.length} landmarks, ${analysis.zones.length} zones`);
40081
+ }
40082
+ }
40083
+ catch (e) {
40084
+ this.console.warn(`[Training] Failed to analyze ${cameraId}:`, e);
40085
+ }
40086
+ }
40087
+ // Get all pending suggestions and auto-accept them
40088
+ const suggestions = this.discoveryEngine.getPendingSuggestions();
40089
+ for (const suggestion of suggestions) {
40090
+ this.applyDiscoverySuggestion(suggestion);
40091
+ this.discoveryEngine.acceptSuggestion(suggestion.id);
40092
+ }
40093
+ // Persist topology after applying suggestions
40094
+ if (suggestions.length > 0 && this.trackingEngine) {
40095
+ const updatedTopology = this.trackingEngine.getTopology();
40096
+ await this.storageSettings.putSetting('topology', JSON.stringify(updatedTopology));
40097
+ this.console.log(`[Training] Auto-applied ${suggestions.length} discoveries (${landmarksFound} landmarks, ${zonesFound} zones)`);
40098
+ }
40099
+ }
40067
40100
  response.send(JSON.stringify(session), {
40068
40101
  headers: { 'Content-Type': 'application/json' },
40069
40102
  });