SDK Analytics Utils

class Metavision::CountingCalibration

Class representing the counting calibration.

The counting calibration has to be launched manually (see calibrate). All options need to be set before running (passing a CalibrationConfig object to the calibrate function). Once started, the calibration will automatically stop once completed. Two functions are provided to monitor the state of the calibration: a function to test if the calibration is running, and a blocking wait function that returns only once the calibration is finished.

Public Functions

CountingCalibration(int width, int height, const std::string &output_path)

Constructor.

Parameters
  • width: Sensor’s width (in pixels)

  • height: Sensor’s height (in pixels)

  • output_path: Path to a JSON file where calibration output will be written

~CountingCalibration() = default

Destructor.

void calibrate(const CalibrationConfig &calibration_parameters)

Starts the counting calibration.

Starts the calibration thread. Once started, the Calibration will stop automatically when completed.

Parameters
  • calibration_parameters: CalibrationConfig object that stores all information needed for calibration.

const CalibrationResults &get_calib()

Gets the result of the calibration.

class Metavision::CountingDrawingHelper

Class that superimposes line counting results on events.

Public Functions

CountingDrawingHelper() = default

Default Constructor.

CountingDrawingHelper(const std::vector<int> &line_counters_ordinates)

Constructor.

Parameters
  • line_counters_ordinates: Ordinates of the lines tracker in the sensor’s image

void add_line_counter(int row)

Adds a new line counter ordinate to the line_counters vector.

Parameters
  • row: Line ordinate

void draw(const timestamp ts, int count, cv::Mat &output_img)

Updates data to display.

Parameters
  • ts: Current timestamp

  • count: Last object count

  • output_img: Output image

enum Metavision::CountingErrorCode

Enum that holds runtime error codes for metavision counting.

See

Metavision::CountingException

Values:

enumerator Error = 0x300000

Base metavision counting error.

enumerator InvalidArgument = Error | 0x01000

Errors related to invalid arguments.

enumerator InvalidNumViews = InvalidArgument | 0x1

Invalid number of views.

enumerator InvalidSize = InvalidArgument | 0x2

Invalid counting input min size.

enumerator InvalidSpeed = InvalidArgument | 0x3

Invalid counting input average speed.

enumerator InvalidDistance = InvalidArgument | 0x4

Invalid counting input average distance object camera.

enumerator InvalidInactivityTime = InvalidArgument | 0x5

Invalid counting argument inactivity time.

enumerator InvalidNotificationSampling = InvalidArgument | 0x6

Invalid counting argument notification sampling.

enumerator InvalidOption = InvalidArgument | 0x7

Invalid input option.

enumerator InvalidDataType = InvalidArgument | 0x8

Invalid counting data type.

enumerator InvalidLinePosition = InvalidArgument | 0x9

Invalid line position.

enumerator LineNotFound = InvalidArgument | 0xa

Line not found (e.g., when removing a specific line)

enumerator FileDoesNotExist = InvalidArgument | 0xb

File does not exist.

enumerator WrongExtension = InvalidArgument | 0xc

File extension is not the one expected.

enumerator CouldNotOpenFile = InvalidArgument | 0xd

Could not open file.

enumerator RuntimeError = Error | 0x02000

Counting runtime errors.

enumerator InvalidEngineModification = RuntimeError | 0x1

Modification of the Engine during run time.

class Metavision::CountingException : public std::system_error

Class for all exceptions thrown from Metavision counting.

See

http://www.cplusplus.com/reference/system_error/system_error/

See

http://en.cppreference.com/w/cpp/error/error_code

Public Functions

CountingException(CountingErrorCode e)

Creates an exception of type e with default error message.

See

CountingErrorCode

Parameters
  • e: Counting error code

CountingException(CountingErrorCode e, const std::string &additional_info)

Creates an exception of type e with precise error description contained in additional_info.

See

CountingErrorCode

Parameters
  • e: Counting error code

  • additional_info: Message containing information about the error

class Metavision::EventsFrameGeneratorBase

Generic class to accumulate events and display them asynchronously on an image when needed. Events passed to the class are buffered while waiting for the call of the drawing function.

Subclassed by Metavision::EventsFrameGeneratorAlgorithm, Metavision::SlidingEventsFrameGeneratorAlgorithm

Public Functions

EventsFrameGeneratorBase(int width, int height)

Constructor.

Parameters
  • width: Sensor’s width

  • height: Sensor’s height

~EventsFrameGeneratorBase()

Destructor.

template<typename InputIt>
void process_events(InputIt first, InputIt last)

Bufferizes events to display.

Parameters
  • first: Iterator to the first event of the buffer

  • last: Iterator to the last event of the buffer

void generate_image_from_events(const timestamp ts, cv::Mat &output_img) = 0

Updates data to display. Consider that we already received the corresponding events up to ts.

Parameters
  • ts: Current timestamp

  • output_img: Output image

class Metavision::EventsFrameGeneratorAlgorithm : public Metavision::EventsFrameGeneratorBase

Class that accumulates events and display them asynchronously on an image when needed.

Events passed to the class are buffered while waiting for the call of the drawing function. Once the image is generated at time ts, the displayed events (up to ts) are deleted.

Public Functions

EventsFrameGeneratorAlgorithm(int width, int height)

Constructor.

Parameters
  • width: Sensor’s width

  • height: Sensor’s height

~EventsFrameGeneratorAlgorithm() = default

Destructor.

void generate_image_from_events(const timestamp ts, cv::Mat &output_img) final override

Updates data to display. Considers that we already received the corresponding events up to ts.

Parameters
  • ts: Current timestamp

  • output_img: Output image

void flush_events_up_to_ts(const timestamp ts)

Erases events up to the timestamp ts, without displaying the events.

If we want to skip the generation of n frames, we just need to call this function once, with the timestamp of the last frame.

Parameters
  • ts: Timestamp

template<typename T>
bool Metavision::init_histogram_bins(T min_val, T max_val, T step, std::vector<T> &bins_centers, std::vector<T> &bins_boundaries)

Computes the histogram bins given a minimum value, a maximum value and a step value.

We split the range [ min_val, max_val ] to get values spaced apart by step . Bins are centered around these values and are of width step so that consecutive bins touch each other. For example, given the range [3, 5] and step = 1, it will compute the bin centers {3, 4, 5}, the boundaries of which are given by {2.5, 3.5, 4.5, 5.5}

Template Parameters
  • T: Type used to define the type of the boundaries of the histogram bins

Parameters
  • min_val: Minimum included value (lower bound of the histogram bins)

  • max_val: Maximum included value (upper bound of the histogram bins)

  • step: Width of the bins of the histogram

  • bins_centers: Output vectors containing the bin centers, e.g. {3, 4, 5}

  • bins_boundaries: Output vectors containing the bin boundaries, e.g. {2.5, 3.5, 4.5, 5.5}

struct LineCluster

Structure that stores the begin and end position of a cluster in a line.

Subclassed by Metavision::LineClusterWithId, Metavision::TimedLineCluster

struct LineClusterWithId : public Metavision::LineCluster

Structure representing a 1D Cluster with its id.

struct TimedLineCluster : public Metavision::LineCluster

Structure representing a 1D cluster with its timestamp.

struct Metavision::MonoCountingStatus

Structure to store the mono counting results on several lines.

Public Members

int global_counter

Maximum count over the line counters.

std::map<int, int> line_mono_counters

Row and counts of each line counter.

timestamp last_count_ts

Timestamp of the last triggered count.

class Metavision::SlidingEventsFrameGeneratorAlgorithm : public Metavision::EventsFrameGeneratorBase

Class that accumulates events and display them asynchronously on an image when needed.

Events passed to the class are buffered while waiting for the call of the drawing function. The difference with the standard EventsFrameGeneratorAlgorithm class is that events won’t be displayed only once. The class maintains a sliding window and erases events that are older than the accumulation time. Thus, it keeps displaying events as long as they’re recent enough.

It allows a trade-off between a high accumulation-time (time between oldest and the most recent displayed timestamps) and a low precision-time (time between two calls of the drawing function).

Public Functions

SlidingEventsFrameGeneratorAlgorithm(int width, int height, timestamp accumulation_time)

Constructor.

Parameters
  • width: Sensor’s width

  • height: Sensor’s height

  • accumulation_time: Temporal size of the sliding window over event-buffers

void generate_image_from_events(const timestamp ts, cv::Mat &output_img) final override

Updates sliding window with a new timestamp and display the events inside [ts - accumulation_time, ts] Consider that we already received the corresponding events up to ts.

Parameters
  • ts: Current timestamp

  • output_img: Output image showing the events inside [ts - accumulation_time, ts]

class Metavision::SpatterTrackerCsvLogger

Class that logs the output of SpatterTrackerAlgorithm to csv format.

Public Functions

SpatterTrackerCsvLogger(std::string file_name)

Constructor.

Parameters
  • file_name: Output file name

void log_output(const Metavision::timestamp ts, const std::vector<EventSpatterCluster> &trackers)

Writes information about the trackers to file.

Parameters
  • ts: Timestamp

  • trackers: Trackers to write

template<typename InputIt>
void Metavision::draw_tracking_results(timestamp ts, InputIt begin, InputIt end, cv::Mat &output)

Generic function used to draw tracking results.

Results are drawn as bounding boxes with tracked objects’ ids beside.

Template Parameters
  • InputIt: Iterator type over a tracking result

Parameters
  • ts: Current timestamp

  • begin: First tracking result to draw

  • end: End of the tracking results buffer

  • output: The output image in which the tracking result will be drawn