4 #include "../include/librealsense2/hpp/rs_sensor.hpp" 5 #include "../include/librealsense2/hpp/rs_processing.hpp" 53 _spatial_alpha_param(alpha_default_val),
54 _spatial_delta_param(delta_default_val),
55 _spatial_iterations(filter_iter_def),
56 _width(0), _height(0), _stride(0), _bpp(0),
58 _current_frm_size_pixels(0),
59 _stereoscopic_depth(false),
60 _focal_lenght_mm(0.
f),
61 _stereo_baseline_mm(0.
f),
62 _holes_filling_mode(holes_fill_def),
63 _holes_filling_radius(0)
68 auto spatial_filter_alpha = std::make_shared<ptr_option<float>>(
73 &
_spatial_alpha_param,
"Alpha factor of Exp.moving average, 1 = no filter, 0 = infinite filter");
75 auto spatial_filter_delta = std::make_shared<ptr_option<uint8_t>>(
81 spatial_filter_delta->on_set([
this, spatial_filter_delta](
float val)
85 if (!spatial_filter_delta->is_valid(val))
87 <<
"Unsupported spatial delta: " << val <<
" is out of range.");
89 _spatial_delta_param =
static_cast<uint8_t>(
val);
93 auto spatial_filter_iterations = std::make_shared<ptr_option<uint8_t>>(
100 auto holes_filling_mode = std::make_shared<ptr_option<uint8_t>>(
114 holes_filling_mode->on_set([
this, holes_filling_mode](
float val)
118 if (!holes_filling_mode->is_valid(val))
120 <<
"Unsupported mode for spatial holes filling selected: value " << val <<
" is out of range.");
122 _holes_filling_mode =
static_cast<uint8_t>(
val);
123 switch (_holes_filling_mode)
139 <<
"Unsupported spatial hole-filling requested: value " << _holes_filling_mode <<
" is out of range.");
189 if (
auto a = As<librealsense::extendable_interface>(snr))
198 else if (
auto depth_emul = As<librealsense::software_sensor>(snr))
210 dss = As<librealsense::depth_stereo_sensor>(snr);
239 float previousInnovation =
state;
242 float innovation = *
im;
244 if (!(*(
int*)&previousInnovation > 0))
245 goto CurrentlyInvalidLR;
250 if (*(
int*)&innovation > 0) {
251 float delta = previousInnovation - innovation;
252 bool smallDifference = delta < deltaZ && delta > -deltaZ;
254 if (smallDifference) {
255 float filtered = innovation * alpha + state * (1.0f -
alpha);
256 *im = state = filtered;
264 previousInnovation = innovation;
272 previousInnovation = innovation;
275 goto CurrentlyInvalidLR;
284 if (*(
int*)&innovation > 0) {
285 previousInnovation = state = innovation;
288 goto CurrentlyValidLR;
298 im = image + (v + 1) * _width - 2;
299 previousInnovation = state = im[1];
302 if (!(*(
int*)&previousInnovation > 0))
303 goto CurrentlyInvalidRL;
307 if (*(
int*)&innovation > 0) {
308 float delta = previousInnovation - innovation;
309 bool smallDifference = delta < deltaZ && delta > -deltaZ;
311 if (smallDifference) {
312 float filtered = innovation * alpha + state * (1.0f -
alpha);
313 *im = state = filtered;
321 previousInnovation = innovation;
329 previousInnovation = innovation;
332 goto CurrentlyInvalidRL;
341 if (*(
int*)&innovation > 0) {
342 previousInnovation = state = innovation;
345 goto CurrentlyValidRL;
365 for (u = 0; u <
_width;) {
367 float *
im = image + u;
369 float previousInnovation =
state;
373 float innovation = *
im;
375 if (!(*(
int*)&previousInnovation > 0))
376 goto CurrentlyInvalidTB;
381 if (*(
int*)&innovation > 0) {
382 float delta = previousInnovation - innovation;
383 bool smallDifference = delta < deltaZ && delta > -deltaZ;
385 if (smallDifference) {
386 float filtered = innovation * alpha + state * (1.0f -
alpha);
387 *im = state = filtered;
395 previousInnovation = innovation;
403 previousInnovation = innovation;
406 goto CurrentlyInvalidTB;
415 if (*(
int*)&innovation > 0) {
416 previousInnovation = state = innovation;
419 goto CurrentlyValidTB;
428 im = image + u + (
_height - 2) * _width;
430 previousInnovation =
state;
433 if (!(*(
int*)&previousInnovation > 0))
434 goto CurrentlyInvalidBT;
438 if (*(
int*)&innovation > 0) {
439 float delta = previousInnovation - innovation;
440 bool smallDifference = delta < deltaZ && delta > -deltaZ;
442 if (smallDifference) {
443 float filtered = innovation * alpha + state * (1.0f -
alpha);
444 *im = state = filtered;
452 previousInnovation = innovation;
460 previousInnovation = innovation;
463 goto CurrentlyInvalidBT;
472 if (*(
int*)&innovation > 0) {
473 previousInnovation = state = innovation;
476 goto CurrentlyValidBT;
float _spatial_edge_threshold
static const textual_icon lock
const uint8_t filter_iter_max
rs2::stream_profile _target_stream_profile
rs2::frame prepare_target_frame(const rs2::frame &f, const rs2::frame_source &source)
stream_profile get_profile() const
const void * get_data() const
const uint8_t holes_fill_def
uint8_t _spatial_iterations
uint8_t _holes_filling_mode
GLenum GLenum GLsizei void * image
void register_option(rs2_option id, std::shared_ptr< option > option)
float _stereo_baseline_mm
GLboolean GLboolean GLboolean GLboolean a
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
float _spatial_alpha_param
const uint8_t holes_fill_step
GLfloat GLfloat GLfloat alpha
const uint8_t delta_default_val
const uint8_t delta_min_val
rs2::stream_profile _source_stream_profile
const uint8_t filter_iter_def
const uint8_t holes_fill_max
virtual float get_stereo_baseline_mm() const =0
void recursive_filter_horizontal_fp(void *image_data, float alpha, float deltaZ)
const float alpha_default_val
rs2_extension _extension_type
stream_filter _stream_filter
void recursive_filter_vertical_fp(void *image_data, float alpha, float deltaZ)
void update_configuration(const rs2::frame &f)
rs2_format format() const
const float alpha_max_val
spatial_holes_filling_types
uint8_t _spatial_delta_param
const uint8_t delta_max_val
const rs2_stream_profile * get() const
const uint8_t filter_iter_min
const uint8_t holes_fill_min
GLsizei GLsizei GLchar * source
uint8_t _holes_filling_radius
const float alpha_min_val
size_t _current_frm_size_pixels
stream_profile clone(rs2_stream type, int index, rs2_format format) const
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
std::string to_string(T value)
const uint8_t filter_iter_step