1#ifndef BITSIM_SENSORS_BACKENDS_MJPEG_HTTP_CAMERA_BACKEND_H
2#define BITSIM_SENSORS_BACKENDS_MJPEG_HTTP_CAMERA_BACKEND_H
4#include "bitsim/bitsim_config.h"
74 std::optional<CameraFrame>
latest_frame()
const override;
109 std::atomic<bool> running_{
false};
110 std::atomic<uint_t> n_reconnects_{0};
112 mutable std::mutex mutex_;
113 std::optional<CameraFrame> frame_;
114 real_t mean_interval_{0.0};
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
CameraBackendBase(const std::string &backend_type)
Definition camera_backend_base.h:76
void disconnect() override
Stop receiving frames.
Definition mjpeg_http_camera_backend.cpp:60
static const std::string BACKEND_TYPE
The backend type.
Definition mjpeg_http_camera_backend.h:37
MJPEG_HTTPCameraBackend(const MJPEG_HTTPCameraBackend &)=delete
std::optional< CameraFrame > latest_frame() const override
The latest frame, if one has been received.
Definition mjpeg_http_camera_backend.cpp:69
uint_t n_reconnects() const noexcept
How many times the stream had to be opened again.
Definition mjpeg_http_camera_backend.h:100
MJPEG_HTTPCameraBackend(const Config &config)
Definition mjpeg_http_camera_backend.cpp:39
MJPEG_HTTPCameraBackend & operator=(const MJPEG_HTTPCameraBackend &)=delete
bool wait_for_frame(real_t timeout) const
Wait until the first frame arrives.
Definition mjpeg_http_camera_backend.cpp:81
void connect() override
Start receiving frames.
Definition mjpeg_http_camera_backend.cpp:50
real_t frame_rate() const
The frame rate of the stream, averaged over the last frames [frames/s]. Zero before two frames have a...
Definition mjpeg_http_camera_backend.cpp:95
~MJPEG_HTTPCameraBackend() override
Definition mjpeg_http_camera_backend.cpp:48
bool is_alive() const override
Whether frames are arriving.
Definition mjpeg_http_camera_backend.cpp:75
const Config & config() const noexcept
Definition mjpeg_http_camera_backend.h:102
static bool can_read_streams()
Whether this OpenCV can read HTTP streams at all. The backend reads them with OpenCV's FFmpeg backend...
Definition mjpeg_http_camera_backend.cpp:32
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
double real_t
real_t
Definition bitsim_types.h:20
Settings of the backend.
Definition mjpeg_http_camera_backend.h:43
real_t io_timeout
Give up opening, or reading a frame, after this long [s].
Definition mjpeg_http_camera_backend.h:63
std::string url
The URL of the stream, e.g. http://raspberrypi.local:8000/stream.
Definition mjpeg_http_camera_backend.h:47
real_t timeout
The stream is alive while frames arrive at most this far apart [s].
Definition mjpeg_http_camera_backend.h:53
real_t reconnect_delay
How long to wait before connecting again after a failure [s].
Definition mjpeg_http_camera_backend.h:58