nx_metadata_sdk  1.0
Metadata SDK
Object Streamer Plugin

// Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/


Introduction

This Plugin is intended to be used for debugging/investigating/developing purposes and can generate any needed sequence of Objects that are taken from a specific user-generated file.

The Taxonomy of the generated Objects (their types and Attributes) must be defined in the Device Agent manifest - a .json file specified in the Device Agent settings. An example of such manifest is provided in manifest.json.

The Object stream to be "played back" by the Plugin is taken from the .json file specified in the Device Agent settings. An example of such file is provided in stream.json.

To generate a stream and manifest files, the provided generate.py script can be used.


Stream file format

A stream file is essentially a script which defines when and what metadata will be generated by the plugin. It is a JSON file containing an array of per-frame object entries. There are several types of entries like bounding boxes and best shots. The following fields are allowed for each entry:

Example:

{
"frameNumber": 0,
"typeId": "nx.base.Vehicle",
"trackId": "$$10",
"attributes": {
"Color": "Red",
"Brand": "Lada",
"Model": "2106",
"LicensePlate.Number": "A001AA",
"LicensePlate.State/Province": "77",
"LicensePlate.Country": "Russia"
},
"boundingBox": {
"x": 0.5822482733134051,
"y": 0.3331168814679488,
"width": 0.17938270955154084,
"height": 0.15537941471920017
}
},
{
"frameNumber": 0,
"typeId": "nx.base.Vehicle",
"trackId": "$$10",
"attributes": {
"Best Shot Type": "URL",
"Color": "Dark Red",
"Brand": "Mercedes",
"Model": "EQE",
"LicensePlate.Number": "KEN560",
"LicensePlate.State/Province": "05",
"LicensePlate.Country": "Kazakhstan"
},
"boundingBox": {
"x": 0.5822482733134051,
"y": 0.3331168814679488,
"width": 0.17938270955154084,
"height": 0.15537941471920017
},
"imageSource": "https://example.com/photos/200/300",
"entryType": "bestShot"
}

Stream generation script

The script generate.py can generate stream.json and manifest.json based on config.json. The example of config.json file is provided.

Command line options

Example:

generate.py --config config.json --manifest-file my_manifest.json --stream-file my_stream.json
--compressed-stream

Configuration file format

The configuration file is a simple JSON file with a JSON object at the top level. The following settings are available:

random Object template settings

All fields are optional.

Example

{
"objectCount": 5,
"streamDurationInFrames": 100,
"typeLibrary":
{
"objectTypes":
[
{
"id": "stub.objectStreamer.custom.type.1",
"name": "Stub OS: Custom Type 1"
}
]
},
"objectTemplates":
[
{
"objectTypeId": "nx.base.Vehicle",
"movementPolicy": "random",
"trackIdPolicy": "changeOncePerStreamCycle",
"minWidth": 0.1,
"minHeight": 0.1,
"maxWidth": 0.3,
"maxHeight": 0.3,
"attributes":
{
"Color": "Red",
"Brand": "Ford",
"Model": "F150",
"LicensePlate.Number": "LHD 8448",
"LicensePlate.State/Province": "Texas",
"LicensePlate.Country": "USA"
},
"bestShots": [
{
"imageSource": "https://picsum.photos/200/300",
"frameNumber": 10,
"attributes": {
"some attribute": "attribute value"
}
}
]
},
{
"objectTypeId": "stub.objectStreamer.custom.type.1",
"movementPolicy": "random",
"attributes":
{
"string attribute 1": "first string attribute",
"string attribute 2": "second string attribute",
"number attribute 1": "0.1",
"number attribute 2": "300"
}
}
]
}