22 #ifndef SRC_PIPELINE_H_
23 #define SRC_PIPELINE_H_
27 #include <condition_variable>
35 #include "opencv2/core.hpp"
36 #include "opencv2/videoio.hpp"
41 #define FRAME_DELAY_MAX 2000
42 #define FRAME_DELAY_MIN 50
43 #define FRAME_DELAY_DEFAULT 1000
92 size_t front_index = 0;
93 size_t back_index = 0;
120 int size = back_index - front_index;
122 return (queue.size() + size);
140 explicit Buffer(
bool* running_ptr,
size_t max_size)
141 : running(running_ptr), queue(max_size) {}
155 if ((uint8_t)(
id + 1) == frame.id && !full) {
156 queue.at(back_index) = frame;
157 back_index = (back_index + 1) % queue.size();
158 if (back_index == front_index) {
191 if ((uint8_t)(
id + 1) == frame.id) {
192 queue.at(back_index) = frame;
193 back_index = (back_index + 1) % queue.size();
194 if (front_index == back_index) {
218 if (size() != 0 || full) {
220 front_index = (front_index + 1) % queue.size();
269 std::vector<FramerateSetting> framerate_settings;
275 size_t current_setting;
291 void notify_pipeline(
void);
360 cv::VideoCapture cap;
382 cv::Mat current_frame;
397 std::condition_variable cv;
416 void thread_body(
void);
427 void timerEvent(
void);
503 std::vector<std::thread> threads;
532 void post_processing_thread_body(
void);
559 explicit Pipeline(uint8_t num_inference_core_threads,
577 bool set_confidence_threshold(
float threshold);
584 float get_confidence_threshold();
594 float increase_framerate(
void);
604 float decrease_framerate(
void);
611 float get_framerate(
void);
628 bool set_pose_change_threshold(
float threshold);
635 float get_pose_change_threshold();
A synchronising buffer to be used as a communication mechanism between threads.
Definition: pipeline.h:86
PopResult< T > pop()
Pop the oldest element in the queue and return it.
Definition: pipeline.h:214
void push(T frame)
Push a frame to the queue.
Definition: pipeline.h:152
bool try_push(T frame)
Push a frame to the queue (doesn't block if queue is full)
Definition: pipeline.h:182
Buffer(bool *running_ptr, size_t max_size)
Construct a new Buffer object.
Definition: pipeline.h:140
A wrapper to make running inference easier.
Definition: inference_core.h:50
Class to maintain access to the cv::VideoCapture used as the input video stream. This class makes use...
Definition: pipeline.h:354
FrameGenerator(void)
Construct a new Frame Generator object.
Definition: pipeline.cpp:31
RawFrame next_frame(void)
Get the newest frame.
Definition: pipeline.cpp:77
~FrameGenerator()
Destroy the Frame Generator object.
Definition: pipeline.cpp:49
void updated_framerate(size_t new_frame_delay)
Notify the FrameGenerator that the frame rate has changed.
Definition: pipeline.cpp:54
Class to maintain the currently set frame rate and any related settings.
Definition: pipeline.h:260
void decrease_framerate(void)
Decrease the frame rate.
Definition: framerate_settings.cpp:86
void increase_framerate(void)
Increase the frame rate.
Definition: framerate_settings.cpp:93
FramerateSetting get_framerate_setting(void)
Get the currently set FramerateSetting
Definition: framerate_settings.cpp:82
FramerateSettings(Pipeline *pipeline)
Construct a new FramerateSettings object.
Definition: framerate_settings.cpp:23
Process the output of an Inference::InferenceCore
Definition: post_processor.h:51
This class handles representations of the user's pose and calculates any updates to their pose that i...
Definition: posture_estimator.h:243
Pre-process the input image before passing to Inference::InferenceCore
Definition: pre_processor.h:51
Wrapper API for the TensorFlow Lite model.
A synchronising buffer and results structure.
Definition: pipeline.h:49
Components of the pipeline at the core of the system.
Definition: framerate_settings.cpp:22
Interface for post processing the output of an Inference::InferenceCore
Interface for representation of user's pose.
Interface for pre processing the input image before passing to Inference::InferenceCore
Result when calling Buffer::pop()
Definition: pipeline.h:64
T value
Actual popped result.
Definition: pipeline.h:65
bool valid
Indicates validity of the result.
Definition: pipeline.h:66
Settings for an IIR filter. Wraps the second-order section coefficients for an IIR filter.
Definition: iir.h:54
Results of running the model for all body parts.
Definition: intermediate_structures.h:199
Contains the id of the frame within the pipeline, as well as the raw image and the results of running...
Definition: pipeline.h:474
Inference::InferenceResults image_results
Definition: pipeline.h:482
uint8_t id
Every frame is assigned a unique id to ensure in-order post processing. This id must be passed throug...
Definition: pipeline.h:480
cv::Mat raw_image
Definition: pipeline.h:481
Parameters relevant to the currently set frame rate.
Definition: pipeline.h:246
size_t frame_delay
Delay in ms that represents the current frame rate.
Definition: pipeline.h:250
IIR::SmoothingSettings smoothing_settings
Definition: pipeline.h:248
Contains the id of the frame within the pipeline, as well as the raw image and the preprocessed_image...
Definition: pipeline.h:328
uint8_t id
Every frame is assigned a unique id to ensure in-order post processing. This id must be passed throug...
Definition: pipeline.h:334
cv::Mat raw_image
Definition: pipeline.h:335
PreProcessing::PreProcessedImage preprocessed_image
Definition: pipeline.h:336
A frame as returned by the FrameGenerator
Definition: pipeline.h:343
uint8_t id
Frame ordering ID.
Definition: pipeline.h:344
cv::Mat raw_image
Raw cv::Mat (OpenCV) image.
Definition: pipeline.h:345
Representation of user's pose for use by the pipeline processing.
Definition: posture_estimator.h:100
The representation of a human's pose, containing all the expected ConnectedJoint
Definition: posture_estimator.h:74
A structure of the pre processed image.
Definition: intermediate_structures.h:85