6#ifndef OPENEV_CORE_MATRICES_HPP
7#define OPENEV_CORE_MATRICES_HPP
13#include <opencv2/core/mat.hpp>
14#include <opencv2/core/mat.inl.hpp>
15#include <opencv2/core/traits.hpp>
23template <
typename Tm = std::u
int8_t>
26 using cv::Mat_<Tm>::Mat_;
34 inline Tm emplace(
const T x,
const T y) {
39 cv::Mat_<Tm>::setTo(0);
43 static constexpr Tm value_ = std::numeric_limits<Tm>::max();
46 inline Tm set(
const T x,
const T y) {
47 if constexpr(std::is_floating_point_v<T>) {
48 return *(this->
template ptr<Tm>(std::lround(y)) + std::lround(x)) = value_;
50 return *(this->
template ptr<Tm>(y) + x) = value_;
55class Time :
public cv::Mat_<double> {
57 using cv::Mat_<
double>::Mat_;
60 inline double insert(
const Event_<T> &e) {
61 return set(e.x, e.y, e.
t);
65 inline double emplace(
const T x,
const T y,
const double t) {
70 cv::Mat_<double>::setTo(0);
75 inline double set(
const T x,
const T y,
const double t) {
76 if constexpr(std::is_floating_point_v<T>) {
77 return *(this->ptr<double>(std::lround(y)) + std::lround(x)) = t;
79 return *(this->ptr<double>(y) + x) = t;
86 using cv::Mat_<
bool>::Mat_;
90 return set(e.x, e.y, e.
p);
94 inline bool emplace(
const T x,
const T y,
const bool p) {
99 cv::Mat_<bool>::setTo(
false);
103 template <
typename T>
104 inline bool set(
const T x,
const T y,
const bool p) {
105 if constexpr(std::is_floating_point_v<T>) {
106 return *(this->ptr<bool>(std::lround(y)) + std::lround(x)) = p;
108 return *(this->ptr<bool>(y) + x) = p;
115 using cv::Mat_<
int>::Mat_;
117 template <
typename T>
119 return set(e.x, e.y, e.
p);
122 template <
typename T>
123 inline int emplace(
const T x,
const T y,
const bool p) {
127 inline void clear() {
128 cv::Mat_<int>::setTo(0);
132 template <
typename T>
133 inline int set(
const T x,
const T y,
const bool p) {
134 if constexpr(std::is_floating_point_v<T>) {
135 return *(this->ptr<int>(std::lround(y)) + std::lround(x)) += (p ? +1 : -1);
137 return *(this->ptr<int>(y) + x) += (p ? +1 : -1);
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
Definition matrices.hpp:24
Definition matrices.hpp:113
Definition matrices.hpp:84
Definition matrices.hpp:55
Basic event-based vision structures based on OpenCV components.