SDK Core ML Preprocessing API

Preprocessing functions in Pytorch They take (N,5) events in (b,x,y,p,t) format.

metavision_core_ml.preprocessing.event_to_tensor_torch.event_cd_to_torch(events)

Converts Events to Torch array Note that Polarities are mapped from {0;1} to {-1;1}

Parameters

events (EventCD) – structured array containing N events

Returns

(Tensor) N,5 in batch_index, x, y, polarity, timestamp (micro-seconds) where the batch index value is 0.

metavision_core_ml.preprocessing.event_to_tensor_torch.event_image(events, batch_size, height, width)

Densifies events into an image

Parameters
  • events (tensor) – N,5 (b,x,y,p,t)

  • batch_size (int) – batch size

  • height (int) – height of output image

  • width (int) – width of output image

metavision_core_ml.preprocessing.event_to_tensor_torch.event_volume(events, batch_size, height, width, start_times, durations, nbins, mode='bilinear', vol=None)

Densifies events into an volume (uniform cut)

Parameters
  • events (tensor) – N,5 (b,x,y,p,t)

  • batch_size (int) – batch size

  • height (int) – height of output volume

  • width (int) – width of output volume

  • start_times – (B,) start times of each volume

  • durations – (B,) durations for each volume

  • nbins (int) – number of time bins for output volume

  • mode (str) – either “bilinear” or “nearest” interpolation of voxels.

metavision_core_ml.preprocessing.event_to_tensor_torch.events_cd_list_to_torch(list_of_events_np_arrays)

Converts a list of Events CD numpy arrays into torch format (N,5) : batch_index, x, y, polarity_timestamp (micro-seconds) Note that Polarities are mapped from {0;1} to {-1;1}

Parameters

list_of_events_np_arrays (list of np.array) – list of structured arrays of EventCD

Returns

value of batch_index corresponds to the position of the event array in the input list

Return type

(Tensor) N,5

metavision_core_ml.preprocessing.event_to_tensor_torch.tensor_to_cd_events(events, batch_size, sort=True)

Convert the event produced by the GPU to our format for later reuse.

Parameters
  • events (np.array) – (N,5) in batch_index, x, y, polarity, timestamp (micro-seconds)

  • batch_size (int) – size of the batch

  • sort (boolean) – whether to sort event chronologically. You might want to avoid doing it if the algorithm you are using doesn’t rely on them.

Returns

list of EventCD arrays, of lenght batch_size

Creates a RGB frame representing the events given as input. :param events: structured array containing events :type events: np.ndarray :param height: Height of the sensor in pixels :type height: int :param width: width of the sensor in pixels :type width: int :param img: optional image of size (height, width, 3) and dtype unint8 to avoid reallocation :type img: np.ndarray

returns

Array of shape (height, width, 3)

rtype

output_array (np.ndarray)