OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
matrices.hpp
Go to the documentation of this file.
1
6#ifndef OPENEV_CORE_MATRICES_HPP
7#define OPENEV_CORE_MATRICES_HPP
8
10
11namespace ev {
12class TimeMat : public cv::Mat_<double> {
13public:
14 template <typename... Args>
15 explicit TimeMat(Args &&...args) : cv::Mat_<double>(std::forward<Args>(args)...) {
16 TimeMat::clear();
17 }
18
19 template <typename T>
20 inline const double &insert(const Event_<T> &e) {
21 if constexpr(std::is_floating_point<T>::value) {
22 return cv::Mat_<double>::operator()(std::round(e.y), std::round(e.x)) = e.t;
23 } else {
24 return cv::Mat_<double>::operator()(e) = e.t;
25 }
26 }
27
28 template <typename T>
29 inline const double &emplace(const T x, const T y, const double t) {
30 if constexpr(std::is_floating_point<T>::value) {
31 return cv::Mat_<double>::operator()(std::round(y), std::round(x)) = t;
32 } else {
33 return cv::Mat_<double>::operator()(y, x) = t;
34 }
35 }
36
37 inline void clear() {
38 cv::Mat_<double>::setTo(0);
39 }
40};
41
42class PolarityMat : public cv::Mat_<bool> {
43public:
44 template <typename... Args>
45 explicit PolarityMat(Args &&...args) : cv::Mat_<bool>(std::forward<Args>(args)...) {
46 PolarityMat::clear();
47 }
48
49 template <typename T>
50 inline const bool &insert(const Event_<T> &e) {
51 if constexpr(std::is_floating_point<T>::value) {
52 return cv::Mat_<bool>::operator()(std::round(e.y), std::round(e.x)) = e.p;
53 } else {
54 return cv::Mat_<bool>::operator()(e) = e.p;
55 }
56 }
57
58 template <typename T>
59 inline const bool &emplace(const T x, const T y, const bool p) {
60 if constexpr(std::is_floating_point<T>::value) {
61 return cv::Mat_<bool>::operator()(std::round(y), std::round(x)) = p;
62 } else {
63 return cv::Mat_<bool>::operator()(y, x) = p;
64 }
65 }
66
67 inline void clear() {
68 cv::Mat_<bool>::setTo(false);
69 }
70};
71
72class CounterMat : public cv::Mat_<int> {
73public:
74 template <typename... Args>
75 explicit CounterMat(Args &&...args) : cv::Mat_<int>(std::forward<Args>(args)...) {
76 CounterMat::clear();
77 }
78
79 template <typename T>
80 inline const int &insert(const Event_<T> &e) {
81 if constexpr(std::is_floating_point<T>::value) {
82 return cv::Mat_<int>::operator()(std::round(e.y), std::round(e.x)) += (e.p ? +1 : -1);
83 } else {
84 return cv::Mat_<int>::operator()(e) += (e.p ? +1 : -1);
85 }
86 }
87
88 template <typename T>
89 inline const int &emplace(const T x, const T y, const bool p) {
90 if constexpr(std::is_floating_point<T>::value) {
91 return cv::Mat_<int>::operator()(std::round(y), std::round(x)) += (p ? +1 : -1);
92 } else {
93 return cv::Mat_<int>::operator()(y, x) += (p ? +1 : -1);
94 }
95 }
96
97 inline void clear() {
98 cv::Mat_<int>::setTo(0);
99 }
100};
101
102} // namespace ev
103
104#endif
Definition matrices.hpp:72
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
Definition matrices.hpp:42
Definition matrices.hpp:12
Basic event-based vision structures based on OpenCV components.