6#ifndef OPENEV_REPRESENTATIONS_SPACE_TIME_HPP
7#define OPENEV_REPRESENTATIONS_SPACE_TIME_HPP
11#include <opencv2/core/hal/interface.h>
12#include <opencv2/core/mat.hpp>
13#include <opencv2/core/matx.hpp>
14#include <opencv2/core/types.hpp>
15#include <opencv2/viz/types.hpp>
19[[maybe_unused]]
constexpr bool USING_SPACE_TIME_HPP =
true;
51template <
typename T, const RepresentationOptions Options = RepresentationOptions::NONE,
typename E =
int>
54 static constexpr double DEFAULT_YAW = 30.0;
55 static constexpr double DEFAULT_PITCH = 20.0;
56 static constexpr double DEFAULT_DEPTH = 1.0;
57 static constexpr double DISTANCE = 2.5;
58 static constexpr int MARGIN = 2;
59 static constexpr double LABEL_SCALE = 0.35;
60 static constexpr double DEFAULT_AXES_LENGTH = 0.25;
61 static constexpr double DEFAULT_FADE = 0.8;
68 explicit SpaceTime_(
const cv::Size canvas,
const cv::Size sensor = cv::Size());
88 inline void showAxes(
const bool state,
const double length = DEFAULT_AXES_LENGTH) {
90 axesLength_ = std::clamp(length, 0.0, 1.0);
98 inline void fadeWithDepth(
const bool state,
const double strength = DEFAULT_FADE) {
100 fadeStrength_ = std::clamp(strength, 0.0, 1.0);
116 axesValue_ = TypeHelper<T>::convert(color);
123 [[nodiscard]]
inline double yaw()
const {
131 [[nodiscard]]
inline double pitch()
const {
159 double yaw_{DEFAULT_YAW};
160 double pitch_{DEFAULT_PITCH};
161 double depth_{DEFAULT_DEPTH};
162 cv::Matx33d rotation_;
165 std::vector<Event_<E>> events_;
169 double axesLength_{DEFAULT_AXES_LENGTH};
171 double fadeStrength_{DEFAULT_FADE};
172 typename TypeHelper<T>::Type axesValue_ = TypeHelper<T>::convert(cv::viz::Color::white());
177 [[nodiscard]]
typename TypeHelper<T>::Type faded_(
const typename TypeHelper<T>::Type &value,
const cv::Point &pixel,
const double age)
const;
178 [[nodiscard]] cv::Point2d corner_(
const double x,
const double y,
const double age)
const;
179 [[nodiscard]] cv::Point2d project_(
const cv::Point3d &point)
const;
181 [[nodiscard]] cv::Size frameSize_()
const override {
185 void clear_()
override;
186 void clear_(
const cv::Mat &background)
override;
187 bool insert_(
const Event_<E> &e)
override;
207#include "openev/representations/space-time.tpp"
Event abstract representation.
This class extends cv::Point_<T> for event data. For more information, please refer here.
Definition types.hpp:86
This class extends ev::EventImage_<T> to draw the events as a cloud in the x-y-t volume seen in persp...
Definition space-time.hpp:52
cv::Point2d project(const Event_< E > &e, const double age) const
Project an event onto the canvas with the current view.
cv::Mat & render()
Render the space-time view.
void setAxesColor(const cv::viz::Color &color)
Set the colour the axes are drawn with. For more information, please refer here.
Definition space-time.hpp:115
void setDepth(const double depth)
Set the depth of the box, that is, how long the time axis is drawn.
void showAxes(const bool state, const double length=DEFAULT_AXES_LENGTH)
Draw the x, y and t axes from the sensor origin, labelled at their ends.
Definition space-time.hpp:88
void setView(const double yaw, const double pitch)
Set the view angles.
cv::Size sensorSize() const
Sensor size.
Definition space-time.hpp:139
double yaw() const
Definition space-time.hpp:123
void fadeWithDepth(const bool state, const double strength=DEFAULT_FADE)
Fade the events towards the background as they recede, so the depth shows.
Definition space-time.hpp:98
double pitch() const
Definition space-time.hpp:131
void setAxesValue(const typename TypeHelper< T >::Type &value)
Set the value the axes are drawn with.
Definition space-time.hpp:107
SpaceTime_(const cv::Size canvas, const cv::Size sensor=cv::Size())
Construct the canvas.
SpaceTime_< cv::Vec3s > SpaceTime3s
Definition space-time.hpp:192
SpaceTime_< cv::Vec3f > SpaceTime3f
Definition space-time.hpp:198
SpaceTime_< cv::Vec3i > SpaceTime3i
Definition space-time.hpp:196
SpaceTime_< cv::Vec3b > SpaceTime3b
Definition space-time.hpp:190
SpaceTime1 SpaceTime
Definition space-time.hpp:203
SpaceTime_< ushort > SpaceTime1w
Definition space-time.hpp:193
SpaceTime_< short > SpaceTime1s
Definition space-time.hpp:191
SpaceTime_< uchar > SpaceTime1b
Definition space-time.hpp:189
SpaceTime1b SpaceTime1
Definition space-time.hpp:201
SpaceTime_< cv::Vec3d > SpaceTime3d
Definition space-time.hpp:200
SpaceTime_< int > SpaceTime1i
Definition space-time.hpp:195
SpaceTime3b SpaceTime3
Definition space-time.hpp:202
SpaceTime_< cv::Vec3w > SpaceTime3w
Definition space-time.hpp:194
SpaceTime_< double > SpaceTime1d
Definition space-time.hpp:199
SpaceTime_< float > SpaceTime1f
Definition space-time.hpp:197