Configure scene metadata over MQTT
This how-to guide shows how to set up and send both the Fusion Tracker output and the Track Summary output using the Analytics MQTT VAPIX API.
Prerequisites
- Access to an MQTT broker
- A device that supports AXIS Scene Metadata
- You have set up and connected the on-device MQTT client to an MQTT broker, through the device's Web Interface or VAPIX API
- cURL installed
Overview
The guide contains the following steps:
- Retrieve the analytics data sources available over MQTT
- Create a new analytics MQTT data publisher
- Retrieve existing analytics MQTT data publishers
- Remove an analytics MQTT data publisher (Optional)
Lets get started!
Step 1: Retrieve the available analytics data sources
To check for the currently available analytics data sources on a device we can use the following GET
method.
Don't forget to replace <device-ip>
, <user>
and <password>
where applicable.
curl --anyauth --user <user>:<password> -X 'GET' \
'http://<device-ip>/config/rest/analytics-mqtt/v1beta/data_sources' \
-H 'Accept: application/json'
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": {
"data_sources": [
{
"key": "com.axis.analytics_scene_description.v0.beta#1"
},
{
"key": "com.axis.consolidated_track.v1.beta#1"
}
]
}
}
Or use the Swagger UI for /analytics-mqtt/v1beta/data_sources
:
http://<device-ip>/config/web-ui/swagger-ui/?url=/config/discover/apis/analytics-mqtt/v1/openapi.json#/analytics-mqtt.v1beta.data_sources/get_analytics_mqtt_v1beta_data_sources
Step 2: Create a new analytics MQTT data publisher
Now we'll create a new analytics MQTT data publisher with the following setup id=my_publisher_id
, data_source_key=com.axis.consolidated_track.v1.beta#1
and mqtt_topic=my_test_mqtt_topic
using a POST
method.
If you would like to retrieve the output data from the Fusion Tracker module instead, you would do data_source_key=com.axis.analytics_scene_description.v0.beta#1
.
The data after #
, i.e 1
represents the origin of the data.
In this case a module instance corresponding to the video source that the module instance uses as input.
If working with a multidirectional camera, 2
, 3
and 4
might also be available.
Don't forget to replace <device-ip>
, <user>
and <password>
where applicable.
curl --anyauth --user <user>:<password> -X 'POST' \
'http://<device-ip>/config/rest/analytics-mqtt/v1beta/publishers' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"data": {"id": "my_publisher", "data_source_key": "com.axis.consolidated_track.v1.beta#1", "mqtt_topic": "my_mqtt_topic"}}'
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": [
{
"id": "my_publisher_id",
"key": "com.axis.consolidated_track.v1.beta#1",
"mqtt_topic": "my_test_mqtt_topic",
"qos": 0,
"retain": false,
"use_topic_prefix": false
}
]
}
Or use the Swagger UI for /analytics-mqtt/v1beta/publishers
:
http://<device-ip>/config/web-ui/swagger-ui/?url=/config/discover/apis/analytics-mqtt/v1/openapi.json#/analytics-mqtt.v1beta.publishers/post_analytics_mqtt_v1beta_publishers
Step 3: Retrieve existing analytics MQTT data publishers
Let's now retrieve the existing analytics MQTT producers by the following GET
method.
Don't forget to replace <device-ip>
, <user>
and <password>
where applicable.
curl --anyauth --user <user>:<password> -X 'GET' \
'http://<device-ip>/config/rest/analytics-mqtt/v1beta/publishers' \
-H 'Accept: application/json'
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": [
{
"id": "my_publisher_id",
"key": "com.axis.consolidated_track.v1.beta#1",
"mqtt_topic": "my_test_mqtt_topic",
"qos": 0,
"retain": false,
"use_topic_prefix": false
}
]
}
Or use the Swagger UI for /analytics-mqtt/v1beta/publishers
:
http://<device-ip>/config/web-ui/swagger-ui/?url=/config/discover/apis/analytics-mqtt/v1/openapi.json#/analytics-mqtt.v1beta.publishers/get_analytics_mqtt_v1beta_publishers
Step 4 Remove an analytics MQTT data publisher (Optional)
Finally, let's clean up and remove the existing analytics MQTT data publisher using the DELETE method.
Don't forget to replace <device-ip>
, <user>
and <password>
where applicable.
curl --anyauth --user <user>:<password> -X 'DELETE' \
'http://<device-ip>/config/rest/analytics-mqtt/v1beta/publishers/my_publisher_id' \
-H 'Accept: application/json'
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success"
}
Or use the Swagger UI for /analytics-mqtt/v1beta/publishers
:
http://<device-ip>/config/web-ui/swagger-ui/?url=/config/discover/apis/analytics-mqtt/v1/openapi.json#/analytics-mqtt.v1beta.publishers/delete_analytics_mqtt_v1beta_publishers__id1_