Metavision Viewer

This tool allows you to stream events from an event-based device or an event file (RAW, DAT or HDF5) and visualize them on a screen. It is also possible to set an ROI and enable the ERC as well as save and load the camera settings to and from a camera settings file.

All those actions are performed using Metavision SDK Driver API. Hence this tool can be used a starting point for your own developments.

The C++ source code of this tool can be found in <install-prefix>/share/metavision/sdk/driver/cpp_samples/metavision_viewer when installing Metavision SDK from installer or packages. For other deployment methods, check the page Path of Samples.

Expected Output

The tool visualizes events acquired from an event-based camera or an event file:

Expected Output from Metavision Viewer tool

How to start

You can directly execute pre-compiled binary installed with Metavision SDK or compile the C++ source code as described in this tutorial.

To start the viewer based on the live stream from your camera, run:

Linux

metavision_viewer

Windows

metavision_viewer.exe

Note

If your camera is not detected and you get the error “Camera not found. Check that a camera is plugged into your system and retry”, please refer to our camera troubleshooting FAQ entry.

To start the viewer based on recorded data, provide the full path to a RAW, DAT or HDF5 file (here, we use a file from our Sample Recordings):

Linux

metavision_viewer -i traffic_monitoring.hdf5

Windows

metavision_viewer.exe -i traffic_monitoring.hdf5

To use the tool to record the live stream from your camera, use the -o option and provide the full path to an output RAW file:

Linux

metavision_viewer -o /path/to/my_record.raw

Windows

metavision_viewer.exe -o /path/to/my_record.raw

If you use this sample to record data, you should perform some checks and configuration to optimize the quality of the data you will collect. Please refer to the section Recording from live camera from Metavision Studio page where we mention camera installation, lighting conditions, focus adjustment and multiple camera settings.

In Metavision Viewer the camera settings (biases, ROI, Anti-Flicker etc.) can be given as an input using the command line option --input-camera-config (or -j). This option accepts JSON files described in the camera settings section of the “Tuning the camera settings” programming guide. You can create such a JSON file by pressing “s” while metavision_viewer is streaming from your camera. Then, you can update this file to use custom camera settings fitting your needs.

To check for additional options:

Linux

metavision_viewer -h

Windows

metavision_viewer.exe -h

Going Further

Like mentioned above, this sample code is a good starting point to build your own viewer/recorder. One thing you may want to explore is the effect of various software algorithms on your event stream. For example, here are the steps to follow to add a PolarityFilter:

  1. at the top of your C++ file, add the include for the filter:

    #include <metavision/sdk/core/algorithms/polarity_filter_algorithm.h>
    
  2. create an instance of your filter. For example you can do it just before the “Setup camera CD callback” block:

    auto algo = Metavision::PolarityFilterAlgorithm(0);
    
  3. in the camera callback, pass the filter to the lambda and process your events:

    int cd_events_cb_id =
    camera.cd().add_callback([&cd_frame_generator_mutex, &cd_frame_generator, &cd_rate_estimator, &algo](
                                 const Metavision::EventCD *ev_begin, const Metavision::EventCD *ev_end) {
        std::unique_lock<std::mutex> lock(cd_frame_generator_mutex);
        // we use a vector of CD events to store the output of the algo
        std::vector<Metavision::EventCD> output;
        algo.process_events(ev_begin, ev_end, std::back_inserter(output));
        // we call the frame generator and rate estimator on the processed events
        cd_frame_generator.add_events(&output[0], &output[0] + output.size());
        if (!output.empty()) {
            cd_rate_estimator.add_data(output.back().t, output.size());
        }
    });