|
bitsim
Model, simulate, estimate and control robots in C++
|
Receives the frames of an MJPEG stream over HTTP, the multipart/x-mixed-replace response that many cameras and camera servers give, for example example 31's FastAPI server on a Raspberry Pi. More...
#include <mjpeg_http_camera_backend.h>


Classes | |
| struct | Config |
| Settings of the backend. More... | |
Public Member Functions | |
| MJPEG_HTTPCameraBackend (const Config &config) | |
| ~MJPEG_HTTPCameraBackend () override | |
| MJPEG_HTTPCameraBackend (const MJPEG_HTTPCameraBackend &)=delete | |
| MJPEG_HTTPCameraBackend & | operator= (const MJPEG_HTTPCameraBackend &)=delete |
| void | connect () override |
| Start receiving frames. | |
| void | disconnect () override |
| Stop receiving frames. | |
| std::optional< CameraFrame > | latest_frame () const override |
| The latest frame, if one has been received. | |
| bool | is_alive () const override |
| Whether frames are arriving. | |
| bool | wait_for_frame (real_t timeout) const |
| Wait until the first frame arrives. | |
| real_t | frame_rate () const |
| The frame rate of the stream, averaged over the last frames [frames/s]. Zero before two frames have arrived. | |
| uint_t | n_reconnects () const noexcept |
| How many times the stream had to be opened again. | |
| const Config & | config () const noexcept |
| Public Member Functions inherited from bitsim::sensors::backends::CameraBackendBase | |
| virtual | ~CameraBackendBase ()=default |
| const std::string & | backend_type_str () const noexcept |
| The type of the backend. | |
Static Public Member Functions | |
| static bool | can_read_streams () |
| Whether this OpenCV can read HTTP streams at all. The backend reads them with OpenCV's FFmpeg backend, which an OpenCV built without FFmpeg does not have; the backend then never receives a frame. | |
Static Public Attributes | |
| static const std::string | BACKEND_TYPE = "MJPEG_HTTP" |
| The backend type. | |
Additional Inherited Members | |
| Protected Member Functions inherited from bitsim::sensors::backends::CameraBackendBase | |
| CameraBackendBase (const std::string &backend_type) | |
Receives the frames of an MJPEG stream over HTTP, the multipart/x-mixed-replace response that many cameras and camera servers give, for example example 31's FastAPI server on a Raspberry Pi.
A thread of its own reads the stream and keeps only the latest frame, so a slow reader never falls behind the camera. If the stream breaks it reconnects. It uses OpenCV's FFmpeg backend to read the stream.
|
explicit |
|
override |
|
delete |
|
static |
Whether this OpenCV can read HTTP streams at all. The backend reads them with OpenCV's FFmpeg backend, which an OpenCV built without FFmpeg does not have; the backend then never receives a frame.
|
inlinenoexcept |
|
overridevirtual |
Start receiving frames.
Implements bitsim::sensors::backends::CameraBackendBase.
|
overridevirtual |
Stop receiving frames.
Implements bitsim::sensors::backends::CameraBackendBase.
| real_t bitsim::sensors::backends::MJPEG_HTTPCameraBackend::frame_rate | ( | ) | const |
The frame rate of the stream, averaged over the last frames [frames/s]. Zero before two frames have arrived.
|
overridevirtual |
Whether frames are arriving.
Implements bitsim::sensors::backends::CameraBackendBase.
|
overridevirtual |
The latest frame, if one has been received.
Implements bitsim::sensors::backends::CameraBackendBase.
|
inlinenoexcept |
How many times the stream had to be opened again.
|
delete |
| bool bitsim::sensors::backends::MJPEG_HTTPCameraBackend::wait_for_frame | ( | real_t | timeout | ) | const |
Wait until the first frame arrives.
| timeout | How long to wait at most [s] |
|
static |
The backend type.