Tutorial 6: Filter events by polarity

In this tutorial we will see how to use one of the available Metavision Designer components to output only events of a certain polarity.

This tutorial does not introduce any additional concepts with respect to the previous tutorials, it only provides an additional example of a simple pipeline.


The first step is to load a DAT video and create the FileProducer to read it.

import metavision_designer_engine as mvd_engine
import metavision_designer_core as mvd_core
import metavision_designer_cv as mvd_cv

input_path = 'PATH_TO_DAT'

# Create controller
controller = mvd_engine.Controller()

# Create producer
cd_prod = mvd_core.FileProducer(input_path)
controller.add_component(cd_prod, "Events producer")

Building the pipeline

We will now create the pipeline by adding the different components to the controller.

In this tutorial we will implement the following pipeline:

Let’s now instantiate the components.

PolarityFilter component is used to output only events of one polarity.

To instantiate a PolarityFilter we need to pass 2 arguments:

  1. the source component producing the events to filter (cd_prod)

  2. which polarity you want to keep: 0 ==> keep only OFF events, 1 ==> keep only ON Events

polarity_filter = mvd_core.PolarityFilter(cd_prod, 0)
controller.add_component(polarity_filter, "Polarity filter")

Now let’s instantiate the components required for the visualization: the FrameGenerator and the ImageDisplayCV.

#frame generator, that will create 2D Buffers from events
frame_gen = mvd_core.FrameGenerator(polarity_filter)
controller.add_component(frame_gen, "Frame generator")

#ImageDisplayCV to display 2D buffers generated by frame_gen
img_disp = mvd_core.ImageDisplayCV(frame_gen)
controller.add_component(img_disp, "Display")
controller.add_renderer(img_disp, mvd_engine.Controller.RenderingMode.SimulationClock, 25.)

We are all set! Let’s now run the pipeline and display only the wanted events!

while not (controller.is_done()):


The expected output is the following:

We finally delete the graphical components, to stop the tutorial properly.

del img_disp


This tutorial was created using Jupiter Notebooks

Download the source code.