6#ifndef OPENEV_CONTAINERS_ARRAY_HPP
7#define OPENEV_CONTAINERS_ARRAY_HPP
20template <
typename T, std::
size_t N>
21class Array_ :
public std::array<Event_<T>, N> {
30 return std::array<Event_<T>, N>::back().t - std::array<Event_<T>, N>::front().t;
37 [[nodiscard]]
inline double rate()
const {
38 return std::array<Event_<T>, N>::size() /
duration();
46 const double x = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / N;
47 const double y = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / N;
48 const double t = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / N;
49 const double p = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
p; }) / N;
50 return {x, y, t, p > 0.5};
57 [[nodiscard]]
inline cv::Point2d
meanPoint()
const {
58 const double x = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / N;
59 const double y = std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / N;
68 return std::accumulate(std::array<
Event_<T>, N>::begin(), std::array<
Event_<T>, N>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / N;
75 [[nodiscard]]
inline double midTime()
const {
76 return 0.5 * (std::array<Event_<T>, N>::front().t + std::array<Event_<T>, N>::back().t);
79template <std::
size_t N>
80using Arrayi = Array_<int, N>;
81template <std::
size_t N>
82using Arrayl = Array_<long, N>;
83template <std::
size_t N>
84using Arrayf = Array_<float, N>;
85template <std::
size_t N>
86using Arrayd = Array_<double, N>;
87template <std::
size_t N>
88using Array = Arrayi<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.
Definition array.hpp:45
double duration() const
Time difference between the last and the first event.
Definition array.hpp:29
cv::Point2d meanPoint() const
Compute the mean x,y point of the events.
Definition array.hpp:57
double midTime() const
Calculate the midpoint time between the oldest and the newest event.
Definition array.hpp:75
double meanTime() const
Compute the mean time of the events.
Definition array.hpp:67
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
bool p
Definition types.hpp:63
double t
Definition types.hpp:62
Basic event-based vision structures based on OpenCV components.