6#ifndef OPENEV_DEVICES_ABSTRACT_CAMERA_HPP
7#define OPENEV_DEVICES_ABSTRACT_CAMERA_HPP
10#include "openev/containers/vector.hpp"
13#include <opencv2/core/mat.hpp>
14#include <opencv2/core/types.hpp>
28constexpr double us(
const T x) {
return static_cast<double>(x) * 1e-6; }
31constexpr double EARTH_GRAVITY = 9.80665;
32constexpr double DEG2RAD = M_PI / 180.0;
33constexpr double SCALE_16B_8B = 1.0 / 256.0;
38 [[nodiscard]]
friend std::ostream &operator<<(std::ostream &os,
const struct BiasValue &value) {
39 os <<
"Coarse: " <<
static_cast<int>(value.coarse) <<
", Fine: " <<
static_cast<int>(value.fine);
42} __attribute__((aligned(2)));
57using StampedMatVector = std::vector<StampedMat>;
58using StampedMatQueue = std::queue<StampedMat>;
68 [[nodiscard]]
bool empty()
const {
69 return x == 0 && y == 0 && z == 0;
76 friend std::ostream &operator<<(std::ostream &os,
const xyz_t &xyz) {
77 os <<
"(" << xyz.x <<
", " << xyz.y <<
", " << xyz.z <<
")";
80} __attribute__((aligned(32)));
93 xyz_t linear_acceleration;
94 xyz_t angular_velocity;
96 [[nodiscard]]
bool empty()
const {
97 return t == 0 && linear_acceleration.empty() && angular_velocity.empty();
102 linear_acceleration.release();
103 angular_velocity.release();
106 friend std::ostream &operator<<(std::ostream &os,
const Imu &imu) {
107 os <<
"t: " << imu.t <<
", acc: " << imu.linear_acceleration <<
", gyr: " << imu.angular_velocity;
110} __attribute__((aligned(128)));
111using ImuVector = std::vector<Imu>;
112using ImuQueue = std::queue<Imu>;
133 timeOffset_ = offset;
156 [[nodiscard]] cv::Rect_<uint16_t>
getRoi()
const;
163 bool setRoi(
const cv::Rect_<uint16_t> &roi);
180 bool setBias(
const int8_t config_bias,
const uint8_t name,
const BiasValue &value);
186 void flush(
const double msec)
const;
204 std::atomic<bool> running_{
false};
206 double timeOffset_{0};
207 cv::Rect_<uint16_t> roi_;
210 virtual void init() = 0;
This is an auxiliary class. This class cannot be instanced.
Definition abstract-camera.hpp:117
cv::Size getSensorSize() const
Get device sensor size.
Definition abstract-camera.cpp:25
void flush(const double msec) const
Discard data during an interval of time.
Definition abstract-camera.cpp:66
virtual bool getData(Queue &events)=0
Get data.
bool setRoi(const cv::Rect_< uint16_t > &roi)
Set current ROI. Events outside the ROI are not considered. Images are cropped according to the ROI.
Definition abstract-camera.cpp:38
void start()
Start reading data.
Definition abstract-camera.cpp:16
bool setBias(const int8_t config_bias, const uint8_t name, const BiasValue &value)
Set the bias value associated with a specific configuration and name.
Definition abstract-camera.cpp:57
cv::Rect_< uint16_t > getRoi() const
Get current ROI.
Definition abstract-camera.cpp:30
void setTimeOffset(const double offset)
Set offset to add after receiving events.
Definition abstract-camera.hpp:132
virtual bool getData(Vector &events)=0
Get data.
void stop()
Stop reading data.
Definition abstract-camera.cpp:21
BiasValue getBias(const int8_t config_bias, const uint8_t name) const
Retrieve the bias value associated with a specific configuration and name.
Definition abstract-camera.cpp:51
This class extends std::queue to implement event queues. For more information, please refer here.
Definition queue.hpp:35
This class extends cv::Mat to include timestamp.
Definition abstract-camera.hpp:53
This class extends std::vector to implement event vectors. For more information, please refer here.
Definition vector.hpp:36
Queue container for basic event structures.
Definition abstract-camera.hpp:20
Definition abstract-camera.hpp:35
This struct is used to store IMU data from a DAVIS event camera.
Definition abstract-camera.hpp:91
This struct is used to store linear acceleration and angular velocity.
Definition abstract-camera.hpp:63