OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
persistent_queue.hpp
1
6#ifndef OPENEV_CONTAINERS_PERSISTENT_QUEUE_HPP
7#define OPENEV_CONTAINERS_PERSISTENT_QUEUE_HPP
8
10#include "openev/core/types.hpp"
11#include <cstddef>
12#include <opencv2/core/types.hpp>
13
14namespace ev {
15constexpr bool USING_PERSISTENT_QUEUE_HPP = true;
16
22template <typename T>
23class PersistentQueue_ : public Queue_<T> {
24 using Queue_<T>::Queue_;
25 using ResultType = TimeType;
26
27public:
33 [[nodiscard]] inline Event_<ResultType> mean() {
34 const std::size_t n = Queue_<T>::size();
35 ResultType x{0};
36 ResultType y{0};
37 ResultType t{0};
38 ResultType p{0};
39
40 for(int i = 0; i < n; i++) {
41 const Event_<T> &e = Queue_<T>::front();
42 x += e.x;
43 y += e.y;
44 t += e.t;
45 p += e.p;
48 }
49
50 return {x / n, y / n, t / n, p / n > 0.5};
51 }
52
58 [[nodiscard]] inline cv::Point_<ResultType> meanPoint() {
59 const std::size_t n = Queue_<T>::size();
60 ResultType x{0};
61 ResultType y{0};
62
63 for(int i = 0; i < n; i++) {
64 const Event_<T> &e = Queue_<T>::front();
65 x += e.x;
66 y += e.y;
69 }
70
71 return {x / n, y / n};
72 }
73
79 [[nodiscard]] inline ResultType meanTime() {
80 const std::size_t n = Queue_<T>::size();
81 ResultType t{0};
82
83 for(int i = 0; i < n; i++) {
84 t += Queue_<T>::front().t;
87 }
88
89 return t / n;
90 }
91};
92using PersistentQueuei = PersistentQueue_<int>;
93using PersistentQueuel = PersistentQueue_<long>;
94using PersistentQueuef = PersistentQueue_<float>;
95using PersistentQueued = PersistentQueue_<double>;
96using PersistentQueue = PersistentQueuei;
97} // namespace ev
98
99#endif // OPENEV_CONTAINERS_PERSISTENT_QUEUE_HPP
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:77
PolarityType p
Definition types.hpp:80
TimeType t
Definition types.hpp:79
This class extends std::queue to implement persistent event queues. For more information,...
Definition persistent_queue.hpp:23
cv::Point_< ResultType > meanPoint()
Compute the mean x,y point of the events without consuming the queue.
Definition persistent_queue.hpp:58
ResultType meanTime()
Compute the mean time of the events without consuming the queue.
Definition persistent_queue.hpp:79
Event_< ResultType > mean()
Compute the mean of the events without consuming the queue.
Definition persistent_queue.hpp:33
This class extends std::queue to implement event queues. For more information, please refer here.
Definition queue.hpp:23
Persistent queue container for basic event structures.
Basic event-based vision structures based on OpenCV components.