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
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:
the source component producing the events to filter (cd_prod)
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
#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.) controller.enable_rendering(True)
We are all set! Let’s now run the pipeline and display only the wanted events!
controller.set_slice_duration(10000) controller.set_batch_duration(100000) while not (controller.is_done()): controller.run(True)