6#ifndef OPENEV_DEVICES_ABSTRACT_CAMERA_HPP
7#define OPENEV_DEVICES_ABSTRACT_CAMERA_HPP
17#include <opencv2/core/mat.hpp>
18#include <opencv2/core/mat.inl.hpp>
19#include <opencv2/core/types.hpp>
34constexpr double us(
const T x) {
return static_cast<double>(x) * 1e-6; }
37constexpr double EARTH_GRAVITY = 9.80665;
38constexpr double DEG2RAD = M_PI / 180.0;
39constexpr double SCALE_16B_8B = 1.0 / 256.0;
70 return deviceHandler_ !=
nullptr;
77 [[nodiscard]]
virtual bool hasAps()
const = 0;
83 [[nodiscard]]
virtual bool hasImu()
const = 0;
109 [[nodiscard]] cv::Rect_<uint16_t>
getRoi()
const;
116 virtual bool setRoi(
const cv::Rect_<uint16_t> &roi) = 0;
177 bool getData(StampedMatVector &frames);
184 bool getData(StampedMatQueue &frames);
271 bool getData(
Vector &events, StampedMatVector &frame, ImuVector &imu);
280 bool getData(
Queue &events, StampedMatQueue &frame, ImuQueue &imu);
292 std::size_t
getEventRaw(std::vector<uint64_t> &data);
307 std::size_t
getEventRaw(uint64_t *&data,
const bool allow_realloc =
true);
313 void flush(
const double usec)
const;
317 template <
typename T1,
typename T2,
typename T3>
318 bool getData_([[maybe_unused]] T1 *dvs, [[maybe_unused]] T2 *aps, [[maybe_unused]] T3 *imu);
320 template <
typename T>
321 std::size_t getEventRaw_(T &data, [[maybe_unused]]
const bool allow_realloc);
323 void interpolate_(cv::Mat &frame)
const;
331 virtual std::size_t setDvsFilterPixels([[maybe_unused]]
const std::vector<cv::Point> &pixels) {
335 std::atomic<bool> running_{
false};
336 bool hasDefectivePixels_{
false};
338 std::vector<cv::Point> saturatedPixels_;
339 caerDeviceHandle deviceHandler_{
nullptr};
340 uint64_t resetTime_{0};
341 cv::Rect_<uint16_t> roi_;
342 bool filterRoiInSoftware_{
false};
This is an auxiliary class. This class cannot be instanced.
Definition abstract-camera.hpp:44
virtual cv::Size getSensorSize() const =0
Get device sensor size.
virtual bool setRoi(const cv::Rect_< uint16_t > &roi)=0
Set current ROI. Events outside the ROI are not considered. Images are cropped according to the ROI.
void setDefectivePixels(const std::string &defective_pixels_file)
Load a defective pixel file. Events on hot pixels are discarded, and saturated pixels are replaced by...
Definition abstract-camera.cpp:45
virtual bool hasImu() const =0
Check whether the device produces IMU data.
virtual void start()=0
Start reading data.
std::size_t getEventRaw(std::vector< uint64_t > &data)
Retrieve raw event data.
Definition abstract-camera.cpp:173
bool isOpen() const
Check whether the device was found and opened.
Definition abstract-camera.hpp:69
cv::Rect_< uint16_t > getRoi() const
Get current ROI.
Definition abstract-camera.cpp:37
virtual std::string getSerialNumber() const =0
Get device serial number, prefixed with the camera family.
void setContainerInterval(const uint32_t usec)
Set the maximum time interval between subsequent containers.
Definition abstract-camera.cpp:90
uint64_t getResetTime() const
Get device reset time.
Definition abstract-camera.hpp:101
void stop()
Stop reading data.
Definition abstract-camera.cpp:31
void setContainerSize(const uint32_t n)
Set the maximum number of events a container may hold before it is delivered. The limit applies to ea...
Definition abstract-camera.cpp:101
void flush(const double usec) const
Discard data during an interval of time.
Definition abstract-camera.cpp:177
virtual bool hasAps() const =0
Check whether the device produces APS frames.
bool getData(Vector &events)
Get DVS data.
Definition abstract-camera.cpp:139
This class extends cv::Mat to include timestamp.
Definition frames.hpp:27
Queue container for basic event structures.
Queuei Queue
Definition queue.hpp:40
Definition abstract-camera.hpp:26
This struct is used to store IMU data from a DAVIS event camera.
Definition imu.hpp:48
Basic event-based vision structures based on OpenCV components.
Vector container for basic event structures.
Vectori Vector
Definition vector.hpp:31