Designer Core API

class metavision_designer_core.CdProducer

Produces CD events from a HalDeviceInterface.

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

Args:

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

class metavision_designer_core.ExtTriggerProducer

Produces External Trigger events from a HalDeviceInterface.

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

Args:

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

class metavision_designer_core.FileProducer

Reads CD events from DAT file.

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

Args:

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:

int: Height in pixels

get_width(self: metavision_designer_core.FileProducer) → int

Gets sensor’s width of the events stream

Returns:

int: Width in pixels

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

Starts to read the data at the given timestamp

Args:

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

class metavision_designer_core.FileProducerTrigger

Reads trigger events from DAT file.

FileProducerIMU allows to read DAT files containing trigger events.

Args:

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

Args:

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

class metavision_designer_core.FlipXFilter

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.

Args:

source (Producer): Input Event2d producer

class metavision_designer_core.FlipYFilter

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.

Args:

source (Producer): Input Event2d producer

class metavision_designer_core.FrameComposer

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.

Args:

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

Args:

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:

int: Height of the output image

get_total_width(self: metavision_designer_core.FrameComposer) → int

Returns the width of the output image

Returns:

int: Width of the output image

class metavision_designer_core.FrameGenerator

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.

Args:

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)

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

Sets the accumulation time of each frame

Args:

dt (int): Accumulation time (in us)

class metavision_designer_core.HalDeviceInterface

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.

Args:

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)

last_timestamp (int, optional): Default to 0

get_latest_error(self: metavision_designer_core.HalDeviceInterface) → int

Gets the latest error code returned by the interface

Returns:

int: The error code (0 if no error)

class metavision_designer_core.ImageDisplayCV

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.

Args:

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

Args:

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

Args:

width (int): Width of the window

height (int): Height of the window

class metavision_designer_core.PolarityFilter

Propagates events of a chosen polarity only.

Args:

source (Producer): Component providing the input event stream

pol (int): Polarity to keep

class metavision_designer_core.PolarityInverter

Changes ON events into OFF events and vice-versa.

Args:

source (Producer): Component providing the input event stream

class metavision_designer_core.PythonConsumer

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.

Args:

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

Args:

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

Args:

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

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]

Args:

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

Args:

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

Args:

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

Args:

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

Args:

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

class metavision_designer_core.StreamLogger

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.

Args:

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

Args:

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

Args:

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

Args:

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

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.

Args:

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

Args:

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

Args:

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

Args:

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.

Args:

cmap (ColorMap): Colormap to set