HAL Architecture

Metavision HAL

Introduction to HAL

The HAL (Hardware Abstraction Layer) is designed as an API to access event-based camera hardware functionalities in a generic way by defining high-level capability interfaces generalizing these functionalities. The purpose of this generic API is to enable operating different event-based cameras from a unified API. This makes it much easier:

  • for camera manufacturers to integrate with existing event-based applications

  • for application developers to support different devices

The dynamic plugin-based architecture of HAL also enables each camera manufacturer to make different system integration choices. For example, the board communication can be implemented using any protocol (USB, MIPI, Ethernet, etc.) as explained in the the Treuzell Protocol page.

HAL Components

The generic access to camera functionalities is achieved using high-level capability interfaces called facilities, which define the standard high-level behavior of each camera functionality. For example, different event-based sensors can implement the concept of Region Of Interest (ROI) in various ways (typically with a series of register accesses) but HAL provides a single I_ROI facility that proposes multiple functions that can be used on those multiple sensors/cameras (Metavision::I_ROI::set_window(), Metavision::I_ROI::enable()…).

When a new camera functionality needs to be supported by the HAL API, a new facility representing it is typically introduced, without impact on other cameras not supporting this functionality.

A given camera is operated using the corresponding HAL plugin, which is maintained and distributed by the device manufacturer.

The plugin is provided in the form of a shared library containing the implementations of the HAL facilities for each hardware feature supported by the device.

The selection of the plugin is done via the HAL Discovery mechanism that will enumerate and select the appropriate plugin for a given device as explained in the next section.

This dynamic plugin-based design enables any application built using Metavision HAL to be compatible, without any modification (compilation or link), with any camera providing its plugin.

The following diagram summarizes the relationships between those different components:

HAL Architecture

Device Discovery

HAL device discovery mechanism allows to build a Metavision::Device. The discovery entry point is the function DeviceDiscovery::open. This function will go through the following steps involving both the HAL module and the Plugin code:

  • get the list of the available plugins (plugins loading phase)

  • find and select the plugin that matches the camera

  • find a Camera Discovery from the selected plugin capable of opening the camera

  • build and return the Metavision::Device

This flow is shown in the following diagram depicting the cascade of calls:

HAL Discovery

Note that, when opening a RAW file, the device discovery behaves almost the same except that compatible plugins are first sorted in order of matching likelihood (priority to matching integrator and plugin names, then matching integrator name and finally any compatible plugin).

HAL Facilities

Facilities provide functions that expose a camera functionality (e.g ROI, biases, digital crop, etc.). The Metavision::I_Facility abstract class is the main class from which all other facilities inherit. A given facility interface exposes a functionality by defining virtual functions, for which plugins supporting this functionality must provide implementations.

From the user point of view, if a facility is available, it is expected that the corresponding camera functionality is available and can be used.

The main facilities are :

This list is not exhaustive and many other facilities exist (I_LL_Biases, I_Monitoring, etc.). Refer to the facility API documentation for more information.

Next Steps

From here, depending on your interest, you can: