Skip to navigation

The Behavior Analytics microservice is implemented in Python and leverages the Python Multiprocessing library for parallel processing.

The perception layer processes camera or video input streams, performing sequential frame analysis for object detection and tracking. It generates object embeddings and sends protobuf messages containing frame metadata to a message broker. The pipeline supports multiple message brokers including Kafka, Redis Streams, and MQTT, allowing flexibility based on deployment requirements.

The metadata from the perception layer represents a frame containing object detection bounding boxes, tracking IDs, embedding vectors, and other attributes. This input is processed by the pipeline to generate Behavior data. A Behavior represents an object tracked over time with its associated attributes.

Configurations

The Behavior Analytics microservice requires configuration files that control various aspects of the analytics pipeline. These files allow users to customize the system’s behavior according to their specific requirements.

Application Configuration File

The main configuration file for Behavior Analytics controls message broker settings, sensor configurations, and pipeline parameters. The configuration supports multiple message broker types (Kafka, Redis Streams, MQTT).

Example Warehouse 2D Kafka configuration:

{
"kafka": {
"brokers": "kafka:29092",
"group": "mdx-spatial-analytics-2d-app",
"consumer": {
"autoOffsetReset": "latest",
"enableAutoCommit": false,
"maxPollIntervalMs": 900000,
"maxPartitionFetchBytes": 10485760,
"fetchMaxBytes": 104857600,
"maxPollRecords": 10000,
"timeout": 0.01
},
"producer": {
"lingerMs": 0
},
"topics": [
{"name": "raw", "value": "mdx-raw"},
{"name": "frames", "value": "mdx-frames"},
{"name": "behavior", "value": "mdx-behavior"},
{"name": "notification", "value": "mdx-notification"},
{"name": "events", "value": "mdx-events"},
{"name": "incidents", "value": "mdx-incidents"}
]
},
"sensors": [
{
"id": "default",
"configs": [
{"name": "proximityDetectionEnable", "value": "true"},
{"name": "proximityDetectionThreshold", "value": "4"},
{"name": "proximityDetectionCenterClasses", "value": "[\"Forklift\"]"},
{"name": "proximityDetectionSurroundingClasses", "value": "[\"Person\"]"}
]
}
],
"app": [
{"name": "sourceType", "value": "kafka"},
{"name": "sinkType", "value": "kafka"},
{"name": "numWorkersForBehaviorCreation", "value": "2"},
{"name": "numWorkersForFrameEnhancement", "value": "2"},
{"name": "behaviorWatermarkSec", "value": "30"},
{"name": "behaviorMaxPoints", "value": "200"},
{"name": "proximityViolationIncidentEnable", "value": "true"},
{"name": "proximityViolationIncidentThreshold", "value": "2"},
{"name": "restrictedAreaViolationIncidentEnable", "value": "true"},
{"name": "confinedAreaViolationIncidentEnable", "value": "true"}
]
}

Message Broker Configuration

ParameterDescriptionDefault Value
sourceTypeMessage broker type for input (kafka, redisStream, mqtt)kafka
sinkTypeMessage broker type for output (kafka, redisStream, mqtt)kafka

Kafka Topics

Topic NameDescriptionDefault Value
rawInput metadata from perception layermdx-raw
behaviorBehavior data outputmdx-behavior
eventsTripwire and ROI eventsmdx-events
framesEnhanced frames metadatamdx-frames
notificationCalibration updates and sensor notificationsmdx-notification
incidentsIncident data from violation detectionmdx-incidents

Pipeline Configuration

ParameterDescriptionDefault Value
numWorkersForBehaviorCreationNumber of workers for behavior creation (0 disables)Required
numWorkersForFrameEnhancementNumber of workers for frame enhancement (0 disables)Required
in3dModeEnable 3D mode for pipeline processingfalse
compactFrameEnable compact frame metadata format (recommended for 3D / multi-sensor frames)false
objectConfidenceThresholdMinimum confidence score for object detection0.5
clusterThresholdCosine similarity threshold for per-object embedding clustering (Chinese Restaurant Process) during state management0.9
imageLocationModeFor image coordinate system, which bbox point is used as the object location (center or bottom_center)bottom_center
roiEventDetectionModeHow ROI ENTRY/EXIT is decided: coordinate tests the object’s representative point against the ROI polygon; bbox tests whether the object’s bounding box overlaps it. bbox is supported only for image calibration, where the bbox and the ROI polygon share image-pixel coordinates; cartesian and geo calibration fall back to coordinate with a one-time warningcoordinate

Playback Configuration

ParameterDescriptionDefault Value
playbackInSimulationModeUse simulated time for playbackfalse
playbackLoopNumber of times to loop through playback data1
playbackFilterEmptyObjectsFilter out frames with no objectstrue
playbackSimulationTimedeltaInMinTime delta in minutes for simulation mode60
playbackSimulationFpsFrames per second for simulation playback1
playbackSimulationBaseTimeBase timestamp for simulation (ISO format)""
playbackStartUpDelaySecDelay in seconds before playback starts0
playbackSensorsList of sensor IDs to include in playback (empty = all)[]

State Management Configuration

ParameterDescriptionDefault Value
behaviorStateValidIntervalMaximum gap (seconds) between an object’s previous state end and next state start before treating them as separate behaviors. This is also the inactivity gap after which a track’s state is reclaimed6
behaviorWatermarkSecWatermark for behavior in seconds30
behaviorMaxPointsMaximum behavior points to store200
behaviorEmitOnceWrite each behavior once — one behaviorStateValidInterval after its track goes quiet — instead of on every batch. Events, anomalies and incidents keep using the per-batch behaviors and are unaffectedfalse
behaviorStateEndToleranceSecGrace window (seconds) past a state’s end within which late messages are still accepted0.1
behaviorTimeThresholdMessages with a timestamp at or before this ISO-8601 instant are filtered out1970-01-01T00:00:00.000Z
stateManagementFilterWhitelist of object types to admit into the pipeline; other types are dropped at frame ingest (empty = no filter)[]

Proximity Detection Configuration (Sensor-level)

ParameterDescriptionDefault Value
proximityDetectionEnableEnable proximity violation detectionfalse
proximityDetectionThresholdDistance threshold in meters1.8
proximityDetectionCenterClassesCenter object types (e.g., AMR, humanoid)[]
proximityDetectionSurroundingClassesSurrounding object types to check[]

Incident Detection Configuration

ParameterDescriptionDefault Value
incidentObjectTtlTTL (seconds) for object presence data3600
proximityViolationIncidentEnableEnable proximity violation incidentsfalse
proximityViolationIncidentThresholdMinimum violation duration (seconds) before an incident is reported; accepts fractional values1
proximityViolationIncidentExpirationWindowLargest detection gap (seconds) tolerated before the current violation run is closed. Keep it below the matching ...Threshold0.5
restrictedAreaViolationIncidentEnableEnable restricted area incidentsfalse
restrictedAreaViolationIncidentThresholdMinimum violation duration (seconds) before an incident is reported; accepts fractional values1
restrictedAreaViolationIncidentExpirationWindowLargest detection gap (seconds) tolerated before the current violation run is closed. Keep it below the matching ...Threshold0.5
confinedAreaViolationIncidentEnableEnable confined area incidentsfalse
confinedAreaViolationIncidentThresholdMinimum violation duration (seconds) before an incident is reported; accepts fractional values1
confinedAreaViolationIncidentExpirationWindowLargest detection gap (seconds) tolerated before the current violation run is closed. Keep it below the matching ...Threshold0.5
fovCountViolationIncidentEnableEnable FOV count violation incidentsfalse
fovCountViolationIncidentObjectThresholdObject count at which the violation fires, compared as count >= threshold (not >). Set to N + 1 to alert on “more than N”1
fovCountViolationIncidentThresholdMinimum violation duration (seconds) before an incident is reported; accepts fractional values1
fovCountViolationIncidentExpirationWindowLargest detection gap (seconds) tolerated before the current violation run is closed. Keep it below the matching ...Threshold0.5
fovCountViolationIncidentObjectTypeObject type to count for FOV violationsPerson

Tripwire Configuration (Sensor-level)

ParameterDescriptionDefault Value
tripwireMinPointsMinimum points before/after tripwire crossing5

Frame Management Configuration (Sensor-level)

ParameterDescriptionDefault Value
sensorMinFramesMinimum frames for frame state management5

Calibration File

The calibration file defines camera parameters, regions of interest (ROIs), tripwires, and coordinate transformations. Use the Calibration tool to generate this JSON file. For more details, refer to the Calibration documentation. For the calibration JSON structure, see Calibration Schema.

Runtime Configuration Adjustments

This section covers common configuration changes for deploying the Behavior Analytics pipeline.

Modifying Message Broker Settings

To switch between message brokers (Kafka, Redis Streams, MQTT), update the sourceType and sinkType parameters:

{
"app": [
{"name": "sourceType", "value": "redisStream"},
{"name": "sinkType", "value": "redisStream"}
]
}

Ensure the corresponding broker configuration section is properly configured (kafka, redisStream, or mqtt).

Configuring Worker Parallelism

Adjust the number of workers based on your deployment’s processing requirements:

{
"app": [
{"name": "numWorkersForBehaviorCreation", "value": "4"},
{"name": "numWorkersForFrameEnhancement", "value": "4"}
]
}

Setting worker count to 0 disables that processing stage. Both parameters are required and have no default values.

Enabling Violation Detection

To enable specific violation types for incident generation:

{
"app": [
{"name": "proximityViolationIncidentEnable", "value": "true"},
{"name": "restrictedAreaViolationIncidentEnable", "value": "true"},
{"name": "confinedAreaViolationIncidentEnable", "value": "true"},
{"name": "fovCountViolationIncidentEnable", "value": "true"},
{"name": "fovCountViolationIncidentObjectThreshold", "value": "5"},
{"name": "fovCountViolationIncidentObjectType", "value": "Person"}
]
}

Configuring Sensor-Specific Settings

Override default configurations for specific sensors:

{
"sensors": [
{
"id": "default",
"configs": [
{"name": "proximityDetectionEnable", "value": "false"},
{"name": "tripwireMinPoints", "value": "5"}
]
},
{
"id": "Warehouse_Cam1",
"configs": [
{"name": "proximityDetectionEnable", "value": "true"},
{"name": "proximityDetectionThreshold", "value": "2.0"},
{"name": "proximityDetectionCenterClasses", "value": "[\"Agility_Digit_Humanoid\"]"},
{"name": "proximityDetectionSurroundingClasses", "value": "[\"Person\"]"}
]
}
]
}

Sensors inherit from the default configuration and override only the specified parameters.

Updating Configuration Without a Restart

Most app and sensors keys can be changed at runtime by publishing an upsert to the mdx-notification topic with the message key behavior-analytics-config. The service validates each item against an allowlist, applies the accepted ones, and publishes an ack carrying the post-apply state and any per-item rejections.

Keys that are read once at startup — sourceType, sinkType, every numWorkersFor* count, and the whole kafka / redisStream / mqtt / coordinateReferenceSystem / inference sections — are rejected by the validator rather than silently ignored, so those changes still require a restart.

Calibration updates use the same topic with the message key calibration. Unlike config updates, calibration updates produce no ack; a rejected payload is visible only in the container logs.

For the full wire contract, the mutable/read-only key lists, and ack semantics, see the Behavior Analytics reference.