Integration Guide#
This guide explains how to integrate the Behavioral Analysis Service into an existing application workflow.
The service is MQTT-driven:
Your upstream application publishes analysis requests.
The service fetches frames from SeaweedFS, runs pose/pattern analysis (and optional VLM confirmation), then publishes results.
Integration Overview#
Data Flow#
The upstream application stores frames in SeaweedFS.
The upstream application publishes a request message to the BA request topic.
The Behavioral Analysis Service consumes the request and fetches frames.
The service evaluates configured patterns.
The service publishes an outcome message to the BA result topic.
The downstream application consumes the result and applies business actions.
Required Changes in Your Application#
1. Publish Requests to MQTT#
Your application must publish JSON messages to the configured request topic (default: ba/requests).
Required/optional request fields:
Field |
Required |
Notes |
|---|---|---|
|
Yes |
Tracked entity identifier |
|
No |
Region/zone identifier |
|
No |
Used with storage path resolution |
|
No |
Scene identifier |
|
No |
Optional cap for frame fetch range |
Example payload:
{
"person_id": "person-042",
"region_id": "shelf-B",
"entry_timestamp": "1700001000000",
"scene_id": "store-01",
"last_frame_ts": "1700001030000"
}
2. Align the SeaweedFS Frame Path Contract#
Frames must be readable by the service under:
{SEAWEEDFS_BUCKET}/{entity_id}/{region_id}/{entry_timestamp}/frames/{timestamp}.jpg
Note:
Bucket name is configurable via
SEAWEEDFS_BUCKET.Filenames should preserve timestamp ordering because the service sorts by timestamp name.
3. Consume Result Messages#
Your application (or another downstream consumer) must subscribe to the configured result topic (default: ba/results).
Typical result fields:
Field |
Notes |
|---|---|
|
Echo/context fields |
|
|
|
Detection confidence |
|
Number of frames processed |
|
Parsed VLM payload or |
|
Present when pattern matched |
|
Pattern description when available |
|
Optional boolean when VLM path is active |
Configuration Mapping Checklist#
Ensure your application-side assumptions match service configuration:
MQTT broker and topics:
MQTT_HOST,MQTT_PORTBA_REQUEST_TOPIC,BA_RESULT_TOPIC
SeaweedFS endpoint and bucket:
SEAWEEDFS_ENDPOINT,SEAWEEDFS_BUCKET
Frame thresholds and fetch behavior:
MIN_FRAMES_FOR_DETECTION,MAX_FRAMES_TO_FETCH,POSE_FRAMES_COUNT
Model path/device:
YOLO_POSE_MODEL,GST_INFERENCE_DEVICE
Pattern configuration file:
PATTERN_CONFIG_PATH
Optional VLM path:
VLM_ENABLED,VLM_ENDPOINT,VLM_MODEL_NAME
Use Configuration as the source of truth for variable definitions and defaults.
End-to-End Validation#
Use this sequence after integration:
Confirm connectivity:
Service can reach MQTT broker.
Service can reach SeaweedFS.
If enabled, service can reach OVMS VLM endpoint.
Confirm frame availability:
Verify frames exist in the expected SeaweedFS path for a known
person_id/region_id/entry_timestamp.Publish one known request:
Send a request on the configured BA request topic with matching identifiers.
Verify service processing logs:
Confirm request received, frames fetched, pose analysis executed.
Verify result publication:
Confirm one output event on BA result topic with expected status and metadata.
Common Integration Pitfalls#
Topic mismatch#
Symptoms:
Requests are published but never consumed.
No BA results observed.
Checks:
Verify publisher topic equals
BA_REQUEST_TOPIC.Verify consumer topic equals
BA_RESULT_TOPIC.
Frame path mismatch#
Symptoms:
Frequent
no_enough_datastatuses.
Checks:
Validate bucket and object key structure match service expectations.
Validate that identifiers in the request match identifiers used in the stored frame path.
Cross-container network isolation#
Symptoms:
Service starts but cannot reach SeaweedFS/MQTT/OVMS.
Checks:
Ensure services share a reachable Docker network.
Ensure endpoint hostnames resolve from the behavioral-analysis container.
Configuration drift between environments#
Symptoms:
Works in one environment, fails in another.
Checks:
Compare
.env/.env.localand runtime variables per environment.Reconfirm topic names, bucket name, and model path.