Edge AI Manager Module Socket Interface

This page describes the socket interface of the the Scailable Edge AI Manager Module
The Scailable Edge AI Manager Module hosts a Unix domain socket on which it accepts messages. These messages can be used to control the module, or to send input tensors. The socket path is determined by the ModuleSocketName setting, and defaults to sclbl/sockets/sclblmod.sock .
All socket messages to the module must start with a header exactly 4 bytes long, which declares the length of the incoming message (excluding the 4 bytes header).
All socket messages to the module must be Json format with a messageType field in its root object. The module will use this field to determine how to handle the incoming message.

Trigger Inference

A socket message can be sent to trigger an inference. This will only have effect if the ExternalTrigger setting is active. After this message is sent, the module will fetch input from the configured input and run inference.
messageType : "COMMAND" Command : "TriggerInference" Json example:
{
"messageType": "COMMAND",
"Command": "TriggerInference"
}

Signal Messages

Signal messages are process signals which are usually sent with a command such as kill and can be used to interrupt the process or kill it immediately.
messageType : "SIGNAL" Signal : <number> For example, to safely stop the module's execution:
{
"messageType":"SIGNAL",
"Signal":2
}

Tensor Inputs

It is possible to send input tensors to the module through it's socket input. These input tensors can take a few forms, which will be outlined below.
By default, the input driver for the AI Manager is set to "VIDEO", which means the AI Manager will fetch its inputs from the configured camera(s). This setting, however, can be changed in the InputDriver setting to "SOCKET". When this is done, the AI Manager will wait for input from its input socket, and perform inference on it once received. The socket path to send the tensors to is controlled by the ModuleSocketName setting.
Sending messages to the Edge AI Manager over socket while the InputDriver is not set to "SOCKET" will result in the input message being ignored.
Each input message has a couple of optional fields: AssignedModelsCFID : < The assigned model CFID's to use for inference as an array of strings. If not given, inference will be run on all assigned models. > Passthrough : <Passthrough Information>
The socket input allows for a passthrough object to be sent. This object will be added to the output tensor without being altered. This is a method for matching output to input by using IDs or timestamps etc.

Generic Json Input Tensor

It is possible to send input tensors to the module as part of a Json message. The input tensor will be considered as generic, and will not be processed in any way.
To send a generic tensor via socket to the Edge AI Manager, a JSON formatted message with a specific structure is expected. Find an example below:
{
"messageType":"SocketInput",
"InputTensor":
{
"input":"AIA7RAAA6EEAAGhCAABoQs3MIEIAAAAA"
},
"Passthrough":
{
"frameNumber":1
}
}
messageType : "SocketInput" InputTensor : <Information about the tensor> input : <The input tensor as a base64 encoded string>

Raw Image Input Tensor

It is possible to send a raw image as input tensor through the input socket. This is an efficient way to transfer large amounts of data on the same device.
This input message is sent in two parts, and it's important to send them in order. The first part is a Json string message, which describes the input data, including the length of the raw data. The module will parse this part of the message, then wait for the second part of the message, which is the raw image data.
The first Json message has a few required fields, and a few optional fields:
Required: messageType : "RawImage" DataLength : <The length of data of the raw image in bytes> Width : <The pixel width of the image> Height : <The pixel height of the image> Channels : <The amount of channels of the image>
Optional: CroppingMethod : < The image cropping method as a number. See InputCameraXAspectRatio > (Default: 2) Masks : < The input masks, as an array of pixel coordinate arrays. See InputCameraXMask > (Default: Empty) MaskType : < Type of mask. Can either be "inclusive" or "exclusive" > (Default: "inclusive")
Additionally, when a linecrossing model is assigned, the linecrossing settings can be sent with each input image. If the settings are sent without a linecrossing model being assigned, the settings will be ignored.
LineCrossingSettings : < Object containing line crossing settings
LineCoordinates : < An array of integers defining the line coordinates in the format xyxy >
DistanceThreshold : < (Optional) A value defining the threshold for detecting linecrossing >
> See settings InputCameraXLineCrossingX1 and InputCameraXLineCrossingDistanceThreshold for the definition of these settings.
Example input:
{
"messageType": "RawImage",
"DataLength": 2764800,
"Width": 1280,
"Height": 720,
"Channels": 3,
"CroppingMethod": 2,
"Masks": [
[171, 119, 171, 493, 493, 497, 482, 126],
[757, 149, 751, 540, 1067, 544, 1060, 160]
],
"MaskType": "inclusive",
"Passthrough": {
"Timestamp": 1686654724051500
},
"AssignedModelsCFID": [
"150531f5-034c-4adc-bdcf-e344692eca0b",
"554dd69b-5f08-46ed-86f0-1a7cedd6f80f"
]
}