Events Recording to files

Using HAL C++ API

While a device is streaming, the raw stream can be recorded to a file using HAL API as shown in the metavision_hal_showcase sample:

Metavision::I_EventsStream *i_eventsstream = device->get_facility<Metavision::I_EventsStream>();
if (i_eventsstream) {
    i_eventsstream->log_raw_data(raw_file_path);
    }
}

Every RAW file contains a header with information about the actual device and plugin that generated it. See details about the file format in ou RAW file page.

To replay a RAW file, the function Metavision::DeviceDiscovery::open_raw_file() creates a Metavision::Device instance able to stream data from the RAW file and behaving similarly to a live device, but with the hardware control features disabled (i.e. biases, ROI etc).

Similarly than the real device, the open_raw_file function iterates over all the available plugins to find one that is able to read and decode the data from the file. The first one found to be compatible is used.

Using SDK Stream C++ API

SDK Stream C++ API provides start_recording and stop_recording in the Camera class:

camera = Metavision::Camera::from_first_available();
camera.start();
camera.start_recording(raw_file_path);
(...)
camera.stop_recording(raw_file_path);
camera.stop();

Check out the metavision_viewer sample to see those functions in action.

Using SDK Core Python API

To record a RAW file using the SDK Core Python API, you need to use the Python binding of the HAL EventsStream facility (get_i_events_stream()) to have access to the functions log_raw_data() and stop_log_raw_data() . Here are the main statements allowing to handle a recording:

device = initiate_device("")
if device.get_i_events_stream():
    device.get_i_events_stream().log_raw_data(file_path)
mv_iterator = EventsIterator.from_device(device=device)
for evs in mv_iterator:
    // events will be recorded automatically but we can also process/display them
device.get_i_events_stream().stop_log_raw_data()

Check out the metavision_simple_recorder sample to see those functions in action.

Note

If you are using the lower level HAL Python API as shown in the metavision_hal_get_started sample recording the stream from the camera is done in a similar way. The only difference is the way to create your device object:

device = DeviceDiscovery.open("")
device.get_i_events_stream().log_raw_data(file_path)
(...)
device.get_i_events_stream().stop_log_raw_data()