30 _source.
init(std::shared_ptr<metadata_parser_map>());
46 catch (std::exception
const &
e)
52 LOG_ERROR(
"Exception was thrown during user processing callback!");
63 std::vector<rs2::frame> frames_to_process;
65 frames_to_process.push_back(f);
67 for (
auto f : composite)
68 frames_to_process.push_back(f);
70 std::vector<rs2::frame> results;
71 for (
auto f : frames_to_process)
79 for (
auto f : composite)
85 results.push_back(
res);
117 bool disparity_result_frame =
false;
118 bool depth_result_frame =
false;
120 for (
auto f : results)
122 auto format =
f.get_profile().format();
124 disparity_result_frame =
true;
126 depth_result_frame =
true;
129 std::vector<rs2::frame> original_set;
138 original_set.push_back(frame);
145 for (
auto s : original_set)
147 auto curr_profile =
s.get_profile();
149 if (find_if(results.begin(), results.end(), [&curr_profile](
rs2::frame& frame) {
151 return curr_profile.
stream_type() == processed_profile.stream_type() &&
152 curr_profile.format() == processed_profile.format() &&
153 curr_profile.stream_index() == processed_profile.stream_index(); }) == results.end())
155 results.push_back(
s);
166 _source.
init(std::shared_ptr<metadata_parser_map>());
173 std::weak_ptr<ptr_option<int>> stream_selector_ref = stream_selector;
174 stream_selector->on_set([
this, stream_selector_ref](
float val)
178 if (!stream_selector_ref.lock()->is_valid(val))
180 <<
"Unsupported stream filter, " << val <<
" is out of range.");
190 std::weak_ptr<ptr_option<int>> format_selector_ref = format_selector;
191 format_selector->on_set([
this, format_selector_ref](
float val)
195 if (!format_selector_ref.lock()->is_valid(val))
197 <<
"Unsupported stream format filter, " << val <<
" is out of range.");
202 auto index_selector = std::make_shared<ptr_option<int>>(-1, std::numeric_limits<int>::max(), 1, -1, &
_stream_filter.
index,
"Stream index");
203 std::weak_ptr<ptr_option<int>> index_selector_ref = index_selector;
204 index_selector->on_set([
this, index_selector_ref](
float val)
208 if (!index_selector_ref.lock()->is_valid(val))
210 <<
"Unsupported stream index filter, " << val <<
" is out of range.");
244 height = vf.get_height();
249 planes[0] = (
byte*)ret.get_data();
263 int height = vf.get_height();
319 _actual_source.invoke_callback(
std::move(result));
331 data.metadata_size = 0;
332 data.system_time = _actual_source.get_time();
335 auto res = _actual_source.alloc_frame(frame_type, vid_stream->get_width() * vid_stream->get_height() *
sizeof(float) * 5,
data,
true);
338 res->set_stream(stream);
355 if (new_bpp == 0 || (new_width == 0 && new_stride == 0) || new_height == 0)
360 throw std::runtime_error(
"If original frame is not video frame, you must specify new bpp, width/stide and height!");
365 auto width = new_width;
367 auto bpp = new_bpp * 8;
394 auto of =
dynamic_cast<frame*
>(original);
396 auto res = _actual_source.alloc_frame(frame_type,
stride *
height, data,
true);
402 res->set_stream(stream);
417 auto of =
dynamic_cast<frame*
>(original);
419 auto res = _actual_source.alloc_frame(frame_type, of->get_frame_data_size(),
data,
true);
424 res->set_stream(stream);
431 if (f ==
nullptr)
return 0;
432 if (
auto c = dynamic_cast<composite_frame*>(f))
433 return static_cast<int>(
c->get_embedded_frames_count());
439 if (
auto comp = dynamic_cast<composite_frame*>(from.
frame))
441 auto frame_buff = comp->get_frames();
442 for (
size_t i = 0;
i < comp->get_embedded_frames_count();
i++)
462 for (
auto&&
f : holders)
466 if (!
res)
return nullptr;
470 for (
auto&&
f : holders)
476 auto frames = cf->get_frames();
477 for (
auto&&
f : holders)
481 auto releaser = [
frames, req_size]()
483 for (
auto i = 0;
i < req_size;
i++)
490 cf->attach_continuation(
std::move(release_frames));
491 cf->set_stream(cf->first()->get_stream());
515 if (
val > 0.
f)
break;
528 const auto&& supported_options = block->get_supported_options();
529 for (
auto&& opt : supported_options)
571 _source_format(source_format),
572 _left_target_format(left_target_format),
573 _left_target_stream(left_target_stream),
574 _left_extension_type(left_extension_type),
575 _left_target_profile_idx(left_idx),
576 _right_target_format(right_target_format),
577 _right_target_stream(right_target_stream),
578 _right_extension_type(right_extension_type),
579 _right_target_profile_idx(right_idx)
stream_filter_processing_block(const char *name)
static const textual_icon lock
virtual const byte * get_frame_data() const =0
rs2::stream_profile _source_stream_profile
const char * rs2_format_to_string(rs2_format format)
virtual rs2_timestamp_domain get_frame_timestamp_domain() const =0
frame allocate_motion_frame(const stream_profile &profile, const frame &original, rs2_extension frame_type=RS2_EXTENSION_MOTION_FRAME) const
virtual rs2::frame prepare_output(const rs2::frame_source &source, rs2::frame input, std::vector< rs2::frame > results)
void copy_frames(frame_holder from, frame_interface **&target)
GLuint const GLchar * name
std::vector< std::shared_ptr< processing_block > > _processing_blocks
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
frame_interface * allocate_motion_frame(std::shared_ptr< stream_profile_interface > stream, frame_interface *original, rs2_extension frame_type=RS2_EXTENSION_MOTION_FRAME) override
int get_embeded_frames_size(frame_interface *f)
void init(std::shared_ptr< metadata_parser_map > metadata_parsers)
int rs2_is_frame_extendable_to(const rs2_frame *frame, rs2_extension extension_type, rs2_error **error)
std::shared_ptr< rs2_frame_callback > frame_callback_ptr
rs2_stream _left_target_stream
rs2_metadata_type get_frame_metadata(rs2_frame_metadata_value frame_metadata) const
bool val_in_range(const T &val, const std::initializer_list< T > &list)
std::shared_ptr< stream_profile_interface > _left_target_stream_profile
void invoke(frame_holder frames) override
stream_profile get_profile() const
virtual rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f)=0
std::function< void(frame_interface *)> on_frame
virtual bool is_blocking() const =0
rs2_format _target_format
bool supports_option(rs2_option id) const override
const void * get_data() const
bool supports_frame_metadata(rs2_frame_metadata_value frame_metadata) const
bool should_process(const rs2::frame &frame) override
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
virtual rs2::frame prepare_frame(const rs2::frame_source &source, const rs2::frame &f)
virtual void process_function(byte *const dest[], const byte *source, int width, int height, int actual_size, int input_size)=0
GLfloat GLfloat GLfloat GLfloat h
rs2_extension _left_extension_type
processing_block(const char *name)
rs2_format _right_target_format
frame_processor_callback_ptr _callback
void register_option(rs2_option id, std::shared_ptr< option > option)
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
rs2_format _source_format
std::shared_ptr< stream_profile_interface > _right_target_stream_profile
rs2_source * get_c_wrapper() override
bool should_process(const rs2::frame &frame) override
bool is_z_or_disparity(rs2_format format)
frame_interface * allocate_video_frame(std::shared_ptr< stream_profile_interface > stream, frame_interface *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) override
generic_processing_block(const char *name)
void register_info(rs2_camera_info info, const std::string &val)
std::shared_ptr< option > get_published_size_option()
virtual void init_profiles_info(const rs2::frame *f)
void invoke(frame_holder frames) override
processing_block & get(rs2_option option)
rs2::stream_profile _target_stream_profile
std::shared_ptr< rs2_frame_processor_callback > frame_processor_callback_ptr
void set_output_callback(frame_callback_ptr callback) override
GLint GLsizei GLsizei height
rs2_stream _right_target_stream
bool match(const rs2::frame &frame)
frame allocate_composite_frame(std::vector< frame > frames) const
GLint GLint GLsizei GLint GLenum format
composite_processing_block()
void set_blocking(bool state) override
GLdouble GLdouble GLint stride
void frame_ready(frame_holder result) override
rs2_format
A stream's format identifies how binary data is encoded within a frame.
interleaved_functional_processing_block(const char *name, rs2_format source_format, rs2_format left_target_format, rs2_stream left_target_stream, rs2_extension left_extension_type, int left_idx, rs2_format right_target_format, rs2_stream right_target_stream, rs2_extension right_extension_type, int right_idx)
virtual rs2_time_t get_frame_timestamp() const =0
void set_processing_callback(frame_processor_callback_ptr callback) override
void update_info(rs2_camera_info info, const std::string &val)
int _left_target_profile_idx
const std::string & get_info(rs2_camera_info info) const override
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
stream_filter _stream_filter
rs2_stream
Streams are different types of data provided by RealSense devices.
virtual std::shared_ptr< sensor_interface > get_sensor() const =0
void add(std::shared_ptr< processing_block > block)
void set_sensor(std::shared_ptr< sensor_interface > s) override
virtual void disable_continuation()=0
virtual void process_function(byte *const dest[], const byte *source, int width, int height, int actual_size, int input_size)=0
std::shared_ptr< metadata_parser_map > metadata_parsers
virtual std::shared_ptr< stream_profile_interface > get_stream() const =0
rs2_format format() const
frame_interface * allocate_composite_frame(std::vector< frame_holder > frames) override
void assign(int width, int height, int stride, int bpp)
const char * rs2_stream_to_string(rs2_stream stream)
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
rs2_extension _extension_type
GLenum GLenum GLenum input
rs2_extension _right_extension_type
virtual bool should_process(const rs2::frame &frame)=0
const rs2_stream_profile * get() const
void set_output_callback(frame_callback_ptr callback) override
synthetic_source _source_wrapper
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
rs2_format _left_target_format
void set_callback(frame_callback_ptr callback)
GLsizei GLsizei GLchar * source
int _right_target_profile_idx
void configure_processing_callback()
frame_interface * allocate_points(std::shared_ptr< stream_profile_interface > stream, frame_interface *original, rs2_extension frame_type=RS2_EXTENSION_POINTS) override
rs2_stream stream_type() const
virtual unsigned long long get_frame_number() const =0
int get_image_bpp(rs2_format format)
stream_profile clone(rs2_stream type, int index, rs2_format format) const
struct rs2_frame rs2_frame
callback_invocation_holder begin_callback()
std::shared_ptr< stream_profile_interface > _source_stream_profile
functional_processing_block(const char *name, rs2_format target_format, rs2_stream target_stream=RS2_STREAM_ANY, rs2_extension extension_type=RS2_EXTENSION_VIDEO_FRAME)
std::string to_string(T value)