Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
482 changes: 261 additions & 221 deletions common/model-views.cpp

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,37 +293,48 @@ namespace rs2
class viewer_model;
class subdevice_model;

void save_processing_block(const char* name,
void save_processing_block_to_config_file(const char* name,
std::shared_ptr<rs2::processing_block> pb, bool enable = true);

class processing_block_model
{
public:
processing_block_model(subdevice_model* owner,
const std::string& name,
std::shared_ptr<rs2::processing_block> block,
std::shared_ptr<rs2::filter> block,
std::function<rs2::frame(rs2::frame)> invoker,
std::string& error_message,
bool enabled = true);

const std::string& get_name() const { return _name; }

option_model& get_option(rs2_option opt) { return options_metadata[opt]; }
option_model& get_option(rs2_option opt);

rs2::frame invoke(rs2::frame f) const { return _invoker(f); }

void save()
void save_to_config_file();

std::vector<rs2_option> get_option_list()
{
save_processing_block(_name.c_str(), _block, enabled);
return _block->get_supported_options();
}

void populate_options(const std::string& opt_base_label,
subdevice_model* model,
bool* options_invalidated,
std::string& error_message);

std::shared_ptr<rs2::filter> get_block() { return _block; }

bool enabled = true;
bool visible = true;
private:
std::shared_ptr<rs2::processing_block> _block;
std::shared_ptr<rs2::filter> _block;
std::map<int, option_model> options_metadata;
std::string _name;
std::string _full_name;
std::function<rs2::frame(rs2::frame)> _invoker;
subdevice_model* _owner;
};

class syncer_model
Expand Down Expand Up @@ -395,6 +406,7 @@ namespace rs2
std::atomic<bool> _active;
};

option_model create_option_mode(rs2_option opt, std::shared_ptr<options> options, const std::string& opt_base_label, bool* options_invalidated, std::string& error_message);

class subdevice_model
{
Expand All @@ -413,6 +425,7 @@ namespace rs2
std::vector<stream_profile> get_selected_profiles();
void stop(viewer_model& viewer);
void play(const std::vector<stream_profile>& profiles, viewer_model& viewer, std::shared_ptr<rs2::asynchronous_syncer>);
bool is_synchronized_frame(viewer_model& viewer, const frame& f);
void update(std::string& error_message, notifications_model& model);
void draw_options(const std::vector<rs2_option>& drawing_order,
bool update_read_only_options, std::string& error_message,
Expand All @@ -428,6 +441,9 @@ namespace rs2
void pause();
void resume();

bool can_enable_zero_order();
void verify_zero_order_conditions();

void restore_ui_selection() { ui = last_valid_ui; }
void store_ui_selection() { last_valid_ui = ui; }

Expand Down Expand Up @@ -500,6 +516,7 @@ namespace rs2

std::shared_ptr<rs2::colorizer> depth_colorizer;
std::shared_ptr<rs2::yuy_decoder> yuy2rgb;
std::shared_ptr<processing_block_model> zero_order_artifact_fix;

std::vector<std::shared_ptr<processing_block_model>> post_processing;
bool post_processing_enabled = true;
Expand Down Expand Up @@ -802,6 +819,9 @@ namespace rs2
void map_id_frame_to_frame(rs2::frame first, rs2::frame second);

rs2::frame apply_filters(rs2::frame f, const rs2::frame_source& source);
std::shared_ptr<subdevice_model> get_frame_origin(const rs2::frame& f);

void zero_first_pixel(const rs2::frame& f);
rs2::frame last_tex_frame;
rs2::processing_block processing_block;
std::shared_ptr<pointcloud> pc;
Expand Down
2 changes: 1 addition & 1 deletion examples/post-processing/rs-post-processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ filter_options::filter_options(const std::string name, rs2::filter& flt) :
supported_options[opt].value = range.def;
supported_options[opt].is_int = filter_slider_ui::is_all_integers(range);
supported_options[opt].description = flt.get_option_description(opt);
std::string opt_name = rs2_option_to_string(opt);
std::string opt_name = flt.get_option_name(opt);
supported_options[opt].name = name + "_" + opt_name;
std::string prefix = "Filter ";
supported_options[opt].label = opt_name;
Expand Down
1 change: 1 addition & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_processing.hpp"
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_record_playback.hpp"
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_sensor.hpp"
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_options.hpp"
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_internal.hpp"
"${CMAKE_CURRENT_LIST_DIR}/librealsense2/hpp/rs_pipeline.hpp"

Expand Down
43 changes: 43 additions & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ extern "C" {
RS2_OPTION_STREAM_FORMAT_FILTER, /**< Select a stream format to process */
RS2_OPTION_STREAM_INDEX_FILTER, /**< Select a stream index to process */
RS2_OPTION_EMITTER_ON_OFF, /**< When supported, this option make the camera to switch the emitter state every frame. 0 for disabled, 1 for enabled */
RS2_OPTION_ZERO_ORDER_POINT_X, /**< Zero order point x*/
RS2_OPTION_ZERO_ORDER_POINT_Y, /**< Zero order point y*/
RS2_OPTION_LLD_TEMPERATURE, /**< LLD temperature*/
RS2_OPTION_MC_TEMPERATURE, /**< MC temperature*/
RS2_OPTION_MA_TEMPERATURE, /**< MA temperature*/
RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_option;

// This function is being deprecated. For existing options it will return option name, but for future API additions the user should call rs2_get_option_name instead.
const char* rs2_option_to_string(rs2_option option);

/** \brief For SR300 devices: provides optimized settings (presets) for specific types of usage. */
Expand Down Expand Up @@ -131,6 +138,42 @@ extern "C" {
*/
void rs2_set_option(const rs2_options* options, rs2_option option, float value, rs2_error** error);

/**
* get the list of supported options of options container
* \param[in] options the options container
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
rs2_options_list* rs2_get_options_list(const rs2_options* options, rs2_error** error);

/**
* get the size of options list
* \param[in] options the option list
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
int rs2_get_options_list_size(const rs2_options_list* options, rs2_error** error);

/**
* get option name
* \param[in] options options object
* \param[in] option option id to be checked
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return human-readable option name
*/
const char* rs2_get_option_name(const rs2_options* options, rs2_option option, rs2_error** error);

/**
* get the specific option from options list
* \param[in] i the index of the option
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
*/
rs2_option rs2_get_option_from_list(const rs2_options_list* options, int i, rs2_error** error);

/**
* Deletes options list
* \param[in] list list to delete
*/
void rs2_delete_options_list(rs2_options_list* list);

/**
* check if particular option is supported by a subdevice
* \param[in] sensor the RealSense sensor
Expand Down
34 changes: 34 additions & 0 deletions include/librealsense2/h/rs_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,40 @@ rs2_processing_block* rs2_create_hole_filling_filter_block(rs2_error** error);
*/
rs2_processing_block* rs2_create_rates_printer_block(rs2_error** error);

/**
* Creates Depth post-processing zero order fix block. The filter invalidates pixels that has a wrong value due to zero order effect
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return zero order fix processing block
*/
rs2_processing_block* rs2_create_zero_order_invalidation_block(rs2_error** error);

/**
* Retrieve processing block specific information, like name.
* \param[in] block The processing block
* \param[in] info processing block info type to retrieve
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return The requested processing block info string, in a format specific to the device model
*/
const char* rs2_get_processing_block_info(const rs2_processing_block* block, rs2_camera_info info, rs2_error** error);

/**
* Check if a processing block supports a specific info type.
* \param[in] block The processing block to check
* \param[in] info The parameter to check for support
* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return True if the parameter both exist and well-defined for the specific device
*/
int rs2_supports_processing_block_info(const rs2_processing_block* block, rs2_camera_info info, rs2_error** error);

/**
* Test if the given processing block can be extended to the requested extension
* \param[in] block processing block
* \param[in] extension The extension to which the sensor should be tested if it is extendable
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return non-zero value iff the processing block can be extended to the given extension
*/
int rs2_is_processing_block_extendable_to(const rs2_processing_block* block, rs2_extension extension_type, rs2_error** error);

#ifdef __cplusplus
}
#endif
Expand Down
31 changes: 31 additions & 0 deletions include/librealsense2/h/rs_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,37 @@ void rs2_register_extrinsics(const rs2_stream_profile* from,
*/
void rs2_get_video_stream_intrinsics(const rs2_stream_profile* mode, rs2_intrinsics* intrinsics, rs2_error** error);

/**
* Returns the list of recommended processing blocks for a specific sensor.
* Order and configuration of the blocks are decided by the sensor
* \param[in] sensor input sensor
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return list of supported sensor recommended processing blocks
*/
rs2_processing_block_list* rs2_get_recommended_processing_blocks(rs2_sensor* sensor, rs2_error** error);

/**
* Returns specific processing blocks from processing blocks list
* \param[in] list the processing blocks list
* \param[in] index the requested processing block
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return processing block
*/
rs2_processing_block* rs2_get_processing_block(const rs2_processing_block_list* list, int index, rs2_error** error);

/**
* Returns the processing blocks list size
* \param[in] list the processing blocks list
* \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return the processing block list size
*/
int rs2_get_recommended_processing_blocks_count(const rs2_processing_block_list* list, rs2_error** error);

/**
* Deletes processing blocks list
* \param[in] list list to delete
*/
void rs2_delete_recommended_processing_blocks(rs2_processing_block_list* list);

#ifdef __cplusplus
}
Expand Down
10 changes: 10 additions & 0 deletions include/librealsense2/h/rs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ typedef enum rs2_extension
RS2_EXTENSION_TM2,
RS2_EXTENSION_SOFTWARE_DEVICE,
RS2_EXTENSION_SOFTWARE_SENSOR,
RS2_EXTENSION_DECIMATION_FILTER,
RS2_EXTENSION_THRESHOLD_FILTER,
RS2_EXTENSION_DISPARITY_FILTER,
RS2_EXTENSION_SPATIAL_FILTER,
RS2_EXTENSION_TEMPORAL_FILTER,
RS2_EXTENSION_HOLE_FILLING_FILTER,
RS2_EXTENSION_ZERO_ORDER_FILTER,
RS2_EXTENSION_RECOMMENDED_FILTERS,
RS2_EXTENSION_COUNT
} rs2_extension;
const char* rs2_extension_type_to_string(rs2_extension type);
Expand Down Expand Up @@ -155,6 +163,7 @@ typedef struct rs2_pipeline_profile rs2_pipeline_profile;
typedef struct rs2_config rs2_config;
typedef struct rs2_device_list rs2_device_list;
typedef struct rs2_stream_profile_list rs2_stream_profile_list;
typedef struct rs2_processing_block_list rs2_processing_block_list;
typedef struct rs2_stream_profile rs2_stream_profile;
typedef struct rs2_frame_callback rs2_frame_callback;
typedef struct rs2_log_callback rs2_log_callback;
Expand All @@ -169,6 +178,7 @@ typedef struct rs2_device_hub rs2_device_hub;
typedef struct rs2_sensor_list rs2_sensor_list;
typedef struct rs2_sensor rs2_sensor;
typedef struct rs2_options rs2_options;
typedef struct rs2_options_list rs2_options_list;
typedef struct rs2_devices_changed_callback rs2_devices_changed_callback;
typedef struct rs2_notification rs2_notification;
typedef struct rs2_notifications_callback rs2_notifications_callback;
Expand Down
15 changes: 15 additions & 0 deletions include/librealsense2/hpp/rs_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,5 +996,20 @@ namespace rs2
private:
size_t _size;
};

template<class T>
class frame_callback : public rs2_frame_callback
{
T on_frame_function;
public:
explicit frame_callback(T on_frame) : on_frame_function(on_frame) {}

void on_frame(rs2_frame* fref) override
{
on_frame_function(frame{ fref });
}

void release() override { delete this; }
};
}
#endif // LIBREALSENSE_RS2_FRAME_HPP
Loading