6#ifndef OPENEV_CORE_MATRICES_HPP
7#define OPENEV_CORE_MATRICES_HPP
11#include <opencv2/core/mat.hpp>
12#include <opencv2/core/mat.inl.hpp>
13#include <opencv2/core/traits.hpp>
26 using cv::Mat_<Tb>::Mat_;
34 inline Tb emplace(
const T x,
const T y) {
39 cv::Mat_<Tb>::setTo(0);
42 static constexpr Tb ON = std::numeric_limits<Tb>::max();
43 static constexpr Tb OFF =
static_cast<Tb
>(0);
47 inline Tb set(
const T x,
const T y) {
48 if constexpr(std::is_floating_point_v<T>) {
49 return *(this->
template ptr<Tb>(std::lround(y)) + std::lround(x)) = ON;
51 return *(this->
template ptr<Tb>(y) + x) = ON;
57class Time :
public cv::Mat_<double> {
59 using cv::Mat_<
double>::Mat_;
62 inline double insert(
const Event_<T> &e) {
63 return set(e.x, e.y, e.
t);
67 inline double emplace(
const T x,
const T y,
const double t) {
72 cv::Mat_<double>::setTo(0);
77 inline double set(
const T x,
const T y,
const double t) {
78 if constexpr(std::is_floating_point_v<T>) {
79 return *(this->ptr<double>(std::lround(y)) + std::lround(x)) = t;
81 return *(this->ptr<double>(y) + x) = t;
88 using cv::Mat_<
bool>::Mat_;
92 return set(e.x, e.y, e.
p);
96 inline bool emplace(
const T x,
const T y,
const bool p) {
100 inline void clear() {
101 cv::Mat_<bool>::setTo(
false);
105 template <
typename T>
106 inline bool set(
const T x,
const T y,
const bool p) {
107 if constexpr(std::is_floating_point_v<T>) {
108 return *(this->ptr<bool>(std::lround(y)) + std::lround(x)) = p;
110 return *(this->ptr<bool>(y) + x) = p;
117 using cv::Mat_<
int>::Mat_;
119 template <
typename T>
121 return set(e.x, e.y, e.
p);
124 template <
typename T>
125 inline int emplace(
const T x,
const T y,
const bool p) {
129 inline void clear() {
130 cv::Mat_<int>::setTo(0);
134 template <
typename T>
135 inline int set(
const T x,
const T y,
const bool p) {
136 if constexpr(std::is_floating_point_v<T>) {
137 return *(this->ptr<int>(std::lround(y)) + std::lround(x)) += (p ? +1 : -1);
139 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:55
bool p
Definition types.hpp:58
double t
Definition types.hpp:57
Definition matrices.hpp:24
Definition matrices.hpp:115
Definition matrices.hpp:86
Definition matrices.hpp:57