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>
30enum class Stereo :
char {
35enum DistanceTypes : uint8_t {
36 DISTANCE_NORM_INF = cv::NORM_INF,
37 DISTANCE_NORM_L1 = cv::NORM_L1,
38 DISTANCE_NORM_L2 = cv::NORM_L2,
39 DISTANCE_NORM_L2SQR = cv::NORM_L2SQR,
40 DISTANCE_NORM_MANHATTAN = DISTANCE_NORM_L1,
41 DISTANCE_NORM_EUCLIDEAN = DISTANCE_NORM_L2,
42 DISTANCE_FLAG_SPATIAL = 0b00010000,
43 DISTANCE_FLAG_TEMPORAL = 0b00100000,
44 DISTANCE_FLAG_SPATIOTEMPORAL = 0b01000000,
45 DISTANCE_FLAG_3D = DISTANCE_FLAG_SPATIOTEMPORAL,
46 DISTANCE_FLAG_2D = DISTANCE_FLAG_SPATIAL,
106 Event_(
const T x,
const T y,
const double t,
const bool p) : cv::Point_<T>(x, y),
t{
t},
p{
p} {};
114 Event_(
const cv::Point_<T> &pt,
const double t,
const bool p) : cv::Point_<T>(pt),
t{
t},
p{
p} {};
138 [[nodiscard]] inline
bool operator==(const
Event_<T> &e)
const {
145 [[nodiscard]]
inline bool operator==(
const cv::Point_<T> &pt)
const {
152 [[nodiscard]]
inline bool operator==(
const cv::Point3_<T> &pt)
const {
166 template <
typename U>
167 [[nodiscard]]
inline operator cv::Point_<U>()
const {
174 template <
typename U>
175 [[nodiscard]]
inline operator cv::Point3_<U>()
const {
186 [[nodiscard]]
inline double distance(
const Event_<T> &e,
const uint8_t type = DISTANCE_NORM_L2 | DISTANCE_FLAG_SPATIAL)
const {
187 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIOTEMPORAL)) {
190 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIAL) || !
static_cast<bool>(type & 0xF0)) {
193 if(
static_cast<bool>(type & DISTANCE_FLAG_TEMPORAL)) {
215 const double dx = this->x -
static_cast<int>(this->x);
216 const double dy = this->y -
static_cast<int>(this->y);
217 if(dx == 0 && dy == 0) {
221 return {(1 - dy), 0, dy, 0};
224 return {(1 - dx), dx, 0, 0};
226 return {(1 - dx) * (1 - dy), dx * (1 - dy), (1 - dx) * dy, dx * dy};
236 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
272 const double dx = this->x -
static_cast<int>(this->x);
273 const double dy = this->y -
static_cast<int>(this->y);
274 if(dx == 0 && dy == 0) {
295 e1.
weight = (1 - dx) * (1 - dy);
296 e2.
weight = dx * (1 - dy);
297 e3.
weight = (1 - dx) * dy;
299 return {e1, e2, e3, e4};
309 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
310 os <<
" w=" + std::to_string(e.
weight);
311 os <<
" d=" + std::to_string(e.
depth);
312 os <<
" s=" + (e.
stereo == Stereo::LEFT ? std::string(
"LEFT") : std::string(
"RIGHT"));
378 [[nodiscard]]
inline bool empty()
const {
379 return cv::Size_<T>::width <= 0 || cv::Size_<T>::height <= 0 ||
length <= 0;
388 return cv::Size_<T>::width * cv::Size_<T>::height *
length;
451 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} {};
466 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} {};
473 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} {};
479 [[nodiscard]]
inline bool empty()
const {
489 template <
typename Te>
491 return cv::Rect_<T>::contains(e) && e.
t >=
t && e.
t <
t +
length;
531 cv::Point_<T> center;
537 Circ_() : center{0, 0}, radius{0} {};
544 Circ_(
const cv::Point_<T> center,
const T radius) : center{center}, radius{radius} {}
550 [[nodiscard]]
inline bool empty()
const {
560 template <
typename Te>
562 return pow(center.x - e.x, 2) + pow(center.y - e.y, 2) <= radius * radius;
565 [[nodiscard]]
inline cv::Size size()
const {
566 return {radius, radius};
569 [[nodiscard]]
inline double area()
const {
570 return M_PI * radius * radius;
This class extends Event to include: weigth, depth, and stereo.
Definition types.hpp:259
std::vector< AugmentedEvent_< int > > bilinearVoting() const
Bilinear voting.
Definition types.hpp:271
Stereo stereo
Definition types.hpp:265
double depth
Definition types.hpp:264
friend std::ostream & operator<<(std::ostream &os, const AugmentedEvent_< T > &e)
Overload of << operator.
Definition types.hpp:308
double weight
Definition types.hpp:263
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:62
bool operator<(const Event_< T > &e) const
Definition types.hpp:159
Event_(const cv::Point_< T > &pt, const double t, const bool p)
Definition types.hpp:114
Event_< T > & operator=(const cv::Point_< T > &p)
Definition types.hpp:124
bool p
Definition types.hpp:65
bool operator==(const cv::Point3_< T > &pt) const
Definition types.hpp:152
bool undistort(const UndistortMap &map)
Definition types.hpp:206
Event_< T > & operator=(Event_< T > &&) noexcept=default
std::array< double, 4 > bilinearVoting() const
Bilinear voting.
Definition types.hpp:214
bool operator==(const cv::Point_< T > &pt) const
Definition types.hpp:145
Event_()
Definition types.hpp:70
Event_(const T x, const T y, const double t, const bool p)
Definition types.hpp:106
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:186
Event_(const Event_< T > &)=default
Event_(const cv::Point_< T > &pt)
Definition types.hpp:97
friend std::ostream & operator<<(std::ostream &os, const Event_< T > &e)
Overload of << operator.
Definition types.hpp:235
double t
Definition types.hpp:64
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:432
Rect3_(const T x, const T y, const T t, const T w, const T h, const T l)
Definition types.hpp:451
Rect3_(const Rect2_< T > &rect, const T t, const T l)
Definition types.hpp:459
Size3_< T > size() const
Size of the rectangular cuboid.
Definition types.hpp:498
T volume() const
Compute the volume.
Definition types.hpp:507
bool empty() const
Check if empty.
Definition types.hpp:479
Rect3_(const cv::Point3_< T > &pt1, const cv::Point3_< T > &pt2)
Definition types.hpp:473
Rect3_(const cv::Point3_< T > &pt, const Size3_< T > sz)
Definition types.hpp:466
int t
Definition types.hpp:434
bool contains(const Event_< Te > &e) const
Check if the rectangular cuboid contains an event.
Definition types.hpp:490
Rect3_()
Definition types.hpp:440
int length
Definition types.hpp:435
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:357
bool empty() const
Check if empty.
Definition types.hpp:378
T volume() const
Compute the volume.
Definition types.hpp:387
Size3_(T w, T h, T l)
Definition types.hpp:372
int length
Definition types.hpp:359
Size3_()
Definition types.hpp:364
Definition undistortion.hpp:25
void error(const char *message, const bool assert_condition=false)
Log message at error level.
Definition logger.hpp:39
This class defines a circle given its center and radius.
Definition types.hpp:530
Circ_()
Definition types.hpp:537
Circ_(const cv::Point_< T > center, const T radius)
Definition types.hpp:544
bool contains(const Event_< Te > &e) const
Check if the circle contains an event.
Definition types.hpp:561
bool empty() const
Check if empty.
Definition types.hpp:550
Event_< long > Eventl
Definition types.hpp:241
Rect2_< double > Rect2d
Definition types.hpp:415
Event_< int > Eventi
Definition types.hpp:240
constexpr bool POSITIVE
Definition types.hpp:27
Size2_< double > Size2d
Definition types.hpp:340
Size2i Size2
Definition types.hpp:341
Rect2i Rect2
Definition types.hpp:416
Rect2 Rect
Definition types.hpp:417
Event_< double > Eventd
Definition types.hpp:243
Size2_< int > Size2i
Definition types.hpp:337
Circ_< long > Circl
Definition types.hpp:574
Rect3_< int > Rect3i
Definition types.hpp:511
Size3i Size3
Definition types.hpp:395
Circ_< double > Circd
Definition types.hpp:576
Rect3i Rect3
Definition types.hpp:515
Circ_< int > Circi
Definition types.hpp:573
cv::Size_< T > Size2_
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:336
Rect3_< double > Rect3d
Definition types.hpp:514
Size2 Size
Definition types.hpp:342
cv::Rect_< T > Rect2_
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:411
Circ_< float > Circf
Definition types.hpp:575
AugmentedEvent_< float > AugmentedEventf
Definition types.hpp:318
AugmentedEventi AugmentedEvent
Definition types.hpp:320
Rect2_< long > Rect2l
Definition types.hpp:413
Rect3_< float > Rect3f
Definition types.hpp:513
AugmentedEvent_< long > AugmentedEventl
Definition types.hpp:317
Size3_< float > Size3f
Definition types.hpp:393
Rect2_< int > Rect2i
Definition types.hpp:412
AugmentedEvent_< int > AugmentedEventi
Definition types.hpp:316
Size3_< double > Size3d
Definition types.hpp:394
constexpr bool NEGATIVE
Definition types.hpp:28
Event_< float > Eventf
Definition types.hpp:242
Size3_< long > Size3l
Definition types.hpp:392
Circi Circ
Definition types.hpp:577
AugmentedEvent_< double > AugmentedEventd
Definition types.hpp:319
Rect2_< float > Rect2f
Definition types.hpp:414
Size2_< long > Size2l
Definition types.hpp:338
Size2_< float > Size2f
Definition types.hpp:339
Eventi Event
Definition types.hpp:244
Size3_< int > Size3i
Definition types.hpp:391
Rect3_< long > Rect3l
Definition types.hpp:512