OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
filtering.hpp
Go to the documentation of this file.
1
6#ifndef OPENEV_EVPROC_FILTERING_HPP
7#define OPENEV_EVPROC_FILTERING_HPP
8
10#include "openev/core/types.hpp"
11#include <cstddef>
12#include <opencv2/core/mat.hpp>
13#include <opencv2/core/types.hpp>
14
15namespace ev {
16[[maybe_unused]] constexpr bool USING_FILTERING_HPP = true;
17
28public:
35 BackgroundActivityFilter(const cv::Size &size, ev::TimeType dt, int radius = 1);
36
37 ~BackgroundActivityFilter() = default;
40 BackgroundActivityFilter &operator=(const BackgroundActivityFilter &) = default;
41 BackgroundActivityFilter &operator=(BackgroundActivityFilter &&) noexcept = default;
42
47 inline void setDt(const ev::TimeType dt) {
48 dt_ = dt;
49 }
50
54 void reset();
55
62 [[nodiscard]] bool operator()(const ev::Event &e);
63
64private:
65 ev::Mat::Time map_;
66 ev::TimeType dt_;
67 int radius_;
68};
69
79public:
85 RefractoryPeriodFilter(const cv::Size &size, ev::TimeType dt);
86
87 ~RefractoryPeriodFilter() = default;
90 RefractoryPeriodFilter &operator=(const RefractoryPeriodFilter &) = default;
91 RefractoryPeriodFilter &operator=(RefractoryPeriodFilter &&) noexcept = default;
92
97 inline void setDt(const ev::TimeType dt) {
98 dt_ = dt;
99 }
100
104 void reset();
105
112 [[nodiscard]] bool operator()(const ev::Event &e);
113
114private:
115 ev::Mat::Time map_;
116 ev::TimeType dt_;
117};
118
123public:
124 static constexpr double DEFAULT_FACTOR = 10.0;
125 static constexpr std::size_t DISABLED = 0;
126
134 HotPixelFilter(const cv::Size &size, ev::TimeType window, double factor = DEFAULT_FACTOR, std::size_t limit = DISABLED);
135
136 ~HotPixelFilter() = default;
137 HotPixelFilter(const HotPixelFilter &) = default;
138 HotPixelFilter(HotPixelFilter &&) noexcept = default;
139 HotPixelFilter &operator=(const HotPixelFilter &) = default;
140 HotPixelFilter &operator=(HotPixelFilter &&) noexcept = default;
141
146 inline void setWindow(const ev::TimeType window) {
147 window_ = window;
148 }
149
154 inline void setFactor(const double factor) {
155 factor_ = factor;
156 }
157
162 inline void setLimit(const std::size_t limit) {
163 limit_ = limit;
164 }
165
170 [[nodiscard]] inline const cv::Mat_<uchar> &mask() const {
171 return mask_;
172 }
173
177 void reset();
178
184 [[nodiscard]] bool operator()(const ev::Event &e);
185
186private:
187 void evaluate_();
188
189 cv::Mat_<int> counts_;
190 cv::Mat_<uchar> mask_;
191 ev::TimeType window_;
192 double factor_;
193 std::size_t limit_;
194 ev::TimeType start_{0};
195 bool started_{false};
196};
197
198} // namespace ev
199
200#endif // OPENEV_EVPROC_FILTERING_HPP
BackgroundActivityFilter(const cv::Size &size, ev::TimeType dt, int radius=1)
Definition filtering.cpp:11
bool operator()(const ev::Event &e)
Definition filtering.cpp:18
void setDt(const ev::TimeType dt)
Set the time threshold.
Definition filtering.hpp:47
void reset()
Forget every recorded event.
Definition filtering.cpp:14
void setLimit(const std::size_t limit)
Set the absolute criterion.
Definition filtering.hpp:162
bool operator()(const ev::Event &e)
Definition filtering.cpp:67
HotPixelFilter(const cv::Size &size, ev::TimeType window, double factor=DEFAULT_FACTOR, std::size_t limit=DISABLED)
Definition filtering.cpp:58
void reset()
Forget every recorded event and every hot pixel.
Definition filtering.cpp:61
const cv::Mat_< uchar > & mask() const
Get the pixels marked as hot when the last window ended.
Definition filtering.hpp:170
void setWindow(const ev::TimeType window)
Set the duration of the time windows.
Definition filtering.hpp:146
void setFactor(const double factor)
Set the criterion relative to the mean count.
Definition filtering.hpp:154
Spatial map storing the timestamp of the most recent event at each pixel.
Definition matrices.hpp:240
void reset()
Forget every recorded event.
Definition filtering.cpp:45
RefractoryPeriodFilter(const cv::Size &size, ev::TimeType dt)
Definition filtering.cpp:42
void setDt(const ev::TimeType dt)
Set the inhibition time.
Definition filtering.hpp:97
bool operator()(const ev::Event &e)
Definition filtering.cpp:49
Event-based matrix representations for accumulating events into spatial maps.
Basic event-based vision structures based on OpenCV components.
Eventi Event
Definition types.hpp:262