6#ifndef OPENEV_CONTAINERS_DEQUE_HPP
7#define OPENEV_CONTAINERS_DEQUE_HPP
9#include "openev/containers/array.hpp"
10#include "openev/containers/vector.hpp"
18#ifndef OPENEV_ARRAY_HPP
19template <
typename T, std::
size_t N>
23#ifndef OPENEV_VECTOR_HPP
35class Deque_ :
public std::deque<Event_<T>> {
49 template <std::
size_t N>
51 std::deque<Event_<T>>::insert(std::deque<
Event_<T>>::end(), array.begin(), array.end());
59 std::deque<Event_<T>>::insert(std::deque<
Event_<T>>::end(), vector.begin(), vector.end());
67 return std::deque<Event_<T>>::back().t - std::deque<Event_<T>>::front().t;
74 [[nodiscard]]
inline double rate()
const {
75 return std::deque<Event_<T>>::size() /
duration();
83 const double x = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / std::deque<
Event_<T>>::size();
84 const double y = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / std::deque<
Event_<T>>::size();
85 const double t = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / std::deque<
Event_<T>>::size();
86 const double p = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
p; }) / std::deque<
Event_<T>>::size();
87 return {x, y, t, p > 0.5};
95 const double x = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / std::deque<
Event_<T>>::size();
96 const double y = std::accumulate(std::deque<
Event_<T>>::begin(), std::deque<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / std::deque<
Event_<T>>::size();
113 return 0.5 * (std::deque<Event_<T>>::front().t + std::deque<Event_<T>>::back().t);
This class extends std::array to implement event arrays. For more information, please refer here.
Definition array.hpp:21
This class extends std::deque to implement event deques. For more information, please refer here.
Definition deque.hpp:35
void push_back(const Vector_< T > &vector)
Push elements from a vector of events.
Definition deque.hpp:58
cv::Point2d meanPoint()
Compute the mean x,y point of the events.
Definition deque.hpp:94
void push_back(const Array_< T, N > &array)
Push elements from an array of events.
Definition deque.hpp:50
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition deque.hpp:74
Eventd mean()
Compute the mean of the events.
Definition deque.hpp:82
double duration() const
Time difference between the last and the first event.
Definition deque.hpp:66
double meanTime()
Compute the mean time of the events.
Definition deque.hpp:104
double midTime() const
Calculate the midpoint time between the oldest and the newest event.
Definition deque.hpp:112
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
This class extends std::vector to implement event vectors. For more information, please refer here.
Definition vector.hpp:36
Basic event-based vision structures based on OpenCV components.