6#ifndef OPENEV_CORE_TYPES_HPP
7#define OPENEV_CORE_TYPES_HPP
13#include <opencv2/core/base.hpp>
14#include <opencv2/core/matx.hpp>
15#include <opencv2/core/types.hpp>
16#include <opencv2/core/utils/logger.hpp>
21constexpr bool USING_TYPES_HPP =
true;
23using TimeType = float;
24using PolarityType = bool;
25using WeightType = float;
26using DepthType = float;
27using CounterType = int16_t;
29constexpr PolarityType
POSITIVE =
static_cast<PolarityType
>(
true);
30constexpr PolarityType
NEGATIVE =
static_cast<PolarityType
>(
false);
51 DISTANCE_NORM_INF =
static_cast<uint8_t
>(cv::NORM_INF),
52 DISTANCE_NORM_L1 =
static_cast<uint8_t
>(cv::NORM_L1),
53 DISTANCE_NORM_L2 =
static_cast<uint8_t
>(cv::NORM_L2),
54 DISTANCE_NORM_L2SQR =
static_cast<uint8_t
>(cv::NORM_L2SQR),
55 DISTANCE_NORM_MANHATTAN = DISTANCE_NORM_L1,
56 DISTANCE_NORM_EUCLIDEAN = DISTANCE_NORM_L2,
121 Event_(
const T x,
const T y,
const TimeType
t,
const PolarityType
p) : cv::Point_<T>(x, y),
t{
t},
p{
p} {};
129 Event_(
const cv::Point_<T> &pt,
const TimeType
t,
const PolarityType
p) : cv::Point_<T>(pt),
t{
t},
p{
p} {};
139 template <
typename U>
175 [[nodiscard]] inline
bool operator==(const
Event_<T> &e)
const {
182 [[nodiscard]]
inline bool operator==(
const cv::Point_<T> &pt)
const {
189 [[nodiscard]]
inline bool operator==(
const cv::Point3_<T> &pt)
const {
203 template <
typename U>
204 [[nodiscard]]
inline explicit operator cv::Point_<U>()
const {
211 template <
typename U>
212 [[nodiscard]]
inline explicit operator cv::Point3_<U>()
const {
233 CV_LOG_ERROR(
nullptr,
"Bad distance option");
244 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
282 os << std::string(
"(" + std::to_string(e.x) +
"," + std::to_string(e.y) +
") " + std::to_string(e.
t) + (e.
p ?
" [+]" :
" [-]"));
283 os <<
" w=" + std::to_string(e.
weight);
284 os <<
" d=" + std::to_string(e.
depth);
285 os <<
" s=" + (e.
stereo ==
Stereo::LEFT ? std::string(
"LEFT") : std::string(
"RIGHT"));
351 [[nodiscard]]
inline bool empty()
const {
352 return cv::Size_<T>::width <= 0 || cv::Size_<T>::height <= 0 ||
length <= 0;
361 return cv::Size_<T>::width * cv::Size_<T>::height *
length;
424 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} {};
439 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} {};
446 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} {};
452 [[nodiscard]]
inline bool empty()
const {
462 template <
typename Te>
464 return cv::Rect_<T>::contains(e) && e.
t >=
t && e.
t <
t +
length;
504 cv::Point_<T> center;
510 Circ_() : center{0, 0}, radius{0} {};
517 Circ_(
const cv::Point_<T> center,
const T radius) : center{center}, radius{std::max(radius, static_cast<T>(0))} {}
523 [[nodiscard]]
inline bool empty()
const {
533 template <
typename Te>
535 return !
empty() && pow(center.x - e.x, 2) + pow(center.y - e.y, 2) <= radius * radius;
542 [[nodiscard]]
inline cv::Size
size()
const {
543 return {radius, radius};
551 [[nodiscard]]
inline double area()
const {
552 return M_PI * radius * radius;
This class extends Event to include: weigth, depth, and stereo.
Definition types.hpp:267
DepthType depth
Definition types.hpp:272
WeightType weight
Definition types.hpp:271
Stereo stereo
Definition types.hpp:273
friend std::ostream & operator<<(std::ostream &os, const AugmentedEvent_< T > &e)
Overload of << operator.
Definition types.hpp:281
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:77
PolarityType p
Definition types.hpp:80
bool operator<(const Event_< T > &e) const
Definition types.hpp:196
Event_< T > & operator=(const cv::Point_< T > &p)
Definition types.hpp:161
Event_(const T x, const T y, const TimeType t, const PolarityType p)
Definition types.hpp:121
bool operator==(const cv::Point3_< T > &pt) const
Definition types.hpp:189
Event_(const cv::Point_< T > &pt, const TimeType t, const PolarityType p)
Definition types.hpp:129
Event_< T > & operator=(Event_< T > &&) noexcept=default
Event_< T > & operator=(const Event_< U > &e)
Definition types.hpp:140
bool operator==(const cv::Point_< T > &pt) const
Definition types.hpp:182
TimeType t
Definition types.hpp:79
Event_()
Definition types.hpp:85
Event_< T > & operator=(const cv::Point3_< T > &p)
Definition types.hpp:151
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:223
Event_(const Event_< T > &)=default
Event_(const cv::Point_< T > &pt)
Definition types.hpp:112
friend std::ostream & operator<<(std::ostream &os, const Event_< T > &e)
Overload of << operator.
Definition types.hpp:243
This class extends cv::Rect_<T> for event data. For more information, please refer here.
Definition types.hpp:405
Rect3_(const T x, const T y, const T t, const T w, const T h, const T l)
Definition types.hpp:424
Rect3_(const Rect2_< T > &rect, const T t, const T l)
Definition types.hpp:432
Size3_< T > size() const
Size of the rectangular cuboid.
Definition types.hpp:471
T volume() const
Compute the volume.
Definition types.hpp:480
bool empty() const
Check if empty.
Definition types.hpp:452
Rect3_(const cv::Point3_< T > &pt1, const cv::Point3_< T > &pt2)
Definition types.hpp:446
Rect3_(const cv::Point3_< T > &pt, const Size3_< T > sz)
Definition types.hpp:439
int t
Definition types.hpp:407
bool contains(const Event_< Te > &e) const
Check if the rectangular cuboid contains an event.
Definition types.hpp:463
Rect3_()
Definition types.hpp:413
int length
Definition types.hpp:408
This class extends cv::Size_<T> for event data. For more information, please refer here.
Definition types.hpp:330
bool empty() const
Check if empty.
Definition types.hpp:351
T volume() const
Compute the volume.
Definition types.hpp:360
Size3_(T w, T h, T l)
Definition types.hpp:345
int length
Definition types.hpp:332
Size3_()
Definition types.hpp:337
This class defines a circle given its center and radius.
Definition types.hpp:503
Circ_()
Definition types.hpp:510
double area() const
Compute the area of the circle.
Definition types.hpp:551
Circ_(const cv::Point_< T > center, const T radius)
Definition types.hpp:517
cv::Size size() const
Bounding square of the circle as a cv::Size (radius × radius).
Definition types.hpp:542
bool contains(const Event_< Te > &e) const
Check if the circle contains an event.
Definition types.hpp:534
bool empty() const
Check if empty.
Definition types.hpp:523
Event_< long > Eventl
Definition types.hpp:249
Rect2_< double > Rect2d
Definition types.hpp:388
constexpr PolarityType POSITIVE
Definition types.hpp:29
Event_< int > Eventi
Definition types.hpp:248
Size2_< double > Size2d
Definition types.hpp:313
Size2i Size2
Definition types.hpp:314
Rect2i Rect2
Definition types.hpp:389
Rect2 Rect
Definition types.hpp:390
Event_< double > Eventd
Definition types.hpp:251
Size2_< int > Size2i
Definition types.hpp:310
Circ_< long > Circl
Definition types.hpp:556
Rect3_< int > Rect3i
Definition types.hpp:484
Size3i Size3
Definition types.hpp:368
Circ_< double > Circd
Definition types.hpp:558
Rect3i Rect3
Definition types.hpp:488
Circ_< int > Circi
Definition types.hpp:555
cv::Size_< T > Size2_
Type alias for cv::Size_<T> providing a named 2D size for event data. For more information,...
Definition types.hpp:309
Rect3_< double > Rect3d
Definition types.hpp:487
Size2 Size
Definition types.hpp:315
DistanceTypes
Norm types and dimensional flags for Event_::distance().
Definition types.hpp:50
@ DISTANCE_FLAG_SPATIOTEMPORAL
Definition types.hpp:59
@ DISTANCE_FLAG_TEMPORAL
Definition types.hpp:58
@ DISTANCE_FLAG_2D
Definition types.hpp:61
@ DISTANCE_FLAG_SPATIAL
Definition types.hpp:57
@ DISTANCE_FLAG_3D
Definition types.hpp:60
cv::Rect_< T > Rect2_
Type alias for cv::Rect_<T> providing a named 2D rectangle for event data. For more information,...
Definition types.hpp:384
Circ_< float > Circf
Definition types.hpp:557
AugmentedEvent_< float > AugmentedEventf
Definition types.hpp:291
AugmentedEventi AugmentedEvent
Definition types.hpp:293
Rect2_< long > Rect2l
Definition types.hpp:386
Rect3_< float > Rect3f
Definition types.hpp:486
AugmentedEvent_< long > AugmentedEventl
Definition types.hpp:290
Size3_< float > Size3f
Definition types.hpp:366
Rect2_< int > Rect2i
Definition types.hpp:385
Stereo
Stereo camera side identifier.
Definition types.hpp:35
@ RIGHT
Definition types.hpp:37
@ LEFT
Definition types.hpp:36
AugmentedEvent_< int > AugmentedEventi
Definition types.hpp:289
Size3_< double > Size3d
Definition types.hpp:367
Event_< float > Eventf
Definition types.hpp:250
Size3_< long > Size3l
Definition types.hpp:365
Circi Circ
Definition types.hpp:559
AugmentedEvent_< double > AugmentedEventd
Definition types.hpp:292
Rect2_< float > Rect2f
Definition types.hpp:387
Size2_< long > Size2l
Definition types.hpp:311
Size2_< float > Size2f
Definition types.hpp:312
Eventi Event
Definition types.hpp:252
Size3_< int > Size3i
Definition types.hpp:364
Rect3_< long > Rect3l
Definition types.hpp:485
constexpr PolarityType NEGATIVE
Definition types.hpp:30