Using Custom Algorithms

Updated: April 19, 2023

You can integrate custom algorithms into applications built using the ADAS library.

You can use hooks to create a library to support your custom algorithms. To integrate your custom algorithms, do the following steps:

  1. Provide your custom algorithm library with implementations for the following functions from the adas_external_algo.h header file:
    probe(adas_fusion_algo_preferences_t *preferences)
    For more information, see adas_fusion_algo_probe_t.”
    open(uint32_t id, adas_fusion_algo_handle_t *return_handle, char *params)
    For more information, see adas_fusion_algo_open_t.”
    process_sensor_buffer(adas_fusion_algo_handle_t algo_handle, const adas_sensor_properties_t *sensor_properties, const adas_sensor_buffer_t * sensor_buffer, const adas_fusion_buffer_t ** return_buffer)
    For more information, see adas_fusion_algo_process_sensor_buffer_t.”
    close(adas_fusion_algo_handle_t algo_handle)
    For more information, see adas_fusion_algo_close_t.”
  2. Create an adas_ext_algorithm_t instance called adas_ext_algorithm_defs and assign your camera driver functions using this opaque data type.
    adas_ext_algorithm_t adas_ext_algorithm_defs = {
        .probe = my_probe_function,
        .open = my_open_algo_instance_function,
        .process_sensor_buffer = my_process_buffer_function,
        .close = my_close_function
    };
    Note: In your algorithm code, you must use adas_ext_algorithm_defs as the variable name for the adas_ext_algorithm_t instance. The ADAS library links the algorithm code to integrate it with your application.
  3. In the file that declares adas_ext_algorithm_defs, you need to specify #define ADAS_EXT_ALGO_API_IMPLEMENT prior to including adas_external_algo.h or any other ADAS library header file. This is necessary to ensure backwards compatibility with future versions of the library. This can be done as follows:
    #define ADAS_EXT_ALGO_API_IMPLEMENT
    #include <adas/adas_external_algo.h>
  4. In the configuration file, set the algorithm properties by setting id to ADAS_ALGO_CUSTOM and path to the location of your custom algorithm library. Optionally, you can use the parameters property to pass a string to the library. For more information about the algorithm object in the configuration file, see Algorithms.” For example:
    {
    ...
    ...
    "algorithm": [
            {
                "id": "ADAS_ALGO_CUSTOM",
                "path": "libfinger_count_algo_example.so",
                "parameters": "five"
                "input": [
                    {
                        "id": "forward_camera"
                    }
                ],
                "output": [
                    {
                        "type": "viewer",
                        "instance": 1
                    }
                ]
            }
        ],
    ...
    ...

Examples of using custom algorithms are available with the Sensor Framework for QNX SDP from the QNX Software Center. For more information, see the source directory in your host installation at $QNX_BASE/source/adas-opencv-examples-version.zip. After you extract the ZIP file, you'll find the example at extraction_directory/source_package_adas_opencv_algorithms/apps/adas/adas_algo_plugins.