Skip to content

ITEP-89520: Sensor tagging for high performan tracker#1308

Open
daddo-intel wants to merge 13 commits intomainfrom
feature/ITEP-89520-analytics-mode-sensor-tagging
Open

ITEP-89520: Sensor tagging for high performan tracker#1308
daddo-intel wants to merge 13 commits intomainfrom
feature/ITEP-89520-analytics-mode-sensor-tagging

Conversation

@daddo-intel
Copy link
Copy Markdown
Contributor

@daddo-intel daddo-intel commented Apr 16, 2026

📝 Description

This PR enables sensor tagging with high performant tracker. To test:

  1. Run make demo-tracker SUPASS=<password>
  2. Create a sensor in scenescape 2D UI e.g sensor_0
  3. docker exec into web container and run:
while true; do
  mosquitto_pub -h broker.scenescape.intel.com -p 1883 \
    --cafile /run/secrets/certs/scenescape-ca.pem \
    --insecure \
    -t "scenescape/data/sensor/sensor_0" \
    -m "{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%S.%6NZ)\",\"subtype\":\"temperature\",\"id\":\"sensor_0\",\"value\":$((RANDOM % 100))}"
  sleep 1
done
  1. In another terminal, docker exec into web container and run:
mosquitto_sub -h broker.scenescape.intel.com -p 1883 \
  --cafile /run/secrets/certs/scenescape-ca.pem \
  --insecure \
  -t "scenescape/regulated/scene/<scene-id>"

Verify that data in regulated topic has sensor values associated with track objects

  1. To run test, run:
    make -C tests sensors-send-events ANALYTICS=true SUPASS=<password>

✨ Type of Change

Select the type of change your PR introduces:

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests
  • 🚂 CI

🧪 Testing Scenarios

Describe how the changes were tested and how reviewers can test them too:

  • ✅ Tested manually
  • 🤖 Ran automated end-to-end tests

✅ Checklist

Before submitting the PR, ensure the following:

  • 🔍 PR title is clear and descriptive
  • 📝 For internal contributors: If applicable, include the JIRA ticket number (e.g., ITEP-123456) in the PR title. Do not include full URLs
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works

@daddo-intel daddo-intel changed the title Feature/itep 89520 analytics mode sensor tagging ITEP-89520: Sensor tagging for high performan tracker Apr 16, 2026
Copy link
Copy Markdown
Contributor

@ltalarcz ltalarcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In review

@saratpoluri
Copy link
Copy Markdown
Contributor

This is focused on environmental sensor only?

Comment thread tests/Makefile Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for sensor tagging when running the high-performance tracker in an analytics-only deployment, and updates functional tests/compose tooling to exercise that path.

Changes:

  • Add analytics-only tracked-object caching in the controller Scene to support associating sensor readings with tracker-published objects.
  • Extend the sensors-send-events functional test target to optionally run against a tracker + analytics-only controller compose stack (gated by ANALYTICS).
  • Update the sensor MQTT functional test to include pixel bboxes and relax assertions when running in analytics mode.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/scenescape-start Pass through ANALYTICS env var into the started container.
tests/functional/tc_sensors_send_mqtt_messages.py Add bounding_box_px, analytics flag handling, and adjust external-topic assertions for analytics runs.
tests/compose/tracker.yml New tracker service compose file for functional tests.
tests/compose/controller_analytics.yml New analytics-only controller compose file for functional tests.
tests/Makefile.functional Add ANALYTICS-gated compose/service selection for sensors-send-events.
tests/Makefile Propagate ANALYTICS into the test runner environment.
controller/src/controller/scene.py Add analytics-only object caching/deserialization and adjust sensor processing to use analytics objects.

Comment thread controller/src/controller/scene.py Outdated
Comment on lines 323 to 334
if self.use_tracker:
for detectionType in self.tracker.trackers.keys():
for obj in self.tracker.currentObjects(detectionType):
# When tracking is disabled, do not rely on obj.frameCount being initialized
if (not self.use_tracker or obj.frameCount > 3) and (is_scene_wide or sensor.isPointWithin(obj.sceneLoc)):
objects_in_sensor.append(obj)
obj.chain_data.active_sensors.add(sensor_id)
else:
for obj in self._analytics_objects.values():
if is_scene_wide or sensor.isPointWithin(obj.sceneLoc):
objects_in_sensor.append(obj)
# Ensure active_sensors is updated (handles scene-wide sensors or objects existing before sensor creation)
obj.chain_data.active_sensors.add(sensor_id)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processSensorData() now branches on self.use_tracker. In non-analytics mode use_tracker can be False (see scene_data.get('use_tracker', True)), but self.tracker is still present and _analytics_objects is never populated (it’s only updated in ControllerMode.isAnalyticsOnly()). This means sensor tagging will silently stop working when tracking is disabled. Consider branching on ControllerMode.isAnalyticsOnly()/self.tracker is None instead, and still iterating self.tracker.currentObjects(...) when a tracker exists (keeping the frameCount gating only when use_tracker is True).

Copilot uses AI. Check for mistakes.
Comment thread tests/compose/tracker.yml
django:
file: ${SECRETSDIR}/django
controller-auth-file:
file: manager/secrets/controller.auth
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controller-auth-file is hardcoded to manager/secrets/controller.auth. Other test compose files use ${SECRETSDIR} for secrets (e.g., tests/compose/web.yml, tests/compose/scene.yml), which allows callers to override secrets location. Using a fixed relative path here can break runs that set SECRETSDIR to a non-default location; consider switching this to ${SECRETSDIR}/controller.auth for consistency.

Suggested change
file: manager/secrets/controller.auth
file: ${SECRETSDIR}/controller.auth

Copilot uses AI. Check for mistakes.
Comment thread tests/Makefile.functional
Comment on lines +312 to +317
$(if $(ANALYTICS),\
$(eval COMPOSE_FILES := $(COMPOSE)/dlstreamer/broker.yml:$(COMPOSE)/ntp.yml:$(COMPOSE)/pgserver.yml:$(COMPOSE)/tracker.yml:$(COMPOSE)/controller_analytics.yml:$(COMPOSE)/web.yml) \
$(eval SERVICES := 'pgserver web tracker controller-analytics'),\
$(eval COMPOSE_FILES := $(COMPOSE)/dlstreamer/broker.yml:$(COMPOSE)/ntp.yml:$(COMPOSE)/pgserver.yml:$(COMPOSE)/scene.yml:$(COMPOSE)/web.yml) \
$(eval SERVICES := 'pgserver web scene')\
)
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make’s $(if $(ANALYTICS), …) treats any non-empty value as true, so ANALYTICS=false would still select the analytics compose stack while the Python test interprets ANALYTICS as false. To avoid surprising behavior, consider explicitly checking for truthy values (e.g., only true/1) when selecting the compose files/services.

Copilot uses AI. Check for mistakes.
obj.chain_data.active_sensors.add(sensor_id)
else:
for obj in self._analytics_objects.values():
if is_scene_wide or sensor.isPointWithin(obj.sceneLoc):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR: I think it is odd that all of region, sensor, tripwires are just handled and operated on openly in our scene class. Think about creating a base class called "Analytic" and Region, Tripwire and Sensor derive from it and the process method is overridden in each.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Comment thread controller/src/controller/scene.py Outdated
Co-authored-by: Sarat Poluri <sarat.chandra.poluri@intel.com>
self.tracked_objects_cache[detection_type] = objects
self.tracked_objects_cache[detection_type] = tracked_objects

if ControllerMode.isAnalyticsOnly():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify if use_tracer and isAnalyticsOnly are redundant.

if ControllerMode.isAnalyticsOnly():
if detection_type in self.tracked_objects_cache:
cached_objects = self.tracked_objects_cache[detection_type]
return self._deserializeTrackedObjects(cached_objects)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I deserialize in updateTrackedObjects, do I need to deserialize here again?

obj.size = obj_data.get('size')
obj.confidence = obj_data.get('confidence')
obj.frameCount = obj_data.get('frame_count', 0)
obj.frameCount = obj_data.get('frame_count', 4) # > 3 so sensor/region checks pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

@daddo-intel
Copy link
Copy Markdown
Contributor Author

This is focused on environmental sensor only?

works for both attribute & environmental sensors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants