4#ifndef LIBREALSENSE_RS2_PROCESSING_HPP
5#define LIBREALSENSE_RS2_PROCESSING_HPP
33 const frame& original,
42 original.
get(), new_bpp, new_width, new_height, new_stride, frame_type, &e);
56 const frame& original,
61 original.
get(), frame_type, &e);
67 const frame& original)
const
85 std::vector<rs2_frame*> refs(frames.size(), (
rs2_frame*)
nullptr);
86 for (
size_t i = 0; i < frames.size(); i++)
87 std::swap(refs[i], frames[i].frame_ref);
103 result.frame_ref =
nullptr;
127 on_frame_function(std::move(frm), src);
145 _queue = std::shared_ptr<rs2_frame_queue>(
161 f.frame_ref =
nullptr;
182 typename std::enable_if<std::is_base_of<rs2::frame, T>::value,
bool>::type
poll_for_frame(T* output)
const
188 frame f{ frame_ref };
189 if (res) *output = f;
194 typename std::enable_if<std::is_base_of<rs2::frame, T>::value,
bool>::type
try_wait_for_frame(T* output,
unsigned int timeout_ms = 5000)
const
200 frame f{ frame_ref };
201 if (res) *output = f;
221 return static_cast<size_t>(res);
239 std::shared_ptr<rs2_frame_queue>
get() {
return _queue; }
242 std::shared_ptr<rs2_frame_queue> _queue;
287 std::swap(f.frame_ref, ptr);
312 _block = std::shared_ptr<rs2_processing_block>(
332 return is_supported > 0;
354 std::shared_ptr<rs2_processing_block>
_block;
373 if (!
_queue.poll_for_frame(&f))
374 throw std::runtime_error(
"Error occured during execution of the processing block! See the log for more info");
383 filter(std::shared_ptr<rs2_processing_block> block,
int queue_size = 1)
396 filter(S processing_function,
int queue_size = 1) :
421 operator bool()
const {
return _block.get() !=
nullptr; }
462 throw std::runtime_error(
"Error occured during execution of the processing block! See the log for more info");
483 std::shared_ptr<rs2_processing_block> init()
487 auto block = std::shared_ptr<rs2_processing_block>(
516 std::shared_ptr<rs2_processing_block> init()
519 auto block = std::shared_ptr<rs2_processing_block>(
548 std::shared_ptr<rs2_processing_block> init()
551 auto block = std::shared_ptr<rs2_processing_block>(
575 static std::shared_ptr<rs2_processing_block> init()
578 auto block = std::shared_ptr<rs2_processing_block>(
615 std::shared_ptr<rs2_processing_block> init()
618 auto block = std::shared_ptr<rs2_processing_block>(
639 std::shared_ptr<rs2_processing_block> init()
642 auto block = std::shared_ptr<rs2_processing_block>(
660 std::shared_ptr<rs2_processing_block> init()
663 auto block = std::shared_ptr<rs2_processing_block>(
679 :_results(queue_size)
681 _sync.start(_results);
691 return frameset(_results.wait_for_frame(timeout_ms));
702 if (_results.poll_for_frame(&result))
719 if (_results.try_wait_for_frame(&result, timeout_ms))
729 _sync.invoke(std::move(f));
767 align(std::shared_ptr<rs2_processing_block> block) :
filter(block, 1) {}
771 std::shared_ptr<rs2_processing_block> init(
rs2_stream align_to)
774 auto block = std::shared_ptr<rs2_processing_block>(
824 std::shared_ptr<rs2_processing_block> init()
827 auto block = std::shared_ptr<rs2_processing_block>(
870 std::shared_ptr<rs2_processing_block> init()
873 auto block = std::shared_ptr<rs2_processing_block>(
898 :
filter( init( streams_to_rotate ), 1 )
903 :
filter( init( streams_to_rotate ), 1 )
922 std::shared_ptr< rs2_processing_block > init( std::vector< rs2_stream > streams_to_rotate )
927 streams_list.
list = std::move( streams_to_rotate );
982 std::shared_ptr<rs2_processing_block> init()
985 auto block = std::shared_ptr<rs2_processing_block>(
1038 std::shared_ptr<rs2_processing_block> init()
1041 auto block = std::shared_ptr<rs2_processing_block>(
1073 std::shared_ptr<rs2_processing_block> init(
bool transform_to_disparity)
1076 auto block = std::shared_ptr<rs2_processing_block>(
1110 std::shared_ptr<rs2_processing_block> init()
1113 auto block = std::shared_ptr<rs2_processing_block>(
1156 std::shared_ptr<rs2_processing_block> init()
1159 auto block = std::shared_ptr<rs2_processing_block>(
1183 std::shared_ptr<rs2_processing_block> init()
1186 auto block = std::shared_ptr<rs2_processing_block>(
1218 std::shared_ptr<rs2_processing_block> init()
1221 auto block = std::shared_ptr<rs2_processing_block>(
1262 std::shared_ptr<rs2_processing_block> init()
1265 auto block = std::shared_ptr<rs2_processing_block>(
1292 operator bool()
const
1297 const std::shared_ptr<rs2_embedded_filter>&
get()
const
1330 _embedded_filter.reset();
1347 _embedded_filter.reset();
align(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:767
frameset process(frameset frames)
Definition rs_processing.hpp:761
friend class context
Definition rs_processing.hpp:770
align(rs2_stream align_to)
Definition rs_processing.hpp:751
Definition rs_processing.hpp:652
asynchronous_syncer()
Definition rs_processing.hpp:657
colorizer(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:821
video_frame colorize(frame depth) const
Definition rs_processing.hpp:815
colorizer()
Definition rs_processing.hpp:790
colorizer(float color_scheme)
Definition rs_processing.hpp:806
decimation_filter(float magnitude)
Definition rs_processing.hpp:852
decimation_filter()
Definition rs_processing.hpp:846
friend class context
Definition rs_processing.hpp:868
decimation_filter(filter f)
Definition rs_processing.hpp:857
depth_huffman_decoder(filter f)
Definition rs_processing.hpp:1097
depth_huffman_decoder()
Definition rs_processing.hpp:1094
friend class context
Definition rs_processing.hpp:1108
embedded_decimation_filter(embedded_filter filter)
Definition rs_processing.hpp:1323
rs2_embedded_filter_type get_type() const
Definition rs_processing.hpp:1284
T as() const
Definition rs_processing.hpp:1310
bool is() const
Definition rs_processing.hpp:1303
const std::shared_ptr< rs2_embedded_filter > & get() const
Definition rs_processing.hpp:1297
embedded_filter(std::shared_ptr< rs2_embedded_filter > filter)
Definition rs_processing.hpp:1278
std::shared_ptr< rs2_embedded_filter > _embedded_filter
Definition rs_processing.hpp:1317
embedded_temporal_filter(embedded_filter filter)
Definition rs_processing.hpp:1340
static void handle(rs2_error *e)
Definition rs_types.hpp:167
Definition rs_frame.hpp:348
Definition rs_processing.hpp:361
filter(std::shared_ptr< rs2_processing_block > block, int queue_size=1)
Definition rs_processing.hpp:383
filter(S processing_function, int queue_size=1)
Definition rs_processing.hpp:396
rs2_processing_block * get() const
Definition rs_processing.hpp:405
rs2::frame process(rs2::frame frame) const override
Definition rs_processing.hpp:369
bool is() const
Definition rs_processing.hpp:408
T as() const
Definition rs_processing.hpp:415
frame_queue get_queue()
Definition rs_processing.hpp:404
frame_queue _queue
Definition rs_processing.hpp:423
Definition rs_frame.hpp:1309
Definition rs_processing.hpp:118
void on_frame(rs2_frame *f, rs2_source *source) override
Definition rs_processing.hpp:123
frame_processor_callback(T on_frame)
Definition rs_processing.hpp:121
void release() override
Definition rs_processing.hpp:130
Definition rs_processing.hpp:134
void enqueue(frame f) const
Definition rs_processing.hpp:157
size_t capacity() const
Definition rs_processing.hpp:228
void operator()(frame f) const
Definition rs_processing.hpp:207
frame wait_for_frame(unsigned int timeout_ms=5000) const
Definition rs_processing.hpp:168
size_t size() const
Definition rs_processing.hpp:216
frame_queue()
Definition rs_processing.hpp:151
bool keep_frames() const
Definition rs_processing.hpp:233
std::shared_ptr< rs2_frame_queue > get()
Definition rs_processing.hpp:239
std::enable_if< std::is_base_of< rs2::frame, T >::value, bool >::type poll_for_frame(T *output) const
Definition rs_processing.hpp:182
std::enable_if< std::is_base_of< rs2::frame, T >::value, bool >::type try_wait_for_frame(T *output, unsigned int timeout_ms=5000) const
Definition rs_processing.hpp:194
frame_queue(unsigned int capacity, bool keep_frames=false)
Definition rs_processing.hpp:142
Definition rs_processing.hpp:18
frame allocate_composite_frame(std::vector< frame > frames) const
Definition rs_processing.hpp:81
void frame_ready(frame result) const
Definition rs_processing.hpp:98
friend class frame_processor_callback
Definition rs_processing.hpp:109
rs2_source * _source
Definition rs_processing.hpp:106
frame allocate_motion_frame(const stream_profile &profile, const frame &original, rs2_extension frame_type=RS2_EXTENSION_MOTION_FRAME) const
Definition rs_processing.hpp:55
frame allocate_video_frame(const stream_profile &profile, const frame &original, int new_bpp=0, int new_width=0, int new_height=0, int new_stride=0, rs2_extension frame_type=RS2_EXTENSION_VIDEO_FRAME) const
Definition rs_processing.hpp:32
frame allocate_points(const stream_profile &profile, const frame &original) const
Definition rs_processing.hpp:66
Definition rs_frame.hpp:355
void keep()
Definition rs_frame.hpp:448
stream_profile get_profile() const
Definition rs_frame.hpp:568
rs2_frame * get() const
Definition rs_frame.hpp:601
Definition rs_frame.hpp:1067
friend class context
Definition rs_processing.hpp:1216
hdr_merge(filter f)
Definition rs_processing.hpp:1205
hdr_merge()
Definition rs_processing.hpp:1203
hole_filling_filter(int mode)
Definition rs_processing.hpp:1139
hole_filling_filter(filter f)
Definition rs_processing.hpp:1144
hole_filling_filter()
Definition rs_processing.hpp:1129
friend class context
Definition rs_processing.hpp:1154
m420_decoder()
Definition rs_processing.hpp:542
m420_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:545
options & operator=(const options &other)
Definition rs_options.hpp:323
options(const options &other)
Definition rs_options.hpp:329
void set_option(rs2_option option, float value) const
Definition rs_options.hpp:256
bool supports(rs2_option option) const
Definition rs_options.hpp:163
pointcloud()
Definition rs_processing.hpp:435
pointcloud(rs2_stream stream, int index=0)
Definition rs_processing.hpp:437
pointcloud(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:478
points calculate(frame depth) const
Definition rs_processing.hpp:448
friend class context
Definition rs_processing.hpp:481
void map_to(frame mapped)
Definition rs_processing.hpp:469
Definition rs_frame.hpp:749
const char * get_info(rs2_camera_info info) const
Definition rs_processing.hpp:340
processing_block(S processing_function)
Definition rs_processing.hpp:309
processing_block(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:298
void invoke(frame f) const
Definition rs_processing.hpp:284
bool supports(rs2_camera_info info) const
Definition rs_processing.hpp:327
void register_simple_option(rs2_option option_id, option_range range)
Definition rs_processing.hpp:348
std::shared_ptr< rs2_processing_block > _block
Definition rs_processing.hpp:354
void start(S on_frame)
Definition rs_processing.hpp:261
rs2_processing_block * get() const
Definition rs_processing.hpp:320
S & operator>>(S &on_frame)
Definition rs_processing.hpp:274
rates_printer()
Definition rs_processing.hpp:1178
friend class context
Definition rs_processing.hpp:1181
rotation_filter(std::vector< rs2_stream > streams_to_rotate, float value)
Definition rs_processing.hpp:902
rotation_filter(std::vector< rs2_stream > streams_to_rotate)
Definition rs_processing.hpp:897
rotation_filter()
Definition rs_processing.hpp:892
rotation_filter(filter f)
Definition rs_processing.hpp:908
friend class context
Definition rs_processing.hpp:920
sequence_id_filter()
Definition rs_processing.hpp:1237
sequence_id_filter(filter f)
Definition rs_processing.hpp:1249
sequence_id_filter(float sequence_id)
Definition rs_processing.hpp:1244
friend class context
Definition rs_processing.hpp:1260
spatial_filter(filter f)
Definition rs_processing.hpp:1026
spatial_filter()
Definition rs_processing.hpp:1007
friend class context
Definition rs_processing.hpp:1036
spatial_filter(float smooth_alpha, float smooth_delta, float magnitude, float hole_fill)
Definition rs_processing.hpp:1018
Definition rs_frame.hpp:23
rs2_format format() const
Definition rs_frame.hpp:44
int stream_index() const
Definition rs_frame.hpp:34
rs2_stream stream_type() const
Definition rs_frame.hpp:39
const rs2_stream_profile * get() const
Definition rs_frame.hpp:146
bool try_wait_for_frames(frameset *fs, unsigned int timeout_ms=5000) const
Definition rs_processing.hpp:716
bool poll_for_frames(frameset *fs) const
Definition rs_processing.hpp:699
void operator()(frame f) const
Definition rs_processing.hpp:727
syncer(int queue_size=1)
Definition rs_processing.hpp:678
frameset wait_for_frames(unsigned int timeout_ms=5000) const
Definition rs_processing.hpp:689
friend class context
Definition rs_processing.hpp:980
temporal_filter(float smooth_alpha, float smooth_delta, int persistence_control)
Definition rs_processing.hpp:963
temporal_filter()
Definition rs_processing.hpp:945
temporal_filter(filter f)
Definition rs_processing.hpp:970
threshold_filter(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:612
threshold_filter(float min_dist=0.15f, float max_dist=4.f)
Definition rs_processing.hpp:594
threshold_filter(filter f)
Definition rs_processing.hpp:601
Definition rs_frame.hpp:648
y411_decoder()
Definition rs_processing.hpp:569
y411_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:572
yuy_decoder()
Definition rs_processing.hpp:510
yuy_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:513
Definition rs_processing_gl.hpp:13
rs2_frame * rs2_allocate_points(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, rs2_error **error)
rs2_frame * rs2_allocate_synthetic_motion_frame(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, rs2_extension frame_type, rs2_error **error)
rs2_frame * rs2_allocate_composite_frame(rs2_source *source, rs2_frame **frames, int count, rs2_error **error)
void rs2_synthetic_frame_ready(rs2_source *source, rs2_frame *frame, rs2_error **error)
rs2_frame * rs2_allocate_synthetic_video_frame(rs2_source *source, const rs2_stream_profile *new_stream, rs2_frame *original, int new_bpp, int new_width, int new_height, int new_stride, rs2_extension frame_type, rs2_error **error)
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls,...
Definition rs_option.h:27
@ RS2_OPTION_FILTER_SMOOTH_ALPHA
Definition rs_option.h:65
@ RS2_OPTION_STREAM_FILTER
Definition rs_option.h:71
@ RS2_OPTION_ROTATION
Definition rs_option.h:128
@ RS2_OPTION_HOLES_FILL
Definition rs_option.h:67
@ RS2_OPTION_SEQUENCE_ID
Definition rs_option.h:108
@ RS2_OPTION_MAX_DISTANCE
Definition rs_option.h:62
@ RS2_OPTION_COLOR_SCHEME
Definition rs_option.h:59
@ RS2_OPTION_STREAM_INDEX_FILTER
Definition rs_option.h:73
@ RS2_OPTION_MIN_DISTANCE
Definition rs_option.h:61
@ RS2_OPTION_FILTER_SMOOTH_DELTA
Definition rs_option.h:66
@ RS2_OPTION_FILTER_MAGNITUDE
Definition rs_option.h:64
@ RS2_OPTION_STREAM_FORMAT_FILTER
Definition rs_option.h:72
rs2_processing_block * rs2_create_rotation_filter_block(rs2_streams_list streams_to_rotate, rs2_error **error)
void rs2_delete_processing_block(rs2_processing_block *block)
rs2_processing_block * rs2_create_decimation_filter_block(rs2_error **error)
rs2_processing_block * rs2_create_m420_decoder(rs2_error **error)
void rs2_delete_frame_queue(rs2_frame_queue *queue)
rs2_processing_block * rs2_create_sequence_id_filter(rs2_error **error)
rs2_processing_block * rs2_create_threshold(rs2_error **error)
rs2_processing_block * rs2_create_yuy_decoder(rs2_error **error)
int rs2_processing_block_register_simple_option(rs2_processing_block *block, rs2_option option_id, float min, float max, float step, float def, rs2_error **error)
void rs2_process_frame(rs2_processing_block *block, rs2_frame *frame, rs2_error **error)
const char * rs2_get_processing_block_info(const rs2_processing_block *block, rs2_camera_info info, rs2_error **error)
rs2_processing_block * rs2_create_units_transform(rs2_error **error)
int rs2_is_processing_block_extendable_to(const rs2_processing_block *block, rs2_extension extension_type, rs2_error **error)
rs2_frame_queue * rs2_create_frame_queue(int capacity, rs2_error **error)
void rs2_enqueue_frame(rs2_frame *frame, void *queue)
rs2_processing_block * rs2_create_temporal_filter_block(rs2_error **error)
rs2_processing_block * rs2_create_rates_printer_block(rs2_error **error)
rs2_processing_block * rs2_create_processing_block(rs2_frame_processor_callback *proc, rs2_error **error)
void rs2_start_processing(rs2_processing_block *block, rs2_frame_callback *on_frame, rs2_error **error)
rs2_frame * rs2_wait_for_frame(rs2_frame_queue *queue, unsigned int timeout_ms, rs2_error **error)
rs2_embedded_filter_type rs2_get_embedded_filter_type(const rs2_embedded_filter *embedded_filter, rs2_error **error)
rs2_processing_block * rs2_create_hdr_merge_processing_block(rs2_error **error)
rs2_processing_block * rs2_create_colorizer(rs2_error **error)
int rs2_try_wait_for_frame(rs2_frame_queue *queue, unsigned int timeout_ms, rs2_frame **output_frame, rs2_error **error)
rs2_processing_block * rs2_create_align(rs2_stream align_to, rs2_error **error)
rs2_processing_block * rs2_create_y411_decoder(rs2_error **error)
int rs2_supports_processing_block_info(const rs2_processing_block *block, rs2_camera_info info, rs2_error **error)
int rs2_is_embedded_filter_extendable_to(const rs2_embedded_filter *embedded_filter, rs2_extension extension_type, rs2_error **error)
rs2_processing_block * rs2_create_hole_filling_filter_block(rs2_error **error)
int rs2_poll_for_frame(rs2_frame_queue *queue, rs2_frame **output_frame, rs2_error **error)
int rs2_frame_queue_size(rs2_frame_queue *queue, rs2_error **error)
rs2_processing_block * rs2_create_spatial_filter_block(rs2_error **error)
rs2_processing_block * rs2_create_sync_processing_block(rs2_error **error)
rs2_processing_block * rs2_create_disparity_transform_block(unsigned char transform_to_disparity, rs2_error **error)
rs2_processing_block * rs2_create_huffman_depth_decompress_block(rs2_error **error)
rs2_processing_block * rs2_create_pointcloud(rs2_error **error)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition rs_sensor.h:47
@ RS2_STREAM_DEPTH
Definition rs_sensor.h:49
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
Definition rs_sensor.h:22
struct rs2_source rs2_source
Definition rs_types.h:292
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition rs_types.h:138
@ RS2_EXTENSION_MOTION_FRAME
Definition rs_types.h:148
@ RS2_EXTENSION_HDR_MERGE
Definition rs_types.h:190
@ RS2_EXTENSION_HOLE_FILLING_FILTER
Definition rs_types.h:169
@ RS2_EXTENSION_DISPARITY_FILTER
Definition rs_types.h:166
@ RS2_EXTENSION_TEMPORAL_FILTER
Definition rs_types.h:168
@ RS2_EXTENSION_ROTATION_FILTER
Definition rs_types.h:195
@ RS2_EXTENSION_DEPTH_HUFFMAN_DECODER
Definition rs_types.h:184
@ RS2_EXTENSION_VIDEO_FRAME
Definition rs_types.h:147
@ RS2_EXTENSION_TEMPORAL_EMBEDDED_FILTER
Definition rs_types.h:202
@ RS2_EXTENSION_SPATIAL_FILTER
Definition rs_types.h:167
@ RS2_EXTENSION_DECIMATION_FILTER
Definition rs_types.h:164
@ RS2_EXTENSION_SEQUENCE_ID_FILTER
Definition rs_types.h:191
@ RS2_EXTENSION_THRESHOLD_FILTER
Definition rs_types.h:165
@ RS2_EXTENSION_DECIMATION_EMBEDDED_FILTER
Definition rs_types.h:201
struct rs2_error rs2_error
Definition rs_types.h:276
rs2_embedded_filter_type
Definition rs_types.h:266
struct rs2_options rs2_options
Definition rs_types.h:303
struct rs2_frame rs2_frame
Definition rs_types.h:279
struct rs2_processing_block rs2_processing_block
Definition rs_types.h:293
Definition rs_types.hpp:200
float def
Definition rs_types.hpp:203
float step
Definition rs_types.hpp:204
float max
Definition rs_types.hpp:202
float min
Definition rs_types.hpp:201
Definition rs_types.hpp:40
Definition rs_types.hpp:35
std::vector< rs2_stream > list
Definition rs_types.hpp:36