6#ifndef OPENEV_CONTAINERS_CIRCULAR_HPP
7#define OPENEV_CONTAINERS_CIRCULAR_HPP
10#include <boost/circular_buffer.hpp>
21 using boost::circular_buffer<
Event_<T>>::circular_buffer;
25 template <
typename... Args>
26 inline void emplace_back(Args &&...args) {
27 boost::circular_buffer<Event_<T>>::push_back(
Event_<T>(std::forward<Args>(args)...));
30 template <
typename... Args>
31 inline void emplace_front(Args &&...args) {
32 boost::circular_buffer<Event_<T>>::push_front(
Event_<T>(std::forward<Args>(args)...));
41 return boost::circular_buffer<Event_<T>>::back().t - boost::circular_buffer<Event_<T>>::front().t;
48 [[nodiscard]]
inline double rate()
const {
49 return boost::circular_buffer<Event_<T>>::size() /
duration();
57 const double x = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / boost::circular_buffer<
Event_<T>>::size();
58 const double y = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / boost::circular_buffer<
Event_<T>>::size();
59 const double t = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / boost::circular_buffer<
Event_<T>>::size();
60 const double p = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
p; }) / boost::circular_buffer<
Event_<T>>::size();
61 return {x, y, t, p > 0.5};
68 [[nodiscard]]
inline cv::Point2d
meanPoint()
const {
69 const double x = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.x; }) / boost::circular_buffer<
Event_<T>>::size();
70 const double y = std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.y; }) / boost::circular_buffer<
Event_<T>>::size();
79 return std::accumulate(boost::circular_buffer<
Event_<T>>::begin(), boost::circular_buffer<
Event_<T>>::end(), 0.0, [](
double sum,
const Event_<T> &e) {
return sum + e.
t; }) / boost::circular_buffer<
Event_<T>>::size();
86 [[nodiscard]]
inline double midTime()
const {
87 return 0.5 * (boost::circular_buffer<Event_<T>>::front().t + boost::circular_buffer<Event_<T>>::back().t);
This class extends boost::circular_buffer to implement event circular buffers. For more information,...
Definition circular.hpp:20
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition circular.hpp:48
Eventd mean() const
Compute the mean of the events.
Definition circular.hpp:56
double midTime() const
Calculate the midpoint time between the oldest and the newest event.
Definition circular.hpp:86
double duration() const
Time difference between the last and the first event.
Definition circular.hpp:40
cv::Point2d meanPoint() const
Compute the mean x,y point of the events.
Definition circular.hpp:68
double meanTime() const
Compute the mean time of the events.
Definition circular.hpp:78
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.