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 std::shared_ptr<rs2_processing_block> init()
578 auto block = std::shared_ptr<rs2_processing_block>(
602 static std::shared_ptr<rs2_processing_block> init()
605 auto block = std::shared_ptr<rs2_processing_block>(
642 std::shared_ptr<rs2_processing_block> init()
645 auto block = std::shared_ptr<rs2_processing_block>(
666 std::shared_ptr<rs2_processing_block> init()
669 auto block = std::shared_ptr<rs2_processing_block>(
687 std::shared_ptr<rs2_processing_block> init()
690 auto block = std::shared_ptr<rs2_processing_block>(
706 :_results(queue_size)
708 _sync.start(_results);
718 return frameset(_results.wait_for_frame(timeout_ms));
729 if (_results.poll_for_frame(&result))
746 if (_results.try_wait_for_frame(&result, timeout_ms))
756 _sync.invoke(std::move(f));
794 align(std::shared_ptr<rs2_processing_block> block) :
filter(block, 1) {}
798 std::shared_ptr<rs2_processing_block> init(
rs2_stream align_to)
801 auto block = std::shared_ptr<rs2_processing_block>(
851 std::shared_ptr<rs2_processing_block> init()
854 auto block = std::shared_ptr<rs2_processing_block>(
897 std::shared_ptr<rs2_processing_block> init()
900 auto block = std::shared_ptr<rs2_processing_block>(
925 :
filter( init( streams_to_rotate ), 1 )
930 :
filter( init( streams_to_rotate ), 1 )
949 std::shared_ptr< rs2_processing_block > init( std::vector< rs2_stream > streams_to_rotate )
954 streams_list.
list = std::move( streams_to_rotate );
1009 std::shared_ptr<rs2_processing_block> init()
1012 auto block = std::shared_ptr<rs2_processing_block>(
1065 std::shared_ptr<rs2_processing_block> init()
1068 auto block = std::shared_ptr<rs2_processing_block>(
1100 std::shared_ptr<rs2_processing_block> init(
bool transform_to_disparity)
1103 auto block = std::shared_ptr<rs2_processing_block>(
1137 std::shared_ptr<rs2_processing_block> init()
1140 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>(
1210 std::shared_ptr<rs2_processing_block> init()
1213 auto block = std::shared_ptr<rs2_processing_block>(
1245 std::shared_ptr<rs2_processing_block> init()
1248 auto block = std::shared_ptr<rs2_processing_block>(
1289 std::shared_ptr<rs2_processing_block> init()
1292 auto block = std::shared_ptr<rs2_processing_block>(
1319 operator bool()
const
1324 const std::shared_ptr<rs2_embedded_filter>&
get()
const
1357 _embedded_filter.reset();
1374 _embedded_filter.reset();
align(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:794
frameset process(frameset frames)
Definition rs_processing.hpp:788
friend class context
Definition rs_processing.hpp:797
align(rs2_stream align_to)
Definition rs_processing.hpp:778
Definition rs_processing.hpp:679
asynchronous_syncer()
Definition rs_processing.hpp:684
colorizer(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:848
video_frame colorize(frame depth) const
Definition rs_processing.hpp:842
colorizer()
Definition rs_processing.hpp:817
colorizer(float color_scheme)
Definition rs_processing.hpp:833
decimation_filter(float magnitude)
Definition rs_processing.hpp:879
decimation_filter()
Definition rs_processing.hpp:873
friend class context
Definition rs_processing.hpp:895
decimation_filter(filter f)
Definition rs_processing.hpp:884
depth_huffman_decoder(filter f)
Definition rs_processing.hpp:1124
depth_huffman_decoder()
Definition rs_processing.hpp:1121
friend class context
Definition rs_processing.hpp:1135
embedded_decimation_filter(embedded_filter filter)
Definition rs_processing.hpp:1350
rs2_embedded_filter_type get_type() const
Definition rs_processing.hpp:1311
T as() const
Definition rs_processing.hpp:1337
bool is() const
Definition rs_processing.hpp:1330
const std::shared_ptr< rs2_embedded_filter > & get() const
Definition rs_processing.hpp:1324
embedded_filter(std::shared_ptr< rs2_embedded_filter > filter)
Definition rs_processing.hpp:1305
std::shared_ptr< rs2_embedded_filter > _embedded_filter
Definition rs_processing.hpp:1344
embedded_temporal_filter(embedded_filter filter)
Definition rs_processing.hpp:1367
static void handle(rs2_error *e)
Definition rs_types.hpp:167
Definition rs_frame.hpp:363
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:1421
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:370
void keep()
Definition rs_frame.hpp:463
stream_profile get_profile() const
Definition rs_frame.hpp:583
rs2_frame * get() const
Definition rs_frame.hpp:616
Definition rs_frame.hpp:1157
friend class context
Definition rs_processing.hpp:1243
hdr_merge(filter f)
Definition rs_processing.hpp:1232
hdr_merge()
Definition rs_processing.hpp:1230
hole_filling_filter(int mode)
Definition rs_processing.hpp:1166
hole_filling_filter(filter f)
Definition rs_processing.hpp:1171
hole_filling_filter()
Definition rs_processing.hpp:1156
friend class context
Definition rs_processing.hpp:1181
m420_decoder()
Definition rs_processing.hpp:542
m420_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:545
nv12_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:572
nv12_decoder()
Definition rs_processing.hpp:569
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:764
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:1205
friend class context
Definition rs_processing.hpp:1208
rotation_filter(std::vector< rs2_stream > streams_to_rotate, float value)
Definition rs_processing.hpp:929
rotation_filter(std::vector< rs2_stream > streams_to_rotate)
Definition rs_processing.hpp:924
rotation_filter()
Definition rs_processing.hpp:919
rotation_filter(filter f)
Definition rs_processing.hpp:935
friend class context
Definition rs_processing.hpp:947
sequence_id_filter()
Definition rs_processing.hpp:1264
sequence_id_filter(filter f)
Definition rs_processing.hpp:1276
sequence_id_filter(float sequence_id)
Definition rs_processing.hpp:1271
friend class context
Definition rs_processing.hpp:1287
spatial_filter(filter f)
Definition rs_processing.hpp:1053
spatial_filter()
Definition rs_processing.hpp:1034
friend class context
Definition rs_processing.hpp:1063
spatial_filter(float smooth_alpha, float smooth_delta, float magnitude, float hole_fill)
Definition rs_processing.hpp:1045
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:743
bool poll_for_frames(frameset *fs) const
Definition rs_processing.hpp:726
void operator()(frame f) const
Definition rs_processing.hpp:754
syncer(int queue_size=1)
Definition rs_processing.hpp:705
frameset wait_for_frames(unsigned int timeout_ms=5000) const
Definition rs_processing.hpp:716
friend class context
Definition rs_processing.hpp:1007
temporal_filter(float smooth_alpha, float smooth_delta, int persistence_control)
Definition rs_processing.hpp:990
temporal_filter()
Definition rs_processing.hpp:972
temporal_filter(filter f)
Definition rs_processing.hpp:997
threshold_filter(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:639
threshold_filter(float min_dist=0.15f, float max_dist=4.f)
Definition rs_processing.hpp:621
threshold_filter(filter f)
Definition rs_processing.hpp:628
Definition rs_frame.hpp:663
y411_decoder()
Definition rs_processing.hpp:596
y411_decoder(std::shared_ptr< rs2_processing_block > block)
Definition rs_processing.hpp:599
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)
rs2_processing_block * rs2_create_nv12_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:48
@ RS2_STREAM_DEPTH
Definition rs_sensor.h:50
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:309
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition rs_types.h:150
@ RS2_EXTENSION_MOTION_FRAME
Definition rs_types.h:160
@ RS2_EXTENSION_HDR_MERGE
Definition rs_types.h:202
@ RS2_EXTENSION_HOLE_FILLING_FILTER
Definition rs_types.h:181
@ RS2_EXTENSION_DISPARITY_FILTER
Definition rs_types.h:178
@ RS2_EXTENSION_TEMPORAL_FILTER
Definition rs_types.h:180
@ RS2_EXTENSION_ROTATION_FILTER
Definition rs_types.h:207
@ RS2_EXTENSION_DEPTH_HUFFMAN_DECODER
Definition rs_types.h:196
@ RS2_EXTENSION_VIDEO_FRAME
Definition rs_types.h:159
@ RS2_EXTENSION_TEMPORAL_EMBEDDED_FILTER
Definition rs_types.h:214
@ RS2_EXTENSION_SPATIAL_FILTER
Definition rs_types.h:179
@ RS2_EXTENSION_DECIMATION_FILTER
Definition rs_types.h:176
@ RS2_EXTENSION_SEQUENCE_ID_FILTER
Definition rs_types.h:203
@ RS2_EXTENSION_THRESHOLD_FILTER
Definition rs_types.h:177
@ RS2_EXTENSION_DECIMATION_EMBEDDED_FILTER
Definition rs_types.h:213
struct rs2_error rs2_error
Definition rs_types.h:293
rs2_embedded_filter_type
Definition rs_types.h:283
struct rs2_options rs2_options
Definition rs_types.h:320
struct rs2_frame rs2_frame
Definition rs_types.h:296
struct rs2_processing_block rs2_processing_block
Definition rs_types.h:310
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