bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
camera_backend_base.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_BACKENDS_CAMERA_BACKEND_BASE_H
2#define BITSIM_SENSORS_BACKENDS_CAMERA_BACKEND_BASE_H
3
4#include "bitsim/bitsim_config.h"
5
6#ifdef BITSIM_OPENCV
7
9
10#include <opencv2/core.hpp>
11
12#include <chrono>
13#include <optional>
14#include <string>
15
16namespace bitsim
17{
19{
20
25{
29 cv::Mat image;
30
35
39 std::chrono::steady_clock::time_point received_at{};
40};
41
46{
47 public:
48 virtual ~CameraBackendBase() = default;
49
53 virtual void connect() = 0;
54
58 virtual void disconnect() = 0;
59
63 virtual std::optional<CameraFrame> latest_frame() const = 0;
64
68 virtual bool is_alive() const = 0;
69
73 const std::string &backend_type_str() const noexcept { return backend_type_; }
74
75 protected:
76 explicit CameraBackendBase(const std::string &backend_type) : backend_type_(backend_type) {}
77
78 private:
79 std::string backend_type_;
80};
81
82} // namespace sensors::backends
83} // namespace bitsim
84
85#endif
86#endif // BITSIM_SENSORS_BACKENDS_CAMERA_BACKEND_BASE_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
virtual void connect()=0
Start receiving frames.
const std::string & backend_type_str() const noexcept
The type of the backend.
Definition camera_backend_base.h:73
virtual void disconnect()=0
Stop receiving frames.
CameraBackendBase(const std::string &backend_type)
Definition camera_backend_base.h:76
virtual std::optional< CameraFrame > latest_frame() const =0
The latest frame, if one has been received.
virtual bool is_alive() const =0
Whether frames are arriving.
Definition camera_backend_base.h:19
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
A frame delivered by a camera backend.
Definition camera_backend_base.h:25
cv::Mat image
The image, in BGR order as OpenCV uses.
Definition camera_backend_base.h:29
std::chrono::steady_clock::time_point received_at
When the backend received the frame.
Definition camera_backend_base.h:39
uint_t index
How many frames the backend has delivered, this one included.
Definition camera_backend_base.h:34