Designer Core API

class metavision_designer_core.CdProducer(self: metavision_designer_core.CdProducer, device: metavision_designer_core.HalDeviceInterface)None

Produces CD events from a HalDeviceInterface.

Specialized EventCD producer collecting events from a physical device, using Metavision Hardware Abstraction Layer.

Parameters

device (HalDeviceInterface) – Device interface to poll events from.

class metavision_designer_core.ExtTriggerProducer(self: metavision_designer_core.ExtTriggerProducer, device: metavision_designer_core.HalDeviceInterface)None

Produces External Trigger events from a HalDeviceInterface.

Specialized EventExtTrigger producer capable of collecting events from a physical device, using Metavision Hardware Abstraction Layer.

Parameters

device (HalDeviceInterface) – Device interface to poll events from.

class metavision_designer_core.FileProducer(self: metavision_designer_core.FileProducer, filename: str, loop: bool = False, offset: int = 0)None

Reads CD events from DAT file.

FileProducer allows to read DAT files containing CD events. These events are then outputted as Event2d stream.

Parameters
  • filename (string) – Name of the file to read events from

  • loop (boolean, optional) – Allows to loop on the file (default : False)

  • offset (int, optional) – Time interval between two consecutive loops, in microseconds (default : 0)

get_height(self: metavision_designer_core.FileProducer)int

Gets the sensor’s height of the events stream

Returns

Height in pixels

Return type

int

get_width(self: metavision_designer_core.FileProducer)int

Gets sensor’s width of the events stream

Returns

Width in pixels

Return type

int

start_at_time(self: metavision_designer_core.FileProducer, offset: int)None

Starts to read the data at the given timestamp

Parameters

offset (int) – Start time offset (in us)

class metavision_designer_core.FileProducerTrigger(self: metavision_designer_core.FileProducerTrigger, filename: str, loop: bool = False, offset: int = 0)None

Reads trigger events from DAT file.

FileProducerIMU allows to read DAT files containing trigger events.

Parameters
  • filename (string) – Name of the file to read IMU events from

  • loop (boolean, optional) – Allows to loop on the file (default : False)

  • offset (long, optional) – Time interval between two consecutive loops. in microseconds (default : 0)

start_at_time(self: metavision_designer_core.FileProducerTrigger, offset: int)None

Starts to read the data at the given timestamp

Parameters

offset (int) – Start time offset (in us)

class metavision_designer_core.FlipXFilter(self: metavision_designer_core.FlipXFilter, source: metavision_designer_engine.Producer)None

Flips the events along the x Axis.

FlipXFilter consumes an Event2d stream, and flips x coordinates along X axis. The generated output is an Event2d stream whose x coordinates are x = xmax - x.

Parameters

source (Producer) – Input Event2d producer

class metavision_designer_core.FlipYFilter(self: metavision_designer_core.FlipYFilter, source: metavision_designer_engine.Producer)None

Flips the events along the y Axis.

FlipYFilter consumes an Event2d stream, and flips y coordinates along y axis. The generated output is an Event2d stream whose y coordinates are y = ymax - y.

Parameters

source (Producer) – Input Event2d producer

class metavision_designer_core.FrameComposer(self: metavision_designer_core.FrameComposer, background_b: int = 0, background_g: int = 0, background_r: int = 0)None

Generates a 2D image by composing the output of multiple 2D array producers.

FrameComposer consumes 2D array streams from multiple producers. The 2D arrays are drawn in a new 2D array stream, that can then be consumed by a renderer like ImageDisplayCV or VideoWriter. Once the FrameComposer has received the position and size of a 2D input, one can start producing on this 2D array stream.

Parameters
  • background_b (int) – Blue component of the background (from 0 to 255)

  • background_g (int) – Green component of the background (from 0 to 255)

  • background_r (int) – Red component of the background (from 0 to 255)

add_image(self: metavision_designer_core.FrameComposer, source: metavision_designer_engine.Producer, x: int, y: int, width: int, height: int, enable_crop: bool = False, cmap: int = - 1, min_rescaling_value: int = 0, max_rescaling_value: int = 255)None

Adds a 2D array source to the composition

Parameters
  • source (Producer) – 2D array input producer

  • x (int) – X-position of the image in the composition

  • y (int) – Y-position of the image in the composition

  • width (int) – X-size of the image in the composition

  • height (int) – Y-size o the image in the composition

  • enable_crop (bool) – Activate cropping

  • cmap (int) –

    Colormap to set

    No Colormap = Negative value

    COLORMAP_AUTUMN = 0

    COLORMAP_BONE = 1

    COLORMAP_JET = 2

    COLORMAP_WINTER = 3

    COLORMAP_RAINBOW = 4

    COLORMAP_OCEAN = 5

    COLORMAP_SUMMER = 6

    COLORMAP_SPRING = 7

    COLORMAP_COOL = 8

    COLORMAP_HSV = 9

    COLORMAP_PINK = 10

    COLORMAP_HOT = 11

  • min_rescaling_value (int) – Min grayscale value for the rescaling

  • max_rescaling_value (int) – Max grayscale value for the rescaling

get_total_height(self: metavision_designer_core.FrameComposer)int

Returns the height of the output image

Returns

Height of the output image

Return type

int

get_total_width(self: metavision_designer_core.FrameComposer)int

Returns the width of the output image

Returns

Width of the output image

Return type

int

class metavision_designer_core.FrameGenerator(*args, **kwargs)

Generates images from Event2d streams

FrameGenerator consumes an Event2d stream, and generates images by accumulating events on a defined time slice. By default, each image will accumulate 40ms of events. The accumulation time can be changed by calling set_dt() function.

Parameters
  • source (Producer) – Producer source providing the Event2D stream

  • on_intensity (float, optional) – Intensity of ON events (default : 1.0)

  • off_intensity (float, optional) – Intensity of OFF events (default : 1.0)

Overloaded function.

  1. __init__(self: metavision_designer_core.FrameGenerator, source: metavision_designer_engine.Producer) -> None

  2. __init__(self: metavision_designer_core.FrameGenerator, source: metavision_designer_engine.Producer, on_intensity: float, off_intensity: float) -> None

set_dt(self: metavision_designer_core.FrameGenerator, dt: int)None

Sets the accumulation time of each frame

Parameters

dt (int) – Accumulation time (in us)

class metavision_designer_core.HalDeviceInterface(*args, **kwargs)

Interface with the HAL device.

HalDeviceInterface creates an interface with the Metavision HAL allowing to read events from event-based cameras. Camera should be correctly configured to output events.

Parameters
  • device (object) – Device instance of a camera

  • polling_interval (float, optional) – Interval to poll data from the camera in seconds. Default to 0.001s (1ms)

Overloaded function.

  1. __init__(self: metavision_designer_core.HalDeviceInterface, device: Metavision::Device, polling_interval: float = 0.001) -> None

  2. __init__(self: metavision_designer_core.HalDeviceInterface, controller: metavision_designer_engine.Controller, device: Metavision::Device, polling_interval: float = 0.001) -> None

get_latest_error(self: metavision_designer_core.HalDeviceInterface)int

Gets the latest error code returned by the interface

Returns

The error code (0 if no error)

Return type

int

class metavision_designer_core.ImageDisplayCV(self: metavision_designer_core.ImageDisplayCV, source: metavision_designer_engine.Producer, autoscale: bool = False)None

Allows user to display images on the screen

ImageDisplayCV creates a Graphical window on the screen and displays frames from the 2D array output of components like FrameGenerator.

Parameters
  • source (Producer) – Input 2D array producer (e.g. FrameGenerator)

  • autoscale (bool, optional) – If True, enable autoscaling of the display (default : False)

set_window_position(self: metavision_designer_core.ImageDisplayCV, x: int, y: int)None

Sets the position of the window on the screen

Parameters
  • x (int) – x coordinate on the screen

  • y (int) – y coordinate on the screen

set_window_size(self: metavision_designer_core.ImageDisplayCV, width: int, height: int)None

Sets the window size of the display

Parameters
  • width (int) – Width of the window

  • height (int) – Height of the window

class metavision_designer_core.PolarityFilter(self: metavision_designer_core.PolarityFilter, source: metavision_designer_engine.Producer, pol: int)None

Propagates events of a chosen polarity only.

Parameters
  • source (Producer) – Component providing the input event stream

  • pol (int) – Polarity to keep

class metavision_designer_core.PolarityInverter(self: metavision_designer_core.PolarityInverter, source: metavision_designer_engine.Producer)None

Changes ON events into OFF events and vice-versa.

Parameters

source (Producer) – Component providing the input event stream

class metavision_designer_core.PythonConsumer(self: metavision_designer_core.PythonConsumer, callback: object)None

Consumer delivering data streams to the python application.

PythonConsumer consumes events streams and 2D arrays from any number of producers in the graph. Corresponding data is delivered to the application using a callback mechanism. Note that a single PythonConsumer can be instantiated in the python application. If multiple event streams are needed, use add_source_xxx to register multiple sources to the PythonConsumer. Find below example of callback.

Parameters

callback (object) – Python function to callback

Example

Below an example of a function callback to pass to the PythonConsumer.

>>> def callback(ts, src_events, src_2D_arrays):
        for src_name in src_events:
            buffer_event = src_events[src_name][2]
            dtype_obj_event = src_events[src_name][1]
            np_event_buffer = np.frombuffer(buffer_event, dtype=np.dtype(dtype_obj_event))
            # ...
        for src_2d_name in src_2D_arrays:
            buffer_shape = src_2D_arrays[src_2d_name][0]
            dtype_obj_buffer = src_2D_arrays[src_2d_name][1]
            buffer_2D = src_2D_arrays[src_2d_name][2]
            np_2D_buffer = np.ndarray(shape=buffer_shape, dtype=dtype_obj, buffer=buffer_2D)
add_source(self: metavision_designer_core.PythonConsumer, source: metavision_designer_engine.Producer, name: str)None

Adds an Event2d source to the PythonConsumer

Parameters
  • source (Producer) – the component providing the events

  • name (str) – the name of the source. Useful to find data corresponding to a specific source.

add_source_ext_trigger(self: metavision_designer_core.PythonConsumer, source: metavision_designer_engine.Producer, name: str)None

Adds an EventExtTrigger source to the PythonConsumer

Parameters
  • source (Producer) – the component providing the events

  • name (str) – the name of the source. Useful to find data corresponding to a specific source.

class metavision_designer_core.RoiFilter(self: metavision_designer_core.RoiFilter, source: metavision_designer_engine.Producer, x0: int, y0: int, x1: int, y1: int, reset_orig: bool = False)None

Propagates events contained in a fixed Region of Interest.

ROI is defined by a constant rectangle. Upper left corner coordinates is (x0, y0) and lower right corner is (x1, y1). The RoiFilter propagates the events (x,y) that validate: x in [x0, x1] and y in [y0, y1]

Parameters
  • source (Producer) – Component providing the input EventCD stream

  • x0 (int) – X coordinate of the upper left corner of the ROI window

  • y0 (int) – Y coordinate of the upper left corner of the ROI window

  • x1 (int) – X coordinate of the lower right corner of the ROI window

  • y1 (int) – Y coordinate of the lower right corner of the ROI window

  • reset_orig (bool, optional) – Subtract (x0, y0) in output events addresses (default : False)

set_x0(self: metavision_designer_core.RoiFilter, x0: int)None

Sets x0 coordinate

Parameters

x0 (int) – x coordinate of the upper left corner of the ROI window

set_x1(self: metavision_designer_core.RoiFilter, x1: int)None

Sets x1 coordinate

Parameters

x1 (int) – x coordinate of the lower right corner of the ROI window

set_y0(self: metavision_designer_core.RoiFilter, y0: int)None

Sets y0 coordinate

Parameters

y0 (int) – y coordinate of the upper left corner of the ROI window

set_y1(self: metavision_designer_core.RoiFilter, y1: int)None

Sets y1 coordinate

Parameters

y1 (int) – y coordinate of the lower right corner of the ROI window

class metavision_designer_core.StreamLogger(self: metavision_designer_core.StreamLogger, source: metavision_designer_engine.Producer, filename: str)None

Logs an event source in a DAT file.

StreamLogger is a consumer component that retrieves any event stream generated by a producer and logs the corresponding events in a DAT file.

Parameters
  • source (Producer) – Source for the event stream to log

  • filename (str) – Name of the file to create

change_destination(self: metavision_designer_core.StreamLogger, filename: str, reset_ts: bool = True)None

Changes the destination file of the logger

Parameters
  • filename (str) – Name of the file to write into

  • reset_ts (bool, optional) – If True, resets the timestamp in the new file

enable(self: metavision_designer_core.StreamLogger, state: bool, reset_ts: bool = True)None

Enables or disables the data logging

Parameters
  • state (bool) – If True, logging is enabled

  • reset_ts (bool, optional) – If True, consider first event timestamp to be zero. Default is True

enable_split(self: metavision_designer_core.StreamLogger, state: bool, split_time: int = 300)None

Enables or disables the automatic split of files

Parameters
  • state (bool) – If True, split is enabled

  • split_time (int, optional) – Time in seconds to split the file. Default is 300

class metavision_designer_core.VideoWriter(self: metavision_designer_core.VideoWriter, src: metavision_designer_engine.Producer, filename: str, fps: float = 25.0, autoscale: bool = False, color: bool = True, codec: str = 'MJPG')None

Generates video files from 2D array producers

VideoWriter creates video files consuming the successive 2D array outputs of a producer. Video files are created using OpenCV and fourCC codecs. The input framerate of the video is set by the frequency of the rendering. The controller slice duration must be compatible with the rendering rate.

Parameters
  • src (Producer) – Producer source providing the 2D array

  • filename (str) – Name of the video file to create

  • fps (float, optional) – Frame rate of the created video (default : 25.)

  • autoscale (bool, optional) – Scale 2D input at each rendering (default : False)

  • color (bool, optional) – Save video output in color (default : True)

  • codec (str, optional) – Fourcc codec (default : ‘MJPG’)

autoscale(self: metavision_designer_core.VideoWriter)None

Automatically finds the scaling factors

enable(self: metavision_designer_core.VideoWriter, state: bool)None

Enables or pauses the video writer

Parameters

state (bool) – State of video writer

enable_ts_in_display(self: metavision_designer_core.VideoWriter, state: bool)None

Overlays current timestamp on the generated images

Parameters

state (bool) – State of timestamp overlay

remove_colormap(self: metavision_designer_core.VideoWriter)None

Removes any colormap and goes back to direct rendering

scale(self: metavision_designer_core.VideoWriter, min: float, max: float)None

Sets scaling factors for color computation in display

Parameters
  • min (float) – Minimum value to render

  • max (float) – Maximum value to render

set_colormap(self: metavision_designer_core.VideoWriter, cmap: cv::ColormapTypes)None

Sets the colormap to use for rendering.

Parameters

cmap (ColorMap) – Colormap to set