SDK Core Algorithms¶
-
template<typename
Impl
>
classMetavision
::
AsyncAlgorithm
¶ An asynchronous events processor class.
Here, asynchronous means that the output of the processing is at variable frequency. This is useful when one wants to apply a process on events on the fly, and another specific one when a condition is fulfilled.
As opposed to frames that arrive at a fixed frequency, events are asynchronous. The event rate depends on the activity, and so the rate varies with time. In the context of event-based processing, it is often that one wants to apply a processing to events on the fly (online processing such as filling an histogram for instance) and another process when it is considered that enough events have been received (for example in term of events processed count, or time slice of events).
The only entry point of this algorithm is the public process_events method. This method will then call two internal processing methods (process_online and process_async) that should be defined by the user and be private. While the first one processes all events that are passed to process_events, the latter one is called whenever the asynchronous condition is met.
The asynchronous condition is user defined, and set via the various ‘set’ methods. See Processing for more details.
class MyAsyncProcess: public AsyncAlgorithm<MyAsyncProcess> { public: MyAsyncProcess() { positive_contrast_events_count_ = 0; negative_contrast_events_count_ = 0; // Will call process async every 3 events processed size_t max_events_to_process = 3; set_processing_n_events(max_events_to_process); } private: template<typename InputIt> inline void process_online(InputIt ev_begin, InputIt ev_end) { // Fills a vector of events events_.insert(events_.end(), ev_begin, ev_end); for (; ev_begin < ev_end; ++ev_begin) { if (ev_begin->p == 1) { ++positive_contrast_events_count_; std::cout << "Positive contrast event count: " << positive_contrast_events_count_ << std::endl; } else { ++negative_contrast_events_count_; std::cout << "Negative contrast event count: " << negative_contrast_events_count_ << std::endl; } } } inline void process_async() { std::cout << "Events processed: " << get_n_processed_events() << std::endl; std::cout << "Events buffer size: " << events_.size() << std::endl; if (positive_contrast_events_count_ > negative_contrast_events_count_) { process_positive_contrast_change(); } else { process_negative_contrast_change(); } positive_contrast_events_count_ = 0; negative_contrast_events_count_ = 0; events_.clear(); } inline void process_positive_contrast_change() { std::cout << "Got more positive contrast changes, applying positive contrast change process." << std::endl; // Apply processing to events_ } inline void process_negative_contrast_change() { std::cout << "Got more negative contrast changes, applying negative contrast change process." << std::endl; // Apply processing to events_ } size_t positive_contrast_events_count_, negative_contrast_events_count_; std::vector<EventCD> events_; friend class Metavision::AsyncAlgorithm<MyAsyncProcess>; }; int main(void) { std::vector<EventCD> my_events {{0,0,1,0}, {0,0,0,0}, {0,0,1,0}, {0,0,0,0}}; MyAsyncProcess async_process; async_process.process_events(my_events.cbegin(), my_events.cend()); async_process.flush(); // Expected output: // Positive contrast event count: 1 // Negative contrast event count: 1 // Positive contrast event count: 2 // Events processed: 3 // Events buffer size: 3 // Got more positive contrast changes, applying positive contrast change process. // Negative contrast event count: 1 // Events processed: 1 // Events buffer size: 1 // Got more negative contrast changes, applying negative contrast change process. }
- Warning
This class uses a Curiously Recursive Template Pattern design. The input template parameter is expected to be a base of this class and the base class should be declared as friend of the derived class.
- Template Parameters
Impl
: The Asynchronous process implementation.
Public Types
-
enum
Processing
¶ Processing types.
Processing policies that define the state to rely on to call the asynchronous process (process_async).
N_EVENTS: event count processing policy. Relies on the number of events processed. N_US: time slice processing policy. Relies on the timestamp of the input events. A time slice T holds events between [(n-1)*T; n*T[. MIXED: a mix between N_US and N_EVENTS processing policy. In this policy, the time slice has priority over the events count. SYNC: synchronous condition. process_async is called at the end of the process_events method. EXTERNAL: Relies on an external condition. process_async is called at each flush call.
Values:
-
enumerator
N_EVENTS
¶
-
enumerator
N_US
¶
-
enumerator
MIXED
¶
-
enumerator
SYNC
¶
-
enumerator
EXTERNAL
¶
-
enumerator
Public Functions
-
void
set_processing_n_events
(const int delta_n_events)¶ Function to call process_async every n events.
-
void
set_processing_n_us
(const timestamp delta_ts)¶ Function to call process_async every n microseconds.
-
void
set_processing_mixed
(const int delta_n_events, const timestamp delta_ts)¶ Function to call process_async every n events and n microseconds. The processing is done if at least one of the conditions is filled.
-
void
set_processing_sync
()¶ Function to call process_async after each process online.
-
void
set_processing_none
()¶ Function to only call process_events without calling process_async.
This is especially useful if the condition to trigger the creation of a buffer is independent from the content of the processed events (for instance, an external trigger events, an other algorithm condition, etc.). The user must then call flush when the condition is filled.
-
void
flush
()¶ Function to call process_async and update the internal state of the processing policy accordingly.
-
template<typename
InputIt
>
voidprocess_events
(InputIt it_begin, InputIt it_end)¶ Function that is calling process online and process state when necessary.
- Parameters
it_begin
: First iterator of the bufferit_end
: End iterator of the buffer
-
template<typename
InputIt
>
voidprocess_events
(const timestamp ts, InputIt it_begin, InputIt it_end)¶ Function that is calling process online and process state when necessary.
- Parameters
ts
: End timestamp of the buffer. Used if higher than the timestamp of the last eventit_begin
: First iterator of the bufferit_end
: End iterator of the buffer
-
int
get_n_processed_events
() const¶ Function to get the number of processed events since the last call to process async.
-
template<class
Event
>
classMetavision
::
FileProducerAlgorithmT
¶ Public Functions
-
FileProducerAlgorithmT
(std::string filename, bool loop = false, timestamp loop_delay = 0)¶ Builds a new FileProducerAlgorithmT object.
- Parameters
filename
: Name of the file to read data fromloop
: If true, the reading from the file will be loopedloop_delay
: Time interval (in us) between two consecutive loops
-
~FileProducerAlgorithmT
()¶ Destructor.
-
template<class
OutputIt
>
voidprocess
(OutputIt d_first, timestamp ts)¶ Processes events until a given timestamp.
-
bool
is_done
()¶ If all events have been processed, returns true.
-
timestamp
get_time_at
(timestamp time_window, bool backward)¶ Gets the timestamp in a given time window.
- Parameters
time_window
: Time difference (in us) with the first (or last) event in the filebackward
: If true, search will be from the end of the file (thus giving time last event - time_window)
-
void
start_at_time
(timestamp start_time)¶ Starts reproducing the file from a given time.
- Parameters
start_time
: Start time
-
uint64_t
get_n_tot_ev
() const¶ Gets the total number of events in the file.
-
void
load_to_ram
()¶ Loads file events to ram.
-
int
get_width
() const¶ Gets the width of the sensor producer that recorded the data.
- Return
Width of the sensor
-
int
get_height
() const¶ Gets the height of the sensor producer that recorded the data.
- Return
Height of the sensor
-
std::string
get_date
() const¶ Gets the date.
- Return
String of the form YYYY-MM-DD h:m:s (example: 2017-03-08 13:36:44 ) (UTC time)
- Note
If the date was not found in the header of the file, an empty string is returned
Public Static Functions
-
void
reset_max_loop_length
()¶ Resets the loop length to zero.
-
-
class
Metavision
::
FlipXAlgorithm
¶ Class that allows to mirror the X axis of an event stream.
The transfer function of this filter impacts only the X coordinates of the Event2d by :
\[ x = width_minus_one - x \]Public Functions
-
FlipXAlgorithm
(std::int16_t width_minus_one)¶ Builds a new FlipXAlgorithm object with the given width.
- Parameters
width_minus_one
: Maximum X coordinate of the events (width-1)
-
~FlipXAlgorithm
() = default¶ Default destructor.
-
template<class
InputIt
, classOutputIt
>
voidprocess
(InputIt first, InputIt last, OutputIt d_first)¶ Applies the Flip X filter to the given input buffer storing the result in the output buffer.
- Parameters
first
: Beginning of the range of the input elementslast
: End of the range of the input elementsd_first
: Beginning of the destination range
-
std::int16_t
width_minus_one
() const¶ Returns the maximum X coordinate of the events.
- Return
Maximum X coordinate of the events
-
void
set_width_minus_one
(std::int16_t width_minus_one)¶ Sets the maximum X coordinate of the events.
- Parameters
width_minus_one
: Maximum X coordinate of the events
-
-
class
Metavision
::
FlipYAlgorithm
¶ Class that allows to mirror the Y axis of an event stream.
The transfer function of this filter impacts only the Y coordinates of the Event2d by :
\[ y = height_minus_one - y \]Public Functions
-
FlipYAlgorithm
(std::int16_t height_minus_one)¶ Builds a new FlipYAlgorithm object with the given height.
- Parameters
height_minus_one
: Maximum Y coordinate of the events
-
~FlipYAlgorithm
() = default¶ Default destructor.
-
template<class
InputIt
, classOutputIt
>
voidprocess
(InputIt first, InputIt last, OutputIt d_first)¶ Applies the Flip Y filter to the given input buffer storing the result in the output buffer.
- Parameters
first
: Beginning of the range of the input elementslast
: End of the range of the input elementsd_first
: Beginning of the destination range
-
std::int16_t
height_minus_one
() const¶ Returns the maximum Y coordinate of the events.
- Return
Maximum Y coordinate of the events
-
void
set_height_minus_one
(std::int16_t height_minus_one)¶ Sets the maximum Y coordinate of the events.
- Parameters
height_minus_one
: Maximum Y coordinate of the events
-
-
class
Metavision
::
FrameGenerationAlgorithm
: private Metavision::AsyncAlgorithm<FrameGenerationAlgorithm>¶ Class that generates frames from events.
#include <iostream> #include "metavision/sdk/base/events/event_cd.h" #include "metavision/sdk/core/algorithms/frame_generation_algorithm.h" using namespace Metavision; int main(void) { // Initializes a frame generation algorithm that generates frames of size 5x1 every 5000 microseconds of events. // Each frame accumulating the last 10 milliseconds. FrameGenerationAlgorithm frame_generation(5, 1, 10000, true, 200); // Sets a callback to print the frame's pixels each time one is generated. frame_generation.set_output_callback([](const timestamp ts, cv::Mat &frame) { std::cout << ">> Frame generated at timestamp t = " << ts << " microseconds." << std::endl; for (int i = 0; i < frame.rows; ++i) { for (int j = 0; j < frame.cols; ++j) { std::cout << "(" << j << "," << i << ") = " << frame.at<cv::Vec3b>(i, j) << std::endl; } } std::cout << std::endl; }); std::vector<EventCD> stream_of_events; // Given the following events: // - x = 0, y = 0, p = 1, t = 0 // - x = 1, y = 0, p = 0, t = 4000 // - x = 2, y = 0, p = 1, t = 6000 // - x = 3, y = 0, p = 1, t = 7000 // - x = 4, y = 0, p = 0, t = 13000 stream_of_events.push_back({0, 0, 1, 0}); stream_of_events.push_back({1, 0, 0, 4000}); stream_of_events.push_back({2, 0, 1, 6000}); stream_of_events.push_back({3, 0, 1, 7000}); stream_of_events.push_back({4, 0, 0, 13000}); std::cout << "[First call to 'process_events'] 2 events to process." << std::endl; frame_generation.process_events(stream_of_events.cbegin(), stream_of_events.cbegin() + 2); std::cout << "[Second call to 'process_events'] 3 events to process." << std::endl; frame_generation.process_events(stream_of_events.cbegin() + 2, stream_of_events.cend()); std::cout << "[All events processed. Flushing...]" << std::endl; // Flush the event pending for asynchronous processing as no event will occur anymore. frame_generation.flush(); std::cout << "[Done]" << std::endl; // Output: // // [First call to 'process_events'] 2 events to process. // [Second call to 'process_events'] 3 events to process. // >> Frame generated at timestamp t = 5000 microseconds. // (0,0) = [236, 223, 216] # An 'on' event with timestamp 0 occurred in the time range [5000 - 10000; 5000[ -> 'on_color' // (1,0) = [201, 126, 64] # An 'off' event with timestamp 4000 occurred in the time range [5000 - 10000; 5000[ -> 'off_color' // (2,0) = [52, 37, 30] # No event occurred in the time range [5000 - 10000; 5000[ -> 'bg_color' // (3,0) = [52, 37, 30] # No event occurred in the time range [5000 - 10000; 5000[ -> 'bg_color' // (4,0) = [52, 37, 30] # No event occurred in the time range [5000 - 10000; 5000[ -> 'bg_color' // // >> Frame generated at timestamp t = 10000 microseconds. // (0,0) = [236, 223, 216] # An 'on' event with timestamp 0 occurred in the time range [10000 - 10000; 10000[ -> 'on_color' // (1,0) = [201, 126, 64] # An 'off' event with timestamp 4000 occurred in the time range [10000 - 10000; 10000[ -> 'off_color' // (2,0) = [236, 223, 216] # An 'on' event with timestamp 6000 occurred in the time range [10000 - 10000; 10000[ -> 'on_color' // (3,0) = [236, 223, 216] # An 'on' event with timestamp 7000 occurred in the time range [10000 - 10000; 10000[ -> 'on_color' // (4,0) = [52, 37, 30] # No event occurred in the time range [10000 - 10000; 10000[ -> 'bg_color' // // [All events processed. Flushing...] // >> Frame generated at timestamp t = 15000 microseconds. // (0,0) = [52, 37, 30] # No event occurred in the time range [15000 - 10000; 10000[ -> 'bg_color' // (1,0) = [52, 37, 30] # No event occurred in the time range [15000 - 10000; 10000[ -> 'bg_color' // (2,0) = [236, 223, 216] # An 'on' event with timestamp 6000 occurred in the time range [15000 - 10000; 15000[ -> 'on_color' // (3,0) = [236, 223, 216] # An 'on' event with timestamp 7000 occurred in the time range [15000 - 10000; 15000[ -> 'on_color' // (4,0) = [201, 126, 64] # An 'off' event with timestamp 13000 occurred in the time range [15000 - 10000; 15000[ -> 'off_color' // // [Done] }
Public Functions
-
FrameGenerationAlgorithm
(int sensor_width, int sensor_height, timestamp accumulation_time_us, bool colored = true, double fps = 0.)¶ Constructor.
- Parameters
sensor_width
: Sensor’s width (in pixels)sensor_height
: Sensor’s height (in pixels)accumulation_time_us
: Accumulation time (in us)colored
: Generates either colored or grayscale imagefps
: The fps at which to generate the frames. The time reference used is the one from the input events
- Exceptions
std::invalid_argument
: If the input fps is not positive or if the input accumulation time is not strictly positive
-
void
set_output_callback
(const OutputCb &output_cb)¶ Function to pass a callback to know when an image has been generated.
- Warning
For efficiency purpose, the cv::Mat passed in the callback is the reference to the internal cv::Mat filled. If it is to be used outside the scope of the callback, the user must ensure to swap or copy it to another object.
-
template<typename
InputIt
>
voidprocess_events
(InputIt it_begin, InputIt it_end)¶ Function that is calling process online and process state when necessary.
- Parameters
it_begin
: First iterator of the bufferit_end
: End iterator of the buffer
-
template<typename
InputIt
>
voidprocess_events
(const timestamp ts, InputIt it_begin, InputIt it_end)¶ Function that is calling process online and process state when necessary.
- Parameters
ts
: End timestamp of the buffer. Used if higher than the timestamp of the last eventit_begin
: First iterator of the bufferit_end
: End iterator of the buffer
-
void
flush
()¶ Function to call process_async and update the internal state of the processing policy accordingly.
-
void
set_fps
(double fps)¶ Sets the fps at which to generate frames and thus the frequency of the asynchronous calls.
The time reference used is the one from the input events.
- Parameters
fps
: The fps to use.
- Exceptions
std::invalid_argument
: If the input fps is not strictly positive.
-
double
get_fps
()¶ Returns the current fps at which frames are generated.
-
void
set_accumulation_time_us
(timestamp accumulation_time_us)¶ Sets the accumulation time (in us) use to generate a frame.
The accumulation time represents the time range of events to fill the frame with. All events displayed in the generated frame at time t will have occurred in [t - dt, t[, where dt is the accumulation time.
-
-
template<class
EventType
>
classMetavision
::
GenericProducerAlgorithm
¶ Allows insertion and storage of events from any source via register_new_event_buffer.
The events will then be produced in a chronological manner with process.
A maximum duration defined by the difference of timestamps between first and last stored event can be set to limit the number of events stored. To enforce this constraint, the producer will either wait for events to be consumed or drop enough events to be able to insert new events, set_max_duration_stored and set_allow_drop_when_overfilled.
Conversely, a timeout can be set, to avoid the producer waiting indefinitely for events to be inserted. According to the timeout value, the producer will either not wait, wait indefinitely or wait for a predefined amount of time before returning the events,
- See
set_timeout.
Public Functions
-
GenericProducerAlgorithm
(timestamp timeout = 0, uint32_t max_events_per_second = 0, timestamp max_duration_stored = std::numeric_limits<timestamp>::max(), bool allow_drop_when_overfilled = false)¶ Constructor.
- Parameters
timeout
: Maximum time to wait for events (in us). If equal 0, no timeout is set (equivalent to infinite timeout); if negative, there will be no wait at all.max_events_per_second
: Maximum event rate when “processing” events up to some time, the latest k events will be output, where k is max_events_per_second * (req_ts - last_ts), the preceding events will simply be droppedmax_duration_stored
: Maximum time difference (in us) between first and last event stored by the producer if the producer already stores enough events, when new events must be added, the oldest events will be dropped if @ref allow_drop_when_overfilled is true, otherwise the producer will wait for enough events to be consumed before continuingallow_drop_when_overfilled
: If true, the oldest events (i.e. event for which the timestamp if older than latest.t - max_duration_stored) are dropped, otherwise, the producer blocks until the oldest events are consumed
-
template<typename
IteratorEv
>
voidregister_new_event_buffer
(IteratorEv start, IteratorEv end)¶ method to add a new buffer of events
When inserting events, a maximum duration stored by the producer can be set. It is disabled by default, so that the producer storage may grow indefinitely if no events are produced, or the production is too slow. If a maximum duration is set, the producer will never store events such that the difference between the first and last event stored is greater than the maximum duration. To achieve this effect, it will either wait for events to be produced if drop is disabled when the producer has overfilled set_allow_drop_when_overfilled, or it will drop enough events so that this condition is met if drop is enabled.
-
template<class
OutputIt
, typenameTimingProfilerType
= TimingProfiler<false>>
voidprocess
(timestamp ts, OutputIt inserter, TimingProfilerType *timing_profiler = TimingProfilerType::instance())¶ method to produce events up to some timestamp
If the timeout has a positive value, it will wait at most timeout us before returning the events “generated”. If the timeout has a negative value, it will immediately return the events generated. If the timeout is zero, it will wait until at least one event with a timestamp greater than ts is registered, before returning the events with a timestamp less or equal to ts.
- Parameters
ts
: Timestamp before which to include events.inserter
: Iterator to insert the eventstiming_profiler
: Profiler to debug
-
void
set_source_as_done
()¶ Sets source as done to let the producer know that no new events will be received.
-
class
Metavision
::
PolarityFilterAlgorithm
¶ Class filter that only propagates events of a certain polarity.
Public Functions
-
PolarityFilterAlgorithm
(std::int16_t polarity)¶ Creates a PolarityFilterAlgorithm class with the given polarity.
- Parameters
polarity
: Polarity to keep
-
~PolarityFilterAlgorithm
() = default¶ Default destructor.
-
template<class
InputIt
, classOutputIt
>
OutputItprocess
(InputIt first, InputIt last, OutputIt d_first)¶ Applies the Polarity filter to the given input buffer storing the result in the output buffer.
- Return
Iterator pointing to the last + 1 event added in the output
- Parameters
first
: Beginning of the range of the input elementslast
: End of the range of the input elementsd_first
: Beginning of the destination range
-
bool
operator()
(const Event2d &ev) const¶ Basic operator to check if an event is accepted.
- Parameters
ev
: Event2D to be tested
-
void
set_polarity
(std::int16_t polarity)¶ Sets the polarity of the filter.
- Parameters
polarity
: Polarity to be used in the filtering process
-
std::int16_t
polarity
() const¶ Returns the polarity used to filter the events.
- Return
Current polarity used in the filtering process
-
-
class
Metavision
::
PolarityInverterAlgorithm
¶ Class that implements a Polarity Inverter filter.
The filter changes the polarity of all the filtered events.
Public Functions
-
PolarityInverterAlgorithm
() = default¶ Builds a new PolarityInverterAlgorithm object.
-
template<class
InputIt
, classOutputIt
>
voidprocess
(InputIt first, InputIt last, OutputIt d_first)¶ Applies the Polarity Inverter filter to the given input buffer storing the result in the output buffer.
- Parameters
first
: Beginning of the range of the input elementslast
: End of the range of the input elementsd_first
: Beginning of the destination range
-
-
class
Metavision
::
RoiFilterAlgorithm
¶ Class that only propagates events which are contained in a certain window of interest defined by the coordinates of the upper left corner and the lower right corner.
Public Functions
-
RoiFilterAlgorithm
(std::int32_t x0, std::int32_t y0, std::int32_t x1, std::int32_t y1, bool reset_ori)¶ Builds a new RoiFilterAlgorithm object which propagates events in the given window.
- Parameters
x0
: X coordinate of the upper left corner of the ROI windowy0
: Y coordinate of the upper left corner of the ROI windowx1
: X coordinate of the lower right corner of the ROI window sy1
: Y coordinate of the lower right corner of the ROI windowreset_ori
: If true, events that passed the ROI filter are expressed in the whole image coordinates. If false, they are expressed in the ROI coordinates system
-
template<class
InputIt
, classOutputIt
>
OutputItprocess
(InputIt first, InputIt last, OutputIt d_first)¶ Applies the ROI Mask filter to the given input buffer storing the result in the output buffer.
- Return
Iterator pointing to the last + 1 event added in the output
- Parameters
first
: Iterator at the beginning of the range of the input elementslast
: Iterator at the end of the range of the input elementsd_first
: Beginning of the destination range
-
bool
is_resetting
() const¶ Returns true if the algorithm is resetting the filtered events.
- Return
true if the algorithm is resetting the filtered events
-
std::int32_t
x0
() const¶ Returns the x coordinate of the upper left corner of the ROI window.
- Return
X coordinate of the upper left corner
-
std::int32_t
y0
() const¶ Returns the y coordinate of the upper left corner of the ROI window.
- Return
Y coordinate of the upper left corner
-
std::int32_t
x1
() const¶ Returns the x coordinate of the lower right corner of the ROI window.
- Return
X coordinate of the lower right corner
-
std::int32_t
y1
() const¶ Returns the y coordinate of the lower right corner of the ROI window.
- Return
Y coordinate of the lower right corner
-
void
set_x0
(std::int32_t x0)¶ Sets the x coordinate of the upper left corner of the ROW window.
- Parameters
x0
: X coordinate of the upper left corner
-
void
set_y0
(std::int32_t y0)¶ Sets the y coordinate of the upper left corner of the ROW window.
- Parameters
y0
: Y coordinate of the upper left corner
-
void
set_x1
(std::int32_t x1)¶ Sets the x coordinate of the lower right corner of the ROW window.
- Parameters
x1
: X coordinate of the lower right corner
-
void
set_y1
(std::int32_t y1)¶ Sets the x coordinate of the lower right corner of the ROW window.
- Parameters
y1
: Y coordinate of the lower right corner
-
A utility class to generate shared ptr around a vector of events according to a processing policy (e.g. AsyncAlgorithm::Processing from AsyncAlgorithm)
The events buffers are allocated within a bounded memory pool (BoundedSharedObjectPool) to reuse the memory and avoid memory allocation.
- Template Parameters
EventT
: The type of events contained in the buffer.BOUNDED_MEMORY
: The type of memory pool to use in the implementation, bounded being a blocking memory pool when all buffers allocated are in use (ObjectPool).
Public Types
ObjectPool. We use a bounded one to avoid reallocation
Alias of callback to process a generated SharedEventsBuffer
Public Functions
Constructor.
Supported mode from (e.g. AsyncAlgorithm::Processing from AsyncAlgorithm): N_EVENTS, N_US, MIXED, NONE.
Setting SharedEventsBufferProducerParameters::buffers_events_count_ to 0 calls set_processing_n_us (unless buffers_time_slice_us_ is 0 as well).
Setting SharedEventsBufferProducerParameters::buffers_time_slice_us_ to 0 calls set_processing_n_events (unless SharedEventsBufferProducerParameters::buffers_events_count_ is 0 as well).
Setting SharedEventsBufferProducerParameters::buffers_events_count_ and SharedEventsBufferProducerParameters::buffers_time_slice_us_ to 0 calls set_processing_none.
Setting non zero value to both SharedEventsBufferProducerParameters::buffers_events_count_ and SharedEventsBufferProducerParameters::buffers_time_slice_us_ calls set_processing_mixed.
The mode can be overridden after calling the constructor.
- Parameters
params
: An SharedEventsBufferProducerParameters object containing the parameters.buffer_produced_cb
: A callback called (SharedEventsBufferProducedCb) whenever a buffer is created.
Resets the internal states of the policy.
-
class
Metavision
::
StreamLoggerAlgorithm
¶ Logs the stream to a file.
Public Functions
-
StreamLoggerAlgorithm
(const std::string &filename, std::size_t width, std::size_t height)¶ Builds a new new StreamLogger object with given geometry.
- Parameters
filename
: Name of the file to write into. If the file already exists, its previous content will be lost.width
: Width of the producerheight
: Height of the producer
-
~StreamLoggerAlgorithm
() = default¶ Default destructor.
-
void
enable
(bool state, bool reset_ts = true, std::int32_t split_time_seconds = InvalidTimestamp)¶ Enables or disables data logging.
- Parameters
state
: Flag to enable/disable the loggerreset_ts
: Flag to reset the timestamp, the timestamp used in the last call to update will be considered as timestamp zerosplit_time_seconds
: Time in seconds to split the file. By default is disabled: InvalidTimestamp (-1).
- Exceptions
It
: will throw an exception if the user tries to reset the timestamp or split the stream while the StreamLogger is enabled and running.
-
bool
is_enable
() const¶ Returns state of data logging.
- Return
true if data logging in enabled false otherwise
-
void
change_destination
(const std::string &filename, bool reset_ts = true)¶ Changes the destination file of the logger.
- Parameters
filename
: Name of the file to write into.reset_ts
: If we are currently recording, the timestamp used in the last call to update will be considered as timestamp zero
-
template<class
InputIterator
>
voidprocess
(InputIterator first, InputIterator last, timestamp ts)¶ Exports the information in the input buffer into the StreamLogger.
- Template Parameters
InputIterator
: Read-Only iterator with Event2d base class
- Parameters
first
: Beginning of the input iteratorlast
: End of the input iteratorts
: Input buffer timestamp
-
void
close
()¶ Closes the streaming.
-