6#ifndef OPENEV_CORE_TYPES_HPP
7#define OPENEV_CORE_TYPES_HPP
15#include <opencv2/core/base.hpp>
16#include <opencv2/core/matx.hpp>
17#include <opencv2/core/types.hpp>
28enum class Stereo :
char {
33enum DistanceTypes : uint8_t {
34 DISTANCE_NORM_INF = cv::NORM_INF,
35 DISTANCE_NORM_L1 = cv::NORM_L1,
36 DISTANCE_NORM_L2 = cv::NORM_L2,
37 DISTANCE_NORM_L2SQR = cv::NORM_L2SQR,
38 DISTANCE_NORM_MANHATTAN = DISTANCE_NORM_L1,
39 DISTANCE_NORM_EUCLIDEAN = DISTANCE_NORM_L2,
40 DISTANCE_FLAG_SPATIAL = 0b00010000,
41 DISTANCE_FLAG_TEMPORAL = 0b00100000,
42 DISTANCE_FLAG_SPATIOTEMPORAL = 0b01000000,
43 DISTANCE_FLAG_3D = DISTANCE_FLAG_SPATIOTEMPORAL,
44 DISTANCE_FLAG_2D = DISTANCE_FLAG_SPATIAL,
104 Event_(
const T x,
const T y,
const double t,
const bool p) : cv::Point_<T>(x, y),
t{
t},
p{
p} {};
112 Event_(
const cv::Point_<T> &pt,
const double t,
const bool p) : cv::Point_<T>(pt),
t{
t},
p{
p} {};
136 [[nodiscard]] inline
bool operator==(const
Event_<T> &e)
const {
143 [[nodiscard]]
inline bool operator==(
const cv::Point_<T> &pt)
const {
150 [[nodiscard]]
inline bool operator==(
const cv::Point3_<T> &pt)
const {
164 template <
typename U>
165 [[nodiscard]]
inline operator cv::Point_<U>()
const {
172 template <
typename U>
173 [[nodiscard]]
inline operator cv::Point3_<U>()
const {
184 [[nodiscard]]
inline double distance(
const Event_<T> &e,
const uint8_t type = DISTANCE_NORM_L2 | DISTANCE_FLAG_SPATIAL)
const {
185 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIOTEMPORAL)) {
188 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIAL) || !
static_cast<bool>(type & 0xF0)) {
191 if(
static_cast<bool>(type & DISTANCE_FLAG_TEMPORAL)) {
194 logger::error(
"Bad distance option");
213 const double dx = this->x -
static_cast<int>(this->x);
214 const double dy = this->y -
static_cast<int>(this->y);
215 if(dx == 0 && dy == 0) {
219 return {(1 - dy), 0, dy, 0};
222 return {(1 - dx), dx, 0, 0};
224 return {(1 - dx) * (1 - dy), dx * (1 - dy), (1 - dx) * dy, dx * dy};
234 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
270 const double dx = this->x -
static_cast<int>(this->x);
271 const double dy = this->y -
static_cast<int>(this->y);
272 if(dx == 0 && dy == 0) {
293 e1.
weight = (1 - dx) * (1 - dy);
294 e2.
weight = dx * (1 - dy);
295 e3.
weight = (1 - dx) * dy;
297 return {e1, e2, e3, e4};
307 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
308 os <<
" w=" + std::to_string(e.
weight);
309 os <<
" d=" + std::to_string(e.
depth);
310 os <<
" s=" + (e.
stereo == Stereo::LEFT ? std::string(
"LEFT") : std::string(
"RIGHT"));
376 [[nodiscard]]
inline bool empty()
const {
377 return cv::Size_<T>::width <= 0 || cv::Size_<T>::height <= 0 ||
length <= 0;
386 return cv::Size_<T>::width * cv::Size_<T>::height *
length;
449 Rect3_(
const T x,
const T y,
const T
t,
const T w,
const T h,
const T l) : cv::Rect_<T>(x, y, w, h),
t{
t},
length{l} {};
464 Rect3_(
const cv::Point3_<T> &pt,
const Size3_<T> sz) : cv::Rect_<T>(cv::Point_<T>(pt.x, pt.y), cv::Size_<T>(sz.width, sz.height)),
t{pt.z},
length{sz.
length} {};
471 Rect3_(
const cv::Point3_<T> &pt1,
const cv::Point3_<T> &pt2) : cv::Rect_<T>(cv::Point_<T>(pt1.x, pt1.y), cv::Size_<T>(pt2.x - pt1.x, pt2.y - pt1.y)),
t{pt1.z},
length{pt2.z - pt1.z} {};
477 [[nodiscard]]
inline bool empty()
const {
487 template <
typename Te>
489 return cv::Rect_<T>::contains(e) && e.
t >=
t && e.
t <
t +
length;
529 cv::Point_<T> center;
535 Circ_() : center{0, 0}, radius{0} {};
542 Circ_(
const cv::Point_<T> center,
const T radius) : center{center}, radius{radius} {}
548 [[nodiscard]]
inline bool empty()
const {
558 template <
typename Te>
560 return pow(center.x - e.x, 2) + pow(center.y - e.y, 2) <= radius * radius;
563 [[nodiscard]]
inline cv::Size size()
const {
564 return {radius, radius};
567 [[nodiscard]]
inline double area()
const {
568 return M_PI * radius * radius;
This class extends Event to include: weigth, depth, and stereo.
Definition types.hpp:257
std::vector< AugmentedEvent_< int > > bilinearVoting() const
Bilinear voting.
Definition types.hpp:269
Stereo stereo
Definition types.hpp:263
double depth
Definition types.hpp:262
friend std::ostream & operator<<(std::ostream &os, const AugmentedEvent_< T > &e)
Overload of << operator.
Definition types.hpp:306
double weight
Definition types.hpp:261
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:60
bool operator<(const Event_< T > &e) const
Definition types.hpp:157
Event_(const cv::Point_< T > &pt, const double t, const bool p)
Definition types.hpp:112
Event_< T > & operator=(const cv::Point_< T > &p)
Definition types.hpp:122
bool p
Definition types.hpp:63
bool operator==(const cv::Point3_< T > &pt) const
Definition types.hpp:150
bool undistort(const UndistortMap &map)
Definition types.hpp:204
Event_< T > & operator=(Event_< T > &&) noexcept=default
std::array< double, 4 > bilinearVoting() const
Bilinear voting.
Definition types.hpp:212
bool operator==(const cv::Point_< T > &pt) const
Definition types.hpp:143
Event_()
Definition types.hpp:68
Event_(const T x, const T y, const double t, const bool p)
Definition types.hpp:104
Event_< T > & operator=(const Event_< T > &)=default
Event_(Event_< T > &&) noexcept=default
double distance(const Event_< T > &e, const uint8_t type=DISTANCE_NORM_L2|DISTANCE_FLAG_SPATIAL) const
Definition types.hpp:184
Event_(const Event_< T > &)=default
Event_(const cv::Point_< T > &pt)
Definition types.hpp:95
friend std::ostream & operator<<(std::ostream &os, const Event_< T > &e)
Overload of << operator.
Definition types.hpp:233
double t
Definition types.hpp:62
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:430
Rect3_(const T x, const T y, const T t, const T w, const T h, const T l)
Definition types.hpp:449
Rect3_(const Rect2_< T > &rect, const T t, const T l)
Definition types.hpp:457
Size3_< T > size() const
Size of the rectangular cuboid.
Definition types.hpp:496
T volume() const
Compute the volume.
Definition types.hpp:505
bool empty() const
Check if empty.
Definition types.hpp:477
Rect3_(const cv::Point3_< T > &pt1, const cv::Point3_< T > &pt2)
Definition types.hpp:471
Rect3_(const cv::Point3_< T > &pt, const Size3_< T > sz)
Definition types.hpp:464
T t
Definition types.hpp:432
bool contains(const Event_< Te > &e) const
Check if the rectangular cuboid contains an event.
Definition types.hpp:488
Rect3_()
Definition types.hpp:438
T length
Definition types.hpp:433
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:355
bool empty() const
Check if empty.
Definition types.hpp:376
T volume() const
Compute the volume.
Definition types.hpp:385
Size3_(T w, T h, T l)
Definition types.hpp:370
T length
Definition types.hpp:357
Size3_()
Definition types.hpp:362
Definition undistortion.hpp:22
This class defines a circle given its center and radius.
Definition types.hpp:528
Circ_()
Definition types.hpp:535
Circ_(const cv::Point_< T > center, const T radius)
Definition types.hpp:542
bool contains(const Event_< Te > &e) const
Check if the circle contains an event.
Definition types.hpp:559
bool empty() const
Check if empty.
Definition types.hpp:548
Rect2_< double > Rect2d
Definition types.hpp:413
constexpr bool POSITIVE
Definition types.hpp:25
Size2_< double > Size2d
Definition types.hpp:338
Size2i Size2
Definition types.hpp:339
Rect2i Rect2
Definition types.hpp:414
Rect2 Rect
Definition types.hpp:415
Size2_< int > Size2i
Definition types.hpp:335
cv::Size_< T > Size2_
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:334
Size2 Size
Definition types.hpp:340
cv::Rect_< T > Rect2_
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:409
Rect2_< long > Rect2l
Definition types.hpp:411
Rect2_< int > Rect2i
Definition types.hpp:410
constexpr bool NEGATIVE
Definition types.hpp:26
Rect2_< float > Rect2f
Definition types.hpp:412
Size2_< long > Size2l
Definition types.hpp:336
Size2_< float > Size2f
Definition types.hpp:337