6#ifndef OPENEV_CONTAINERS_VECTOR_HPP
7#define OPENEV_CONTAINERS_VECTOR_HPP
9#include "openev/containers/array.hpp"
10#include "openev/containers/queue.hpp"
19#ifndef OPENEV_ARRAY_HPP
20template <
typename T, std::
size_t N>
24#ifndef OPENEV_QUEUE_HPP
37 using std::vector<T>::vector;
42 std::vector<T>::push_back(e);
50 template <std::
size_t N>
52 std::vector<T>::reserve(std::vector<T>::size() + array.size());
53 std::vector<T>::insert(std::vector<T>::end(), array.begin(), array.end());
62 std::vector<T>::reserve(std::vector<T>::size() + queue.size());
63 if(keep_events_in_queue) {
64 const std::size_t size = queue.size();
65 for(std::size_t i = 0; i < size; i++) {
66 std::vector<T>::emplace_back(std::move(queue.front()));
67 queue.emplace(queue.front());
71 while(!queue.empty()) {
72 std::vector<T>::emplace_back(std::move(queue.front()));
83 return (std::vector<T>::back()).t - (std::vector<T>::front()).t;
90 [[nodiscard]]
inline double rate()
const {
91 return std::vector<T>::size() /
duration();
104 for(
const T &e : *
this) {
105 x +=
static_cast<double>(e.x);
106 y +=
static_cast<double>(e.y);
107 t +=
static_cast<double>(e.t);
108 p +=
static_cast<double>(e.p);
111 const std::size_t size = std::vector<T>::size();
112 return {x / size, y / size, t / size, p / size >= 0.5};
120 return std::accumulate(std::vector<T>::begin(), std::vector<T>::end(), 0.0, [](
double sum,
const T &e) {
return sum + e.t; }) / std::vector<T>::size();
123using Vectori = Vector_<Eventi>;
124using Vectorl = Vector_<Eventl>;
125using Vectorf = Vector_<Eventf>;
126using Vectord = Vector_<Eventd>;
127using Vector = Vector_<Event>;
128using AugmentedVectori = Vector_<AugmentedEventi>;
129using AugmentedVectorl = Vector_<AugmentedEventl>;
130using AugmentedVectorf = Vector_<AugmentedEventf>;
131using AugmentedVectord = Vector_<AugmentedEventd>;
132using AugmentedVector = Vector_<AugmentedEvent>;
This class extends std::array to implement event arrays. For more information, please refer here.
Definition array.hpp:21
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:60
This class extends std::queue to implement event queues. For more information, please refer here.
Definition queue.hpp:35
This class extends std::vector to implement event vectors. For more information, please refer here.
Definition vector.hpp:36
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition vector.hpp:90
double duration() const
Time difference between the last and the first event in the vector.
Definition vector.hpp:82
double meanTime() const
Compute the mean time of the events in the vector.
Definition vector.hpp:119
Eventd mean() const
Compute the mean of the events in the vector.
Definition vector.hpp:98
void push_back(const Array_< T, N > &array)
Push back elements from an array of events.
Definition vector.hpp:51
void push_back(Queue_< T > &queue, const bool keep_events_in_queue=false)
Push back elements from a queue of events.
Definition vector.hpp:61
Basic event-based vision structures based on OpenCV components.