6#ifndef OPENEV_CONTAINERS_VECTOR_HPP
7#define OPENEV_CONTAINERS_VECTOR_HPP
9#include "openev/containers/array.hpp"
19#ifndef OPENEV_ARRAY_HPP
20template <
typename T, std::
size_t N>
24#ifndef OPENEV_QUEUE_HPP
36class Vector_ :
public std::vector<Event_<T>> {
50 template <std::
size_t N>
52 std::vector<Event_<T>>::reserve(std::vector<
Event_<T>>::size() + array.size());
53 std::vector<Event_<T>>::insert(std::vector<
Event_<T>>::end(), array.begin(), array.end());
61 return std::vector<Event_<T>>::back().t - std::vector<Event_<T>>::front().t;
68 [[nodiscard]]
inline double rate()
const {
69 return std::vector<Event_<T>>::size() /
duration();
77 const double x = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / std::vector<
Event_<T>>::size();
78 const double y = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / std::vector<
Event_<T>>::size();
79 const double t = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / std::vector<
Event_<T>>::size();
80 const double p = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
p; }) / std::vector<
Event_<T>>::size();
81 return {x, y, t, p > 0.5};
88 [[nodiscard]]
inline cv::Point2d
meanPoint()
const {
89 const double x = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / std::vector<
Event_<T>>::size();
90 const double y = std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / std::vector<
Event_<T>>::size();
99 return std::accumulate(std::vector<
Event_<T>>::begin(), std::vector<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / std::vector<
Event_<T>>::size();
107 return 0.5 * (std::vector<Event_<T>>::front().t + std::vector<Event_<T>>::back().t);
110using Vectori = Vector_<int>;
111using Vectorl = Vector_<long>;
112using Vectorf = Vector_<float>;
113using Vectord = Vector_<double>;
114using Vector = Vectori;
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
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
double midTime() const
Calculate the midpoint time between the oldest and the newest event.
Definition vector.hpp:106
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition vector.hpp:68
double duration() const
Time difference between the last and the first event.
Definition vector.hpp:60
double meanTime() const
Compute the mean time of the events.
Definition vector.hpp:98
Eventd mean() const
Compute the mean of the events.
Definition vector.hpp:76
void push_back(const Array_< T, N > &array)
Push back elements from an array of events.
Definition vector.hpp:51
cv::Point2d meanPoint() const
Compute the mean x,y point of the events.
Definition vector.hpp:88
Queue container for basic event structures.
Basic event-based vision structures based on OpenCV components.