SDK Analytics Algorithms¶
-
class
Metavision
::
CountingAlgorithm
¶ Class to count objects using Metavision Counting API.
Public Types
-
using
OutputCb
= std::function<void(const OutputEvent&)>¶ Type of the callback to access the last count.
Public Functions
-
CountingAlgorithm
(int width, int height, const CountingAlgorithmConfig &config)¶ Constructor.
- Parameters
width
: Sensor’s width (in pixels)height
: Sensor’s height (in pixels)config
: Counting configuration
-
~CountingAlgorithm
()¶ Default destructor.
-
void
add_line_counter
(int row)¶ Adds a new line to count objects.
- Parameters
row
: Specifies which row (y coordinate in pixels) is used to count
-
template<typename
InputIt
>
voidprocess_events
(InputIt it_begin, InputIt it_last)¶ Processes a buffer of events.
- Parameters
it_begin
: The first element of the buffer of eventsit_last
: The last element of the buffer of events
-
void
set_output_callback
(const OutputCb &output_cb)¶ Function to pass a callback to get the last count.
- Parameters
output_cb
: Function to call
-
void
reset_counters
()¶ Resets the count of all lines.
-
using
-
template<typename
T
, typenameV
, VT
::*v
, typenameprecision_type
= float>
classMetavision
::
DominantValueEventsAlgorithm
¶ Class computing the dominant value of an event’s field from an events batch.
- Template Parameters
T
: Type for which the dominant value of one of its fields will be estimatedV
: Type of the field from which the dominant value is extractedv
: Address inT
of the field from which the dominant value is extractedprecision_type
: Return type of the dominant value, used to define the type of the boundaries of the histogram bins
Public Functions
-
DominantValueEventsAlgorithm
(precision_type min_val, precision_type max_val, precision_type precision_val, unsigned int min_count)¶ Constructor.
We split the range [
min_val
,max_val
] to get values spaced byprecision_val
. Bins are centered around these values and are of a width that ensures that consecutive bins touch each other. For example, given the range [3, 5] andprecision_val
= 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}- Note
The histogram bins are initialized during the class construction and won’t change dynamically.
- Parameters
min_val
: Minimum included value (lower bound of the histogram bins)max_val
: Maximum included value (upper bound of the histogram bins)precision_val
: Width of the bins of the histogram (same unit as the value to estimate)min_count
: Minimum size of a given bin in the histogram to be eligible as dominant
-
template<typename
InputIt
>
boolcompute_dominant_value
(InputIt begin, InputIt end, precision_type &output_dominant_value)¶ Computes the dominant value from a batch of events.
- Return
false if none of the bins were sufficiently filled with respect to the count criterion
- Template Parameters
InputIt
: An iterator type over an event of typeT
- Parameters
begin
: First iterator of theT
events buffer to processend
: End iterator of theT
events buffer to processoutput_dominant_value
: Peak of the histogram of the values contained betweenbegin
andend
-
template<typename
precision_type
= float>
classMetavision
::
DominantValueMapAlgorithm
¶ Class computing the dominant value of a map.
- Template Parameters
precision_type
: Return type of the dominant value, used to define the type of the boundaries of the histogram bins
Public Functions
-
DominantValueMapAlgorithm
(precision_type min_val, precision_type max_val, precision_type precision_val, unsigned int min_count)¶ Constructor.
We split the range [
min_val
,max_val
] to get values spaced apart byprecision_val
. 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] andprecision_val
= 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}- Note
The histogram bins are initialized during the class construction and won’t change dynamically.
- Parameters
min_val
: Minimum included value (lower bound of the histogram bins)max_val
: Maximum included value (upper bound of the histogram bins)precision_val
: Width of the bins of the histogram (same unit as the value to estimate)min_count
: Minimum size of a given bin in the histogram to be eligible as dominant
-
~DominantValueMapAlgorithm
() = default¶ Destructor.
-
bool
compute_dominant_value
(const cv::Mat &value_map, precision_type &output_dominant_value)¶ Computes the dominant value from a value map.
- Return
false if none of the bins were sufficiently filled with respect to the count criterion
- Parameters
value_map
: Input map containing valuesoutput_dominant_value
: Peak of the histogram of the values contained invalue_map
-
class
Metavision
::
FrequencyMapAsyncAlgorithm
¶ Class that estimates the pixel-wise frequency of vibrating objects using Metavision Vibration API.
Public Types
Public Functions
-
FrequencyMapAsyncAlgorithm
(int width, int height, const FrequencyEstimationConfig &frequency_config)¶ Builds a new FrequencyMapAsyncAlgorithm object.
- Parameters
width
: Sensor’s width in pixelsheight
: Sensor’s height in pixelsfrequency_config
: Frequency estimation configuration
-
~FrequencyMapAsyncAlgorithm
()¶ Default destructor.
-
void
set_output_callback
(const OutputCb &output_cb)¶ Sets a callback to get the output frequency map.
- Parameters
output_cb
: Callback to call
-
void
set_update_frequency
(const float freq)¶ Sets the frequency at which the algorithm generates the frequency map.
- Parameters
freq
: Frequency at which the frequency map will be generated
-
-
class
Metavision
::
HeatMapFrameGeneratorAlgorithm
¶ Class that produces a BGR image of a floating point value map.
A colormap bar at the bottom of the image shows the color convention. Pixels for which a value was not computed are shown in black. Also pixels outside the defined minimum/maximum values are shown in black too.
Public Types
-
using
float_type
= float¶ Type of foating point values.
Public Functions
-
HeatMapFrameGeneratorAlgorithm
(float_type min_value, float_type max_value, float_type value_precision, int width, int height, const std::string &unit_str = std::string(), unsigned int cmap = cv::COLORMAP_JET, bool do_invert_cmap = true)¶ Constructor.
- Parameters
min_value
: Minimum valuemax_value
: Maximum valuevalue_precision
: Precision used to determine the number of decimal digits to display (0.5, 0.01, …)width
: Sensor’s width (in pixels)height
: Sensor’s height (in pixels)unit_str
: String representation of the values’s unit, e.g. Hz, us, m/s …cmap
: Colormap used to colorize the value mapdo_invert_cmap
: Flip the uchar values before applying the color map
-
~HeatMapFrameGeneratorAlgorithm
() = default¶ Destructor.
-
void
generate_bgr_heat_map
(const cv::Mat &value_map, cv::Mat &out_image_bgr)¶ Draws the value map with a bar showing the colormap convention.
- Parameters
value_map
: Input value map, 1 floating point channel (CV_32SC1)out_image_bgr
: Output image
-
using
-
template<typename
T
, typenameF
, FT
::*f
>
classMetavision
::
MapGeneratorAsyncAlgorithm
: public Metavision::AsyncAlgorithm<MapGeneratorAsyncAlgorithm<T, F, f>>¶ Class that accumulates events in a map.
More specifically, this class accumulates one of the event’s fields in a map. Each map’s cell contains the last value of that field at that location. Under the hood this class uses the OpenCV’s Mat_<T> structure, meaning that it is only compatible with the types for which the Mat_<T> structure is compatible too (i.e. uchar, short, ushort, int, float and double). This class is not compatible with OpenCV’s vector types (i.e. instantiations of the Vec<T, int cn> class).
- Template Parameters
T
: Type, one of the fields of which will be accumulated in the mapF
: Type of the field that will be accumulated in the mapf
: Address inT
of the field to be accumulated
Public Functions
-
MapGeneratorAsyncAlgorithm
(int width, int height)¶ Builds a new MapGeneratorAsyncAlgorithm object.
- Parameters
width
: Sensor’s width (in pixels)height
: Sensor’s height (in pixels)
-
~MapGeneratorAsyncAlgorithm
() = default¶ Default destructor.
-
void
set_output_callback
(const OutputCb &cb)¶ Sets the callback that will be called to let the user retrieve the generated map.
The generated map will be passed through the callback via a non constant reference, meaning that the client is free to copy it or swap it.
- Note
In case of a swap with a non initialized map, it will automatically be initialized by the MapGeneratorAsyncAlgorithm.
- Parameters
cb
: The callback to call
-
class
Metavision
::
PeriodMapAsyncAlgorithm
¶ Class that estimates the pixel-wise period of vibrating objects using Metavision Vibration API.
Public Types
Public Functions
-
PeriodMapAsyncAlgorithm
(int width, int height, const PeriodEstimationConfig &period_map_async_config)¶ Builds a new PeriodMapAsyncAlgorithm object.
- Parameters
width
: Sensor’s width (in pixels)height
: Sensor’s height (in pixels)period_map_async_config
: Period estimation configuration
-
~PeriodMapAsyncAlgorithm
()¶ Default destructor.
-
void
set_output_callback
(const OutputCb &output_cb)¶ Sets a callback to get the output period map.
- Parameters
output_cb
: Callback to call
-
void
set_update_frequency
(const float freq)¶ Sets the frequency at which the algorithm generates the period map.
- Parameters
freq
: Frequency at which the period map will be generated
-
-
class
Metavision
::
SpatterTrackerAlgorithm
¶ Class that tracks spatter clusters using Metavision SpatterTracking API.
Public Types
-
using
TrackerCb
= std::function<void(const timestamp, const std::vector<EventSpatterCluster>&)>¶ Type of the callback to access the output cluster events.
Public Functions
-
SpatterTrackerAlgorithm
(int width, int height, const SpatterTrackerAlgorithmConfig &config)¶ Builds a new SpatterTrackerAlgorithm object.
- Parameters
width
: Sensor’s width (in pixels)height
: Sensor’s height (in pixels)config
: Spatter tracker’s configuration
-
~SpatterTrackerAlgorithm
()¶ Default destructor.
-
void
set_callback
(const TrackerCb &tracker_cb)¶ Registers a callback to get the output cluster events.
- Parameters
tracker_cb
: Function to call
-
void
remove_callback
()¶ Removes the callback.
-
void
set_nozone
(cv::Point center, int radius)¶ Sets the region that isn’t processed.
- Parameters
center
: Center of the regionradius
: Radius of the region
-
void
set_write_range
(const timestamp &time_from, const timestamp &time_to)¶ Sets the time to start and stop writing the outcome video.
- Parameters
time_from
: Timestamp to start writing the outcome videotime_to
: Timestamp to stop writing the outcome video
-
int
get_cluster_count
() const¶ Returns the current number of clusters.
- Return
The current number of clusters
-
using
-
class
Metavision
::
TrackingAlgorithm
¶ Class that tracks objects using Metavision Tracking API.
Public Functions
-
TrackingAlgorithm
(int sensor_width, int sensor_height, TrackingConfig &config)¶ Builds a new TrackingAlgorithm object.
- Parameters
sensor_width
: Sensor’s width.sensor_height
: Sensor’s height.config
: Tracking’s configuration.
-
~TrackingAlgorithm
()¶ Default Destructor.
-
void
set_output_callback
(const OutputCb &output_cb)¶ Sets a callback to retrieve the list of tracked objects (see EventTrackingData) when the tracker is updated (see set_update_frequency).
- Note
The generated vector will be passed to the callback as a non constant reference, meaning that the client is free to copy it or swap it. In case of a swap, the swapped vector will be automatically cleaned.
- Parameters
output_cb
: Function to call
-
std::uint16_t
get_min_size
() const¶ Gets the size of the smallest trackable object.
-
std::uint16_t
get_max_size
() const¶ Gets the size of the biggest trackable object.
-
float
get_min_speed
() const¶ Gets the speed of the slowest trackable object.
-
float
get_max_speed
() const¶ Gets the speed of the fastest trackable object.
-
void
set_min_size
(std::uint16_t min_size)¶ Sets the size of the smallest trackable object.
- Parameters
min_size
: Size of the smallest object (in pixels)
-
void
set_max_size
(std::uint16_t max_size)¶ Sets the size of the biggest trackable object.
- Parameters
max_size
: Size of the biggest object (in pixels)
-
void
set_min_speed
(float min_speed)¶ Sets the speed of the slowest trackable object.
- Parameters
min_speed
: Speed of the slowest object
-
void
set_max_speed
(float max_speed)¶ Sets the speed of the fastest trackable object.
- Parameters
max_speed
: Speed of the fastest object
-
void
set_update_frequency
(float freq)¶ Sets the frequency at which the algorithm generates the output.
- Parameters
freq
: Frequency to generate the output
-