6#ifndef OPENEV_CONTAINERS_ARRAY_HPP
7#define OPENEV_CONTAINERS_ARRAY_HPP
20template <
typename T, std::
size_t N>
21class Array_ :
public std::array<T, N> {
22 using std::array<T, N>::array;
30 return (std::array<T, N>::back()).t - (std::array<T, N>::front()).t;
37 [[nodiscard]]
inline double rate()
const {
38 return std::array<T, N>::size() /
duration();
51 for(
const T &e : *
this) {
52 x +=
static_cast<double>(e.x);
53 y +=
static_cast<double>(e.y);
54 t +=
static_cast<double>(e.t);
55 p +=
static_cast<double>(e.p);
58 return {x / N, y / N, t / N, p / N >= 0.5};
66 return std::accumulate(std::array<T, N>::begin(), std::array<T, N>::end(), 0.0, [](
double sum,
const T &e) {
return sum + e.t; }) / N;
69template <std::
size_t N>
70using Arrayi = Array_<Eventi, N>;
71template <std::
size_t N>
72using Arrayl = Array_<Eventl, N>;
73template <std::
size_t N>
74using Arrayf = Array_<Eventf, N>;
75template <std::
size_t N>
76using Arrayd = Array_<Eventd, N>;
77template <std::
size_t N>
78using Array = Array_<Event, N>;
79template <std::
size_t N>
80using AugmentedArrayi = Array_<AugmentedEventi, N>;
81template <std::
size_t N>
82using AugmentedArrayl = Array_<AugmentedEventl, N>;
83template <std::
size_t N>
84using AugmentedArrayf = Array_<AugmentedEventf, N>;
85template <std::
size_t N>
86using AugmentedArrayd = Array_<AugmentedEventd, N>;
87template <std::
size_t N>
88using AugmentedArray = Array_<AugmentedEvent, N>;
This class extends std::array to implement event arrays. For more information, please refer here.
Definition array.hpp:21
Eventd mean() const
Compute the mean of the events in the array.
Definition array.hpp:45
double duration() const
Time difference between the last and the first event in the array.
Definition array.hpp:29
double meanTime() const
Compute the mean time of the events in the array.
Definition array.hpp:65
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition array.hpp:37
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:60
Basic event-based vision structures based on OpenCV components.