6#ifndef OPENEV_CONTAINERS_CIRCULAR_HPP
7#define OPENEV_CONTAINERS_CIRCULAR_HPP
10#include <boost/circular_buffer.hpp>
12#include <opencv2/core/types.hpp>
23 using boost::circular_buffer<
Event_<T>>::circular_buffer;
27 template <
typename... Args>
28 inline void emplace_back(Args &&...args) {
29 boost::circular_buffer<Event_<T>>::push_back(
Event_<T>(std::forward<Args>(args)...));
32 template <
typename... Args>
33 inline void emplace_front(Args &&...args) {
34 boost::circular_buffer<Event_<T>>::push_front(
Event_<T>(std::forward<Args>(args)...));
43 return boost::circular_buffer<Event_<T>>::back().t - boost::circular_buffer<Event_<T>>::front().t;
50 [[nodiscard]]
inline double rate()
const {
51 return boost::circular_buffer<Event_<T>>::size() /
duration();
59 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();
60 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();
61 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();
62 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();
63 return {x, y, t, p > 0.5};
70 [[nodiscard]]
inline cv::Point2d
meanPoint()
const {
71 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();
72 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();
81 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();
88 [[nodiscard]]
inline double midTime()
const {
89 return 0.5 * (boost::circular_buffer<Event_<T>>::front().t + boost::circular_buffer<Event_<T>>::back().t);
CircularBufferi CircularBuffer
Definition circular.hpp:96
CircularBuffer_< float > CircularBufferf
Definition circular.hpp:94
CircularBuffer_< long > CircularBufferl
Definition circular.hpp:93
CircularBuffer_< int > CircularBufferi
Definition circular.hpp:92
CircularBuffer_< double > CircularBufferd
Definition circular.hpp:95
This class extends boost::circular_buffer to implement event circular buffers. For more information,...
Definition circular.hpp:22
double rate() const
Compute event rate as the ratio between the number of events and the time difference between the last...
Definition circular.hpp:50
Eventd mean() const
Compute the mean of the events.
Definition circular.hpp:58
double midTime() const
Calculate the midpoint time between the oldest and the newest event.
Definition circular.hpp:88
double duration() const
Time difference between the last and the first event.
Definition circular.hpp:42
cv::Point2d meanPoint() const
Compute the mean x,y point of the events.
Definition circular.hpp:70
double meanTime() const
Compute the mean time of the events.
Definition circular.hpp:80
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:62
bool p
Definition types.hpp:65
double t
Definition types.hpp:64
Basic event-based vision structures based on OpenCV components.
Event_< double > Eventd
Definition types.hpp:243