Algorithms

Algorithms are defined in a single array named algorithm in JSON format.

Specifying algorithms is optional. If you are specifying algorithms, here is an example:

...
  "algorithm": [
        {
            "id": "ADAS_ALGO_CUSTOM",
            "path": "libmotion_detection_algo_example.so",
            "input": [
                {
                    "id": "forward_camera"
                }
            ],
            "output": [
                {
                    "type": "viewer",
                    "instance": 4
                }
            ]
        },
        {
            "id": "ADAS_ALGO_LIDAR_GROUPING",
            "input": [
                {
                    "id": "side_lidar"
                }
            ],
            "output": [
                {
                    "type": "viewer",
                    "instance": 3
                }
            ]
        },
        {
            "id": "ADAS_ALGO_RADAR_GROUPING",
            "input": [
                {
                    "id": "front_radar"
                }
            ],
            "output": [
                {
                    "type": "viewer",
                    "instance": 2
                }
            ]
        }
    ],
...

Attributes:

There are properties that you can use to configure an algorithm object:

id
(Required) The algorithm to apply. Valid algorithms are of type adas_algorithm_t.
If you specify ADAS_ALGO_CUSTOM, then you must also specify the path for your custom algorithm. For example:
...
  "algorithm": [
        {
            "id": "ADAS_ALGO_CUSTOM",
            "path": "/usr/share/algorithms/myAlgorithm.so
            "input": [
                {
                    "id": "forward_camera"
                }
            ],
            "output": [
                {
                    "type": "viewer",
                    "instance": 4
                }
            ]
        },
...
For more information, see Using Custom Algorithms.”
input
(Required) An array of one or more inputs that this algorithm applies to. Each entry in this array is defined by the id data. What you specify as the id must correspond to the id of one of the entries in your top-level input array that defines the inputs for the ADAS library. For more information on this other array, see Inputs. For example, if in your input array, you have this entry:
...
    "input": [
        {
            "source": "sensor",            
            "instance": "SENSOR_UNIT_1",
            "id": "forward_camera"
        },
        ...
     ]
...
then you can specify forward_camera as the id property in an entry of the input property for your algorithm. For example:
...
    "algorithm": [
        {
            ...
            "input": [
                {
                    "id": "forward_camera"
                }
            ],
...
parameters
(Only required with id:ADAS_ALGO_CUSTOM) A string to pass to the custom algorithm. The format you choose is dependent on the implementation of your library. For example, you could specify the string as a property/value pair as shown here, but no structure is actually imposed:
"parameters" = "horizon=33"
path
(Only required with id:ADAS_ALGO_CUSTOM) The path to the library. This must be a location specified by the LD_LIBRARY_PATH environment variable. For example, /lib/dll.
output
(Required) An array of one or more outputs for this algorithm. Each object in this array is defined by the following properties:
  • type
  • instance

Here, type can be set to viewer, and instance is the index of the viewer that's configured in the viewer array. The index is in range [1..n] where n is the total number of viewers in the array.

For example, if in your viewer array, you have these entries:
...
    "viewer": [
        {
            "type": "ADAS_VIEWER_CAMERA",
            ...
        },
        {
            "type": "ADAS_VIEWER_POINT_CLOUD",
            ...
        },
        {
            "type": "ADAS_VIEWER_OVERLAY",
            ...
        },
        {
            "type": "ADAS_VIEWER_NATIVE_CAMERA",
            ...
        }
        ],
...
then you can specify 3 (the viewer whose type is ADAS_VIEWER_OVERLAY) as the instance property in an entry of your output array for your algorithm. For example:
...
    "algorithm": [
        ...
            "output": [
                {
                    "type": "viewer",
                    "instance": 3
                }
            ]
...