6#ifndef OPENEV_CORE_TYPES_HPP
7#define OPENEV_CORE_TYPES_HPP
14#include <opencv2/core/base.hpp>
15#include <opencv2/core/matx.hpp>
16#include <opencv2/core/types.hpp>
24enum class Stereo :
char {
29enum DistanceTypes : uint8_t {
30 DISTANCE_NORM_INF = cv::NORM_INF,
31 DISTANCE_NORM_L1 = cv::NORM_L1,
32 DISTANCE_NORM_L2 = cv::NORM_L2,
33 DISTANCE_NORM_L2SQR = cv::NORM_L2SQR,
34 DISTANCE_NORM_MANHATTAN = DISTANCE_NORM_L1,
35 DISTANCE_NORM_EUCLIDEAN = DISTANCE_NORM_L2,
36 DISTANCE_FLAG_SPATIAL = 0b00010000,
37 DISTANCE_FLAG_TEMPORAL = 0b00100000,
38 DISTANCE_FLAG_SPATIOTEMPORAL = 0b01000000,
39 DISTANCE_FLAG_3D = DISTANCE_FLAG_SPATIOTEMPORAL,
40 DISTANCE_FLAG_2D = DISTANCE_FLAG_SPATIAL,
100 Event_(
const T x,
const T y,
const double t,
const bool p) : cv::Point_<T>(x, y),
t{
t},
p{
p} {};
108 Event_(
const cv::Point_<T> &pt,
const double t,
const bool p) : cv::Point_<T>(pt),
t{
t},
p{
p} {};
132 [[nodiscard]] inline
bool operator==(const
Event_<T> &e)
const {
139 [[nodiscard]]
inline bool operator==(
const cv::Point_<T> &pt)
const {
146 [[nodiscard]]
inline bool operator==(
const cv::Point3_<T> &pt)
const {
160 template <
typename U>
161 [[nodiscard]]
inline operator cv::Point_<U>()
const {
168 template <
typename U>
169 [[nodiscard]]
inline operator cv::Point3_<U>()
const {
180 [[nodiscard]]
inline double distance(
const Event_<T> &e,
const uint8_t type = DISTANCE_NORM_L2 | DISTANCE_FLAG_SPATIAL)
const {
181 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIOTEMPORAL)) {
184 if(
static_cast<bool>(type & DISTANCE_FLAG_SPATIAL) || !
static_cast<bool>(type & 0xF0)) {
187 if(
static_cast<bool>(type & DISTANCE_FLAG_TEMPORAL)) {
201 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
239 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
240 os <<
" w=" + std::to_string(e.
weight);
241 os <<
" d=" + std::to_string(e.
depth);
242 os <<
" s=" + (e.
stereo == Stereo::LEFT ? std::string(
"LEFT") : std::string(
"RIGHT"));
308 [[nodiscard]]
inline bool empty()
const {
309 return cv::Size_<T>::width <= 0 || cv::Size_<T>::height <= 0 ||
length <= 0;
318 return cv::Size_<T>::width * cv::Size_<T>::height *
length;
381 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} {};
396 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} {};
403 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} {};
409 [[nodiscard]]
inline bool empty()
const {
419 template <
typename Te>
421 return cv::Rect_<T>::contains(e) && e.
t >=
t && e.
t <
t +
length;
461 cv::Point_<T> center;
467 Circ_() : center{0, 0}, radius{0} {};
474 Circ_(
const cv::Point_<T> center,
const T radius) : center{center}, radius{std::max(radius, static_cast<T>(0))} {}
480 [[nodiscard]]
inline bool empty()
const {
490 template <
typename Te>
492 return !
empty() && pow(center.x - e.x, 2) + pow(center.y - e.y, 2) <= radius * radius;
495 [[nodiscard]]
inline cv::Size size()
const {
496 return {radius, radius};
499 [[nodiscard]]
inline double area()
const {
500 return M_PI * radius * radius;
This class extends Event to include: weigth, depth, and stereo.
Definition types.hpp:224
Stereo stereo
Definition types.hpp:230
double depth
Definition types.hpp:229
friend std::ostream & operator<<(std::ostream &os, const AugmentedEvent_< T > &e)
Overload of << operator.
Definition types.hpp:238
double weight
Definition types.hpp:228
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:56
bool operator<(const Event_< T > &e) const
Definition types.hpp:153
Event_(const cv::Point_< T > &pt, const double t, const bool p)
Definition types.hpp:108
Event_< T > & operator=(const cv::Point_< T > &p)
Definition types.hpp:118
bool p
Definition types.hpp:59
bool operator==(const cv::Point3_< T > &pt) const
Definition types.hpp:146
Event_< T > & operator=(Event_< T > &&) noexcept=default
bool operator==(const cv::Point_< T > &pt) const
Definition types.hpp:139
Event_()
Definition types.hpp:64
Event_(const T x, const T y, const double t, const bool p)
Definition types.hpp:100
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:180
Event_(const Event_< T > &)=default
Event_(const cv::Point_< T > &pt)
Definition types.hpp:91
friend std::ostream & operator<<(std::ostream &os, const Event_< T > &e)
Overload of << operator.
Definition types.hpp:200
double t
Definition types.hpp:58
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:362
Rect3_(const T x, const T y, const T t, const T w, const T h, const T l)
Definition types.hpp:381
Rect3_(const Rect2_< T > &rect, const T t, const T l)
Definition types.hpp:389
Size3_< T > size() const
Size of the rectangular cuboid.
Definition types.hpp:428
T volume() const
Compute the volume.
Definition types.hpp:437
bool empty() const
Check if empty.
Definition types.hpp:409
Rect3_(const cv::Point3_< T > &pt1, const cv::Point3_< T > &pt2)
Definition types.hpp:403
Rect3_(const cv::Point3_< T > &pt, const Size3_< T > sz)
Definition types.hpp:396
int t
Definition types.hpp:364
bool contains(const Event_< Te > &e) const
Check if the rectangular cuboid contains an event.
Definition types.hpp:420
Rect3_()
Definition types.hpp:370
int length
Definition types.hpp:365
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:287
bool empty() const
Check if empty.
Definition types.hpp:308
T volume() const
Compute the volume.
Definition types.hpp:317
Size3_(T w, T h, T l)
Definition types.hpp:302
int length
Definition types.hpp:289
Size3_()
Definition types.hpp:294
void error(const char *message, const bool assert_condition=false)
Log message at error level.
Definition logger.hpp:38
This class defines a circle given its center and radius.
Definition types.hpp:460
Circ_()
Definition types.hpp:467
Circ_(const cv::Point_< T > center, const T radius)
Definition types.hpp:474
bool contains(const Event_< Te > &e) const
Check if the circle contains an event.
Definition types.hpp:491
bool empty() const
Check if empty.
Definition types.hpp:480
Event_< long > Eventl
Definition types.hpp:206
Rect2_< double > Rect2d
Definition types.hpp:345
Event_< int > Eventi
Definition types.hpp:205
constexpr bool POSITIVE
Definition types.hpp:21
Size2_< double > Size2d
Definition types.hpp:270
Size2i Size2
Definition types.hpp:271
Rect2i Rect2
Definition types.hpp:346
Rect2 Rect
Definition types.hpp:347
Event_< double > Eventd
Definition types.hpp:208
Size2_< int > Size2i
Definition types.hpp:267
Circ_< long > Circl
Definition types.hpp:504
Rect3_< int > Rect3i
Definition types.hpp:441
Size3i Size3
Definition types.hpp:325
Circ_< double > Circd
Definition types.hpp:506
Rect3i Rect3
Definition types.hpp:445
Circ_< int > Circi
Definition types.hpp:503
cv::Size_< T > Size2_
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:266
Rect3_< double > Rect3d
Definition types.hpp:444
Size2 Size
Definition types.hpp:272
cv::Rect_< T > Rect2_
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:341
Circ_< float > Circf
Definition types.hpp:505
AugmentedEvent_< float > AugmentedEventf
Definition types.hpp:248
AugmentedEventi AugmentedEvent
Definition types.hpp:250
Rect2_< long > Rect2l
Definition types.hpp:343
Rect3_< float > Rect3f
Definition types.hpp:443
AugmentedEvent_< long > AugmentedEventl
Definition types.hpp:247
Size3_< float > Size3f
Definition types.hpp:323
Rect2_< int > Rect2i
Definition types.hpp:342
AugmentedEvent_< int > AugmentedEventi
Definition types.hpp:246
Size3_< double > Size3d
Definition types.hpp:324
constexpr bool NEGATIVE
Definition types.hpp:22
Event_< float > Eventf
Definition types.hpp:207
Size3_< long > Size3l
Definition types.hpp:322
Circi Circ
Definition types.hpp:507
AugmentedEvent_< double > AugmentedEventd
Definition types.hpp:249
Rect2_< float > Rect2f
Definition types.hpp:344
Size2_< long > Size2l
Definition types.hpp:268
Size2_< float > Size2f
Definition types.hpp:269
Eventi Event
Definition types.hpp:209
Size3_< int > Size3i
Definition types.hpp:321
Rect3_< long > Rect3l
Definition types.hpp:442